From 09e72d1e7ec27bb1d568b9d1b2cd5c4184f5cb20 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Fri, 17 Sep 2021 15:21:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=81=94=E9=94=81=E4=BF=A1=E5=8F=B7?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E2=80=94=E2=80=94=E8=81=94=E9=94=81=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E4=B8=8D=E6=BB=A1=E8=B6=B3=EF=BC=8C=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E6=9C=BA=E6=98=BE=E7=A4=BA=E7=A6=81=E6=AD=A2?= =?UTF-8?q?=E4=BF=A1=E5=8F=B7=EF=BC=8C=E8=81=94=E9=94=81=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E6=BB=A1=E8=B6=B3=E6=97=B6=E8=87=AA=E5=8A=A8=E5=BC=80=E6=94=BE?= =?UTF-8?q?=E4=BF=A1=E5=8F=B7=20=E4=BF=A1=E5=8F=B7=E6=9C=BA=E4=BA=AE?= =?UTF-8?q?=E7=81=AF=E3=80=81=E7=81=AD=E7=81=AF=E6=8E=A7=E5=88=B6=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E8=81=94=E9=94=81=E4=B8=80=E7=9B=B4=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E8=80=8C=E9=9D=9E=E8=A7=A6=E5=8F=91=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=81=93=E5=B2=94=E8=BD=AC=E5=8A=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATP/ground/AtpSectionService.java | 7 --- .../simulation/cbtc/CI/CiApiServiceImpl2.java | 4 +- .../rtss/simulation/cbtc/CI/CiLogic.java | 31 +++++++---- .../CI/device/CiDeviceStatusCollector.java | 1 + .../cbtc/CI/device/CiRouteService.java | 10 ++-- .../simulation/cbtc/CI/device/CiService.java | 39 +++++--------- .../CI/device/CiSignalControlService.java | 22 ++++---- .../CI/device/CiSwitchControlService.java | 4 +- .../simulation/cbtc/data/map/Section.java | 3 ++ .../rtss/simulation/cbtc/data/map/Signal.java | 53 +++++++++++++------ .../cbtc/data/vr/VirtualRealityTrain.java | 2 +- 11 files changed, 93 insertions(+), 83 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java index 98afc4a89..9fa810b7e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java @@ -1,6 +1,5 @@ package club.joylink.rtss.simulation.cbtc.ATP.ground; -import club.joylink.rtss.simulation.cbtc.CI.device.CiSignalControlService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; @@ -10,7 +9,6 @@ import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -27,9 +25,6 @@ import java.util.stream.Collectors; @Component public class AtpSectionService { - @Autowired - private CiSignalControlService signalControlService; - /** * 收集列车接近信号机消息并发送给CI */ @@ -51,10 +46,8 @@ public class AtpSectionService { } if (1 == a) { // 只有通信车接近 signal.changeToCbtcMode(); - this.signalControlService.controlLightOfSignal(simulation, signal); } else if (2 == a) { // 有非通信车接近 signal.changeToBackupMode(); - this.signalControlService.controlLightOfSignal(simulation, signal); } signal.updateApproachLock();//更新信号机接近锁闭状态 }); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java index d675116df..22931c07b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java @@ -87,7 +87,7 @@ public class CiApiServiceImpl2 implements CiApiService { "进路未锁闭,不能重开信号机"); } BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!lockedRoute.isDelayUnlocking(), "进路延时解锁中,不能重开"); - this.routeService.routeReopen(simulation, lockedRoute); + signal.setForbidden(false); } @Override @@ -405,7 +405,7 @@ public class CiApiServiceImpl2 implements CiApiService { // if (config.isSomeCommandNeedInit()) { // BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isInit(), signal.debugStr() + "未初始化"); // } - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isForbidAspect(), + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isDefaultAspect(), String.format("信号机[%s]需处于关闭状态", signal.getCode())); boolean signalApproachOccupied = signal.getApproachPathList() .stream().anyMatch(sectionPath -> sectionPath.getSectionList().stream().anyMatch(Section::isOccupied)); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java index 8e3039c71..3663df22c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java @@ -9,10 +9,7 @@ import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; -import club.joylink.rtss.simulation.cbtc.data.map.MapConfig; -import club.joylink.rtss.simulation.cbtc.data.map.Route; -import club.joylink.rtss.simulation.cbtc.data.map.RouteOverlap; -import club.joylink.rtss.simulation.cbtc.data.map.Section; +import club.joylink.rtss.simulation.cbtc.data.map.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -35,8 +32,12 @@ public class CiLogic { public void run(Simulation simulation) { // 采集真实设备状态 this.deviceStatusCollector.collect(simulation); - // 联锁监控逻辑 + // 信号机监控控制 SimulationDataRepository repository = simulation.getRepository(); + for (Signal signal : repository.getSignalList()) { + this.signalMonitor(simulation, signal); + } + // 联锁监控逻辑 List routeList = repository.getRouteList(); for (Route route : routeList) { this.interlockMonitor(simulation, route); @@ -47,6 +48,10 @@ public class CiLogic { } } + private void signalMonitor(Simulation simulation, Signal signal) { + this.signalControlService.controlLightOfSignal(simulation, signal); + } + /** * 进路监控 * @param simulation @@ -72,7 +77,7 @@ public class CiLogic { if (route.isNormalUnlock()) { this.routeService.trainUnlockRoute(simulation, route); } - if (route.isOpenMain() || route.isOpenGuide()) { + if (route.isLock()) { // 进路首区段列车占用,进路开始解锁 Section firstLogicSection = route.getFirstLogicSection(); SimulationDataRepository repository = simulation.getRepository(); @@ -80,13 +85,17 @@ public class CiLogic { this.trainUnlockStart(simulation, route); } } - if (route.isOpenMain()) { // 主信号开放 + if (route.isLock()) { this.ciService.interlockCheck(simulation, route); - SignalAspect aspect = this.ciService.getRouteCurrentMaxAspect(route); - if (!aspect.equals(route.getStart().getAspect())) {//与联锁显示不同,关闭信号 + Signal start = route.getStart(); + if (route.isOpenMain() && !start.isSupportMainAspect()) {//与联锁显示不同,关闭信号 log.info("进路[{}]联锁条件不满足,关闭信号", route.debugStr()); this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, - route.getStart(), route.getStart().getSignalModel().getDefaultAspect()); + start, start.getDefaultAspect()); + } else if (start.isDefaultAspect() && !start.isForbidden() && start.isSupportMainAspect()) { + log.info("进路[{}]联锁条件满足,开放信号", route.debugStr()); + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, + start, route.getAspect()); } } // 进路延续保护办理判断 @@ -100,7 +109,7 @@ public class CiLogic { route.startNormalUnlock(); log.info("进路[{}]因列车进入,关闭信号", route.debugStr()); this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, - route.getStart(), route.getStart().getSignalModel().getDefaultAspect()); + route.getStart(), route.getStart().getDefaultAspect()); } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiDeviceStatusCollector.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiDeviceStatusCollector.java index 2716f9a7e..05bba2654 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiDeviceStatusCollector.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiDeviceStatusCollector.java @@ -21,6 +21,7 @@ import java.util.List; public class CiDeviceStatusCollector { @Autowired private GroundAtpApiService groundAtpApiService; + public void collect(Simulation simulation) { SimulationDataRepository repository = simulation.getRepository(); this.collectSection(repository, repository.getSectionList()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiRouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiRouteService.java index e5b5955d4..0a287e8fb 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiRouteService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiRouteService.java @@ -224,13 +224,13 @@ public class CiRouteService { this.ciService.interlockCheck(simulation, route); if (!route.getStart().isBlockade()) { if (route.isGuideSetting()) { - this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getStart().getSignalModel().getGuideAspect()); + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getStart().getGuideAspect()); } else { this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getAspect()); } } if ((route.getAspect().equals(route.getStart().getAspect())) || - (route.isGuideSetting() && route.getStart().getAspect().equals(route.getStart().getSignalModel().getGuideAspect()))) { + (route.isGuideSetting() && route.getStart().isGuideAspect())) { log.debug("进路[{}]信号开放,办理结束", route.debugStr()); route.settingOver(); } @@ -289,7 +289,7 @@ public class CiRouteService { this.cancelFleet(route); // 关闭始端信号机 this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, - route.getStart(), route.getStart().getSignalModel().getDefaultAspect()); + route.getStart(), route.getStart().getDefaultAspect()); log.debug(String.format("取消进路,信号机[%s(%s)]关灯", route.getStart().getName(), route.getStart().getCode())); //进路解锁 @@ -330,7 +330,7 @@ public class CiRouteService { public void delayUnlockStart(Simulation simulation, Route route, DelayUnlockDevice device) { device.delayUnlockStart(route); route.setDelayUnlockDevice(device); - this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getStart().getSignalModel().getDefaultAspect()); + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getStart().getDefaultAspect()); } /** @@ -400,7 +400,7 @@ public class CiRouteService { } else { if (route.isOpenMain() || route.isOpenGuide()) { this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), - route.getStart().getSignalModel().getDefaultAspect()); + route.getStart().getDefaultAspect()); } route.setLock(false); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiService.java index 31abb2a4c..fedad5ef2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiService.java @@ -39,19 +39,6 @@ public class CiService { } } - /** - * 进路当前最高信号显示 - * - * @param route - * @return - */ - public SignalAspect getRouteCurrentMaxAspect(Route route) { - if (route.isNormalUnlock()) { - return route.getStart().getSignalModel().getDefaultAspect(); - } - return route.getStart().getMaxAspectByLevel(route.getAspect()); - } - /** * 延续保护检查 * @@ -116,7 +103,7 @@ public class CiService { return false; } else { Signal pSignal = flsElement.getPSignal(); - if (pSignal != null && !pSignal.getSignalModel().getDefaultAspect().equals(pSignal.getAspect())) { + if (pSignal != null && !pSignal.isDefaultAspect()) { return false; } } @@ -125,9 +112,10 @@ public class CiService { return true; } - public void interlockCheck(Simulation simulation, Route route) { + public int interlockCheck(Simulation simulation, Route route) { int level = this.checkRouteLevel(simulation, route); route.getStart().setLevel(level); + return level; } private int checkRouteLevel(Simulation simulation, Route route) { @@ -179,7 +167,7 @@ public class CiService { } else { SwitchElement fpae = flsElement.getFpae(); Signal pSignal = flsElement.getPSignal(); - if (pSignal != null && !pSignal.getSignalModel().getDefaultAspect().equals(pSignal.getAspect())) { + if (pSignal != null && !pSignal.isDefaultAspect()) { if (fpae != null) { if (fpae.isOnPosition()) { return level; @@ -211,10 +199,6 @@ public class CiService { } } } - - if (route.getStart().isCbtcMode()) { - level = Signal.LEVEL_Atp; // ATP级 - } // 站台紧急停车 if (!CollectionUtils.isEmpty(route.getEspList())) { for (ESP esp : route.getEspList()) { @@ -225,6 +209,9 @@ public class CiService { } } } + if (route.getStart().isCbtcMode()) { + level = Signal.LEVEL_Atp; // ATP级 + } // 区段占用检查 for (Section section : sectionList) { if (section.isOccupied()) { @@ -253,12 +240,12 @@ public class CiService { if(Stand.Fault.PSD_CANNOT_BE_CLOSED.equals(psd.getStand().getFault()) && !psd.getStand().isInterlockRelease()) { return Signal.LEVEL_Guide; } - if (!psd.isCloseAndLock() && !psd.isInterlockRelease()) { -// log.debug("联锁网络检查:站台[{}({})]屏蔽门[{}({})]未关闭", -// psd.getStand().getName(), psd.getStand().getCode(), -// psd.getName(), psd.getCode()); - return level; - } +// if (!psd.isCloseAndLock() && !psd.isInterlockRelease()) { +//// log.debug("联锁网络检查:站台[{}({})]屏蔽门[{}({})]未关闭", +//// psd.getStand().getName(), psd.getStand().getCode(), +//// psd.getName(), psd.getCode()); +// return level; +// } } } // 站台扣车 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSignalControlService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSignalControlService.java index 902e03aff..bfe292297 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSignalControlService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSignalControlService.java @@ -56,15 +56,14 @@ public class CiSignalControlService { */ public void controlLightOfSignal(Simulation simulation, Signal signal) { VirtualRealitySignal vrSignal = signal.getVirtualSignal(); - if (signal.isCbtcMode()) { - if (vrSignal != null && !signal.isLogicLight()) { + if (signal.isCbtcMode() && !signal.isForcePhysical() && !signal.isLogicLight()) { + if (vrSignal != null) { this.virtualRealityDeviceService.control(simulation, vrSignal, SignalAspect.No); + } else { + signal.setLogicLight(true); } - } else { - if (vrSignal != null && signal.isLogicLight()) { - if (signal.getLockedRoute() != null && signal.getLockedRoute().getAspect().equals(signal.getAspect())) { - signal.getLockedRoute().startSetting(simulation.getSystemTime()); - } + } else if ((!signal.isCbtcMode() || signal.isForcePhysical()) && signal.isLogicLight()) { + if (vrSignal != null) { this.virtualRealityDeviceService.control(simulation, vrSignal, vrSignal.getModel().getDefaultAspect()); } } @@ -77,7 +76,7 @@ public class CiSignalControlService { public void blockade(Simulation simulation, Signal signal) { if(!signal.isBlockade()) { signal.setBlockade(true); - this.closeRoute(simulation, signal); + this.tryControlSignalAspectAccordingLevel(simulation, signal, signal.getDefaultAspect()); if (signal.getLockedRoute() != null) { signal.setReblockade(true); log.debug(signal.debugStr() + "因信号机封锁且有锁闭的进路而重复封锁"); @@ -96,10 +95,7 @@ public class CiSignalControlService { } public void closeRoute(Simulation simulation, Signal signal) { - if (signal.isLogicLight()) { - signal.setAspect(signal.getSignalModel().getDefaultAspect()); - } else { - this.virtualRealityDeviceService.control(simulation, signal.getVirtualSignal(), signal.getSignalModel().getDefaultAspect()); - } + signal.setForbidden(true); + this.tryControlSignalAspectAccordingLevel(simulation, signal, signal.getDefaultAspect()); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSwitchControlService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSwitchControlService.java index 569bd7adc..06e25191a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSwitchControlService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSwitchControlService.java @@ -97,9 +97,9 @@ public class CiSwitchControlService { return this.turn2NormalPosition(simulation, aSwitch); } } else { - if (aSwitch.isPosN()) { + if (vrSwitch.isPosN()) { return this.turn2ReversePosition(simulation, aSwitch); - } else if (aSwitch.isPosR()) { + } else if (vrSwitch.isPosR()) { return this.turn2ReversePosition(simulation, aSwitch); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java index 5461909e5..00d94e200 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java @@ -481,6 +481,9 @@ public class Section extends DelayUnlockDevice { * 计轴占用出清 */ public void axleCounterClear() { + if (AxleFault.FAULT.equals(this.getFault())) { + this.setFault(null); + } this.nctOccupied = false; if (!CollectionUtils.isEmpty(logicList)) { logicList.forEach(Section::axleCounterClear); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java index eeefd6584..4f294d5bc 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java @@ -190,7 +190,10 @@ public class Signal extends DelayUnlockDevice { * 当前信号显示 */ private SignalAspect aspect; - + /** + * 是否禁止联锁自动开信号 + */ + private boolean forbidden; /** * 引导信号开放剩余时间,单位ms */ @@ -257,7 +260,12 @@ public class Signal extends DelayUnlockDevice { * @return */ public boolean changeToCbtcMode() { + if (this.getVirtualSignal() == null) { + this.mode = Mode_CBTC; + return true; + } if (!this.isCtc()) { + this.mode = Mode_BM; return false; } if (this.mode != Mode_CBTC) { @@ -272,7 +280,8 @@ public class Signal extends DelayUnlockDevice { * @return */ public boolean changeToBackupMode() { - if (this.getVirtualSignal() == null) { + if (this.getVirtualSignal() == null) { // 虚拟信号 + this.mode = Mode_CBTC; return false; } if (this.mode != Mode_BM) { @@ -300,20 +309,6 @@ public class Signal extends DelayUnlockDevice { } } - /** - * 是否开启引导信号 - */ - public boolean isGuideAspect() { - return this.aspect != null && this.aspect.equals(this.signalModel.getGuideAspect()); - } - /** - * 是否禁止信号 - * @return - */ - public boolean isForbidAspect() { - return this.aspect != null && this.aspect.equals(this.signalModel.getDefaultAspect()); - } - public boolean isMainAspect() { return this.signalModel.getMainAspects() != null && this.signalModel.getMainAspects().contains(this.aspect); } @@ -596,6 +591,32 @@ public class Signal extends DelayUnlockDevice { return this.signalModel.getDefaultAspect(); } + public boolean isSupportMainAspect() { + if (this.isMainLevel()) { + return true; + } + if (this.isAtpLevel() && this.isCbtcMode()) { + return true; + } + return false; + } + + public boolean isDefaultAspect() { + return this.aspect.equals(this.signalModel.getDefaultAspect()); + } + + public SignalAspect getDefaultAspect() { + return this.signalModel.getDefaultAspect(); + } + + public boolean isGuideAspect() { + return this.aspect.equals(this.signalModel.getGuideAspect()); + } + + public SignalAspect getGuideAspect() { + return this.signalModel.getGuideAspect(); + } + public enum LightColor { RED, YELLOW, diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index 14c19d6d0..83c828d53 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -887,7 +887,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { boolean right = this.right; Section section = this.headPosition.getSection(); Signal signal = section.getSignalOf(right); - if (signal == null || !signal.isForbidAspect()) { //没有同向信号机或信号机不处于信号关闭状态 + if (signal == null || !signal.isDefaultAspect()) { //没有同向信号机或信号机不处于信号关闭状态 throw new SimulationException(SimulationExceptionType.Invalid_Operation, "指令要求:列车车头所在区段有同向信号机并且信号关闭"); } From b95af3b5b5aa5300f5484d3e26c3f29d45c92f85 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Fri, 17 Sep 2021 16:37:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8C=BA=E6=AE=B5ARB=E9=A2=84=E5=A4=8D?= =?UTF-8?q?=E4=BD=8Dbug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/CI/CiApiServiceImpl2.java | 7 ++++--- .../rtss/simulation/cbtc/data/map/Section.java | 15 ++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java index 22931c07b..5140af0c6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java @@ -520,10 +520,11 @@ public class CiApiServiceImpl2 implements CiApiService { BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(), section.debugStr() + "不是计轴区段也不归属于任何计轴区段"); VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter(); - if (!virtualAxleCounter.isOccupy()) + if (!virtualAxleCounter.isOccupy()){ + VirtualRealitySectionAxleCounter.Fault.FAULT.apply(virtualAxleCounter); Section.AxleFault.ARB.apply(axleSection); - else - virtualAxleCounter.preReset(); + } + virtualAxleCounter.preReset(); } @Override diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java index 00d94e200..1e83a1854 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java @@ -481,9 +481,12 @@ public class Section extends DelayUnlockDevice { * 计轴占用出清 */ public void axleCounterClear() { - if (AxleFault.FAULT.equals(this.getFault())) { + if (AxleFault.FAULT.equals(this.getFault()) || AxleFault.ARB.equals(this.getFault())) { this.setFault(null); } + if (this.isInvalid()) { + this.judgeAsValid(); + } this.nctOccupied = false; if (!CollectionUtils.isEmpty(logicList)) { logicList.forEach(Section::axleCounterClear); @@ -874,14 +877,8 @@ public class Section extends DelayUnlockDevice { List relSwitchList = this.getRelSwitchList(); for (Switch aSwitch : relSwitchList) { aSwitch.getA().setInvalid(false); - if (aSwitch.isPosN()) { - aSwitch.getB().setInvalid(false); - } else if (aSwitch.isPosR()) { - aSwitch.getC().setInvalid(false); - } else { - aSwitch.getB().setInvalid(false); - aSwitch.getC().setInvalid(false); - } + aSwitch.getB().setInvalid(false); + aSwitch.getC().setInvalid(false); } } else if (!CollectionUtils.isEmpty(this.logicList)) { for (Section logic : this.logicList) { From 56ba88d2cdce358f8a491376c49009d3f3d0fccf Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Sat, 18 Sep 2021 13:51:30 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E6=9C=BA=E5=B0=81?= =?UTF-8?q?=E9=94=81=E5=90=8E=E4=B8=8D=E8=83=BD=E5=BC=80=E4=BF=A1=E5=8F=B7?= =?UTF-8?q?=20=E8=BF=9B=E8=B7=AF=E5=8A=9E=E7=90=86=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E4=B8=8D=E5=8F=96=E6=B6=88=E9=94=81=E9=97=AD=20=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=E7=82=B9=E7=81=AF=E6=93=8D=E4=BD=9C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20=E8=BF=9B=E8=B7=AF=E7=9B=B4=E6=8E=A5=E5=BC=80=E6=94=BEbug?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/service/AtsStationService.java | 14 ++--- .../rtss/simulation/cbtc/CI/CiLogic.java | 2 +- .../cbtc/CI/device/CiRouteService.java | 18 ++----- .../cbtc/CI/device/CiStandService.java | 52 ++++++++----------- .../simulation/cbtc/data/map/Section.java | 2 +- .../cbtc/tool/DeviceStatusModifyTool.java | 12 +++-- 6 files changed, 39 insertions(+), 61 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java index fde15969d..8dd566c77 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java @@ -370,18 +370,10 @@ public class AtsStationService { List signalList = simulation.getRepository().getSignalList().stream() .filter(signal -> station.equals(signal.getInterlockStation())).collect(Collectors.toList()); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(signalList, station.debugStr() + "下无信号机"); - // todo 信号显示变为aspect一个字段,此处逻辑不再适用 - if (!signalList.get(0).isForcePhysical()) { -// signalList.forEach(signal -> { -// VirtualRealitySignal virtualSignal = signal.getVirtualSignal(); -// if (virtualSignal != null) { -// virtualSignal.apply(signal.isGreenOpen(), signal.isYellowOpen(), signal.isRedOpen()); -// } -// signal.changeLightType(false); -// signal.setForcePhysical(true); -// }); - } else { + if (signalList.get(0).isForcePhysical()) { signalList.forEach(signal -> signal.setForcePhysical(false)); + } else { + signalList.forEach(signal -> signal.setForcePhysical(true)); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java index 3663df22c..cfbbd7b1e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java @@ -92,7 +92,7 @@ public class CiLogic { log.info("进路[{}]联锁条件不满足,关闭信号", route.debugStr()); this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, start, start.getDefaultAspect()); - } else if (start.isDefaultAspect() && !start.isForbidden() && start.isSupportMainAspect()) { + } else if (start.isDefaultAspect() && !start.isForbidden() && !start.isBlockade() && start.isSupportMainAspect()) { log.info("进路[{}]联锁条件满足,开放信号", route.debugStr()); this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, start, route.getAspect()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiRouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiRouteService.java index 0a287e8fb..60489ecc4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiRouteService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiRouteService.java @@ -207,7 +207,6 @@ public class CiRouteService { if (simulation.getSystemTime().isAfter(route.getSettingStartTime().plusSeconds(SimulationConstants.ROUTE_SETTING_TIMEOUT))) { log.info("进路[{}]办理超时,取消办理2", route.debugStr()); route.settingOver(); - route.setLock(false); return; } } @@ -223,11 +222,10 @@ public class CiRouteService { // 检查信号开放条件,开信号 this.ciService.interlockCheck(simulation, route); if (!route.getStart().isBlockade()) { - if (route.isGuideSetting()) { - this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getStart().getGuideAspect()); - } else { - this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getAspect()); - } + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getAspect()); + } + if (route.isGuideSetting()) { + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getStart().getGuideAspect()); } if ((route.getAspect().equals(route.getStart().getAspect())) || (route.isGuideSetting() && route.getStart().isGuideAspect())) { @@ -601,14 +599,6 @@ public class CiRouteService { } } - public void routeReopen(Simulation simulation, Route route) { - // 检查信号开放条件,开信号 - this.ciService.interlockCheck(simulation, route); - if (!route.getStart().isBlockade()) { - this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getAspect()); - } - } - /** * 设置自动进路模式 * diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiStandService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiStandService.java index e77fd5005..8f3da1808 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiStandService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiStandService.java @@ -2,8 +2,6 @@ package club.joylink.rtss.simulation.cbtc.CI.device; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.PSD; -import club.joylink.rtss.simulation.cbtc.data.map.Route; -import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; @@ -11,15 +9,11 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Objects; - @Slf4j @Component public class CiStandService { @Autowired private VirtualRealityDeviceService virtualRealityDeviceService; - @Autowired - private CiSignalControlService signalService; /** * 打开屏蔽门 * @@ -70,10 +64,10 @@ public class CiStandService { public void cancelSysHoldTrain(Simulation simulation, Stand stand) { stand.setSysHoldTrain(false); - // 如果所有扣车都取消,开放出站信号机 - if (!stand.isHoldTrain()) { - this.reopenSignal(simulation, stand); - } +// // 如果所有扣车都取消,开放出站信号机 +// if (!stand.isHoldTrain()) { +// this.reopenSignal(simulation, stand); +// } } public void ibpHoldTrain(Simulation simulation, Stand stand) { @@ -82,10 +76,10 @@ public class CiStandService { public void cancelIbpHoldTrain(Simulation simulation, Stand stand) { stand.setIbpHoldTrain(false); - // 如果所有扣车都取消,开放出站信号机 - if (!stand.isHoldTrain()) { - this.reopenSignal(simulation, stand); - } +// // 如果所有扣车都取消,开放出站信号机 +// if (!stand.isHoldTrain()) { +// this.reopenSignal(simulation, stand); +// } } /** @@ -101,25 +95,25 @@ public class CiStandService { } else { stand.setStationHoldTrain(false); } - // 如果所有扣车都取消,开放出站信号机 - if (!stand.isHoldTrain()) { - this.reopenSignal(simulation, stand); - } +// // 如果所有扣车都取消,开放出站信号机 +// if (!stand.isHoldTrain()) { +// this.reopenSignal(simulation, stand); +// } } public void cancelAllHoldTrain(Simulation simulation, Stand stand) { stand.setCenterHoldTrain(false); stand.setStationHoldTrain(false); - this.reopenSignal(simulation, stand); +// this.reopenSignal(simulation, stand); } - private void reopenSignal(Simulation simulation, Stand stand) { - Signal signal = stand.getSection().getSignalOf(stand.isRight()); - if (Objects.nonNull(signal) && !signal.isMainAspect()) { - Route lockedRoute = signal.getLockedRoute(); - this.signalService.tryControlSignalAspectAccordingLevel(simulation, signal, lockedRoute.getAspect()); - } - } +// private void reopenSignal(Simulation simulation, Stand stand) { +// Signal signal = stand.getSection().getSignalOf(stand.isRight()); +// if (Objects.nonNull(signal) && !signal.isMainAspect()) { +// Route lockedRoute = signal.getLockedRoute(); +// this.signalService.tryControlSignalAspectAccordingLevel(simulation, signal, lockedRoute.getAspect()); +// } +// } /** * 设置或取消互锁解除 @@ -128,8 +122,8 @@ public class CiStandService { public void setOrCancelInterlockRelease(Simulation simulation, Stand stand, boolean release) { stand.getPsd().getVirtualScreenDoor().updateIL(release); stand.getPsd().setInterlockRelease(release); - if (release) { - this.reopenSignal(simulation, stand); - } +// if (release) { +// this.reopenSignal(simulation, stand); +// } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java index 1e83a1854..8f27b59c9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java @@ -669,7 +669,7 @@ public class Section extends DelayUnlockDevice { } private boolean isRouteLockBy(Route route) { - return this.routeLock && route.equals(this.route); + return this.routeLock && this.route.equals(route); } public void forceUnlocking() { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/tool/DeviceStatusModifyTool.java b/src/main/java/club/joylink/rtss/simulation/cbtc/tool/DeviceStatusModifyTool.java index 1275a673a..1d25f8f50 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/tool/DeviceStatusModifyTool.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/tool/DeviceStatusModifyTool.java @@ -117,12 +117,14 @@ public class DeviceStatusModifyTool { private void openSignalDirectly(Signal signal, SignalAspect aspect) { VirtualRealitySignal virtualSignal = signal.getVirtualSignal(); signal.changeLightType(true); - if (signal.isLogicLight() && !signal.isVirtual()) { - virtualSignal.control(SignalAspect.No); - } else { - virtualSignal.control(aspect); + if (virtualSignal != null) { + if (signal.isLogicLight()) { + virtualSignal.control(SignalAspect.No); + } else { + virtualSignal.control(aspect); + } + virtualSignal.finish(); } - virtualSignal.finish(); signal.setAspect(aspect); }