From bd5901251918ebccb27924760f6b61ee283f8a9e Mon Sep 17 00:00:00 2001 From: weizhihong Date: Thu, 28 Apr 2022 18:17:49 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=B6=88=E6=81=AF=E4=BD=93=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=BF=90=E8=A1=8C=E6=96=B9=E5=90=91=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assist/StationDirectionService.java | 32 +++++++-------- .../simulation/cbtc/CTC/CTCLogicLoop.java | 13 +++++++ .../cbtc/build/InterlockBuilder2.java | 10 ----- .../cbtc/data/map/StationDirection.java | 39 ++++++++----------- .../data/status/StationDirectionStatus.java | 14 ++++++- .../data/vo/StationDirectionStatusVO.java | 2 + 6 files changed, 59 insertions(+), 51 deletions(-) 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