diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/StationDirectionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/StationDirectionService.java index a0294e2aa..e5d2241ea 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/StationDirectionService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/StationDirectionService.java @@ -67,33 +67,27 @@ public class StationDirectionService { /** * 改方按钮按下校验 */ - public ButtonValidInterface turnDirectionPressDownValid = (simulation, stationLabelEnum) -> { - boolean isExist = stationLabelEnum.getButtonList() - .stream() - .anyMatch(button -> Button.ButtonTypeEnum.CHANGE_DIRECTION.equals(button.getType())); - if (!isExist) { - throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:按钮不存在"); - } + public ButtonValidInterface turnDirectionPressDownValid = (simulation, stationDirection) -> { // 区间是否空闲 - if (IndicatorStatusEnum.R.equals(stationLabelEnum.getSectionAspect())) { + if (IndicatorStatusEnum.R.equals(stationDirection.getSectionAspect())) { throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段非空闲"); } // 接车进路有锁闭,有车进入 - boolean isReceiveConflict = stationLabelEnum.getReceiveRouteList().stream().anyMatch(Route::isLock); + boolean isReceiveConflict = stationDirection.getReceiveRouteList().stream().anyMatch(Route::isLock); if (isReceiveConflict) { throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:存在接车进路冲突"); } // 查找发车进路方向的站台上是否有停靠列车 - Optional routeOptional = stationLabelEnum.getReceiveRouteList().stream().findAny(); + Optional routeOptional = stationDirection.getReceiveRouteList().stream().findAny(); if (routeOptional.isEmpty()) { throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:没有接车进路"); } Route route = routeOptional.get(); List standList; if (route.isRight()) { - standList = stationLabelEnum.getStation().getRdStandList(); + standList = stationDirection.getStation().getRdStandList(); } else { - standList = stationLabelEnum.getStation().getLdStandList(); + standList = stationDirection.getStation().getLdStandList(); } // 获取靠停列车 List sectionCodeList = simulation.getRepository().getOnlineTrainList() @@ -111,8 +105,8 @@ public class StationDirectionService { /** * 接、发辅助按钮操作校验 */ - public ButtonValidInterface turnAssistValid = (simulation, stationLabelEnum) -> { - if (!stationLabelEnum.isMainAssistStatus()) { + public ButtonValidInterface turnAssistValid = (simulation, stationDirection) -> { + if (!stationDirection.isMainAssistStatus()) { throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:总辅助按钮未按下"); } }; @@ -120,15 +114,17 @@ public class StationDirectionService { /** * 接辅助按钮后续操作 */ - public ButtonThenInterface receiveAssistThen = (simulation, stationLabelEnum) -> { - + public ButtonThenInterface receiveAssistThen = (simulation, stationDirection) -> { + // 重新设置倒计时时间 + stationDirection.getRemain().set(StationDirection.DEFAULT_RECEIVE_DELAY_TIME); }; /** * 接辅助按钮后续操作 */ - public ButtonThenInterface deliverAssistThen = (simulation, stationLabelEnum) -> { - + public ButtonThenInterface deliverAssistThen = (simulation, stationDirection) -> { + // 重新设置倒计时时间 + stationDirection.getRemain().set(StationDirection.DEFAULT_DELIVER_DELAY_TIME); }; /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java index dd2d71bab..72914b9aa 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java @@ -46,6 +46,8 @@ public class CTCLogicLoop { buildNewCtcStationPlan(simulation); updateCtcStationPlan(simulation); sendMessage(simulation); + // 车站运行方向倒计时 + refreshStationDirection(simulation); } private void sendMessage(Simulation simulation) { @@ -233,4 +235,15 @@ public class CTCLogicLoop { public void addJobs(Simulation simulation) { simulation.addJob(NAME, () -> this.run(simulation), RATE); } + + /** + * 运行方向接发辅助按钮倒计时 + * + * @param simulation 仿真信息 + */ + private void refreshStationDirection(Simulation simulation) { + simulation.getRepository().getStationList().forEach(station -> station.getStationDirectionMap().values().stream() + .filter(stationDirection -> stationDirection.getRemain().intValue() != 0) + .forEach(stationDirection -> stationDirection.getRemain().decrementAndGet())); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java index 10252bc5e..63f607f58 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java @@ -1601,16 +1601,6 @@ public class InterlockBuilder2 { model.getDeliverRouteList().add((Route) elementMap.get(code)); }); } - // 放入按钮数据 - station.getButtonList().stream() - .filter(button -> model.getLabelEnum().equals(button.getLabel())) - .forEach(button -> model.getButtonList().add(button)); - - // 放入指示灯数据 - station.getIndicatorList().stream() - .filter(indicator -> model.getLabelEnum().equals(indicator.getLabel())) - .forEach(indicator -> model.getIndicatorList().add(indicator)); - station.getStationDirectionMap().put(model.getLabelEnum(), model); elementMap.put(model.getCode(), model); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationDirection.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationDirection.java index 08c175999..c5eba30de 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationDirection.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/StationDirection.java @@ -10,6 +10,7 @@ import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; /** * 指示灯设备 @@ -22,12 +23,12 @@ public class StationDirection extends MapNamedElement { /** * 发辅助默认倒计时 25s */ - public static final int DEFAULT_DELIVER_DELAY_TIME = 25 * 1000; + public static final int DEFAULT_DELIVER_DELAY_TIME = 25; /** * 接辅助默认倒计时 15s */ - public static final int DEFAULT_RECEIVE_DELAY_TIME = 15 * 1000; + public static final int DEFAULT_RECEIVE_DELAY_TIME = 15; /** * 车站 @@ -44,10 +45,15 @@ public class StationDirection extends MapNamedElement { */ private Signal signal; + /** + * 剩余时间 + */ + private AtomicInteger remain = new AtomicInteger(0); + /** * 处于接、发状态 */ - private ReceiveAndDeliverModel receiveAndDeliver; + private ReceiveAndDeliverModel model; /** * 接车灯状态 @@ -104,20 +110,11 @@ public class StationDirection extends MapNamedElement { */ private List
sectionList; - /** - * 按钮集合 - */ - private List