From 3ad550984087e9999f62c5d19b48196cd1b8f9c6 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Mon, 30 Aug 2021 18:11:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=81=93=E5=B2=94=E8=BD=AC?= =?UTF-8?q?=E5=8A=A8=E9=97=AE=E9=A2=98=EF=BC=9B=E5=A2=9E=E5=8A=A0=E5=88=97?= =?UTF-8?q?=E8=BD=A6=E8=B0=83=E5=BA=A6=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/ATS/data/AtsMessage.java | 7 ++ .../cbtc/ATS/operation/OperateMethod.java | 2 + .../handler/StandOperateHandler.java | 2 +- .../handler/TrainOperateHandler.java | 6 +- .../ATS/operation/vo/RegulationParam.java | 33 +++++++++ .../cbtc/ATS/service/AtsStandService.java | 10 ++- .../cbtc/ATS/service/AtsTrainService.java | 69 +++++++++++++++++++ .../simulation/cbtc/CI/CiApiServiceImpl.java | 1 - .../rtss/simulation/cbtc/data/map/Stand.java | 11 +++ .../rtss/simulation/cbtc/data/map/Switch.java | 13 +--- .../simulation/cbtc/data/vo/TrainInfo.java | 8 +-- .../cbtc/data/vr/VirtualRealitySwitch.java | 1 + .../simulation/cbtc/robot/RobotLogicLoop.java | 2 +- 13 files changed, 143 insertions(+), 22 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/ATS/data/AtsMessage.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/RegulationParam.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/data/AtsMessage.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/data/AtsMessage.java new file mode 100644 index 000000000..5035857f5 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/data/AtsMessage.java @@ -0,0 +1,7 @@ +package club.joylink.rtss.simulation.cbtc.ATS.data; + +import java.time.LocalDateTime; + +public class AtsMessage { + private LocalDateTime time; +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/OperateMethod.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/OperateMethod.java index a1d2faecb..a7ed69567 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/OperateMethod.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/OperateMethod.java @@ -71,6 +71,8 @@ public class OperateMethod { args[i] = enumConstant; } } + } else if (Map.class.isAssignableFrom(parameter.getType())) { + args[i] = JsonUtils.read(JsonUtils.writeValueAsString(param.get(parameter.getName())), parameter.getType()); } else { args[i] = JsonUtils.read(JsonUtils.writeValueAsString(param), parameter.getType()); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StandOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StandOperateHandler.java index 6c73f6b49..23f5719e8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StandOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StandOperateHandler.java @@ -134,7 +134,7 @@ public class StandOperateHandler { */ @OperateHandlerMapping(type = Operation.Type.Stand_Set_Run_Time) public void setRunTime(Simulation simulation, String standCode, int runLevelTime, boolean runLevelTimeForever) { - atsStandService.setRunTime(simulation, standCode, runLevelTime, runLevelTimeForever); + atsStandService.setRunTime(simulation, standCode, runLevelTime, runLevelTimeForever, null); } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/TrainOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/TrainOperateHandler.java index 05e4a5c56..3cbb1d241 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/TrainOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/TrainOperateHandler.java @@ -4,6 +4,7 @@ import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping; +import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.RegulationParam; import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.TrainTypeUpdateParam; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainLoadService; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainService; @@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.Objects; @OperateHandler @@ -383,7 +385,7 @@ public class TrainOperateHandler { } @OperateHandlerMapping(type = Operation.Type.Train_Regulation) - public void regulation(Simulation simulation, String groupNumber, BusinessConsts.Regulation regulation) { - + public void regulation(Simulation simulation, String groupNumber, BusinessConsts.Regulation regulation, RegulationParam regulationParam) { + atsTrainService.regulation(simulation, groupNumber, regulation, regulationParam); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/RegulationParam.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/RegulationParam.java new file mode 100644 index 000000000..e6ffb2da8 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/vo/RegulationParam.java @@ -0,0 +1,33 @@ +package club.joylink.rtss.simulation.cbtc.ATS.operation.vo; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.Map; + +/** + * 列车调度参数 + */ +@Getter +@Setter +@NoArgsConstructor +public class RegulationParam { + /** + * 列车停站时间 + * k - standCode + */ + private Map parkTimeMap; + + /** + * 列车区间运行时间 + * k - standCode + */ + private Map runTimeMap; + + /** + * 列车跳停/不跳 + * k - standCode + */ + private Map skipMap; +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStandService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStandService.java index 4e4e1dccc..010dff437 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStandService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStandService.java @@ -22,6 +22,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -241,6 +242,7 @@ public class AtsStandService { stand.addTrainParkingTime(groupNumber, parkingTime); } else { stand.setParkingTime(parkingTime); + stand.clearTrainParkingTime(); } stand.setParkingAlwaysValid(parkingAlwaysValid); } @@ -248,9 +250,13 @@ public class AtsStandService { /** * 设置站间运行等级 */ - public void setRunTime(Simulation simulation, String standCode, int level, boolean alwaysValid) { + public void setRunTime(Simulation simulation, String standCode, int level, boolean alwaysValid, String groupNumber) { Stand stand = getStand(simulation, standCode); - stand.setRunLevelTime(level); + if (StringUtils.hasText(groupNumber)) { + stand.addTrainRunTime(groupNumber, level); + } else { + stand.setRunLevelTime(level); + } stand.setRunLevelTimeForever(alwaysValid); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java index 064cd1e08..b40f715e8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java @@ -1,6 +1,8 @@ package club.joylink.rtss.simulation.cbtc.ATS.service; +import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.RegulationParam; import club.joylink.rtss.simulation.cbtc.ATS.service.stage.AtsHeadTrainStageService; import club.joylink.rtss.simulation.cbtc.ATS.service.stage.AtsPlanTrainStageService; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; @@ -946,4 +948,71 @@ public class AtsTrainService { TrainInfo trainInfo = simulation.getRepository().getSupervisedTrainByGroup(groupNumber); trainInfo.setAtsAutoTrigger(autoTrigger); } + + public void regulation(Simulation simulation, String groupNumber, BusinessConsts.Regulation regulation, RegulationParam regulationParam) { + SimulationDataRepository repository = simulation.getRepository(); + switch (regulation) { + case TIME_TABLE_REGULATION: { + if (StringUtils.hasText(groupNumber)) { + TrainInfo trainInfo = repository.getSupervisedTrainByGroup(groupNumber); + trainInfo.setAtsAutoAdjust(true); + } else { + repository.getSuperviseTrainList().forEach(trainInfo -> + trainInfo.setAtsAutoAdjust(true)); + } + break; + } + case HEADWAY_REGULATION_FRONT: + break; + case HEADWAY_REGULATION_FRONT_AND_BACK: + break; + case REGULATION_OFF: { + if (StringUtils.hasText(groupNumber)) { + TrainInfo trainInfo = repository.getSupervisedTrainByGroup(groupNumber); + trainInfo.setAtsAutoAdjust(false); + } else { + repository.getSuperviseTrainList().forEach(trainInfo -> + trainInfo.setAtsAutoAdjust(false)); + } + if (regulationParam == null) + break; + if (!CollectionUtils.isEmpty(regulationParam.getParkTimeMap())) { + regulationParam.getParkTimeMap().forEach((k, v) -> { + atsStandService.setParkTime(simulation, k, v, true, groupNumber); + }); + } + if (!CollectionUtils.isEmpty(regulationParam.getRunTimeMap())) { + regulationParam.getRunTimeMap().forEach((k, v) -> { + atsStandService.setRunTime(simulation, k, v, true, groupNumber); + }); + } + if (!CollectionUtils.isEmpty(regulationParam.getSkipMap())) { + regulationParam.getSkipMap().forEach((k, v) -> { + if (StringUtils.hasText(groupNumber)) { + Stand stand = repository.getByCode(k, Stand.class); + if (v) { + if (!stand.isAllSkip()) { + atsStandService.setJumpStop(simulation, k, groupNumber); + } + } else { + if (stand.isAllSkip()) { + atsStandService.cancelJumpStop(simulation, k, null); + repository.getAllVrTrain().forEach(train -> + atsStandService.setJumpStop(simulation, k, train.getGroupNumber())); + } + atsStandService.cancelJumpStop(simulation, k, groupNumber); + } + } else { + if (v) { + atsStandService.setJumpStop(simulation, k, null); + } else { + atsStandService.cancelJumpStop(simulation, k, null); + } + } + }); + } + break; + } + } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java index f0e4716a9..be42562fa 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java @@ -105,7 +105,6 @@ public class CiApiServiceImpl implements CiApiService { public void turn(Simulation simulation, String switchCode) { Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); boolean toNormal = aSwitch.judgeTurnToNormal(); - aSwitch.setLastTurnToNormal(toNormal); if (toNormal) { if (!this.switchService.turn2NormalPosition(simulation, aSwitch)) { log.info(String.format("道岔[%s(%s)]锁闭,不能进行定操", aSwitch.getName(), aSwitch.getCode())); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java index 6756bacab..fb7f32637 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java @@ -121,6 +121,9 @@ public class Stand extends MayOutOfOrderDevice { */ private int runLevelTime; + /** 列车-停站时间map */ + private final Map runTimeMap = new ConcurrentHashMap<>(); + /** * 区间运行时间是否一直有效 */ @@ -345,6 +348,14 @@ public class Stand extends MayOutOfOrderDevice { this.parkingTimeMap.clear(); } + public void addTrainRunTime(String groupNumber, int runLevelTime) { + this.runTimeMap.put(groupNumber, runLevelTime); + } + + public void clearTrainRunTime() { + this.runTimeMap.clear(); + } + /** * 站台折返类型策略 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java index 2ab252cf8..e5bba1c03 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java @@ -144,11 +144,6 @@ public class Switch extends MayOutOfOrderDevice { */ private boolean init; - /** - * 上一次是否是将道岔转向定位 - */ - private Boolean lastTurnToNormal; - @Override public void reset() { super.reset(); @@ -170,7 +165,6 @@ public class Switch extends MayOutOfOrderDevice { this.interlockReserve = false; this.blockadeInvalid = false; this.init = false; - this.lastTurnToNormal = null; } /** @@ -442,11 +436,8 @@ public class Switch extends MayOutOfOrderDevice { } else if (this.normalPosition) { toNormal = false; } else { - if (this.lastTurnToNormal != null) { - toNormal = !this.lastTurnToNormal; - } else { - toNormal = true; - } + VirtualRealitySwitch virtualSwitch = this.virtualSwitch; + return !virtualSwitch.isToNormal(); } return toNormal; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java index ffc273149..9bf1d8744 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java @@ -266,6 +266,10 @@ public class TrainInfo extends MapElement { /** 通信是否正常 */ private boolean communicable; + /** ats自动调整 */ + @Setter + private boolean atsAutoAdjust = true; + public TrainInfo(String groupNumber) { super(groupNumber, DeviceType.TRAIN); this.groupNumber = groupNumber; @@ -616,10 +620,6 @@ public class TrainInfo extends MapElement { return !Stand.TurnBackType.DEFAULT.name().equals(this.turnBackStrategy); } - public boolean isManual() { - return TrainType.MANUAL.equals(getType()); - } - public void turnBackInit(Section lastRouteSection) { this.turnBack = true; this.turnBackStatus = INIT; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySwitch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySwitch.java index 3e5afbe0a..42507904a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySwitch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySwitch.java @@ -65,6 +65,7 @@ public class VirtualRealitySwitch extends VirtualRealityDevice { this.setting = false; this.remainTime = null; this.timeoutRemain = 0; + this.toNormal = this.normal; this.fault = null; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java index f587d6357..b92e4d88f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java @@ -173,7 +173,7 @@ public class RobotLogicLoop { switch (train.getDriveMode()) { case AM: //AM模式下不需要司机驾驶 TrainInfo trainInfo = repository.getSupervisedTrainByGroup(train.getGroupNumber()); - if (trainInfo.isManual()) { + if (trainInfo.isManualTrain()) { train.setTarget(train.getRobotTargetPosition().getSection()); train.setRobotTargetPosition(null); }