diff --git a/src/main/java/club/joylink/rtss/constants/IndicatorStatusEnum.java b/src/main/java/club/joylink/rtss/constants/IndicatorStatusEnum.java deleted file mode 100644 index ceba9df18..000000000 --- a/src/main/java/club/joylink/rtss/constants/IndicatorStatusEnum.java +++ /dev/null @@ -1,19 +0,0 @@ -package club.joylink.rtss.constants; - -/** - * 指标灯枚举 - */ -public enum IndicatorStatusEnum { - /** 无显示,灭灯 */ - No, - /** 红 */ - R, - /** 绿 */ - G, - /** 黄 */ - Y, - /** 白 */ - W, - /** 白闪(flashing) */ - WF -} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationDirectionOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationDirectionOperateHandler.java index 04746827a..8c4fa3da2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationDirectionOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationDirectionOperateHandler.java @@ -7,7 +7,7 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler import club.joylink.rtss.simulation.cbtc.ATS.service.assist.ButtonValidInterface; import club.joylink.rtss.simulation.cbtc.ATS.service.assist.StationDirectionService; import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.data.map.Button; +import club.joylink.rtss.simulation.cbtc.data.map.StationDirection; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -35,7 +35,7 @@ public class StationDirectionOperateHandler { validInterface = stationDirectionService.turnDirectionPressDownValid; } stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum - , Button.ButtonTypeEnum.CHANGE_DIRECTION, isPressDown, validInterface, null); + , StationDirection.ButtonTypeEnum.CHANGE_DIRECTION, isPressDown, validInterface, null); } /** @@ -49,8 +49,8 @@ public class StationDirectionOperateHandler { @OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_MAIN_ASSIST) public void pressMainAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum , Integer pressDown) { - stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, Button.ButtonTypeEnum.MAIN_ASSIST - , (pressDown == 1), null, null); + stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, StationDirection.ButtonTypeEnum.MAIN_ASSIST + , (pressDown == 1), null, stationDirectionService.turnAssistThen); } /** @@ -62,7 +62,7 @@ public class StationDirectionOperateHandler { */ @OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_RECEIVE_ASSIST) public void pressReceiveAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) { - stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, Button.ButtonTypeEnum.RECEIVE_ASSIST + stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, StationDirection.ButtonTypeEnum.RECEIVE_ASSIST , Boolean.TRUE, stationDirectionService.turnAssistValid, stationDirectionService.receiveAssistThen); } @@ -75,7 +75,7 @@ public class StationDirectionOperateHandler { */ @OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_DELIVER_ASSIST) public void pressDeliverAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) { - stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, Button.ButtonTypeEnum.DELIVER_ASSIST + stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, StationDirection.ButtonTypeEnum.DELIVER_ASSIST , Boolean.TRUE, stationDirectionService.turnAssistValid, stationDirectionService.deliverAssistThen); } } 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 e5d2241ea..5eeeb9967 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 @@ -1,10 +1,12 @@ package club.joylink.rtss.simulation.cbtc.ATS.service.assist; import club.joylink.rtss.constants.DirectionLabelEnum; -import club.joylink.rtss.constants.IndicatorStatusEnum; import club.joylink.rtss.entity.DraftMapStationDirection; import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.data.map.*; +import club.joylink.rtss.simulation.cbtc.data.map.Route; +import club.joylink.rtss.simulation.cbtc.data.map.Stand; +import club.joylink.rtss.simulation.cbtc.data.map.Station; +import club.joylink.rtss.simulation.cbtc.data.map.StationDirection; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; @@ -33,7 +35,7 @@ public class StationDirectionService { * @param validMethod 操作检验 * @param buttonDoMethod 操作后触发动作 */ - public void changeButtonAspect(Simulation simulation, String stationCode, DirectionLabelEnum label, Button.ButtonTypeEnum type, + public void changeButtonAspect(Simulation simulation, String stationCode, DirectionLabelEnum label, StationDirection.ButtonTypeEnum type, boolean pressDown, ButtonValidInterface validMethod, ButtonThenInterface buttonDoMethod) { Station curStation = getStationByCode(simulation, stationCode); StationDirection stationDirection = curStation.getStationDirectionMap().get(label); @@ -62,14 +64,20 @@ public class StationDirectionService { stationDirection.refreshAspectStatus(); // 刷新区段占用状态 stationDirection.refreshSectionStatus(); + // 辅助灯状态 + stationDirection.refreshAssistStatus(); } /** * 改方按钮按下校验 */ public ButtonValidInterface turnDirectionPressDownValid = (simulation, stationDirection) -> { + // 如果处于发辅助状态,说明存在异常情况正在人为处理,直接跳过判断 + if (stationDirection.isMainAssistStatus() && stationDirection.isDeliverAssistStatus()) { + return; + } // 区间是否空闲 - if (IndicatorStatusEnum.R.equals(stationDirection.getSectionAspect())) { + if (StationDirection.IndicatorStatusEnum.O.equals(stationDirection.getSectionAspect())) { throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段非空闲"); } // 接车进路有锁闭,有车进入 @@ -111,10 +119,24 @@ public class StationDirectionService { } }; + /** + * 总辅助后续操作 + */ + public ButtonThenInterface turnAssistThen = (simulation, stationDirection) -> { + // 总辅助弹起后,接发辅助、倒计时重置 + if (!stationDirection.isMainAssistStatus()) { + stationDirection.setReceiveAssistStatus(false); + stationDirection.setDeliverAssistStatus(false); + stationDirection.getRemain().set(0); + } + }; + /** * 接辅助按钮后续操作 */ public ButtonThenInterface receiveAssistThen = (simulation, stationDirection) -> { + // 按下接辅助,弹起发辅助 + stationDirection.setDeliverAssistStatus(false); // 重新设置倒计时时间 stationDirection.getRemain().set(StationDirection.DEFAULT_RECEIVE_DELAY_TIME); }; @@ -123,6 +145,8 @@ public class StationDirectionService { * 接辅助按钮后续操作 */ public ButtonThenInterface deliverAssistThen = (simulation, stationDirection) -> { + // 按下发辅助,弹起发辅助 + stationDirection.setReceiveAssistStatus(false); // 重新设置倒计时时间 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 72914b9aa..bd5a47ed4 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 @@ -242,8 +242,17 @@ public class CTCLogicLoop { * @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())); + simulation.getRepository().getStationList() + .forEach(station -> + station.getStationDirectionMap().values().stream() + .filter(stationDirection -> stationDirection.getRemain().intValue() != 0) + .forEach(stationDirection -> { + // 如果倒数结束弹起接、发辅助按钮 + if (stationDirection.getRemain().decrementAndGet() == 0) { + stationDirection.setDeliverAssistStatus(false); + stationDirection.setReceiveAssistStatus(false); + } + }) + ); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java index fb78f1ead..ff50538e3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java @@ -699,11 +699,6 @@ public class MapDeviceBuilder { Map> sectionArriveMap = MapDeviceBuilder.buildNormalStandTrackAdjoinSections(mapDataBuildResult.getDeviceMap()); mapDataBuildResult.setSectionArriveNearMap(sectionArriveMap); } - - // 构建接、发、区间、辅助指示灯 - MapDeviceBuilder.buildIndicatorList(elementMap, errMsgList, graphData.getIndicatorLightList()); - // 构建辅助、改方按钮 - MapDeviceBuilder.buildButtonList(elementMap, errMsgList, graphData.getSignalButtonList()); } private static List buildStand(MapGraphDataNewVO graphData, Map elementMap, List errMsgList) { @@ -1505,69 +1500,4 @@ public class MapDeviceBuilder { private static boolean isCross(String type) { return Objects.equals(type, BusinessConsts.Section.SectionType.Type05); } - - /** - * 构建指示灯 - * - * @param elementMap 资源map - * @param indicatorList 指示灯信息 - */ - private static void buildIndicatorList(Map elementMap, List errMsgList - , List indicatorList) { - // 区间占用\辅助状态\总辅助\发车辅助\接车辅助\接\发车箭头\复原\事故\闭塞 - List indicatorTypeList = Arrays.asList( - "SectionOccupied", "AssistStatus", "TotalAssist", "DepartAssist", "PickAssist", - "PickArrow", "DepartArrow", "Recovery", "Accident", "Occlusion" - ); - indicatorList - .stream() - .filter(mapIndicatorLightVO -> indicatorTypeList.contains(mapIndicatorLightVO.getType())) - .forEach(mapSignalButtonVO -> { - if (elementMap.containsKey(mapSignalButtonVO.getCode())) { - errMsgList.add("已存在指示灯 " + mapSignalButtonVO.getStationCode()); - } else { - Indicator indicator = new Indicator(mapSignalButtonVO.getCode(), mapSignalButtonVO.getName()); - indicator.setLabel(mapSignalButtonVO.getLabelEnum()); - indicator.setTypeStr(mapSignalButtonVO.getType()); - Station station = (Station) elementMap.get(mapSignalButtonVO.getStationCode()); - indicator.setStation(station); - station.getIndicatorList().add(indicator); - elementMap.put(mapSignalButtonVO.getCode(), indicator); - } - }); - } - - /** - * 构建按钮设备 - * - * @param elementMap 设备Map - * @param errMsgList 错误日志 - * @param signalButtonList 按钮列表 - */ - private static void buildButtonList(Map elementMap, List errMsgList - , List signalButtonList) { - // 总、接、发、改方 - List buttonTypeList = Arrays.asList( - MapSignalButtonVO.Type.ASSIST, - MapSignalButtonVO.Type.PICK_ASSIST, - MapSignalButtonVO.Type.DEPART_ASSIST, - MapSignalButtonVO.Type.CHANGE_DIRECTION - ); - signalButtonList - .stream() - .filter(mapSignalButtonVO -> buttonTypeList.contains(mapSignalButtonVO.getType())) - .forEach(mapSignalButtonVO -> { - if (elementMap.containsKey(mapSignalButtonVO.getCode())) { - errMsgList.add("已存在按钮 " + mapSignalButtonVO.getStationCode()); - } else { - Button button = new Button(mapSignalButtonVO.getCode(), mapSignalButtonVO.getName()); - button.setLabel(mapSignalButtonVO.getLabelEnum()); - Station station = (Station) elementMap.get(mapSignalButtonVO.getStationCode()); - button.setStation(station); - button.setTypeStr(mapSignalButtonVO.getType()); - station.getButtonList().add(button); - elementMap.put(mapSignalButtonVO.getCode(), button); - } - }); - } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Button.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Button.java deleted file mode 100644 index 572178438..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Button.java +++ /dev/null @@ -1,84 +0,0 @@ -package club.joylink.rtss.simulation.cbtc.data.map; - -import club.joylink.rtss.constants.DirectionLabelEnum; -import club.joylink.rtss.vo.map.graph.MapSignalButtonVO; -import lombok.Getter; -import lombok.Setter; - -/** - * 操作按钮 - */ -@Setter -@Getter -public class Button extends MapNamedElement { - /** - * 车站 - */ - private Station station; - - /** - * 当前信号显示 - */ - private boolean isPressDown; - - /** - * 方向标签 - */ - private DirectionLabelEnum label; - - /** - * 按钮类型 - */ - private ButtonTypeEnum type; - - public Button(String code, String name) { - super(code, name, DeviceType.BUTTON); - isPressDown = Boolean.FALSE; - } - - protected Button(String code, String name, DeviceType deviceType) { - super(code, name, deviceType); - } - - @Override - public void reset() { - isPressDown = Boolean.FALSE; - } - - public void setTypeStr(MapSignalButtonVO.Type typeStr) { - this.type = getType(typeStr); - } - - /** - * 获取枚举信息 - * - * @param type 类型 - * @return 枚举 - */ - public static ButtonTypeEnum getType(MapSignalButtonVO.Type type) { - switch (type) { - case ASSIST: - return ButtonTypeEnum.MAIN_ASSIST; - case PICK_ASSIST: - return ButtonTypeEnum.DELIVER_ASSIST; - case DEPART_ASSIST: - return ButtonTypeEnum.RECEIVE_ASSIST; - case CHANGE_DIRECTION: - return ButtonTypeEnum.CHANGE_DIRECTION; - default: - return ButtonTypeEnum.NO; - } - } - - public enum ButtonTypeEnum { - // 总辅助 - MAIN_ASSIST, - // 接辅助 - RECEIVE_ASSIST, - // 发辅助 - DELIVER_ASSIST, - // 改方 - CHANGE_DIRECTION, - NO; - } -} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Indicator.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Indicator.java deleted file mode 100644 index cca5556a3..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Indicator.java +++ /dev/null @@ -1,133 +0,0 @@ -package club.joylink.rtss.simulation.cbtc.data.map; - - -import club.joylink.rtss.constants.DirectionLabelEnum; -import club.joylink.rtss.constants.IndicatorStatusEnum; -import lombok.Getter; -import lombok.Setter; - -/** - * 指示灯设备 - */ -@Setter -@Getter -public class Indicator extends MapNamedElement { - /** - * 车站 - */ - private Station station; - - /** - * 当前信号显示 - */ - private IndicatorStatusEnum aspect; - - /** - * 方向标签 - */ - private DirectionLabelEnum label; - - /** - * 是否开启 - */ - private boolean on; - - /** - * 灯类型 - */ - private IndicatorTypeEnum type; - - public Indicator(String code, String name) { - super(code, name, DeviceType.INDICATOR); - on = false; - } - - @Override - public void reset() { - on = false; - aspect = getDefaultStatus(); - } - - - /** - * 获取默认状态 - * - * @return 默认状态 - */ - public IndicatorStatusEnum getDefaultStatus() { - // 接 - if (IndicatorTypeEnum.RECEIVE.equals(type)) { - return IndicatorStatusEnum.Y; - // 发 - } else if (IndicatorTypeEnum.DELIVER.equals(type)) { - return IndicatorStatusEnum.G; - } else { - return IndicatorStatusEnum.No; - } - } - - public void setTypeStr(String type) { - this.type = getType(type); - } - - /** - * 枚举对应 - * - * @param type 前端类型 - * @return 枚举值 - */ - public static IndicatorTypeEnum getType(String type) { - switch (type) { - // 接 - case "receive": - case "PickArrow": - return IndicatorTypeEnum.RECEIVE; - // 发 - case "deliver": - case "DepartArrow": - return IndicatorTypeEnum.DELIVER; - // 区间 - case "section": - case "SectionOccupied": - return IndicatorTypeEnum.SECTION; - //辅助 - case "assist": - case "AssistStatus": - case "TotalAssist": - case "DepartAssist": - case "PickAssist": - return IndicatorTypeEnum.ASSIST; - //复原 - case "Recovery": - return IndicatorTypeEnum.RECOVERY; - //事故 - case "Accident": - return IndicatorTypeEnum.ACCIDENT; - //闭塞 - case "Occlusion": - return IndicatorTypeEnum.OCCLUSION; - default: - return IndicatorTypeEnum.NO; - } - } - - public enum IndicatorTypeEnum { - // 接 - RECEIVE, - // 发 - DELIVER, - // 区间 - SECTION, - // 辅助 - ASSIST, - // 恢复 - RECOVERY, - // 事故 - ACCIDENT, - // 闭塞 - OCCLUSION, - // 无类型 - NO; - - } -} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java index 6cbea8e10..79b23c9d7 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java @@ -30,8 +30,6 @@ public class Station extends MayOutOfOrderDevice { ldStandList = new ArrayList<>(); controlMode = ControlMode.Center; stationDirectionMap = new HashMap<>(); - buttonList = new ArrayList<>(); - indicatorList = new ArrayList<>(); } /** @@ -189,16 +187,6 @@ public class Station extends MayOutOfOrderDevice { */ private Map stationDirectionMap; - /** - * 按钮列表 - */ - private List