From 7b960c809e01cc5f2eb02396585081d4b1124935 Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Wed, 5 May 2021 18:54:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E9=93=81=E8=BF=9B=E8=B7=AF=E6=8E=92?= =?UTF-8?q?=E5=88=97=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rt/CIL/CilRouteLogicService.java | 75 ++++++++++++------- .../rt/CIL/CilSwitchLogicService.java | 2 +- .../rtss/simulation/rt/CIL/bo/CilSection.java | 4 + .../rtss/simulation/rt/CIL/bo/CilSwitch.java | 6 +- 4 files changed, 59 insertions(+), 28 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java index e64ac3358..096a7f0b5 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java @@ -25,11 +25,7 @@ public class CilRouteLogicService { public void routeLogic(RtSimulation rtSimulation, CilRepository cilRepository) { List supervisedRouteList = cilRepository.getSupervisedRouteList(); for (CilRoute cilRoute : supervisedRouteList) { - if (!cilRoute.isSettingFinished()) { - this.settingProgress(rtSimulation, cilRepository, cilRoute, cilRepository.getConfig()); - } else { - monitorRoute(rtSimulation, cilRepository, cilRoute); - } + this.settingProgress(rtSimulation, cilRepository, cilRoute, cilRepository.getConfig()); if (cilRoute.isDelayUnlocking()) { this.monitorDelayUnlockingRoute(rtSimulation, cilRoute, cilRepository.getConfig()); } @@ -118,7 +114,7 @@ public class CilRouteLogicService { cilRoute.setGl(true); //引导锁 } } else { - //进路不能锁闭,直接办理引导进路 + //进路不能锁闭,检查、办理引导进路 List routes = commonRepository.getRoutesByStartSignal(cilSignal.getId()); Optional routeOptional = routes.stream().filter(cr -> { List spList = cr.getPathElement().getSpList(); @@ -182,10 +178,15 @@ public class CilRouteLogicService { public boolean canOpenSignal(RtSimulation rtSimulation, String routeId) { CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class); CilRoute cilRoute = cilRepository.getRouteById(routeId); - if (cilRoute.isTrainIn()) - return false; CommonRepository commonRepository = rtSimulation.getRepository(CommonRepository.NAME, CommonRepository.class); CommonRoute commonRoute = commonRepository.getRouteById(cilRoute.getId()); + //检查区段占用 + for (CommonSection commonSection : commonRoute.getPathElement().getAllSectionList()) { + if (cilRepository.getSectionById(commonSection.getId()).isAxcOccupy()) { + return false; + } + } + //检查信号级别 CilSignal cilSignal = cilRepository.getSignalById(commonRoute.getStart().getId()); return cilSignal.sufficientLevel(commonRoute.getSignalAspect(), false); } @@ -264,17 +265,32 @@ public class CilRouteLogicService { */ private void check4SetRoute(CilRepository cilRepository, CommonRoute commonRoute) { checkConflictingRoute(cilRepository, commonRoute); - // 道岔检查 + checkSwitches(cilRepository, commonRoute); + checkStartSignal(cilRepository, commonRoute); + //检查区段 + for (CommonSection commonSection : commonRoute.getPathElement().getSectionList()) { + CilSection cilSection = cilRepository.getSectionById(commonSection.getId()); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(cilSection.isAxcOccupy(), "区段占用"); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(cilSection.isRl() || cilSection.isOl(), "区段锁闭"); + } + } + + /** + * 检查道岔 + */ + private void checkSwitches(CilRepository cilRepository, CommonRoute commonRoute) { List spList = commonRoute.getPathElement().getSpList(); if (!CollectionUtils.isEmpty(spList)) { for (SwitchPosition switchPosition : spList) { CommonSwitch commonSwitch = switchPosition.getCommonSwitch(); CilSwitch cilSwitch = cilRepository.getSwitchById(commonSwitch.getId()); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(cilSwitch.isBl(), "进路内道岔封锁"); + if (cilSwitch.isLocked()) { + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(switchPosition.getPosition() == cilSwitch.getPosition(), + "道岔已锁闭且位置不正确"); + } } } - checkStartSignal(cilRepository, commonRoute); - checkRouteSections(cilRepository, commonRoute); } /** @@ -313,6 +329,10 @@ public class CilRouteLogicService { checkConflictingRoute(cilRepository, commonRoute); checkStartSignal(cilRepository, commonRoute); checkRouteSections(cilRepository, commonRoute); + for (CommonSection commonSection : commonRoute.getPathElement().getSectionList()) { + CilSection cilSection = cilRepository.getSectionById(commonSection.getId()); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(cilSection.isLocked(), "区段锁闭"); + } } public boolean cancelRoute(RtSimulation rtSimulation, String routeId) { @@ -436,15 +456,15 @@ public class CilRouteLogicService { } } } else { - try2LockRouteDevices(rtSimulation, cilRepository, cilRoute, commonRoute); - setLockingStateByInterlockCheck(cilRepository, cilRoute, commonRoute); + if (!cilRoute.isSettingFinished()) { + try2LockRouteDevices(rtSimulation, cilRepository, cilRoute, commonRoute); + } + monitorRoute(rtSimulation, cilRepository, cilRoute); CilSignal cilSignal = cilRepository.getSignalById(commonRoute.getStart().getId()); - updateSignalLevel(cilRepository, cilRoute, commonRoute, cilSignal); + if (cilRoute.isCanAutoOpen()) + try2OpenSignal4Route(rtSimulation, cilRoute, commonRoute, cilSignal, commonRoute.getSignalAspect()); if (cilSignal.getSignalAspect() == commonRoute.getSignalAspect()) //信号机已开启进路指定的信号 cilRoute.finishSetting(); - if (cilRoute.isCanAutoOpen()) { - try2OpenSignal4Route(rtSimulation, cilRoute, commonRoute, cilSignal, commonRoute.getSignalAspect()); - } } } @@ -457,8 +477,6 @@ public class CilRouteLogicService { CilSignal cilSignal = cilRepository.getSignalById(commonRoute.getStart().getId()); setLockingStateByInterlockCheck(cilRepository, cilRoute, commonRoute); updateSignalLevel(cilRepository, cilRoute, commonRoute, cilSignal); - //列车进入进路检查 - cilRoute.setTrainIn(this.isTrainIn(cilRepository, commonRoute)); if (!cilSignal.isGuideAspect()) { //非引导信号 CommonSignal commonSignal = commonRepository.getSignalById(cilSignal.getId()); //信号开放条件检查,不通过时关闭信号 @@ -505,7 +523,7 @@ public class CilRouteLogicService { } // 侧防设备转动、锁闭 List flsList = commonRoute.getFlsList(); - if (!CollectionUtils.isEmpty(flsList)) { //进路侧防不为空 + if (!CollectionUtils.isEmpty(flsList)) { if (!cilRoute.isFl()) { //进路未侧防锁闭 for (CommonFls commonFls : flsList) { SwitchPosition target = commonFls.getTarget(); @@ -825,7 +843,17 @@ public class CilRouteLogicService { return; CilSignal cilSignal = cilRepository.getSignalById(commonRoute.getStart().getId()); if (cilSignal.isGuideAspect()) { - if (cilSignal.getGuideTime() != 0) { //引导信号的关闭只依赖时间 + List spList = commonRoute.getPathElement().getSpList(); + if (!CollectionUtils.isEmpty(spList)) { + for (SwitchPosition sp : spList) { + CilSwitch cilSwitch = cilRepository.getSwitchById(sp.getCommonSwitch().getId()); + if (!cilSwitch.isMgl() && !cilSwitch.isRouteLockOnPosition(cilRoute.getId(), sp.getPosition())) { + cilSignal.clearGuideTime(); + cilSignalLogicService.openForbiddenAspect(rtSimulation, cilSignal.getId()); + } + } + } + if (cilSignal.getGuideTime() != 0) { //引导信号延时关闭 cilSignal.updateGuideTime(); if (cilSignal.getGuideTime() == 0) { cilSignalLogicService.openForbiddenAspect(rtSimulation, cilSignal.getId()); @@ -837,9 +865,4 @@ public class CilRouteLogicService { } } } - - private boolean isTrainIn(CilRepository cilRepository, CommonRoute commonRoute) { - return commonRoute.getPathElement().getAllSectionList() - .stream().anyMatch(cs -> cilRepository.getSectionById(cs.getId()).isAxcOccupy()); - } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSwitchLogicService.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSwitchLogicService.java index 3e59d84ef..df8154006 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSwitchLogicService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSwitchLogicService.java @@ -54,7 +54,7 @@ public class CilSwitchLogicService { if (cilSwitch.getPosition() == position) { return; } - if (!cilSwitch.isLocked() && !isOccupy(rtSimulation, commonSwitch.getId())) { + if (!cilSwitch.isLocked() && !isOccupy(rtSimulation, commonSwitch.getId()) && !cilSwitch.isRouteUse()) { srdApiService.turnSwitch(rtSimulation, commonSwitch.getId(), position); } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSection.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSection.java index 1151ae7da..569b41cc1 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSection.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSection.java @@ -81,4 +81,8 @@ public class CilSection extends CilDevice { public boolean isDelayUnlocking() { return this.delayTime != 0; } + + public boolean isLocked() { + return ol || rl; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitch.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitch.java index 896bd879a..a97adff49 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitch.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitch.java @@ -98,6 +98,10 @@ public class CilSwitch extends CilDevice { this.routeUseToPosition = 0; } + public boolean isRouteUse() { + return this.routeUseToPosition != 0; + } + public void lockByRoute(String routeId) { if (!Objects.equals(routeId, this.routeId)) { this.routeId = routeId; @@ -131,7 +135,7 @@ public class CilSwitch extends CilDevice { } public boolean isLocked() { - return sl || rl || ol || fl; + return sl || rl || ol || fl || mgl; } public boolean isRouteLockOnPosition(@NonNull String routeId, int position) {