From b5bd2b403582258719790b9432e77c3f34cc1048 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 22 Apr 2022 17:24:19 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8E=BB=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=8C=87=E4=BB=A4=EF=BC=8C=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E3=80=91=20=E3=80=90=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=82=B9=E7=81=AF=E6=93=8D=E4=BD=9C=E4=B8=8E=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E4=BA=AE=E7=81=AF=E6=93=8D=E4=BD=9C=E4=B8=80=E8=87=B4=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: weizhihong --- .../cbtc/ATS/operation/Operation.java | 10 -- .../handler/AssistOperateHandler.java | 28 ----- .../ATS/service/assist/AssistService.java | 108 +++++------------- .../cbtc/data/status/ButtonStatus.java | 12 +- .../cbtc/data/vo/ButtonStatusVO.java | 5 - 5 files changed, 31 insertions(+), 132 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java index b1bf9f207..1b762c799 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java @@ -839,16 +839,6 @@ public class Operation { * 按下改方按钮 */ ASSIST_PRESS_DOWN_TURN_DIRECTION, - - /** - * 抬起改方按钮 - */ - ASSIST_PRESS_UP_TURN_DIRECTION, - - /** - * 邻站办理发车进路 - */ - ASSIST_DELIVER_ROUTE_HANDLE } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/AssistOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/AssistOperateHandler.java index e7da27dbc..31d2e1086 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/AssistOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/AssistOperateHandler.java @@ -31,32 +31,4 @@ public class AssistOperateHandler { , assistService.turnDirectionPressDownValid , assistService.turnDirectionPressDownDo); } - - /** - * 改方按钮抬起操作 - * - * @param simulation 仿真数据 - * @param stationCode 车站编码 - * @param label 按钮类型 - */ - @OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_UP_TURN_DIRECTION) - public void pressUpTurnDirection(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) { - assistService.changeButtonAspect(simulation, - stationCode, labelEnum, ButtonTypeEnum.CHANGE_DIRECTION, Boolean.FALSE - , null - , assistService.turnDirectionPressUpDo); - } - - - /** - * 邻站办理发车进路 - * - * @param simulation 仿真数据 - * @param stationCode 车站编码 - * @param routeCode 进路编码 - */ - @OperateHandlerMapping(type = Operation.Type.ASSIST_DELIVER_ROUTE_HANDLE) - public void deliverRouteHandle(Simulation simulation, String stationCode, String routeCode) { - assistService.deliverRouteHandle(simulation, stationCode, routeCode); - } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/AssistService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/AssistService.java index 540e6250a..3da252d1b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/AssistService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/assist/AssistService.java @@ -98,76 +98,40 @@ public class AssistService { if (receiveIndicator == null || deliverIndicator == null) { return; } + // 接车进路 + Route receiveRoute = receiveIndicator.getRoute(); + // 发车进路 + Route deliverRoute = deliverIndicator.getRoute(); IndicatorStatusEnum receiveStatus; IndicatorStatusEnum deliverStatus; - // 如果处于改方状态,接车灯熄灭、发车灯点亮为绿色 - if (receiveIndicator.isChangeDirection()) { - receiveStatus = IndicatorStatusEnum.R; + // 两个进路都锁闭存在问题 + if (receiveRoute.isLock() && deliverRoute.isLock()) { + receiveStatus = IndicatorStatusEnum.Y; + deliverStatus = IndicatorStatusEnum.G; + } else if (receiveRoute.isLock() && !deliverRoute.isLock()) { // 亮接、灭发 + receiveStatus = IndicatorStatusEnum.Y; deliverStatus = IndicatorStatusEnum.No; - } else { - // 接车进路 - Route receiveRoute = receiveIndicator.getRoute(); - // 发车进路 - Route deliverRoute = deliverIndicator.getRoute(); - // 两个进路都锁闭存在问题 - if (receiveRoute.isLock() && deliverRoute.isLock()) { - receiveStatus = IndicatorStatusEnum.Y; - deliverStatus = IndicatorStatusEnum.G; - } else if (receiveRoute.isLock() && !deliverRoute.isLock()) { // 亮接、灭发 - receiveStatus = IndicatorStatusEnum.Y; - deliverStatus = IndicatorStatusEnum.No; - } else if (!receiveRoute.isLock() && deliverRoute.isLock()) { // 亮发、灭接 - receiveStatus = IndicatorStatusEnum.No; - deliverStatus = IndicatorStatusEnum.G; - } else { // 复位 - receiveStatus = receiveIndicator.getDefaultStatus(); - deliverStatus = deliverIndicator.getDefaultStatus(); + } else if (!receiveRoute.isLock() && deliverRoute.isLock()) { // 亮发、灭接 + receiveStatus = IndicatorStatusEnum.No; + deliverStatus = IndicatorStatusEnum.G; + } else { // 复位 + receiveStatus = receiveIndicator.getDefaultStatus(); + deliverStatus = deliverIndicator.getDefaultStatus(); + } + // 判断状态是否变化 + if (deliverStatus.equals(deliverIndicator.getAspect()) || receiveStatus.equals(receiveIndicator.getAspect())) { + // 变化接车灯亮、发车灯灭 + if (IndicatorStatusEnum.G.equals(deliverStatus)) { + curStation.getButtonsList() + .stream() + .filter(button -> labelEnum.equals(button.getLabel()) && ButtonTypeEnum.CHANGE_DIRECTION.equals(button.getType())) + .forEach(button -> button.setPressDown(IndicatorStatusEnum.G.equals(deliverStatus))); } } receiveIndicator.setAspect(receiveStatus); deliverIndicator.setAspect(deliverStatus); } - /** - * 邻站办理发车进路 - * - * @param simulation 仿真实体 - * @param stationCode 车站编码 - * @param routeCode 进路编码 - */ - public void deliverRouteHandle(Simulation simulation, String stationCode, String routeCode) { - Station curStation = getStationByCode(simulation, stationCode); - Route route = simulation.getRepository().getByCode(routeCode, Route.class); - List stationList = simulation.getRepository().getStationList(); - // 获取邻站索引 - int nextIndex = stationList.indexOf(curStation) + (route.isRight() ? -1 : 1); - if (nextIndex >= 0 && nextIndex < stationList.size()) { - Station nextStation = stationList.get(nextIndex); - // 修改指示灯改方状态 - if (!CollectionUtils.isEmpty(nextStation.getIndicatorList())) { - nextStation.getIndicatorList() - .stream() - .filter(indicator -> indicator.getRoute() != null && routeCode.equals(indicator.getRoute().getCode())) - .forEach(indicator -> { - log.info(indicator.getCode() + indicator.getType()); - indicator.setChangeDirection(Boolean.FALSE); - }); - } - // 抬起改方按钮 - if (!CollectionUtils.isEmpty(nextStation.getButtonsList())) { - nextStation.getButtonsList() - .stream() - .filter(button -> button.getStand().isRight() == route.isRight() - && ButtonTypeEnum.CHANGE_DIRECTION.equals(button.getType())) - .forEach(button -> { - log.info(button.getCode()); - button.setPressDown(Boolean.FALSE); - }); - } - } - routeService.setRoute(simulation, route); - } - /** * 改方按钮按下校验 */ @@ -215,30 +179,12 @@ public class AssistService { } // 列车换端 atpService.turnDirectionImmediately(train); - // 获取接车指示灯 - Indicator receiveIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.RECEIVE); - receiveIndicator.setChangeDirection(Boolean.TRUE); // 获取发车指示灯 Indicator deliverIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.DELIVER); // 办进路 routeService.setRoute(simulation, deliverIndicator.getRoute()); }; - /** - * 抬起改方后续动作按钮 - */ - public ButtonThenInterface turnDirectionPressUpDo = (simulation, button) -> { - if (button == null) { - throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:按钮不存在"); - } - // 获取接车指示灯 - Indicator receiveIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.RECEIVE); - if (receiveIndicator == null) { - throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:指示灯不存在"); - } - receiveIndicator.setChangeDirection(Boolean.FALSE); - }; - /** * 获取当前车站实体 * @@ -315,9 +261,9 @@ public class AssistService { * @return 列车数据 */ private VirtualRealityTrain getSandStopTrain(Simulation simulation, String sectionCode) { - Optional trainOptional = simulation.getRepository().getAllVrTrain() + Optional trainOptional = simulation.getRepository().getOnlineTrainList() .stream() - .filter(trainInfo -> sectionCode.equals(trainInfo.getHeadPosition().getSection().getCode())) + .filter(trainInfo -> trainInfo != null && sectionCode.equals(trainInfo.getHeadPosition().getSection().getCode())) .findAny(); VirtualRealityTrain train; if (trainOptional.isPresent()) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/ButtonStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/ButtonStatus.java index 1a7bef6ff..564f3df1d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/ButtonStatus.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/ButtonStatus.java @@ -4,13 +4,11 @@ import club.joylink.rtss.simulation.cbtc.data.map.Button; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.vo.ButtonStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.DeviceStatusVO; -import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer; -import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import lombok.Getter; import lombok.Setter; +import java.util.Objects; + /** * 按钮设备状态信息 */ @@ -18,8 +16,6 @@ import lombok.Setter; @Getter public class ButtonStatus extends DeviceStatus { - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) private boolean pressDown; public ButtonStatus(Button button) { @@ -32,10 +28,10 @@ public class ButtonStatus extends DeviceStatus { Button button = (Button) device; ButtonStatusVO status = (ButtonStatusVO) statusVO; boolean change = Boolean.FALSE; - if (pressDown != button.isPressDown()) { + if (!Objects.equals(pressDown, button.isPressDown())) { change = Boolean.TRUE; pressDown = button.isPressDown(); - status.setPressDown(button.isPressDown()); + status.setPressDown(pressDown); } return change; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ButtonStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ButtonStatusVO.java index cf2389ca6..2fd42df47 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ButtonStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/ButtonStatusVO.java @@ -1,7 +1,6 @@ package club.joylink.rtss.simulation.cbtc.data.vo; import club.joylink.rtss.simulation.cbtc.data.map.Button; -import club.joylink.rtss.simulation.cbtc.data.status.ButtonStatus; import lombok.Getter; import lombok.Setter; @@ -14,10 +13,6 @@ public class ButtonStatusVO extends DeviceStatusVO { private Boolean pressDown; - public ButtonStatusVO(ButtonStatus buttonStatus) { - super(buttonStatus.getCode(), buttonStatus.getDeviceType()); - } - public ButtonStatusVO(Button button) { super(button.getCode(), button.getDeviceType()); }