【修改单操生成时背景设置逻辑】

This commit is contained in:
weizhihong 2023-05-20 13:31:57 +08:00
parent d048ae9c60
commit 145bc63540
2 changed files with 58 additions and 104 deletions

View File

@ -33,25 +33,22 @@ public enum BgSceneStatusRule {
*/ */
ROUTE_SET_BG_SCENE("排列进路背景") { ROUTE_SET_BG_SCENE("排列进路背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Route route = (Route) mapElement; Route route = (Route) mapElement;
route.getSwitchList().forEach(switchElement -> switchElement.getASwitch().setSingleLock(false)); route.getSwitchList().forEach(switchElement -> switchElement.getASwitch().setSingleLock(false));
return getBgScene(simulation);
} }
}, },
ROUTE_CANCEL_BG_SCENE("取消进路背景") { ROUTE_CANCEL_BG_SCENE("取消进路背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
openRouteDirect(simulation, (Route) mapElement); openRouteDirect(simulation, (Route) mapElement);
return getBgScene(simulation);
} }
}, },
ROUTE_OPEN_AUTO_SETTING_BG_SCENE("进路交自动控背景") { ROUTE_OPEN_AUTO_SETTING_BG_SCENE("进路交自动控背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Route route = (Route) mapElement; Route route = (Route) mapElement;
route.setAtsControl(false); route.setAtsControl(false);
return getBgScene(simulation);
} }
}, },
/** /**
@ -59,10 +56,9 @@ public enum BgSceneStatusRule {
*/ */
BUTTON_BLOCK_BG_SCENE("解封按钮背景") { BUTTON_BLOCK_BG_SCENE("解封按钮背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
signal.setBlockade(true); signal.setBlockade(true);
return getBgScene(simulation);
} }
}, },
/** /**
@ -70,10 +66,9 @@ public enum BgSceneStatusRule {
*/ */
SWITCH_NP_BG_SCENE("道岔定位背景") { SWITCH_NP_BG_SCENE("道岔定位背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Switch iSwitch = (Switch) mapElement; Switch iSwitch = (Switch) mapElement;
setSingleSwitchPositionDirectly(iSwitch, false); setSingleSwitchPositionDirectly(iSwitch, false);
return getBgScene(simulation);
} }
}, },
/** /**
@ -81,20 +76,18 @@ public enum BgSceneStatusRule {
*/ */
SWITCH_RP_BG_SCENE("道岔反位背景") { SWITCH_RP_BG_SCENE("道岔反位背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Switch iSwitch = (Switch) mapElement; Switch iSwitch = (Switch) mapElement;
setSingleSwitchPositionDirectly(iSwitch, true); setSingleSwitchPositionDirectly(iSwitch, true);
return getBgScene(simulation);
} }
}, },
SWITCH_NP_NB_BG_SCENE("宁波道岔定位背景") { SWITCH_NP_NB_BG_SCENE("宁波道岔定位背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Switch iSwitch = (Switch) mapElement; Switch iSwitch = (Switch) mapElement;
iSwitch.setAuto(false); iSwitch.setAuto(false);
iSwitch.setDispatcherReserve(true); iSwitch.setDispatcherReserve(true);
setSingleSwitchPositionDirectly(iSwitch, false); setSingleSwitchPositionDirectly(iSwitch, false);
return getBgScene(simulation);
} }
}, },
/** /**
@ -102,12 +95,11 @@ public enum BgSceneStatusRule {
*/ */
SWITCH_UNBLOCK_BG_SCENE("道岔解封背景") { SWITCH_UNBLOCK_BG_SCENE("道岔解封背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Switch iSwitch = (Switch) mapElement; Switch iSwitch = (Switch) mapElement;
iSwitch.setBlockade(true); iSwitch.setBlockade(true);
iSwitch.getAllSections().stream().forEach(section -> section.setBlockade(true)); iSwitch.getAllSections().forEach(section -> section.setBlockade(true));
iSwitch.setInit(false); iSwitch.setInit(false);
return getBgScene(simulation);
} }
}, },
/** /**
@ -115,57 +107,52 @@ public enum BgSceneStatusRule {
*/ */
SWITCH_SINGLE_BLOCK_BG_SCENE("道岔单锁背景") { SWITCH_SINGLE_BLOCK_BG_SCENE("道岔单锁背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Switch iSwitch = (Switch) mapElement; Switch iSwitch = (Switch) mapElement;
iSwitch.setSingleLock(false); iSwitch.setSingleLock(false);
return getBgScene(simulation);
} }
}, },
SWITCH_SINGLE_UNBLOCK_BG_SCENE("道岔单解背景") { SWITCH_SINGLE_UNBLOCK_BG_SCENE("道岔单解背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Switch iSwitch = (Switch) mapElement; Switch iSwitch = (Switch) mapElement;
iSwitch.setSingleLock(true); iSwitch.setSingleLock(true);
return getBgScene(simulation);
} }
}, },
SWITCH_FAULT_UNLOCK_BG_SCENE("道岔故障解锁背景") { SWITCH_FAULT_UNLOCK_BG_SCENE("道岔故障解锁背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Switch iSwitch = (Switch) mapElement; Switch iSwitch = (Switch) mapElement;
iSwitch.setRouteLock(true); iSwitch.setRouteLock(true);
iSwitch.getAllSections().forEach(section -> section.setRouteLock(true)); iSwitch.getAllSections().forEach(section -> section.setRouteLock(true));
return getBgScene(simulation);
} }
}, },
SWITCH_AXLE_FAULT_PRE_RESET_BG_SCENE("道岔计轴预复位背景") { SWITCH_AXLE_FAULT_PRE_RESET_BG_SCENE("道岔计轴预复位背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Switch iSwitch = (Switch) mapElement; Switch iSwitch = (Switch) mapElement;
Switch.SwitchFault.AXLE_FAULT.apply(iSwitch); Switch.SwitchFault.AXLE_FAULT.apply(iSwitch);
return getBgScene(simulation);
} }
}, },
SWITCH_SECTION_ACTIVE_BG_SCENE("道岔区段激活背景") { SWITCH_SECTION_ACTIVE_BG_SCENE("道岔区段激活背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Switch iSwitch = (Switch) mapElement; Switch iSwitch = (Switch) mapElement;
return SECTION_ACTIVE_BG_SCENE.doHandle(simulation, iSwitch.getA(), client); SECTION_ACTIVE_BG_SCENE.doHandle(simulation, iSwitch.getA(), client);
} }
}, },
SWITCH_SECTION_LIMIT_SPEED("道岔区段速度限制背景") { SWITCH_SECTION_LIMIT_SPEED("道岔区段速度限制背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Switch iSwitch = (Switch) mapElement; Switch iSwitch = (Switch) mapElement;
iSwitch.getAllSections().forEach(section -> section.setSpeedUpLimit(5)); iSwitch.getAllSections().forEach(section -> section.setSpeedUpLimit(5));
return getBgScene(simulation);
} }
}, },
SWITCH_ACTIVE_BG_SCENE("道岔区段激活背景") { SWITCH_ACTIVE_BG_SCENE("道岔区段激活背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Switch iSwitch = (Switch) mapElement; Switch iSwitch = (Switch) mapElement;
return BgSceneStatusRule.SECTION_ACTIVE_BG_SCENE.doHandle(simulation,iSwitch.getA(), client); BgSceneStatusRule.SECTION_ACTIVE_BG_SCENE.doHandle(simulation,iSwitch.getA(), client);
} }
}, },
/** /**
@ -173,12 +160,11 @@ public enum BgSceneStatusRule {
*/ */
SIGNAL_TURN_ON_BG_SCENE("信号机点灯背景") { SIGNAL_TURN_ON_BG_SCENE("信号机点灯背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
signal.setAspect(SignalAspect.No); signal.setAspect(SignalAspect.No);
VirtualRealitySignal vrSignal = signal.getVirtualSignal(); VirtualRealitySignal vrSignal = signal.getVirtualSignal();
vrSignal.setAspect(SignalAspect.No); vrSignal.setAspect(SignalAspect.No);
return getBgScene(simulation);
} }
}, },
/** /**
@ -186,12 +172,11 @@ public enum BgSceneStatusRule {
*/ */
SIGNAL_TURN_OFF_BG_SCENE("信号机灭灯背景") { SIGNAL_TURN_OFF_BG_SCENE("信号机灭灯背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
VirtualRealitySignal vrSignal = signal.getVirtualSignal(); VirtualRealitySignal vrSignal = signal.getVirtualSignal();
signal.setAspect(vrSignal.getModel().getDefaultAspect()); signal.setAspect(vrSignal.getModel().getDefaultAspect());
vrSignal.setAspect(vrSignal.getModel().getDefaultAspect()); vrSignal.setAspect(vrSignal.getModel().getDefaultAspect());
return getBgScene(simulation);
} }
}, },
/** /**
@ -199,7 +184,7 @@ public enum BgSceneStatusRule {
*/ */
SIGNAL_REOPEN_BG_SCENE("信号机重开背景") { SIGNAL_REOPEN_BG_SCENE("信号机重开背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
Route route = signal.getRouteList().get(0); Route route = signal.getRouteList().get(0);
openRouteDirect(simulation, route); openRouteDirect(simulation, route);
@ -207,7 +192,6 @@ public enum BgSceneStatusRule {
signal.setForbidden(true); signal.setForbidden(true);
signal.setAspect(signal.getDefaultAspect()); signal.setAspect(signal.getDefaultAspect());
vrSignal.setAspect(signal.getDefaultAspect()); vrSignal.setAspect(signal.getDefaultAspect());
return getBgScene(simulation);
} }
}, },
/** /**
@ -215,7 +199,7 @@ public enum BgSceneStatusRule {
*/ */
SIGNAL_CLOSE_BG_SCENE("信号机关灯背景") { SIGNAL_CLOSE_BG_SCENE("信号机关灯背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
Route route = signal.getRouteList().stream() Route route = signal.getRouteList().stream()
// .filter(r -> r.getSwitchList().stream().allMatch(switchElement -> switchElement.isNormal())) // .filter(r -> r.getSwitchList().stream().allMatch(switchElement -> switchElement.isNormal()))
@ -224,7 +208,6 @@ public enum BgSceneStatusRule {
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error); throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
} }
openRouteDirect(simulation, route); openRouteDirect(simulation, route);
return getBgScene(simulation);
} }
}, },
/** /**
@ -232,7 +215,7 @@ public enum BgSceneStatusRule {
*/ */
SIGNAL_GUIDE_BG_SCENE("信号机引导背景") { SIGNAL_GUIDE_BG_SCENE("信号机引导背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
// 开放进路 // 开放进路
Route route = signal.getRouteList().get(0); Route route = signal.getRouteList().get(0);
@ -247,7 +230,6 @@ public enum BgSceneStatusRule {
.filter(o -> o instanceof VirtualRealityTrain).findFirst().get(); .filter(o -> o instanceof VirtualRealityTrain).findFirst().get();
Section section = route.getStart().getSection(); Section section = route.getStart().getSection();
trainOnline(simulation, train, section, route.isRight()); trainOnline(simulation, train, section, route.isRight());
return getBgScene(simulation);
} }
}, },
/** /**
@ -255,25 +237,23 @@ public enum BgSceneStatusRule {
*/ */
SIGNAL_ROUTE_AUTO_SET_BG_SCENE("进路交自动控背景") { SIGNAL_ROUTE_AUTO_SET_BG_SCENE("进路交自动控背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
Route route = signal.getRouteList().get(0); Route route = signal.getRouteList().get(0);
route.setAtsControl(false); route.setAtsControl(false);
return getBgScene(simulation);
} }
}, },
SIGNAL_ROUTE_CANCEL_AUTO_SET_BG_SCENE("取消联锁自动触发背景") { SIGNAL_ROUTE_CANCEL_AUTO_SET_BG_SCENE("取消联锁自动触发背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
Route route = signal.getRouteList().get(0); Route route = signal.getRouteList().get(0);
route.setCiControl(true); route.setCiControl(true);
return getBgScene(simulation);
} }
}, },
SIGNAL_SET_CI_AUTO_BG_SCENE("联锁自动进路背景") { SIGNAL_SET_CI_AUTO_BG_SCENE("联锁自动进路背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
List<Route> fltRouteList = signal.getRouteList().stream().filter(Route::isFlt).collect(Collectors.toList()); List<Route> fltRouteList = signal.getRouteList().stream().filter(Route::isFlt).collect(Collectors.toList());
boolean isSetFlt = simulation.getRepository().getConfig().isSetRouteBeforeSetFlt(); boolean isSetFlt = simulation.getRepository().getConfig().isSetRouteBeforeSetFlt();
@ -282,30 +262,27 @@ public enum BgSceneStatusRule {
openRouteDirect(simulation, route); openRouteDirect(simulation, route);
} }
} }
return getBgScene(simulation);
} }
}, },
SIGNAL_CANCEL_SET_CI_AUTO_BG_SCENE("取消联锁自动进路背景") { SIGNAL_CANCEL_SET_CI_AUTO_BG_SCENE("取消联锁自动进路背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
Route route = signal.getRouteList().get(0); Route route = signal.getRouteList().get(0);
openRouteDirect(simulation, route); openRouteDirect(simulation, route);
route.setFleetMode(true); route.setFleetMode(true);
return getBgScene(simulation);
} }
}, },
SIGNAL_UN_BLOCK_BG_SCENE("信号机解封锁背景") { SIGNAL_UN_BLOCK_BG_SCENE("信号机解封锁背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
signal.setBlockade(true); signal.setBlockade(true);
return getBgScene(simulation);
} }
}, },
SIGNAL_HUMAN_RELEASE_BG_SCENE("信号机总人解背景"){ SIGNAL_HUMAN_RELEASE_BG_SCENE("信号机总人解背景"){
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
Route route = signal.getRouteList().get(0); Route route = signal.getRouteList().get(0);
openRouteDirect(simulation, route); openRouteDirect(simulation, route);
@ -315,18 +292,16 @@ public enum BgSceneStatusRule {
.filter(o -> o instanceof VirtualRealityTrain).findFirst().get(); .filter(o -> o instanceof VirtualRealityTrain).findFirst().get();
Section section = route.getStart().getSection(); Section section = route.getStart().getSection();
trainOnline(simulation, train, section, route.isRight()); trainOnline(simulation, train, section, route.isRight());
return getBgScene(simulation);
} }
}, },
SIGNAL_HUMAN_RELEASE_NB_BG_SCENE("宁波信号机总人解背景"){ SIGNAL_HUMAN_RELEASE_NB_BG_SCENE("宁波信号机总人解背景"){
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Signal signal = (Signal) mapElement; Signal signal = (Signal) mapElement;
Route route = signal.getRouteList().get(0); Route route = signal.getRouteList().get(0);
openRouteDirect(simulation, route); openRouteDirect(simulation, route);
closeSignalDirectly(route.getStart()); closeSignalDirectly(route.getStart());
Section.AxleFault.FAULT.apply(route.getStart().getSection()); Section.AxleFault.FAULT.apply(route.getStart().getSection());
return getBgScene(simulation);
} }
}, },
/** /**
@ -334,10 +309,9 @@ public enum BgSceneStatusRule {
*/ */
SECTION_FAULT_LOCK_BG_SCENE("区段区故解背景") { SECTION_FAULT_LOCK_BG_SCENE("区段区故解背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
Section.AxleFault.FAULT_LOCK.apply(section); Section.AxleFault.FAULT_LOCK.apply(section);
return getBgScene(simulation);
} }
}, },
/** /**
@ -345,7 +319,7 @@ public enum BgSceneStatusRule {
*/ */
SECTION_FAULT_UNLOCK_BG_SCENE("区段故障解锁背景") { SECTION_FAULT_UNLOCK_BG_SCENE("区段故障解锁背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
section.setRouteLock(true); section.setRouteLock(true);
if (section.isCross()) { if (section.isCross()) {
@ -353,12 +327,11 @@ public enum BgSceneStatusRule {
} else if (section.isShowLogic()) { } else if (section.isShowLogic()) {
section.getLogicList().forEach(s -> s.setRouteLock(true)); section.getLogicList().forEach(s -> s.setRouteLock(true));
} }
return getBgScene(simulation);
} }
}, },
SECTION_UNLOCK_BG_SCENE("区段解封背景"){ SECTION_UNLOCK_BG_SCENE("区段解封背景"){
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
section.setBlockade(true); section.setBlockade(true);
if (!CollectionUtils.isEmpty(section.getLogicList())) { if (!CollectionUtils.isEmpty(section.getLogicList())) {
@ -366,7 +339,6 @@ public enum BgSceneStatusRule {
logic.setBlockade(true); logic.setBlockade(true);
} }
} }
return getBgScene(simulation);
} }
}, },
/** /**
@ -374,7 +346,7 @@ public enum BgSceneStatusRule {
*/ */
SECTION_ACTIVE_BG_SCENE("区段激活背景") { SECTION_ACTIVE_BG_SCENE("区段激活背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
Section axleSection = section; Section axleSection = section;
if (Objects.nonNull(section.getParent())) { if (Objects.nonNull(section.getParent())) {
@ -384,7 +356,6 @@ public enum BgSceneStatusRule {
for (Section logic : axleSection.getLogicList()) { for (Section logic : axleSection.getLogicList()) {
logic.setCutOff(true); logic.setCutOff(true);
} }
return getBgScene(simulation);
} }
}, },
/** /**
@ -392,27 +363,25 @@ public enum BgSceneStatusRule {
*/ */
SECTION_CANCEL_LIMIT_SPEED_BG_SCENE("区段取消限速背景") { SECTION_CANCEL_LIMIT_SPEED_BG_SCENE("区段取消限速背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
section.setSpeedUpLimit(5); section.setSpeedUpLimit(5);
return getBgScene(simulation);
} }
}, },
SECTION_CONFIRM_AXIS_VALID_BG_SCENE("设置计轴生效背景") { SECTION_CONFIRM_AXIS_VALID_BG_SCENE("设置计轴生效背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
if (Objects.nonNull(section.getParent())) { if (Objects.nonNull(section.getParent())) {
section.getParent().judgeAsNctOccupied(simulation); section.getParent().judgeAsNctOccupied(simulation);
} else { } else {
section.judgeAsNctOccupied(simulation); section.judgeAsNctOccupied(simulation);
} }
return getBgScene(simulation);
} }
}, },
SECTION_AXIS_PRE_RESET_BG_SCENE("计轴预复位背景") { SECTION_AXIS_PRE_RESET_BG_SCENE("计轴预复位背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
if(!section.isAxleCounter() && !section.isCross()){ if(!section.isAxleCounter() && !section.isCross()){
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error); throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
@ -422,12 +391,11 @@ public enum BgSceneStatusRule {
virtualAxleCounter.setPreReset(false); virtualAxleCounter.setPreReset(false);
virtualAxleCounter.setLeftCount(2); virtualAxleCounter.setLeftCount(2);
virtualAxleCounter.setRightCount(2); virtualAxleCounter.setRightCount(2);
return getBgScene(simulation);
} }
}, },
SECTION_TURN_BACK_REENTRY_STRATEGY("区段折返策略修改背景"){ SECTION_TURN_BACK_REENTRY_STRATEGY("区段折返策略修改背景"){
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
Stand stand = section.getStandList().get(0); Stand stand = section.getStandList().get(0);
stand.setTypeStrategy(Stand.TurnBackType.AUTO); stand.setTypeStrategy(Stand.TurnBackType.AUTO);
@ -435,16 +403,14 @@ public enum BgSceneStatusRule {
VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream() VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream()
.filter(o -> o instanceof VirtualRealityTrain).findFirst().get(); .filter(o -> o instanceof VirtualRealityTrain).findFirst().get();
BgSceneStatusRule.trainOnline(simulation, train, section, stand.isRight()); BgSceneStatusRule.trainOnline(simulation, train, section, stand.isRight());
return getBgScene(simulation);
} }
}, },
SECTION_CLOSE_BG_SCENE("轨道开放背景") { SECTION_CLOSE_BG_SCENE("轨道开放背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Section section = (Section) mapElement; Section section = (Section) mapElement;
section.setCloseInit(false); section.setCloseInit(false);
section.setClosed(true); section.setClosed(true);
return getBgScene(simulation);
} }
}, },
/** /**
@ -452,15 +418,14 @@ public enum BgSceneStatusRule {
*/ */
STATION_POWER_ON_UNLOCK("车站上电解锁背景") { STATION_POWER_ON_UNLOCK("车站上电解锁背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Station station = MapElementRule.queryStation(mapElement); Station station = MapElementRule.queryStation(mapElement);
restartInterlock(simulation, station); restartInterlock(simulation, station);
return getBgScene(simulation);
} }
}, },
STATION_OPEN_AUTO_SETTING_BG_SCENE("全站进路交ATS自动控背景") { STATION_OPEN_AUTO_SETTING_BG_SCENE("全站进路交ATS自动控背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Station station = MapElementRule.queryStation(mapElement); Station station = MapElementRule.queryStation(mapElement);
if(!station.isInterlock()) { if(!station.isInterlock()) {
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error); throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
@ -480,12 +445,11 @@ public enum BgSceneStatusRule {
} }
} }
} }
return getBgScene(simulation);
} }
}, },
STATION_CLOSE_AUTO_SETTING_BG_SCENE("全站进路交人工控背景"){ STATION_CLOSE_AUTO_SETTING_BG_SCENE("全站进路交人工控背景"){
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Station station = (Station) mapElement; Station station = (Station) mapElement;
if(!station.isInterlock()) { if(!station.isInterlock()) {
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error); throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
@ -505,28 +469,25 @@ public enum BgSceneStatusRule {
} }
} }
} }
return getBgScene(simulation);
} }
}, },
STATION_CENTER_CONTROL_BG_SCENE ("车站设置中控背景") { STATION_CENTER_CONTROL_BG_SCENE ("车站转换中控设置的背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Station station = MapElementRule.queryStation(mapElement); Station station = MapElementRule.queryStation(mapElement);
station.setControlMode(Station.ControlMode.Local); station.setControlMode(Station.ControlMode.Local);
return getBgScene(simulation);
} }
}, },
STATION_STATION_CONTROL_BG_SCENE("车站转为站控背景") { STATION_STATION_CONTROL_BG_SCENE("车站转为站控设置的背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Station station = MapElementRule.queryStation(mapElement); Station station = MapElementRule.queryStation(mapElement);
station.setControlMode(Station.ControlMode.Center); station.setControlMode(Station.ControlMode.Center);
return getBgScene(simulation);
} }
}, },
STAND_EARLY_DEPART_BG_SCENE("提前发车背景") { STAND_EARLY_DEPART_BG_SCENE("提前发车背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Stand stand = (Stand) mapElement; Stand stand = (Stand) mapElement;
Section section = stand.getSection(); Section section = stand.getSection();
Route route = stand.getSection().getSignalToRight().getRouteList().stream().filter(r -> Route route = stand.getSection().getSignalToRight().getRouteList().stream().filter(r ->
@ -540,12 +501,11 @@ public enum BgSceneStatusRule {
VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream() VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream()
.filter(o -> o instanceof VirtualRealityTrain).findFirst().get(); .filter(o -> o instanceof VirtualRealityTrain).findFirst().get();
BgSceneStatusRule.trainOnline(simulation,train,section,route.isRight()); BgSceneStatusRule.trainOnline(simulation,train,section,route.isRight());
return getBgScene(simulation);
} }
}, },
STAND_CANCEL_HOLD_TRAIN_BG_SCENE("站台取消扣车背景") { STAND_CANCEL_HOLD_TRAIN_BG_SCENE("站台取消扣车背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Stand stand = (Stand) mapElement; Stand stand = (Stand) mapElement;
if ("localWork".equals(client)) { if ("localWork".equals(client)) {
// 现地设置背景为现地扣车 // 现地设置背景为现地扣车
@ -554,31 +514,27 @@ public enum BgSceneStatusRule {
// 行调设置背景为中心扣车 // 行调设置背景为中心扣车
stand.setCenterHoldTrain(true); stand.setCenterHoldTrain(true);
} }
return getBgScene(simulation);
} }
}, },
STAND_FORCE_CANCEL_HOLD_TRAIN_BG_SCENE("强制取消扣车背景") { STAND_FORCE_CANCEL_HOLD_TRAIN_BG_SCENE("强制取消扣车背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Stand stand = (Stand) mapElement; Stand stand = (Stand) mapElement;
stand.setCenterHoldTrain(true); stand.setCenterHoldTrain(true);
return getBgScene(simulation);
} }
}, },
STAND_CANCEL_JUMP_STOP_BG_SCENE("站台取消设置跳停背景") { STAND_CANCEL_JUMP_STOP_BG_SCENE("站台取消设置跳停背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Stand stand = (Stand) mapElement; Stand stand = (Stand) mapElement;
stand.setAllSkip(true); stand.setAllSkip(true);
return getBgScene(simulation);
} }
}, },
STAND_STRATEGY_BG_SCENE("人工折返策略设置背景") { STAND_STRATEGY_BG_SCENE("人工折返策略设置背景") {
@Override @Override
public String doHandle(Simulation simulation, MapElement mapElement, String client) { public void doHandle(Simulation simulation, MapElement mapElement, String client) {
Stand stand = (Stand) mapElement; Stand stand = (Stand) mapElement;
stand.setTypeStrategy(Stand.TurnBackType.AUTO); stand.setTypeStrategy(Stand.TurnBackType.AUTO);
return getBgScene(simulation);
} }
} }
; ;
@ -595,7 +551,7 @@ public enum BgSceneStatusRule {
/** /**
* 操作 * 操作
*/ */
public abstract String doHandle(Simulation simulation, MapElement mapElement, String client); public abstract void doHandle(Simulation simulation, MapElement mapElement, String client);
/** /**
* 直接开放进路 * 直接开放进路
@ -644,7 +600,7 @@ public enum BgSceneStatusRule {
/** /**
* 获取仿真背景 * 获取仿真背景
*/ */
public String getBgScene(Simulation simulation) { public static String getBgScene(Simulation simulation) {
return JsonUtils.writeValueAsString(new StorageSimulation(simulation, false)); return JsonUtils.writeValueAsString(new StorageSimulation(simulation, false));
} }

View File

@ -19,10 +19,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Getter @Getter
@ -65,7 +62,7 @@ public class Training2Rule {
/** /**
* 设置状态处理方法 * 设置状态处理方法
*/ */
private BgSceneStatusRule sceneRule; private List<BgSceneStatusRule> sceneRule;
/** /**
* 步骤列表 * 步骤列表
@ -101,7 +98,7 @@ public class Training2Rule {
this.labels = JsonUtils.readCollection(rule.getLabels(), List.class, String.class); this.labels = JsonUtils.readCollection(rule.getLabels(), List.class, String.class);
} }
if (StringUtils.hasText(rule.getSceneRule())) { if (StringUtils.hasText(rule.getSceneRule())) {
this.sceneRule = BgSceneStatusRule.valueOf(rule.getSceneRule()); this.sceneRule = Arrays.stream(rule.getSceneRule().split(",")).map(BgSceneStatusRule::valueOf).collect(Collectors.toList());
} }
if (StringUtils.hasText(rule.getSteps())) { if (StringUtils.hasText(rule.getSteps())) {
this.steps = JsonUtils.readCollection(rule.getSteps(), List.class, StepRule.class); this.steps = JsonUtils.readCollection(rule.getSteps(), List.class, StepRule.class);
@ -139,7 +136,8 @@ public class Training2Rule {
} }
// 背景设置 // 背景设置
if (sceneRule != null) { if (sceneRule != null) {
copyTraining2.setBgSceneJson(sceneRule.doHandle(simulation, mapElement, this.client)); sceneRule.forEach(rule -> rule.doHandle(simulation, mapElement, this.client));
copyTraining2.setBgSceneJson(BgSceneStatusRule.getBgScene(simulation));
} }
List<Step2VO> step2VOList = null; List<Step2VO> step2VOList = null;
// 步骤 // 步骤