Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
walker-sheng 2021-01-22 16:28:07 +08:00
commit dc6fc9345c
18 changed files with 239 additions and 228 deletions

View File

@ -75,6 +75,8 @@ public class Operation {
Switch_Force_Turn, Switch_Force_Turn,
/** 道岔钩锁*/ /** 道岔钩锁*/
Switch_Hook_Lock, Switch_Hook_Lock,
/** 道岔强解 */
Switch_Force_Unlock,
//--------------------------- 区段 --------------------------- //--------------------------- 区段 ---------------------------
/** 封锁 */ /** 封锁 */

View File

@ -112,10 +112,4 @@ public class SectionOperateHandler {
this.atsSectionService.confirmAxleValid(simulation, section); this.atsSectionService.confirmAxleValid(simulation, section);
} }
/**强解*/
@OperateHandlerMapping(type = Operation.Type.Section_Force_Unlock)
public void forceUnlock(Simulation simulation, String sectionCode) {
this.ciApiService.sectionForceUnlock(simulation, sectionCode);
}
} }

View File

@ -117,8 +117,8 @@ public class SignalOperateHandler {
* @param routeCodeList * @param routeCodeList
*/ */
@OperateHandlerMapping(type = Operation.Type.Signal_Close_Auto_Setting) @OperateHandlerMapping(type = Operation.Type.Signal_Close_Auto_Setting)
public void setRouteHumanControl(Simulation simulation, List<String> routeCodeList) { public void setRouteHumanControl(Simulation simulation, String signalCode, List<String> routeCodeList) {
this.atsRouteService.setRouteHumanControl(simulation, routeCodeList); this.atsRouteService.setRouteHumanControl(simulation, signalCode, routeCodeList);
} }
/** /**
@ -128,8 +128,8 @@ public class SignalOperateHandler {
* @param routeCodeList * @param routeCodeList
*/ */
@OperateHandlerMapping(type = Operation.Type.Signal_Open_Auto_Setting) @OperateHandlerMapping(type = Operation.Type.Signal_Open_Auto_Setting)
public void setRouteAtsControl(Simulation simulation, List<String> routeCodeList) { public void setRouteAtsControl(Simulation simulation, String signalCode, List<String> routeCodeList) {
this.atsRouteService.setRouteAtsControl(simulation, routeCodeList); this.atsRouteService.setRouteAtsControl(simulation, signalCode, routeCodeList);
} }

View File

@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -35,32 +36,48 @@ public class AtsRouteService {
* 进路收人工控 * 进路收人工控
* *
* @param simulation * @param simulation
* @param signalCode
* @param routeCodeList * @param routeCodeList
*/ */
public void setRouteHumanControl(Simulation simulation, List<String> routeCodeList) { public void setRouteHumanControl(Simulation simulation, String signalCode, List<String> routeCodeList) {
if (!CollectionUtils.isEmpty(routeCodeList)) { if (!CollectionUtils.isEmpty(routeCodeList)) {
routeCodeList.forEach(routeCode -> { routeCodeList.forEach(routeCode -> {
Route route = simulation.getRepository().getByCode(routeCode, Route.class); Route route = simulation.getRepository().getByCode(routeCode, Route.class);
route.setAtsControl(false); route.setAtsControl(false);
}); });
} else if (StringUtils.hasText(signalCode)) {
Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
List<Route> routeList = signal.getRouteList();
if (!CollectionUtils.isEmpty(routeList)) {
routeList.forEach(route -> route.setAtsControl(false));
}
} }
} }
/** /**
* 进路交自动控 * 进路交自动控
*/ */
public void setRouteAtsControl(Simulation simulation, List<String> routeCodeList) { public void setRouteAtsControl(Simulation simulation, String signalCode, List<String> routeCodeList) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
if (!CollectionUtils.isEmpty(routeCodeList)) { if (!CollectionUtils.isEmpty(routeCodeList)) {
List<Route> routes = routeCodeList.stream().map(routeCode -> repository.getByCode(routeCode, Route.class)).collect(Collectors.toList()); List<Route> routes = routeCodeList.stream().map(routeCode -> repository.getByCode(routeCode, Route.class)).collect(Collectors.toList());
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) { if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
Signal start = routes.get(0).getStart(); Signal start = routes.get(0).getStart();
String startSignalCode = start.getCode(); String startSignalCode = start.getCode();
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routes.stream().allMatch(route-> route.getStart().getCode().equals(startSignalCode)), BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routes.stream().allMatch(route -> route.getStart().getCode().equals(startSignalCode)),
"所选进路的始端信号机不同,处理逻辑未知"); "所选进路的始端信号机不同,处理逻辑未知");
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(start.isHumanControl(), String.format("信号机[%s]需处于人工控状态", start.getCode())); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(start.isHumanControl(), String.format("信号机[%s]需处于人工控状态", start.getCode()));
} }
routes.forEach(route -> route.setAtsControl(true)); routes.forEach(route -> route.setAtsControl(true));
} else if (StringUtils.hasText(signalCode)) {
Signal signal = repository.getByCode(signalCode, Signal.class);
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isHumanControl(), String.format("信号机[%s]需处于人工控状态", signal.getCode()));
}
List<Route> routeList = signal.getRouteList();
if (!CollectionUtils.isEmpty(routeList)) {
routeList.forEach(route -> route.setAtsControl(true));
}
} }
} }

View File

@ -293,9 +293,9 @@ public class CILogicLoop {
Switch.SwitchFault fault = (Switch.SwitchFault) aSwitch.getFault(); Switch.SwitchFault fault = (Switch.SwitchFault) aSwitch.getFault();
if (fault != null) { if (fault != null) {
aSwitch.setSplit(true);
switch (fault) { switch (fault) {
case SPLIT: case SPLIT:
case SQUEEZE:
break; break;
case NORMAL_SPLIT: { case NORMAL_SPLIT: {
VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch();
@ -309,7 +309,6 @@ public class CILogicLoop {
} }
} }
} else { } else {
aSwitch.setSplit(false);
VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch();
aSwitch.apply(virtualSwitch.isNormal(), virtualSwitch.isReverse()); aSwitch.apply(virtualSwitch.isNormal(), virtualSwitch.isReverse());
} }

View File

@ -164,8 +164,6 @@ public interface CiApiService {
*/ */
void sectionFaultUnlock(Simulation simulation, String sectionCode); void sectionFaultUnlock(Simulation simulation, String sectionCode);
void sectionForceUnlock(Simulation simulation, String sectionCode);
/** /**
* 区故解 * 区故解
* @param simulation * @param simulation

View File

@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -191,7 +192,7 @@ public class CiApiServiceImpl implements CiApiService {
Route route = simulation.getRepository().getByCode(routeCode, Route.class); Route route = simulation.getRepository().getByCode(routeCode, Route.class);
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
TrainInfo firstTrain = repository.querySignalApproachedFirstTrain(route.getStart()); TrainInfo firstTrain = repository.querySignalApproachedFirstTrain(route.getStart());
if (route.isApproachLock() && Objects.nonNull(firstTrain) && !firstTrain.isStop()) { // 接近锁闭总人解 if (route.isApproachLock() /*&& Objects.nonNull(firstTrain) && !firstTrain.isStop()*/) { // 接近锁闭总人解
this.routeService.humanCancel(simulation, route); this.routeService.humanCancel(simulation, route);
} else { } else {
this.routeService.cancelNoApproachLock(simulation, route); this.routeService.cancelNoApproachLock(simulation, route);
@ -206,20 +207,6 @@ public class CiApiServiceImpl implements CiApiService {
@Override @Override
public void sectionFaultUnlock(Simulation simulation, String sectionCode) { public void sectionFaultUnlock(Simulation simulation, String sectionCode) {
Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
List<Route> lockedRouteList = simulation.getRepository().queryAllLockedRoute();
Route lockedRoute = null;
for (Route route : lockedRouteList) {
if (route.isRouteSection(section)) {
lockedRoute = route;
break;
}
}
this.sectionService.sectionFaultUnlock(simulation, section, lockedRoute);
}
@Override
public void sectionForceUnlock(Simulation simulation, String sectionCode) {
Section section = simulation.getRepository().getByCode(sectionCode, Section.class); Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
List<Route> lockedRouteList = simulation.getRepository().queryAllLockedRoute(); List<Route> lockedRouteList = simulation.getRepository().queryAllLockedRoute();
Route lockedRoute = null; Route lockedRoute = null;
@ -229,7 +216,7 @@ public class CiApiServiceImpl implements CiApiService {
break; break;
} }
} }
this.sectionService.sectionForceUnlock(simulation, section, lockedRoute); this.sectionService.sectionFaultUnlock(simulation, section, lockedRoute);
} }
@Override @Override
@ -371,51 +358,57 @@ public class CiApiServiceImpl implements CiApiService {
public void setGuide(Simulation simulation, String signalCode, String routeCode) { public void setGuide(Simulation simulation, String signalCode, String routeCode) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
MapConfig config = repository.getConfig(); MapConfig config = repository.getConfig();
if (config.isGuideNeedRouteSettingFirst()) { Signal signal;
// 需要先办理进路 Route route = null;
if (Objects.isNull(signalCode)) { if (StringUtils.hasText(signalCode)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument,"操作参数缺少信号机"); signal = repository.getByCode(signalCode, Signal.class);
} else { } else if (StringUtils.hasText(routeCode)) {
Signal signal = repository.getByCode(signalCode, Signal.class); route = repository.getByCode(routeCode, Route.class);
if (!CollectionUtils.isEmpty(signal.getRouteList())) { // 是进路始端 signal = route.getStart();
Route lockedRoute = signal.getLockedRoute();
if (Objects.isNull(lockedRoute)) { // 没有已办理进路异常
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,"操作信号机没有已办理的进路");
} else { // 开引导信号
this.signalService.openGuideSignal(simulation, signal);
}
}
}
return;
}
if (routeCode != null) {
Route route = repository.getByCode(routeCode, Route.class);
if (route.isLock()) {
signalService.openGuideSignal(simulation, route.getStart());
} else {
routeService.settingGuideRoute(simulation, route);
}
} else if (signalCode != null) {
Signal signal = repository.getByCode(signalCode, Signal.class);
if (signal.getLockedRoute() != null) { //如果有已锁闭进路
signalService.openGuideSignal(simulation, signal);
} else if (!CollectionUtils.isEmpty(signal.getRouteList())) { //如果signal锁闭进路为null筛选最合适的进路直线进路>分叉进路>折返进路
List<Route> collect = signal.getRouteList().stream()
.filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList()))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect)) {
collect = signal.getRouteList().stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(collect)) {
collect = signal.getRouteList();
}
Route route = collect.get(0);
routeService.settingGuideRoute(simulation, route);
} else { //如果信号机没有关联进路
signalService.openGuideSignal(simulation, signal);
}
} else { } else {
throw new SimulationException(SimulationExceptionType.Illegal_Argument,"操作参数缺少信号机或进路"); throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("signalCode和routeCode不能都为空");
}
//条件检查
if (config.isGuideNeedRouteSettingFirst()) {
List<Route> routeList = signal.getRouteList();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeList, String.format("信号机[%s]非进路始端信号机", signal.getCode()));
if (route != null) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(route.isLock(), String.format("进路[%s]未办理", route.getCode()));
} else {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(signal.getLockedRoute(), String.format("信号机[%s]无已办理进路", signal.getCode()));
}
}
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isClose(), String.format("信号机[%s]需处于关闭状态", signal.getCode()));
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isApproachOccupy(), String.format("对%s开放引导操作失败接近区段没有列车占用", signal.getName()));
//办理引导进路或开放引导信号
if (config.isGuideNeedRouteSettingFirst()) {
signalService.openGuideSignal(simulation, signal);
} else {
if (route != null) {
if (route.isLock()) {
signalService.openGuideSignal(simulation, route.getStart());
} else {
routeService.settingGuideRoute(simulation, route);
}
} else {
if (signal.getLockedRoute() != null) { //如果有已锁闭进路
signalService.openGuideSignal(simulation, signal);
} else if (!CollectionUtils.isEmpty(signal.getRouteList())) { //如果signal锁闭进路为null筛选最合适的进路直线进路>分叉进路>折返进路
List<Route> collect = signal.getRouteList().stream()
.filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList()))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect)) {
collect = signal.getRouteList().stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(collect)) {
collect = signal.getRouteList();
}
route = collect.get(0);
routeService.settingGuideRoute(simulation, route);
} else { //如果信号机没有关联进路
signalService.openGuideSignal(simulation, signal);
}
}
} }
} }
@ -474,6 +467,7 @@ public class CiApiServiceImpl implements CiApiService {
@Override @Override
public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) { public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(aSwitch.isSectionOccupied(), "道岔未被占用,不能使用强转");
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isLocked(), String.format("道岔[%s]锁闭,无法转动", aSwitch.getCode())); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isLocked(), String.format("道岔[%s]锁闭,无法转动", aSwitch.getCode()));
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
if (normal == null) { if (normal == null) {

View File

@ -153,6 +153,12 @@ public class RouteService {
// 封锁状态 // 封锁状态
if (section.isBlockade()) { if (section.isBlockade()) {
return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section);
} else if (!CollectionUtils.isEmpty(section.getLogicList())) {
for (Section logicSection : section.getLogicList()) {
if (logicSection.isBlockade()) {
return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, logicSection);
}
}
} }
// 进路内区段锁闭方向不是此进路方向 // 进路内区段锁闭方向不是此进路方向
if ((section.isRouteLock() || section.isOverlapLock()) && if ((section.isRouteLock() || section.isOverlapLock()) &&
@ -650,7 +656,10 @@ public class RouteService {
if (route.isLock()) { // 进路锁闭 if (route.isLock()) { // 进路锁闭
// 取消进路逻辑 // 取消进路逻辑
if (simulation.getRepository().getConfig().isCancelAtsControlOfAllRoutesWhenCancelRoute()) { if (simulation.getRepository().getConfig().isCancelAtsControlOfAllRoutesWhenCancelRoute()) {
route.getStart().getRouteList().forEach(aRoute -> aRoute.setAtsControl(false)); route.getStart().getRouteList().forEach(aRoute -> {
aRoute.setAtsControl(false);
aRoute.setCiControl(false);
});
} else { } else {
route.setAtsControl(false); route.setAtsControl(false);
} }
@ -728,7 +737,10 @@ public class RouteService {
String.format("正在延时解锁")); String.format("正在延时解锁"));
} }
if (simulation.getRepository().getConfig().isCancelAtsControlOfAllRoutesWhenCancelRoute()) { if (simulation.getRepository().getConfig().isCancelAtsControlOfAllRoutesWhenCancelRoute()) {
route.getStart().getRouteList().forEach(aRoute -> aRoute.setAtsControl(false)); route.getStart().getRouteList().forEach(aRoute -> {
aRoute.setAtsControl(false);
aRoute.setCiControl(false);
});
} else { } else {
route.setAtsControl(false); route.setAtsControl(false);
} }
@ -1066,6 +1078,9 @@ public class RouteService {
} else { } else {
if (section.isSwitchTrack()) { // 如果是道岔区段解锁道岔 if (section.isSwitchTrack()) { // 如果是道岔区段解锁道岔
section.routeUnlocking(right); section.routeUnlocking(right);
if (section.getParent() != null && section.getParent().isCross()) {
section.getParent().routeUnlocking(right);
}
relSwitch.routeUnlock(); relSwitch.routeUnlock();
relSwitch.overlapUnLock(); relSwitch.overlapUnLock();
// 侧防解锁 // 侧防解锁

View File

@ -4,8 +4,6 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
import club.joylink.rtss.simulation.cbtc.data.map.Route; import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -26,14 +24,13 @@ public class SectionService {
/** /**
* 封锁(封锁后包含区段的进路不能排列) * 封锁(封锁后包含区段的进路不能排列)
* @param section
*/ */
public void blockade(Section section) { public void blockade(Section section) {
// if(section.isRouteLock() || section.isOverlapLock()) { // if(section.isRouteLock() || section.isOverlapLock()) {
// log.info(String.format("区段[%s(%s)]进路锁闭,不能封锁", section.getName(), section.getCode())); // log.info(String.format("区段[%s(%s)]进路锁闭,不能封锁", section.getName(), section.getCode()));
// return; // return;
// } // }
if(!section.isBlockade()) { if (!section.isBlockade()) {
section.setBlockade(true); section.setBlockade(true);
if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) { if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) {
section.getLogicList().forEach(logic -> logic.setBlockade(true)); section.getLogicList().forEach(logic -> logic.setBlockade(true));
@ -43,10 +40,9 @@ public class SectionService {
/** /**
* 解封 * 解封
* @param section
*/ */
public void unblock(Section section) { public void unblock(Section section) {
if(section.isBlockade()) { if (section.isBlockade()) {
section.setBlockade(false); section.setBlockade(false);
if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) { if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) {
section.getLogicList().forEach(logic -> logic.setBlockade(false)); section.getLogicList().forEach(logic -> logic.setBlockade(false));
@ -56,33 +52,8 @@ public class SectionService {
/** /**
* 区故解 * 区故解
* @param simulation
* @param section
* @param route
*/ */
public void sectionFaultUnlock(Simulation simulation, Section section, Route route) { public void sectionFaultUnlock(Simulation simulation, Section section, Route route) {
if (Objects.nonNull(route) && route.isApproachLock()) { // 进路接近锁闭
// 关闭进路始端信号机
this.signalService.close(simulation, route.getStart());
// 区段延时解锁
section.setDelayTime(route.getDelayReleaseTime() * 1000);
} else { // 解锁
if (Objects.nonNull(route)) {
if (route.isOpen()) {
this.signalService.close(simulation, route.getStart());
} else if (route.isLock()){
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"延时解锁中");
}
}
section.faultUnlock();
if(section.isShowLogic()){
section.getLogicList().forEach(ls -> ls.faultUnlock());
}
}
}
public void sectionForceUnlock(Simulation simulation, Section section, Route route) {
if (route != null) { if (route != null) {
if (route.isOpen()) { if (route.isOpen()) {
signalService.close(simulation, route.getStart()); signalService.close(simulation, route.getStart());
@ -90,19 +61,23 @@ public class SectionService {
if (route.isApproachLock()) { if (route.isApproachLock()) {
// 区段延时解锁 // 区段延时解锁
section.setDelayTime(route.getDelayReleaseTime() * 1000); section.setDelayTime(route.getDelayReleaseTime() * 1000);
if(section.isShowLogic()){ if (section.isShowLogic()) {
section.getLogicList().forEach(ls -> ls.setDelayTime(route.getDelayReleaseTime() * 1000)); section.getLogicList().forEach(ls -> ls.setDelayTime(route.getDelayReleaseTime() * 1000));
} }
return; return;
} else {
route.setLock(false);
} }
} }
section.forceUnlocking(); section.faultUnlock();
if(section.isShowLogic()){ if (section.isShowLogic()) {
section.getLogicList().forEach(ls -> ls.forceUnlocking()); section.getLogicList().forEach(Section::faultUnlock);
} }
} }
/** /**
* 区段延时区故解 * 区段延时区故解
*
* @param simulation * @param simulation
* @param section * @param section
*/ */
@ -114,7 +89,7 @@ public class SectionService {
List<Route> routeList = simulation.getRepository().queryAllLockedRoute(); List<Route> routeList = simulation.getRepository().queryAllLockedRoute();
Route lockedRoute = null; Route lockedRoute = null;
for (Route route : routeList) { for (Route route : routeList) {
if (route.isRouteSection(section)) { if (route.containSection(section)) {
lockedRoute = route; lockedRoute = route;
break; break;
} }
@ -123,11 +98,7 @@ public class SectionService {
lockedRoute.setLock(false); lockedRoute.setLock(false);
this.signalService.close(simulation, lockedRoute.getStart()); this.signalService.close(simulation, lockedRoute.getStart());
} }
if(section.isFaultLock()){ section.faultUnlock();
section.faultUnlock();
}else{
section.forceUnlocking();
}
section.setDelayTime(0); section.setDelayTime(0);
} else { } else {
section.setDelayTime(remainTime); section.setDelayTime(remainTime);

View File

@ -8,8 +8,6 @@ import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Switch; import club.joylink.rtss.simulation.cbtc.data.map.Switch;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent; import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
@ -134,22 +132,19 @@ public class SwitchService {
* @param route * @param route
*/ */
public void switchFaultUnlock(Simulation simulation, Switch aSwitch, Route route) { public void switchFaultUnlock(Simulation simulation, Switch aSwitch, Route route) {
if (Objects.nonNull(route) && route.isApproachLock()) { // 进路接近锁闭 if (route != null) {
// 关闭进路始端信号机 if (route.isOpen()) {
this.signalService.close(simulation, route.getStart()); signalService.close(simulation, route.getStart());
// 区段延时解锁 }
aSwitch.setDelayTime(route.getDelayReleaseTime()*1000); if (route.isApproachLock()) {
} else { // 解锁 // 区段延时解锁
if (Objects.nonNull(route)) { aSwitch.setDelayTime(route.getDelayReleaseTime() * 1000);
if (route.isOpen()) { return;
this.signalService.close(simulation, route.getStart()); } else {
} else if (route.isLock()){ route.setLock(false);
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"延时解锁中");
}
} }
aSwitch.sectionFaultUnlock();
} }
aSwitch.sectionFaultUnlock();
} }
public void delayUnlock(Simulation simulation, Switch aSwitch) { public void delayUnlock(Simulation simulation, Switch aSwitch) {

View File

@ -31,6 +31,7 @@ public abstract class MayOutOfOrderDevice extends MapNamedElement {
@JsonSubTypes.Type(value = Switch.SwitchFault.class, name = "Switch$SwitchFault$1"), @JsonSubTypes.Type(value = Switch.SwitchFault.class, name = "Switch$SwitchFault$1"),
@JsonSubTypes.Type(value = Switch.SwitchFault.class, name = "Switch$SwitchFault$2"), @JsonSubTypes.Type(value = Switch.SwitchFault.class, name = "Switch$SwitchFault$2"),
@JsonSubTypes.Type(value = Switch.SwitchFault.class, name = "Switch$SwitchFault$3"), @JsonSubTypes.Type(value = Switch.SwitchFault.class, name = "Switch$SwitchFault$3"),
@JsonSubTypes.Type(value = Switch.SwitchFault.class, name = "Switch$SwitchFault$4"),
@JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$1"), @JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$1"),
@JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$1"), @JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$1"),
@JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$2"), @JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$2"),

View File

@ -66,11 +66,6 @@ public class Section extends MayOutOfOrderDevice {
*/ */
private boolean axleCounter; private boolean axleCounter;
/**
* 是否岔心
*/
private boolean crossing;
/** /**
* 虚拟真实计轴器 * 虚拟真实计轴器
*/ */
@ -91,7 +86,7 @@ public class Section extends MayOutOfOrderDevice {
private Section parent; private Section parent;
/** /**
* 关联的逻辑区段列表 * 岔心关联的道岔计轴区段道岔计轴区段关联的道岔区段物理区段关联的逻辑区段
*/ */
private List<Section> logicList; private List<Section> logicList;
@ -535,10 +530,13 @@ public class Section extends MayOutOfOrderDevice {
/** /**
* 进路锁闭(连同逻辑区段) * 进路锁闭(连同逻辑区段)
*
* @param right
*/ */
public void routeLocking(boolean right) { public void routeLocking(boolean right) {
//岔心锁闭
if (this.parent != null && this.parent.isCross()) {
this.parent.setRouteLock(true);
this.parent.setLockRight(right);
}
this.routeLock = true; this.routeLock = true;
this.lockRight = right; this.lockRight = right;
if (!CollectionUtils.isEmpty(this.logicList)) { if (!CollectionUtils.isEmpty(this.logicList)) {
@ -552,6 +550,12 @@ public class Section extends MayOutOfOrderDevice {
* @param right * @param right
*/ */
public void routeUnlocking(boolean right) { public void routeUnlocking(boolean right) {
//岔心锁闭
if (this.parent != null && this.parent.isCross()) {
this.parent.setRouteLock(false);
this.parent.setOverlapLock(false);
this.parent.setLockRight(false);
}
if (this.isRouteLockOn(right)) { if (this.isRouteLockOn(right)) {
this.routeLock = false; this.routeLock = false;
this.overlapLock = false; this.overlapLock = false;
@ -575,6 +579,11 @@ public class Section extends MayOutOfOrderDevice {
* 进路延续保护(连同逻辑区段) * 进路延续保护(连同逻辑区段)
*/ */
public void overlapLocking(boolean lockRight) { public void overlapLocking(boolean lockRight) {
//封锁岔心
if (this.parent != null && this.parent.isCross()) {
this.parent.setOverlapLock(true);
this.parent.setLockRight(lockRight);
}
this.overlapLock = true; this.overlapLock = true;
this.lockRight = lockRight; this.lockRight = lockRight;
if (!CollectionUtils.isEmpty(this.logicList)) { if (!CollectionUtils.isEmpty(this.logicList)) {

View File

@ -371,7 +371,7 @@ public class Signal extends MayOutOfOrderDevice {
} }
public void guideStart() { public void guideStart() {
this.guideRemain = 15 * 1000; this.guideRemain = 30 * 1000;
} }
public void guideInfinite() { public void guideInfinite() {
@ -391,7 +391,7 @@ public class Signal extends MayOutOfOrderDevice {
*/ */
public boolean isHumanControl() { public boolean isHumanControl() {
if (!CollectionUtils.isEmpty(routeList)) { if (!CollectionUtils.isEmpty(routeList)) {
return routeList.stream().noneMatch(Route::isAtsControl); return routeList.stream().allMatch(route -> !route.isAtsControl() && !route.isCiControl());
} else { } else {
return false; return false;
} }

View File

@ -94,11 +94,6 @@ public class Switch extends MayOutOfOrderDevice {
*/ */
private int delayTime; private int delayTime;
/**
* 是否失表故障
*/
private boolean split;
/** /**
* 无状态 * 无状态
*/ */
@ -116,14 +111,11 @@ public class Switch extends MayOutOfOrderDevice {
this.normalPosition = true; this.normalPosition = true;
this.reversePosition = false; this.reversePosition = false;
this.delayTime = 0; this.delayTime = 0;
this.split = false;
this.noStatus = false; this.noStatus = false;
} }
/** /**
* 是否被锁闭 * 是否被锁闭
*
* @return
*/ */
public boolean isLocked() { public boolean isLocked() {
return this.singleLock || this.routeLock || this.overlapLock || this.isFpLock(); return this.singleLock || this.routeLock || this.overlapLock || this.isFpLock();
@ -131,8 +123,6 @@ public class Switch extends MayOutOfOrderDevice {
/** /**
* 是否道岔区段被占用 * 是否道岔区段被占用
*
* @return
*/ */
public boolean isSectionOccupied() { public boolean isSectionOccupied() {
return this.a.isOccupied(); return this.a.isOccupied();
@ -140,9 +130,6 @@ public class Switch extends MayOutOfOrderDevice {
/** /**
* 道岔是否在定/反位上 * 道岔是否在定/反位上
*
* @param normal
* @return
*/ */
public boolean isOnPosition(boolean normal) { public boolean isOnPosition(boolean normal) {
return (this.normalPosition && normal) || (!normal && this.reversePosition); return (this.normalPosition && normal) || (!normal && this.reversePosition);
@ -150,9 +137,6 @@ public class Switch extends MayOutOfOrderDevice {
/** /**
* 是否道岔关联的区段 * 是否道岔关联的区段
*
* @param section
* @return
*/ */
public boolean isRelatedSection(Section section) { public boolean isRelatedSection(Section section) {
return Objects.equals(this.a.getCode(), section.getCode()) || return Objects.equals(this.a.getCode(), section.getCode()) ||
@ -286,7 +270,7 @@ public class Switch extends MayOutOfOrderDevice {
if (section.isSwitchTrack() && Objects.equals(section.getRelSwitch().getC(), section)) { // 是另一个道岔的C区段则是联动道岔 if (section.isSwitchTrack() && Objects.equals(section.getRelSwitch().getC(), section)) { // 是另一个道岔的C区段则是联动道岔
return section.getRelSwitch(); return section.getRelSwitch();
} }
if (Objects.nonNull(section.getParent()) && section.getParent().isCrossing()) { if (Objects.nonNull(section.getParent()) && section.getParent().isCross()) {
if (Objects.equals(section.getRightSection(), this.getC())) { if (Objects.equals(section.getRightSection(), this.getC())) {
return section.getLeftSection().getRelSwitch(); return section.getLeftSection().getRelSwitch();
} else if (Objects.equals(section.getLeftSection(), this.getC())) { } else if (Objects.equals(section.getLeftSection(), this.getC())) {
@ -380,6 +364,19 @@ public class Switch extends MayOutOfOrderDevice {
return List.of(a, b, c); return List.of(a, b, c);
} }
/**
* 是否失表
*/
public boolean isLoss() {
return !this.isNormalPosition() && !this.isReversePosition();
}
public void forceUnlock() {
this.routeLock = false;
this.overlapLock = false;
this.fpLock = false;
}
public enum SwitchFault implements DeviceFault { public enum SwitchFault implements DeviceFault {
/** /**
* 道岔失表 * 道岔失表
@ -428,10 +425,33 @@ public class Switch extends MayOutOfOrderDevice {
aSwitch.setReversePosition(false); aSwitch.setReversePosition(false);
return true; return true;
} }
},
/**
* 挤岔
*/
SQUEEZE {
@Override
public boolean apply(MayOutOfOrderDevice device) {
Switch aSwitch = (Switch) device;
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
if (VirtualRealitySwitch.Fault.SQUEEZE.apply(vrSwitch)) {
aSwitch.setFault(this);
aSwitch.setNormalPosition(false);
aSwitch.setReversePosition(false);
return true;
}
return false;
}
@Override
public void fix(MayOutOfOrderDevice device) {
super.fix(device);
Switch aSwitch = (Switch) device;
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
VirtualRealitySwitch.Fault.SQUEEZE.fix(vrSwitch);
vrSwitch.startSetting(true);
}
} }
} }
public boolean isLoss() {
return !this.isNormalPosition() && !this.isReversePosition();
}
} }

View File

@ -55,11 +55,6 @@ public class SwitchStatus extends DeviceStatus {
@JsonDeserialize(using = Boolean2NumDeserializer.class) @JsonDeserialize(using = Boolean2NumDeserializer.class)
private boolean reversePosition; private boolean reversePosition;
/** 是否故障失表了 */
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private boolean split;
/** /**
* 延时区段故障解锁剩余时间,单位s * 延时区段故障解锁剩余时间,单位s
*/ */
@ -68,6 +63,11 @@ public class SwitchStatus extends DeviceStatus {
@JsonSerialize(using = Boolean2NumSerializer.class) @JsonSerialize(using = Boolean2NumSerializer.class)
private boolean noStatus; private boolean noStatus;
/**
* 故障
*/
private Switch.SwitchFault fault;
public SwitchStatus(Switch aSwitch) { public SwitchStatus(Switch aSwitch) {
super(aSwitch.getCode(), aSwitch.getDeviceType()); super(aSwitch.getCode(), aSwitch.getDeviceType());
this.singleLock = aSwitch.isSingleLock(); this.singleLock = aSwitch.isSingleLock();
@ -77,7 +77,6 @@ public class SwitchStatus extends DeviceStatus {
this.overlapLock = aSwitch.isOverlapLock(); this.overlapLock = aSwitch.isOverlapLock();
this.normalPosition = aSwitch.isNormalPosition(); this.normalPosition = aSwitch.isNormalPosition();
this.reversePosition = aSwitch.isReversePosition(); this.reversePosition = aSwitch.isReversePosition();
this.split = aSwitch.isSplit();
this.delayTime = aSwitch.getDelayTime() / 1000; this.delayTime = aSwitch.getDelayTime() / 1000;
this.noStatus = aSwitch.isNoStatus(); this.noStatus = aSwitch.isNoStatus();
} }
@ -122,11 +121,6 @@ public class SwitchStatus extends DeviceStatus {
status.setReversePosition(this.reversePosition); status.setReversePosition(this.reversePosition);
change = true; change = true;
} }
if (!Objects.equals(this.split, aSwitch.isSplit())) {
this.split = aSwitch.isSplit();
status.setSplit(this.split);
change = true;
}
int dt = aSwitch.getDelayTime() / 1000; int dt = aSwitch.getDelayTime() / 1000;
if (dt != this.delayTime) { if (dt != this.delayTime) {
this.delayTime = dt; this.delayTime = dt;
@ -138,21 +132,26 @@ public class SwitchStatus extends DeviceStatus {
status.setNoStatus(this.noStatus); status.setNoStatus(this.noStatus);
change = true; change = true;
} }
if (!Objects.equals(this.fault, aSwitch.getFault())) {
this.fault = (Switch.SwitchFault) aSwitch.getFault();
status.setFault(this.fault != null ? this.fault.name() : null);
change = true;
}
return change; return change;
} }
@Override @Override
public DeviceStatusVO convert2VO(MapElement device) { public DeviceStatusVO convert2VO(MapElement device) {
SwitchStatusVO statusVO = new SwitchStatusVO((Switch) device); SwitchStatusVO statusVO = new SwitchStatusVO((Switch) device);
statusVO.setSplit(split);
statusVO.setReversePosition(reversePosition); statusVO.setReversePosition(reversePosition);
statusVO.setNormalPosition(normalPosition); statusVO.setNormalPosition(normalPosition);
statusVO.setOverlapLock(overlapLock); statusVO.setOverlapLock(overlapLock);
statusVO.setRouteLock(routeLock); statusVO.setRouteLock(routeLock);
statusVO.setFpLock(this.fpLock); statusVO.setFpLock(fpLock);
statusVO.setBlockade(blockade); statusVO.setBlockade(blockade);
statusVO.setSingleLock(singleLock); statusVO.setSingleLock(singleLock);
statusVO.setNoStatus(noStatus); statusVO.setNoStatus(noStatus);
statusVO.setFault(this.fault != null ? this.fault.name() : null);
return statusVO; return statusVO;
} }
} }

View File

@ -79,13 +79,6 @@ public class StorageSwitch extends StorageMayOutOfOrderDevice {
*/ */
private Integer delayTime; private Integer delayTime;
/**
* 是否失表
*/
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean split;
@JsonSerialize(using = Boolean2NumSerializer.class) @JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class) @JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean noStatus; private Boolean noStatus;
@ -136,10 +129,6 @@ public class StorageSwitch extends StorageMayOutOfOrderDevice {
change = true; change = true;
storageSwitch.setDelayTime(s.getDelayTime()); storageSwitch.setDelayTime(s.getDelayTime());
} }
if (s.isSplit()) {
change = true;
storageSwitch.setSplit(s.isSplit());
}
if (s.isNoStatus()) { if (s.isNoStatus()) {
change = true; change = true;
storageSwitch.setNoStatus(s.isNoStatus()); storageSwitch.setNoStatus(s.isNoStatus());
@ -166,7 +155,6 @@ public class StorageSwitch extends StorageMayOutOfOrderDevice {
s.setNormalPosition(normalPosition != null ? normalPosition : true); s.setNormalPosition(normalPosition != null ? normalPosition : true);
s.setReversePosition(reversePosition != null ? reversePosition : false); s.setReversePosition(reversePosition != null ? reversePosition : false);
s.setDelayTime(delayTime != null ? delayTime : 0); s.setDelayTime(delayTime != null ? delayTime : 0);
s.setSplit(split != null ? split : false);
s.setNoStatus(noStatus != null ? noStatus : false); s.setNoStatus(noStatus != null ? noStatus : false);
} }
} }

View File

@ -46,16 +46,15 @@ public class SwitchStatusVO extends DeviceStatusVO {
@JsonSerialize(using = Boolean2NumSerializer.class) @JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean reversePosition; private Boolean reversePosition;
/** 是否故障失表了 */
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean split;
@JsonInclude @JsonInclude
private Integer delayTime; private Integer delayTime;
@JsonSerialize(using = Boolean2NumSerializer.class) @JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean noStatus; private Boolean noStatus;
@JsonInclude
private String fault;
public SwitchStatusVO(Switch aSwitch) { public SwitchStatusVO(Switch aSwitch) {
super(aSwitch.getCode(), aSwitch.getDeviceType()); super(aSwitch.getCode(), aSwitch.getDeviceType());
} }

View File

@ -14,20 +14,30 @@ import java.util.Objects;
@Setter @Setter
public class VirtualRealitySwitch extends VirtualRealityDevice { public class VirtualRealitySwitch extends VirtualRealityDevice {
/** 虚拟道岔转换时间 */ /**
* 虚拟道岔转换时间
*/
private float settingTime; private float settingTime;
/** 是否定位 */ /**
* 是否定位
*/
private boolean normal; private boolean normal;
/** 是否反位 */ /**
* 是否反位
*/
private boolean reverse; private boolean reverse;
// -------------运行逻辑控制参数------------- // -------------运行逻辑控制参数-------------
/** 是否正在转换 */ /**
* 是否正在转换
*/
private boolean setting; private boolean setting;
/** 道岔转换剩余时间 */ /**
* 道岔转换剩余时间
*/
private Float remainTime; private Float remainTime;
/** /**
@ -35,10 +45,12 @@ public class VirtualRealitySwitch extends VirtualRealityDevice {
*/ */
private int timeoutRemain; private int timeoutRemain;
/** 道岔转换指令——是否转动到定位 */ /**
* 道岔转换指令是否转动到定位
*/
private boolean toNormal; private boolean toNormal;
/*private SwitchFault fault;*/ private Fault fault;
public VirtualRealitySwitch(String code, String name) { public VirtualRealitySwitch(String code, String name) {
super(code, name, MapElement.DeviceType.SWITCH); super(code, name, MapElement.DeviceType.SWITCH);
@ -76,7 +88,6 @@ public class VirtualRealitySwitch extends VirtualRealityDevice {
/** /**
* 开始转换 * 开始转换
* @param toNormal
*/ */
public void startSetting(boolean toNormal) { public void startSetting(boolean toNormal) {
this.remainTime = this.settingTime; this.remainTime = this.settingTime;
@ -92,11 +103,10 @@ public class VirtualRealitySwitch extends VirtualRealityDevice {
this.setting = false; this.setting = false;
this.remainTime = null; this.remainTime = null;
this.timeoutRemain = 0; this.timeoutRemain = 0;
/*if (this.isFault()) { if (Fault.SQUEEZE.equals(this.fault)) {
// 如果故障
return; return;
}*/ }
if(this.toNormal) { if (this.toNormal) {
this.normal = true; this.normal = true;
this.reverse = false; this.reverse = false;
} else { } else {
@ -107,6 +117,7 @@ public class VirtualRealitySwitch extends VirtualRealityDevice {
/** /**
* 是否失表 * 是否失表
*
* @return * @return
*/ */
public boolean isLoss() { public boolean isLoss() {
@ -117,10 +128,10 @@ public class VirtualRealitySwitch extends VirtualRealityDevice {
* 失去表示 * 失去表示
*/ */
public void loss() { public void loss() {
if(this.normal) { if (this.normal) {
this.normal = false; this.normal = false;
} }
if(this.reverse) { if (this.reverse) {
this.reverse = false; this.reverse = false;
} }
} }
@ -136,30 +147,29 @@ public class VirtualRealitySwitch extends VirtualRealityDevice {
return this.isSetting() && Objects.equals(toNormal, this.toNormal); return this.isSetting() && Objects.equals(toNormal, this.toNormal);
} }
/*public enum SwitchFault implements DeviceFault { public enum Fault {
*//** 道岔挤岔 *//* /**
SPLIT{ * 挤岔
*/
SQUEEZE {
@Override @Override
public boolean applyOn(VirtualRealityDevice device) { public boolean apply(VirtualRealitySwitch vrSwitch) {
VirtualRealitySwitch vrSwitch = (VirtualRealitySwitch) device; if (this.equals(vrSwitch.getFault()))
if (Objects.equals(vrSwitch.getFault(), SPLIT)) {
return false; return false;
} vrSwitch.setFault(this);
vrSwitch.setFault(SPLIT); vrSwitch.setNormal(false);
if (!vrSwitch.isLoss()) { vrSwitch.setReverse(false);
vrSwitch.setToNormal(vrSwitch.isNormal());
}
vrSwitch.loss();
return true; return true;
} }
};
@Override public abstract boolean apply(VirtualRealitySwitch vrSwitch);
public void clearFrom(VirtualRealityDevice device) {
VirtualRealitySwitch vrSwitch = (VirtualRealitySwitch) device; public void fix(VirtualRealitySwitch vrSwitch) {
if (this.equals(vrSwitch.getFault())) {
vrSwitch.setFault(null); vrSwitch.setFault(null);
vrSwitch.endSetting();
} }
}, }
}*/ }
} }