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/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/CiApiServiceImpl2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java index 8f8ed2c3c..f70ff9ee7 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)); @@ -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/CI/CiLogic.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java index 8e3039c71..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 @@ -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.isBlockade() && 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..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,14 +222,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()); - } 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().getAspect().equals(route.getStart().getSignalModel().getGuideAspect()))) { + (route.isGuideSetting() && route.getStart().isGuideAspect())) { log.debug("进路[{}]信号开放,办理结束", route.debugStr()); route.settingOver(); } @@ -289,7 +287,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 +328,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 +398,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); } @@ -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/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/CiStandService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiStandService.java index 8c40a0082..8c01c8a24 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 @@ -4,6 +4,8 @@ import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl; +import club.joylink.rtss.simulation.cbtc.data.map.PSD; +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; import lombok.extern.slf4j.Slf4j; @@ -17,8 +19,6 @@ import java.util.Objects; public class CiStandService { @Autowired private VirtualRealityDeviceService virtualRealityDeviceService; - @Autowired - private CiSignalControlService signalService; /** * 打开屏蔽门 */ @@ -93,10 +93,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) { @@ -105,10 +105,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); +// } } /** @@ -124,25 +124,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()); +// } +// } /** * 设置或取消互锁解除 @@ -151,9 +151,9 @@ 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/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..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 @@ -481,6 +481,12 @@ public class Section extends DelayUnlockDevice { * 计轴占用出清 */ public void axleCounterClear() { + 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); @@ -663,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() { @@ -871,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) { 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, "指令要求:列车车头所在区段有同向信号机并且信号关闭"); } 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); }