From 0e3ab8cac8d9b6ce59624cfac1bfb6d4ded6082f Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 23 Apr 2021 15:20:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=89=88=E4=BB=BF=E7=9C=9F=E8=BF=9B?= =?UTF-8?q?=E8=B7=AF=E4=B8=8E=E5=8F=96=E6=B6=88=E8=BF=9B=E8=B7=AF=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=EF=BC=9B=E5=AD=90=E7=B3=BB=E7=BB=9F=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/rt/RtSimulationController.java | 6 - .../rtss/services/MapSystemService.java | 12 +- .../rtss/simulation/rt/CIL/CilApiService.java | 11 +- .../rt/CIL/CilRouteLogicService.java | 156 ++++++++++-------- .../rt/CIL/CilSignalLogicService.java | 38 +++-- .../rtss/simulation/rt/CIL/bo/CilOverlap.java | 33 +++- .../simulation/rt/CIL/bo/CilRepository.java | 8 + .../rt/CIL/bo/CilRepositoryBuilder.java | 8 +- .../rtss/simulation/rt/CIL/bo/CilSection.java | 16 +- .../rtss/simulation/rt/CIL/bo/CilSignal.java | 49 ++++-- .../rtss/simulation/rt/CIL/bo/CilSwitch.java | 12 ++ .../rtss/simulation/rt/SRD/SrdApiService.java | 3 + .../rtss/simulation/rt/SRD/bo/SrSignal.java | 12 ++ .../rt/operation/SignalOperationHandler.java | 6 +- .../rtss/simulation/rt/repo/CommonFls.java | 24 +++ 15 files changed, 268 insertions(+), 126 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/simulation/rt/RtSimulationController.java b/src/main/java/club/joylink/rtss/controller/simulation/rt/RtSimulationController.java index bb1a3acfe..9218ebb91 100644 --- a/src/main/java/club/joylink/rtss/controller/simulation/rt/RtSimulationController.java +++ b/src/main/java/club/joylink/rtss/controller/simulation/rt/RtSimulationController.java @@ -41,10 +41,4 @@ public class RtSimulationController { this.rtSimulationService.init(id); } - @ApiOperation(value = "清除仿真") - @DeleteMapping("/{group}/clear") - public void clearSimulation(@PathVariable String group, @ApiIgnore @RequestAttribute UserVO user) { - this.rtSimulationService.clearSimulation(group, user); - } - } diff --git a/src/main/java/club/joylink/rtss/services/MapSystemService.java b/src/main/java/club/joylink/rtss/services/MapSystemService.java index a9f5efe38..4e50595cc 100644 --- a/src/main/java/club/joylink/rtss/services/MapSystemService.java +++ b/src/main/java/club/joylink/rtss/services/MapSystemService.java @@ -170,12 +170,14 @@ public class MapSystemService implements IMapSystemService { @Override public void updateMapSystem(Long id, MapSystemVO mapSystemVO) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(mapSystemVO.getName(), "名称不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(mapSystemVO.getNewApi(), "是否使用新版接口不能为空"); MapSystem mapSystem = getEntity(id); - if (StringUtils.hasText(mapSystemVO.getName()) && !Objects.equals(mapSystem.getName(), mapSystemVO.getName())) { - mapSystem.setName(mapSystemVO.getName()); - mapSystem.setNewApi(mapSystemVO.getNewApi()); - mapSystemDAO.updateByPrimaryKey(mapSystem); - } + if (Objects.equals(mapSystemVO.getName(), mapSystem.getName()) && Objects.equals(mapSystemVO.getNewApi(), mapSystem.getNewApi())) + return; + mapSystem.setName(mapSystemVO.getName()); + mapSystem.setNewApi(mapSystemVO.getNewApi()); + mapSystemDAO.updateByPrimaryKey(mapSystem); } @Override diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilApiService.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilApiService.java index 288042b12..2f56b850d 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilApiService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilApiService.java @@ -18,6 +18,7 @@ public class CilApiService { /** * 转动道岔 + * * @param simulation * @param id */ @@ -27,6 +28,7 @@ public class CilApiService { /** * 定操 + * * @param simulation * @param id */ @@ -36,6 +38,7 @@ public class CilApiService { /** * 反操 + * * @param simulation * @param id */ @@ -43,9 +46,13 @@ public class CilApiService { this.cilSwitchLogicService.turn(simulation, id, CilSwitch.REVERSE); } - public void setRoute(RtSimulation simulation, String id) { + public boolean setRoute(RtSimulation simulation, String id) { CilRepository repository = simulation.getRepository(CilRepository.NAME, CilRepository.class); CilRoute cilRoute = repository.getRouteById(id); - cilRouteLogicService.setRoute(simulation, cilRoute); + return cilRouteLogicService.setRoute(simulation, cilRoute); + } + + public boolean cancelRoute(RtSimulation simulation, String id) { + return cilRouteLogicService.cancelRoute(simulation, id); } } 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 c86878760..8b7606b65 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 @@ -3,7 +3,7 @@ package club.joylink.rtss.simulation.rt.CIL; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.rt.CIL.bo.*; import club.joylink.rtss.simulation.rt.RtSimulation; -import club.joylink.rtss.simulation.rt.SRD.SrdApiService; +import club.joylink.rtss.simulation.rt.SRD.bo.SrSignal; import club.joylink.rtss.simulation.rt.repo.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -14,9 +14,6 @@ import java.util.List; @Component public class CilRouteLogicService { - @Autowired - private SrdApiService srdApiService; - @Autowired private CilSwitchLogicService cilSwitchLogicService; @@ -46,9 +43,12 @@ public class CilRouteLogicService { * @return 是否办理 */ public boolean setRoute(RtSimulation rtSimulation, CilRoute cilRoute) { + CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class); + if (cilRepository.isSupervised(cilRoute.getId())) { + return false; + } CommonRepository commonRepository = rtSimulation.getRepository(CommonRepository.NAME, CommonRepository.class); CommonRoute commonRoute = commonRepository.getRouteById(cilRoute.getId()); - CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class); // 检查 // 延续保护选择 this.selectRouteOverlap(cilRepository, commonRoute, cilRoute); @@ -80,8 +80,38 @@ public class CilRouteLogicService { return true; } - public boolean cancelRoute(RtSimulation rtSimulation, CilRoute cilRoute) { - return false; + public boolean cancelRoute(RtSimulation rtSimulation, String routeId) { + CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class); + if (!cilRepository.isSupervised(routeId)) { + return false; + } + CilRoute cilRoute = cilRepository.removeSupervisedRoute(routeId); + CommonRepository commonRepository = rtSimulation.getRepository(CommonRepository.NAME, CommonRepository.class); + CommonRoute commonRoute = commonRepository.getRouteById(routeId); + // 关灯 + CommonSignal commonSignal = commonRoute.getStart(); + CilSignal cilSignal = cilRepository.getSignalById(commonSignal.getId()); + cilSignalLogicService.UpdateSignalDisplay(rtSimulation, cilSignal, SrSignal.RED, true); + /* 取消进路相关所有设备的锁闭状态 */ + // 延续保护解锁 + if (cilRoute.getOverlap() != null) { + cilRoute.getOverlap().unlock(cilRepository); + } + cilRoute.setOl(false); + // 侧防解锁 + for (CommonFls commonFls : commonRoute.getFlsList()) { + List firstLevel = commonFls.getFirstLevelList(); + if (firstLevel != null) { + for (CommonFls.FlsElement flsElement : firstLevel) { + flsElement.unLock(cilRepository); + } + } + } + cilRoute.setFl(false); + // 进路解锁 + cancelRouteLock(cilRepository, commonRoute); + cilRoute.setLock(false); + return true; } private void routeUse(CilRepository cilRepository, SwitchPosition switchPosition) { @@ -174,9 +204,9 @@ public class CilRouteLogicService { CommonRepository commonRepository = rtSimulation.getRepository(CommonRepository.NAME, CommonRepository.class); CommonRoute commonRoute = commonRepository.getRouteById(cilRoute.getId()); CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class); - if (config.isLockFirst()) { - this.lockFirst(cilRepository, commonRoute, cilRoute); - } +// if (config.isLockFirst()) { +// this.lockFirst(cilRepository, commonRoute, cilRoute); +// } TrackWay pathElement = commonRoute.getPathElement(); CommonSignal commonSignal = commonRoute.getStart(); CilSignal cilSignal = cilRepository.getSignalById(commonSignal.getId()); @@ -185,28 +215,33 @@ public class CilRouteLogicService { cilSwitchLogicService.tryTurn(rtSimulation, pathElement.getSpList()); // 转动道岔 boolean allLock = try2RouteLockSwitches(cilRepository, cilRoute, pathElement.getSpList()); // 锁闭道岔 if (allLock) { - if (!config.isLockFirst()) { +// if (!config.isLockFirst()) { routeLockSections(cilRepository, commonRoute, pathElement.getSectionList()); - } +// } cilRoute.setLock(true); } } // 侧防设备转动、锁闭 - if (!cilRoute.isFl()) { + if (!cilRoute.isFl()) { //进路未侧防锁闭 List flsList = pathElement.getFlsList(); - if (!CollectionUtils.isEmpty(flsList)) { + if (!CollectionUtils.isEmpty(flsList)) { //进路侧防不为空 boolean allSwitchLocked = true; for (CommonFls commonFls : flsList) { - List firstLevelList = commonFls.getFirstLevelList(); - for (CommonFls.FlsElement commonFlsElement : firstLevelList) { - //侧防道岔转动 - cilSwitchLogicService.tryTurn(rtSimulation, cilRepository, commonFlsElement.getPp().getCommonSwitch(), commonFlsElement.getPp().getPosition()); - cilSwitchLogicService.tryTurn(rtSimulation, cilRepository, commonFlsElement.getPae().getCommonSwitch(), commonFlsElement.getPae().getPosition()); - //侧防设备锁闭 -// this.lock(cilRepository, commonFlsElement); - boolean allLock = commonFlsElement.lock(cilRepository); - if (!allLock) { - allSwitchLocked = false; + SwitchPosition target = commonFls.getTarget(); + if (commonRoute.getPathElement().isContainSwitchPosition(target.getCommonSwitch().getId(), target.isNormal())) { //进路包含侧防所防护的道岔位置 + List firstLevelList = commonFls.getFirstLevelList(); + for (CommonFls.FlsElement commonFlsElement : firstLevelList) { + //侧防信号机关闭并锁闭 + CilSignal flsSignal = cilRepository.getSignalById(commonFlsElement.getPs().getId()); + cilSignalLogicService.try2UpdateSignalDisplay(rtSimulation, flsSignal, CilSignal.RED, true); + //侧防道岔转动 + cilSwitchLogicService.tryTurn(rtSimulation, cilRepository, commonFlsElement.getPp().getCommonSwitch(), commonFlsElement.getPp().getPosition()); + cilSwitchLogicService.tryTurn(rtSimulation, cilRepository, commonFlsElement.getPae().getCommonSwitch(), commonFlsElement.getPae().getPosition()); + //侧防设备锁闭 + boolean allLock = commonFlsElement.lock(cilRepository); + if (!allLock) { + allSwitchLocked = false; + } } } } @@ -217,6 +252,7 @@ public class CilRouteLogicService { } // 延续保护设备转动、锁闭 if (!cilRoute.isOl()) { + CommonOverlap commonOverlap = commonRoute.getOverlap(); CilOverlap overlap = cilRoute.getOverlap(); if (overlap != null) { TrackWay selectedPath = overlap.getSelectedPath(); @@ -224,9 +260,9 @@ public class CilRouteLogicService { cilSwitchLogicService.tryTurn(rtSimulation, selectedPath.getSpList()); boolean allSwitchesLocked = try2OverlapLockSwitches(cilRepository, overlap, pathElement.getSpList()); // 锁闭道岔 if (allSwitchesLocked) { - if (!config.isLockFirst()) { - overlapLockSections(cilRepository, overlap, overlap.getSelectedPath().getSectionList()); - } +// if (!config.isLockFirst()) { + overlapLockSections(cilRepository, commonOverlap.getStart().isRight(), overlap.getSelectedPath().getSectionList()); +// } } } } @@ -244,7 +280,8 @@ public class CilRouteLogicService { cilSignal.updateLevel(CilSignal.LEVEL_2); } } - boolean routeCtcMode = cilRoute.getCilServer().isCtcMode(); +// boolean routeCtcMode = cilRoute.getCilServer().isCtcMode(); + boolean routeCtcMode = true; if (cilRoute.isCanAutoOpen()) { if (cilSignal.getSignalAspect() == commonRoute.getSignalAspect()) { //信号机已开启进路指定的信号 cilRoute.setCanAutoOpen(false); @@ -335,6 +372,18 @@ public class CilRouteLogicService { return flag; } + private void cancelRouteLock(CilRepository cilRepository, CommonRoute commonRoute) { + TrackWay pathElement = commonRoute.getPathElement(); + for (SwitchPosition switchPosition : pathElement.getSpList()) { + CilSwitch cilSwitch = cilRepository.getSwitchById(switchPosition.getCommonSwitch().getId()); + cilSwitch.cancelRouteLock(); + } + for (CommonSection commonSection : pathElement.getSectionList()) { + CilSection cilSection = cilRepository.getSectionById(commonSection.getId()); + cilSection.cancelRouteLock(); + } + } + /** * 预先锁闭(锁闭进路内和延续保护的区段) */ @@ -345,11 +394,12 @@ public class CilRouteLogicService { routeLockSections(cilRepository, commonRoute, pathElement.getSectionList()); } // 延续保护区段锁闭 + CommonOverlap commonOverlap = commonRoute.getOverlap(); CilOverlap overlap = cilRoute.getOverlap(); if (overlap != null) { TrackWay selectedPath = overlap.getSelectedPath(); if (selectedPath != null) { - overlapLockSections(cilRepository, overlap, selectedPath.getSectionList()); + overlapLockSections(cilRepository, commonOverlap.getStart().isRight(), selectedPath.getSectionList()); } } } @@ -510,13 +560,13 @@ public class CilRouteLogicService { // return level; // } - /** - * 进路征用并转换道岔 - * - * @param rtSimulation - * @param cilRoute - * @return 是否所有道岔已经转换到位 - */ +// /** +// * 进路征用并转换道岔 +// * +// * @param rtSimulation +// * @param cilRoute +// * @return 是否所有道岔已经转换到位 +// */ // private void turnSwitch(RtSimulation rtSimulation, CilRoute cilRoute) { // // 进路内道岔 // CilRoutePathElement pathElement = cilRoute.getPathElement(); @@ -544,23 +594,7 @@ public class CilRouteLogicService { // // 延续保护侧防道岔 // } - /** - * @param rtSimulation - * @param cilSwitchPosition - * @return 是否转换命令已经发出 - */ - private boolean turnSwitch(RtSimulation rtSimulation, CilSwitchPosition cilSwitchPosition) { - CilSwitch cilSwitch = cilSwitchPosition.getCilSwitch(); - if (!cilSwitchPosition.isOnPosition()) { - if (cilSwitch.isRl() || cilSwitch.isSl() || cilSwitch.isOccupy()) { // 道岔进路锁闭/单锁/占用,不转换道岔 - return false; - } - this.srdApiService.turnSwitch(rtSimulation, cilSwitch.getId(), cilSwitchPosition.getPosition()); - } - return true; - } - -// private void lockRouteDevices(CilRoute cilRoute) { + // private void lockRouteDevices(CilRoute cilRoute) { // CilRoutePathElement pathElement = cilRoute.getPathElement(); // this.routeLockPathDevices(cilRoute, pathElement); // // 延续保护锁闭 @@ -626,7 +660,7 @@ public class CilRouteLogicService { // overlapLockSections(overlap, sectionList); // } - private void overlapLockSections(CilRepository cilRepository, CilOverlap overlap, List sectionList) { + private void overlapLockSections(CilRepository cilRepository, boolean right, List sectionList) { for (CommonSection commonSection : sectionList) { CommonSwitch belongSwitch = commonSection.getBelongSwitch(); if (belongSwitch != null) { @@ -634,23 +668,13 @@ public class CilRouteLogicService { } List relateList = commonSection.getRelateList(); if (relateList.isEmpty()) { - cilRepository.getSectionById(commonSection.getId()).lockByOverlap(overlap); + cilRepository.getSectionById(commonSection.getId()).lockByOverlap(right); } else { for (CommonSection section : relateList) { - cilRepository.getSectionById(section.getId()).lockByOverlap(overlap); + cilRepository.getSectionById(section.getId()).lockByOverlap(right); } } } } - /** - * 进路监控 - * - * @param cilRoute - */ - private void watchRoute(CilRoute cilRoute) { -// if (cilRoute.isOpenAspect()) { -// -// } - } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSignalLogicService.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSignalLogicService.java index e91af7c77..6dda203b0 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSignalLogicService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSignalLogicService.java @@ -34,27 +34,33 @@ public class CilSignalLogicService { // } } - /** - * 尝试更新信号机显示 - */ - public void try2UpdateSignalDisplay(RtSimulation rtSimulation, CilSignal signal, boolean logic, int aspect) { - if (logic) { - srdApiService.changeSignalLight(rtSimulation, signal.getId(), SrSignal.OFF); - signal.setAspect(aspect); - } else { + public void try2UpdateSignalDisplay(RtSimulation rtSimulation, CilSignal signal, int aspect, boolean ctcMode) { + // TODO: 2021/4/20 因信号机缺少表示虚拟信号机的字段,故缺少对虚拟信号机的检查 +// boolean logic = !signal.isUta() && ctcMode && !signal.isForceLight(); +// if (signal.sufficientLevel(aspect, logic)) { +// if (logic) { +// signal.setAspect(aspect); +// } else { +// srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect); +// } +// } + if (signal.sufficientLevel(aspect, false)) { srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect); } } - public void try2UpdateSignalDisplay(RtSimulation rtSimulation, CilSignal signal, int aspect, boolean ctcMode) { + public void UpdateSignalDisplay(RtSimulation rtSimulation, CilSignal signal, int aspect, boolean ctcMode) { // TODO: 2021/4/20 因信号机缺少表示虚拟信号机的字段,故缺少对虚拟信号机的检查 - boolean logic = !signal.isUta() && ctcMode && !signal.isForceLight(); - if (signal.sufficientLevel(aspect, logic)) { - if (logic) { - signal.setAspect(aspect); - } else { - srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect); - } +// boolean logic = !signal.isUta() && ctcMode && !signal.isForceLight(); +// if (signal.sufficientLevel(aspect, logic)) { +// if (logic) { +// signal.setAspect(aspect); +// } else { +// srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect); +// } +// } + if (signal.sufficientLevel(aspect, false)) { + srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect); } } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilOverlap.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilOverlap.java index da6966bf5..58c0eaf55 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilOverlap.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilOverlap.java @@ -1,17 +1,20 @@ package club.joylink.rtss.simulation.rt.CIL.bo; +import club.joylink.rtss.simulation.rt.repo.CommonSection; +import club.joylink.rtss.simulation.rt.repo.SwitchPosition; import club.joylink.rtss.simulation.rt.repo.TrackWay; import lombok.Getter; +import org.springframework.util.CollectionUtils; import java.util.List; @Getter public class CilOverlap extends CilDevice { - boolean right; - CilSignal start; - CilSection releaseSection; - List pathElementList; +// boolean right; +// CilSignal start; +// CilSection releaseSection; +// List pathElementList; int releaseTime; // 延续保护解锁时间 // CilRoutePathElement selectedPath; // 选择出所需办理的路径 @@ -28,4 +31,26 @@ public class CilOverlap extends CilDevice { public void updateSelectedPath(TrackWay path) { this.selectedPath = path; } + + /** + * 解锁道岔和区段 + */ + public void unlock(CilRepository cilRepository) { + if (selectedPath == null) + return; + List spList = selectedPath.getSpList(); + if (CollectionUtils.isEmpty(spList)) + return; + for (SwitchPosition switchPosition : spList) { + CilSwitch cilSwitch = cilRepository.getSwitchById(switchPosition.getCommonSwitch().getId()); + cilSwitch.cancelOverlapLock(); + } + List sectionList = selectedPath.getSectionList(); + if (CollectionUtils.isEmpty(sectionList)) + return; + for (CommonSection commonSection : sectionList) { + CilSection cilSection = cilRepository.getSectionById(commonSection.getId()); + cilSection.cancelOverlapLock(); + } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java index 5dd64171f..cff511545 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java @@ -112,4 +112,12 @@ public class CilRepository extends SimulationRepository { public void addSupervisedRoute(CilRoute cilRoute) { this.supervisedRouteMap.put(cilRoute.getId(), cilRoute); } + + public boolean isSupervised(String routeId) { + return this.supervisedRouteMap.containsKey(routeId); + } + + public CilRoute removeSupervisedRoute(String routeId) { + return this.supervisedRouteMap.remove(routeId); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepositoryBuilder.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepositoryBuilder.java index 7a5d3624a..a62b856a3 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepositoryBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepositoryBuilder.java @@ -205,13 +205,13 @@ public class CilRepositoryBuilder { BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(cilSection, String.format("不存在id为[%s]的区段", overlapVO.getUnlockSectionCode())); CilSignal cilSignal = signalMap.get(overlapVO.getSignalCode()); - cilOverlap.releaseSection = cilSection; - cilOverlap.start = cilSignal; - cilOverlap.right = cilSignal.isRight(); +// cilOverlap.releaseSection = cilSection; +// cilOverlap.start = cilSignal; +// cilOverlap.right = cilSignal.isRight(); cilOverlap.releaseTime = overlapVO.getUnlockTime(); BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(cilSignal, String.format("不存在id为[%s]的信号机", overlapVO.getSignalCode())); - cilOverlap.pathElementList = buildPathElementList(cilSignal, overlapVO.getPathList(), sectionMap, switchMap, flsMap); +// cilOverlap.pathElementList = buildPathElementList(cilSignal, overlapVO.getPathList(), sectionMap, switchMap, flsMap); } } 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 0e10d9856..8e640ddfb 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 @@ -44,13 +44,21 @@ public class CilSection extends CilDevice { } } - public void lockByOverlap(CilOverlap overlap) { + public void cancelRouteLock() { + this.rl = false; + } + + public void lockByOverlap(boolean right) { if (!this.ol) { this.ol = true; - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(this.rl && this.lr != overlap.isRight()); - if (this.lr != overlap.isRight()) { - this.lr = overlap.isRight(); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(this.rl && this.lr != right); + if (this.lr != right) { + this.lr = right; } } } + + public void cancelOverlapLock() { + this.ol = false; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSignal.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSignal.java index 40f1bf4b5..26a12096b 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSignal.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSignal.java @@ -18,6 +18,14 @@ public class CilSignal extends CilDevice { public static final int GREEN = 2; // 绿灯信号(直向通行) public static final int YELLOW = 3; // 黄灯信号(侧向通行) public static final int GUIDE = 4; // 引导信号(正线为黄红) + public static final int LL = 5; // 绿绿 + public static final int LH = 6; // 绿黄 + public static final int HH = 7; // 黄黄 + public static final int HSH = 8; // 黄闪黄 + public static final int BH = 9; // 白红 + public static final int L = 10; // 蓝 + public static final int B = 11; // 白 + public static final int HS = 12; // 红闪 boolean logic; boolean forceLight; // 强制点灯 boolean bl; // 封锁 @@ -31,6 +39,8 @@ public class CilSignal extends CilDevice { public static final int LEVEL_3 = 3; //ATP级 public static final int LEVEL_4 = 4; //主信号级 + boolean fl; //侧防锁闭(侧防锁闭后不能排列任何以此为始端信号机的进路) + public CilSignal(String id, String name) { super(id, name); } @@ -62,20 +72,29 @@ public class CilSignal extends CilDevice { * 信号机有足够的级别以{aspect}显示 */ public boolean sufficientLevel(int aspect, boolean logic) { - switch (aspect) { - case RED: - return true; - case GUIDE: - return level == LEVEL_2 || level == LEVEL_3 || level == LEVEL_4; - case GREEN: - case YELLOW: - if (logic) { - return level == LEVEL_3 || level == LEVEL_4; - } else { - return level == LEVEL_4; - } - default: - throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("未知的显示状态"); - } +// switch (aspect) { +// case RED: +// return true; +// case GUIDE: +// return level == LEVEL_2 || level == LEVEL_3 || level == LEVEL_4; +// case GREEN: +// case YELLOW: +// if (logic) { +// return level == LEVEL_3 || level == LEVEL_4; +// } else { +// return level == LEVEL_4; +// } +// default: +// throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception(String.format("未知的显示状态[%s]", aspect)); +// } + return level == LEVEL_4; + } + + public void flankLock() { + this.fl = true; + } + + public void cancelFlankLock() { + this.fl = false; } } 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 4bd4d2f87..66b521054 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 @@ -68,18 +68,30 @@ public class CilSwitch extends CilDevice { } } + public void cancelRouteLock() { + this.rl = false; + } + public void lockByOverlap(CilOverlap overlap) { if (!this.ol) { this.ol = true; } } + public void cancelOverlapLock() { + this.ol = false; + } + public void flankLock() { if (!this.fl) { this.fl = true; } } + public void cancelFlankLock() { + this.fl = false; + } + public boolean isLocked() { return sl || rl || ol || fl; } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/SRD/SrdApiService.java b/src/main/java/club/joylink/rtss/simulation/rt/SRD/SrdApiService.java index 0926fd4ec..d0a485c37 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/SRD/SrdApiService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/SRD/SrdApiService.java @@ -69,6 +69,9 @@ public class SrdApiService { boolean change = false; if (srSignal.getState() != aspect) { LocalDateTime systemTime = rtSimulation.getSystemTime(); + if (aspect >= 5 && aspect <= 12) { //2021-04-23 10:41:52 临时 + srSignal.open(systemTime, aspect); + } switch (aspect) { case SrSignal.OFF:{ srSignal.close(systemTime); diff --git a/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrSignal.java b/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrSignal.java index 9b0b143de..379f11dfe 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrSignal.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrSignal.java @@ -28,6 +28,14 @@ public class SrSignal extends SrDevice { public static final int GREEN = 2; // 绿灯信号(直向通行) public static final int YELLOW = 3; // 黄灯信号(侧向通行) public static final int GUIDE = 4; // 引导信号(正线为黄红) + public static final int LL = 5; // 绿绿 + public static final int LH = 6; // 绿黄 + public static final int HH = 7; // 黄黄 + public static final int HSH = 8; // 黄闪黄 + public static final int BH = 9; // 白红 + public static final int L = 10; // 蓝 + public static final int B = 11; // 白 + public static final int HS = 12; // 红闪 AtomicInteger command = new AtomicInteger(NONE); public static final int NONE = 0; @@ -97,4 +105,8 @@ public class SrSignal extends SrDevice { throw new IllegalArgumentException(String.format("无效的道岔状态:[%s]", state)); } } + + public void open(LocalDateTime systemTime, int aspect) { + this.startTurn(systemTime, aspect); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/operation/SignalOperationHandler.java b/src/main/java/club/joylink/rtss/simulation/rt/operation/SignalOperationHandler.java index d969dbe6e..0f3d8a0e4 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/operation/SignalOperationHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/operation/SignalOperationHandler.java @@ -13,13 +13,11 @@ public class SignalOperationHandler { @SimulationOperationMapping("Signal_Set_Route") public boolean setRoute(RtSimulation simulation, String id) { - this.cilApiService.setRoute(simulation, id); - return true; + return this.cilApiService.setRoute(simulation, id); } @SimulationOperationMapping("Signal_Cancel_Route") public boolean cancelRoute(RtSimulation simulation, String id) { - this.cilApiService.turnSwitch(simulation, id); - return true; + return this.cilApiService.cancelRoute(simulation, id); } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonFls.java b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonFls.java index 67336fe74..638cf8c7f 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonFls.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonFls.java @@ -1,6 +1,7 @@ package club.joylink.rtss.simulation.rt.repo; import club.joylink.rtss.simulation.rt.CIL.bo.CilRepository; +import club.joylink.rtss.simulation.rt.CIL.bo.CilSignal; import club.joylink.rtss.simulation.rt.CIL.bo.CilSwitch; import lombok.Getter; @@ -47,6 +48,14 @@ public class CommonFls extends CommonDevice { flag = false; } } + if (this.ps != null) { + CilSignal cilSignal = cilRepository.getSignalById(this.ps.getId()); + if (cilSignal.isForbidAspect()) { + cilSignal.flankLock(); + } else { + flag = false; + } + } if (this.pae != null) { CilSwitch cilSwitch = cilRepository.getSwitchById(pae.getCommonSwitch().getId()); if (pae.getPosition() == cilSwitch.getPosition()) { @@ -57,5 +66,20 @@ public class CommonFls extends CommonDevice { } return flag; } + + public void unLock(CilRepository cilRepository) { + if (this.pp != null) { + CilSwitch cilSwitch = cilRepository.getSwitchById(this.pp.getCommonSwitch().getId()); + cilSwitch.cancelFlankLock(); + } + if (this.ps != null) { + CilSignal cilSignal = cilRepository.getSignalById(this.ps.getId()); + cilSignal.cancelFlankLock(); + } + if (this.pae != null) { + CilSwitch cilSwitch = cilRepository.getSwitchById(this.pae.getCommonSwitch().getId()); + cilSwitch.cancelFlankLock(); + } + } } }