From 1505ff46042ca410f180ca13c337c4f8326e9ea8 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 28 Apr 2021 15:40:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E9=93=81=E5=BC=95=E5=AF=BC=E6=80=BB?= =?UTF-8?q?=E9=94=81=E5=92=8C=E9=80=9A=E8=BF=87=E8=BF=9B=E8=B7=AF=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/rt/RtSimulationController.java | 3 +- .../rtss/simulation/rt/ATS/bo/AtsSignal.java | 8 +- .../rtss/simulation/rt/CIL/CilApiService.java | 4 +- .../rt/CIL/CilRouteLogicService.java | 106 +++++++++++------- .../rt/CIL/CilSignalLogicService.java | 19 +++- .../simulation/rt/CIL/bo/CilRepository.java | 2 +- .../rt/CIL/bo/CilRepositoryBuilder.java | 1 - .../rtss/simulation/rt/CIL/bo/CilSignal.java | 19 +++- .../simulation/rt/RtSimulationService.java | 8 +- .../rtss/simulation/rt/repo/CommonFls.java | 2 +- .../rtss/simulation/rt/repo/CommonRoute.java | 10 ++ .../simulation/rt/vo/SimulationBasicInfo.java | 30 +++++ .../vo/client/map/newmap/MapSignalNewVO.java | 6 + 13 files changed, 156 insertions(+), 62 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/rt/vo/SimulationBasicInfo.java 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 9218ebb91..51ee133ec 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 @@ -3,6 +3,7 @@ package club.joylink.rtss.controller.simulation.rt; import club.joylink.rtss.constants.MapPrdTypeEnum; import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO; import club.joylink.rtss.simulation.rt.RtSimulationService; +import club.joylink.rtss.simulation.rt.vo.SimulationBasicInfo; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.map.MapVO; @@ -25,7 +26,7 @@ public class RtSimulationController { @ApiOperation(value = "根据仿真group获取仿真基础信息") @GetMapping("/{id}") - public SimulationVO getSimulationBasicInfo(@PathVariable String id) { + public SimulationBasicInfo getSimulationBasicInfo(@PathVariable String id) { return rtSimulationService.getBasicInfo(id); } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/ATS/bo/AtsSignal.java b/src/main/java/club/joylink/rtss/simulation/rt/ATS/bo/AtsSignal.java index 7b42c20fb..d1fa91250 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/ATS/bo/AtsSignal.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/ATS/bo/AtsSignal.java @@ -17,6 +17,7 @@ public class AtsSignal extends AtsDevice { int level; String lrId; int delayTime; + int guideTime; public AtsSignal(String id, String name) { super(id, name); @@ -26,7 +27,7 @@ public class AtsSignal extends AtsDevice { List buildMessage() { return Arrays.asList(this.id, this.signalAspect, this.convert(this.logic), this.convert(this.forceLight), this.convert(this.bl), this.convert(this.rbl), - this.level, this.lrId, this.delayTime); + this.level, this.lrId, this.delayTime, this.guideTime); } public boolean applyChange(CilSignal cilSignal) { @@ -72,6 +73,11 @@ public class AtsSignal extends AtsDevice { stateList.set(8, this.delayTime); change = true; } + if (!Objects.equals(this.guideTime, cilSignal.getGuideTime())) { + this.guideTime = cilSignal.getGuideTime(); + stateList.set(9, this.guideTime); + change = true; + } return change; } } 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 75237adcc..1e5ce5f8d 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 @@ -57,9 +57,7 @@ public class CilApiService { } public boolean setRoute(RtSimulation simulation, String id) { - CilRepository repository = simulation.getRepository(CilRepository.NAME, CilRepository.class); - CilRoute cilRoute = repository.getRouteById(id); - return cilRouteLogicService.setRoute(simulation, cilRoute); + return cilRouteLogicService.setRoute(simulation, id); } public boolean cancelRoute(RtSimulation simulation, String signalId) { 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 c48210191..03ac9a428 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,6 @@ 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.bo.SrSignal; import club.joylink.rtss.simulation.rt.repo.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -29,9 +28,7 @@ public class CilRouteLogicService { if (cilRoute.isDelayUnlocking()) { this.monitorDelayUnlockingRoute(rtSimulation, cilRoute, cilRepository.getConfig()); } - if (cilRoute.isGl()) { - this.monitorGuide(rtSimulation, cilRoute); - } + this.monitorGuide(rtSimulation, cilRoute); } } @@ -40,6 +37,7 @@ public class CilRouteLogicService { List spList = commonRoute.getPathElement().getSpList(); spList.forEach(sp -> cilRepository.getSwitchById(sp.getCommonSwitch().getId()).setMgl(true)); //设置引导总锁 CilSignal cilSignal = cilRepository.getSignalById(commonRoute.getStart().getId()); + cilSignal.updateLevel(CilSignal.LEVEL_2); if (cilRepository.getSectionById(commonRoute.getPathElement().getStart().getId()).isAxcOccupy()) { //进路首区段占用 cilSignal.initGuideTime(); } @@ -50,6 +48,7 @@ public class CilRouteLogicService { CommonRepository commonRepository = simulation.getRepository(CommonRepository.NAME, CommonRepository.class); CilRepository cilRepository = simulation.getRepository(CilRepository.NAME, CilRepository.class); List signals = commonRepository.querySignalsByDirection(right); + boolean find = false; //发现引导总锁 for (CommonSignal signal : signals) { CilSignal cilSignal = cilRepository.getSignalById(signal.getId()); if (!StringUtils.hasText(cilSignal.getRouteId())) @@ -58,7 +57,6 @@ public class CilRouteLogicService { List spList = commonRepository.getRouteById(cilRoute.getId()).getPathElement().getSpList(); if (CollectionUtils.isEmpty(spList)) continue; - boolean find = false; //发现引导总锁 for (SwitchPosition sp : spList) { CilSwitch cilSwitch = cilRepository.getSwitchById(sp.getCommonSwitch().getId()); if (cilSwitch.isMgl()) { @@ -67,9 +65,9 @@ public class CilRouteLogicService { } } if (find) - return; + cilSignalLogicService.update2ForbiddenAspect(simulation, signal.getId()); } - cilRepository.getSwitches().forEach(cilSwitch -> cilSwitch.setMgl(false)); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(find, "无引导总锁"); } public void setGuide(RtSimulation simulation, String signalId, String routeId) { @@ -97,16 +95,22 @@ public class CilRouteLogicService { throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("参数缺失"); } //执行 - /* 进路锁闭,但因为区段占用导致无法开放信号 */ if (cilRoute != null) { - if (cilRoute.isLock() && cilSignal.isForbidAspect()) { - cilSignalLogicService.UpdateSignalDisplay(simulation, cilSignal, CilSignal.GUIDE, false); - if (cilRepository.getSectionById(commonRoute.getPathElement().getStart().getId()).isAxcOccupy()) { //进路首区段占用 + //进路锁闭,但因为区段占用导致无法开放信号 + if (cilRoute.isLock()) { + if (cilSignal.isForbidAspect(commonSignal.isShunting())) { + cilSignalLogicService.UpdateSignalDisplay(simulation, cilSignal, CilSignal.GUIDE, false); + if (cilRepository.getSectionById(commonRoute.getPathElement().getStart().getId()).isAxcOccupy()) { //进路首区段占用 + cilSignal.initGuideTime(); + } + } else if (cilSignal.isGuideAspect() && cilSignal.getGuideTime() != 0) { //之前开放了引导信号,重复点击续时间 cilSignal.initGuideTime(); + } else { + throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("信号正常开放,不能办理引导"); } } } else { - /* 进路不能锁闭,直接办理引导进路 */ + //进路不能锁闭,直接办理引导进路 List routes = commonRepository.getRoutesByStartSignal(cilSignal.getId()); Optional routeOptional = routes.stream().filter(cr -> { List spList = cr.getPathElement().getSpList(); @@ -138,15 +142,15 @@ public class CilRouteLogicService { cilRoute.setGl(false); cilSignal.clearGuideTime(); if (cilSignal.isGuideAspect()) { - cilSignalLogicService.UpdateSignalDisplay(simulation, cilSignal, CilSignal.RED, false); + cilSignalLogicService.update2ForbiddenAspect(simulation, signalId); } } else { BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(cilRoute.isDelayUnlocking(), "进路已在延时解锁中"); - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(cilRoute.isTrainIn(), "进路非空闲状态"); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(cilSignalLogicService.isApproachOccupied(simulation, signalId), "进路未接近锁闭"); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(cilRoute.isTrainIn(), "进路非空闲状态"); //关闭信号 - cilSignalLogicService.UpdateSignalDisplay(simulation, cilSignal, CilSignal.RED, false); + cilSignalLogicService.update2ForbiddenAspect(simulation, signalId); //设置延时解锁 cilSignal.initDelayTime(); cilRoute.setDelayUnlocking(true); @@ -176,32 +180,34 @@ public class CilRouteLogicService { /** * 排列进路接口,包括办理冲突检查和选出延续保护及一些初始化工作 - * - * @param rtSimulation - * @param cilRoute * @return 是否办理 */ - public boolean setRoute(RtSimulation rtSimulation, CilRoute cilRoute) { + public boolean setRoute(RtSimulation rtSimulation, String routeId) { /* 检查 */ CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class); + CilRoute cilRoute = cilRepository.getRouteById(routeId); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(cilRepository.isSupervised(cilRoute.getId()), "进路已经办理"); CommonRepository commonRepository = rtSimulation.getRepository(CommonRepository.NAME, CommonRepository.class); CommonRoute commonRoute = commonRepository.getRouteById(cilRoute.getId()); if (!CollectionUtils.isEmpty(commonRoute.getMultiRouteAspectList())) { for (CommonRoute.MultiRouteAspect mra : commonRoute.getMultiRouteAspectList()) { - check4SetRoute(cilRepository, mra.getRoute()); - init4SetRoute(cilRoute, cilRepository, mra.getRoute()); + CommonRoute subCommonRoute = mra.getRoute(); + CilRoute subCilRoute = cilRepository.getRouteById(subCommonRoute.getId()); + check4SetRoute(cilRepository, subCommonRoute); + init4SetRoute(subCilRoute, cilRepository, subCommonRoute); + CilSignal cilSignal = cilRepository.getSignalById(subCommonRoute.getStart().getId()); + cilSignal.setRouteId(subCilRoute.getId()); } } else { check4SetRoute(cilRepository, commonRoute); init4SetRoute(cilRoute, cilRepository, commonRoute); + CommonSignal commonSignal = commonRepository.getSignalById(commonRoute.getStart().getId()); + CilSignal cilSignal = cilRepository.getSignalById(commonSignal.getId()); + cilSignal.setRouteId(cilRoute.getId()); } // 开始办理 cilRoute.startSetting(rtSimulation.getSystemTime()); cilRepository.addSupervisedRoute(cilRoute); - CommonSignal commonSignal = commonRepository.getSignalById(commonRoute.getStart().getId()); - CilSignal cilSignal = cilRepository.getSignalById(commonSignal.getId()); - cilSignal.setRouteId(cilRoute.getId()); return true; } @@ -240,6 +246,12 @@ public class CilRouteLogicService { * 进路办理条件检查 */ private void check4SetRoute(CilRepository cilRepository, CommonRoute commonRoute) { + //敌对进路检查 + List conflictingList = commonRoute.getConflictingList(); + if (!CollectionUtils.isEmpty(conflictingList)) { + boolean nonSettingConflictingRoute = conflictingList.stream().noneMatch(cr -> cilRepository.isSupervised(cr.getId())); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(nonSettingConflictingRoute, "敌对进路已经办理"); + } // 道岔检查 List spList = commonRoute.getPathElement().getSpList(); if (!CollectionUtils.isEmpty(spList)) { @@ -271,7 +283,7 @@ public class CilRouteLogicService { // 关灯 CommonSignal commonSignal = commonRoute.getStart(); CilSignal cilSignal = cilRepository.getSignalById(commonSignal.getId()); - cilSignalLogicService.UpdateSignalDisplay(rtSimulation, cilSignal, SrSignal.H, true); + cilSignalLogicService.update2ForbiddenAspect(rtSimulation, cilSignal.getId()); cilSignal.setRouteId(null); /* 取消进路相关所有设备的锁闭状态 */ // 延续保护解锁 @@ -358,20 +370,18 @@ public class CilRouteLogicService { CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class); List routes = commonRoute.getMultiRouteAspectList(); if (!CollectionUtils.isEmpty(routes)) { - CommonRoute route = routes.get(0).getRoute(); - System.out.println(route.getId()); - for (SwitchPosition sp : route.getPathElement().getSpList()) { - System.out.println(sp.getCommonSwitch().getName() + ":" + sp.getPosition()); - } for (int i = routes.size() - 1; i >= 0; i--) { CommonRoute.MultiRouteAspect mra = routes.get(i); CommonRoute subCommonRoute = mra.getRoute(); CilRoute subCilRoute = cilRepository.getRouteById(subCommonRoute.getId()); CilSignal cilSignal = cilRepository.getSignalById(subCommonRoute.getStart().getId()); - monitorRoute(rtSimulation, cilRepository, cilSignal, subCommonRoute, subCilRoute); if (cilSignal.getSignalAspect() != mra.getSignalAspect()) { - lockRouteDevices(rtSimulation, cilRepository, subCilRoute, subCommonRoute); - try2OpenSignal4Route(rtSimulation, subCilRoute, subCommonRoute, cilSignal, subCommonRoute.getSignalAspect()); + if (!cilRepository.isSupervised(subCilRoute.getId())) { + setRoute(rtSimulation, subCilRoute.getId()); + if (i == 0) { + cilRepository.removeSupervisedRoute(cilRoute.getId()); + } + } break; } } @@ -379,21 +389,20 @@ public class CilRouteLogicService { lockRouteDevices(rtSimulation, cilRepository, cilRoute, commonRoute); CilSignal cilSignal = cilRepository.getSignalById(commonRoute.getStart().getId()); try2OpenSignal4Route(rtSimulation, cilRoute, commonRoute, cilSignal, commonRoute.getSignalAspect()); - monitorRoute(rtSimulation, cilRepository, cilSignal, commonRoute, cilRoute); + monitorRoute(rtSimulation, commonRepository, cilRepository, cilSignal, commonRoute, cilRoute); } } /** * 监控进路(目前只是信号显示) */ - private void monitorRoute(RtSimulation rtSimulation, CilRepository cilRepository, CilSignal cilSignal, CommonRoute commonRoute, CilRoute cilRoute) { + private void monitorRoute(RtSimulation rtSimulation, CommonRepository commonRepository, CilRepository cilRepository, CilSignal cilSignal, CommonRoute commonRoute, CilRoute cilRoute) { //列车进入进路检查 - boolean routeSectionOccupied = commonRoute.getPathElement().getAllSectionList() - .stream().anyMatch(cs -> cilRepository.getSectionById(cs.getId()).isAxcOccupy()); - cilRoute.setTrainIn(routeSectionOccupied); + cilRoute.setTrainIn(this.isTrainIn(cilRepository, commonRoute)); if (!cilSignal.isGuideAspect()) { //非引导信号 + CommonSignal commonSignal = commonRepository.getSignalById(cilSignal.getId()); //信号开放条件检查,不通过时关闭信号 - if (!cilSignal.isForbidAspect()) { + if (!cilSignal.isForbidAspect(commonSignal.isShunting())) { if (!canOpenSignal(rtSimulation, cilRoute.getId())) { cilSignalLogicService.try2UpdateSignalDisplay(rtSimulation, cilSignal, CilSignal.RED, false); } @@ -496,6 +505,12 @@ public class CilRouteLogicService { } else { cilSignal.updateLevel(CilSignal.LEVEL_2); } + } else { + if (commonRoute.getPathElement().getSpList().stream().allMatch(sp->cilRepository.getSwitchById(sp.getCommonSwitch().getId()).isMgl())) { + cilSignal.updateLevel(CilSignal.LEVEL_2); + } else { + cilSignal.updateLevel(CilSignal.LEVEL_1); + } } } @@ -546,7 +561,7 @@ public class CilRouteLogicService { CommonSignal ps = flsElement.getPs(); if (ps != null) { CilSignal cilSignal = cilRepository.getSignalById(ps.getId()); - if (!cilSignal.isForbidAspect() || !cilSignal.isFl()) { + if (!cilSignal.isForbidAspect(ps.isShunting()) || !cilSignal.isFl()) { return false; } } @@ -741,18 +756,25 @@ public class CilRouteLogicService { CommonRepository commonRepository = rtSimulation.getRepository(CommonRepository.NAME, CommonRepository.class); CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class); CommonRoute commonRoute = commonRepository.getRouteById(cilRoute.getId()); + if (!CollectionUtils.isEmpty(commonRoute.getMultiRouteAspectList())) + return; CilSignal cilSignal = cilRepository.getSignalById(commonRoute.getStart().getId()); if (cilSignal.isGuideAspect()) { if (cilSignal.getGuideTime() != 0) { //引导信号的关闭只依赖时间 cilSignal.updateGuideTime(); if (cilSignal.getGuideTime() == 0) { - cilSignalLogicService.UpdateSignalDisplay(rtSimulation, cilSignal, CilSignal.RED, false); + cilSignalLogicService.update2ForbiddenAspect(rtSimulation, cilSignal.getId()); } } else { if (cilRepository.getSectionById(commonRoute.getPathElement().getStart().getId()).isAxcOccupy()) { - cilSignalLogicService.UpdateSignalDisplay(rtSimulation, cilSignal, CilSignal.RED, false); + cilSignalLogicService.update2ForbiddenAspect(rtSimulation, cilSignal.getId()); } } } } + + 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/CilSignalLogicService.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSignalLogicService.java index 4f53196db..bf8d8ad97 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 @@ -22,6 +22,18 @@ public class CilSignalLogicService { @Autowired private CilRouteLogicService cilRouteLogicService; + public void update2ForbiddenAspect(RtSimulation simulation, String signalId) { + CommonRepository commonRepository = simulation.getRepository(CommonRepository.NAME, CommonRepository.class); + CilRepository cilRepository = simulation.getRepository(CilRepository.NAME, CilRepository.class); + CommonSignal commonSignal = commonRepository.getSignalById(signalId); + CilSignal cilSignal = cilRepository.getSignalById(signalId); + if (commonSignal.isShunting()) { + UpdateSignalDisplay(simulation, cilSignal, CilSignal.A, false); + } else { + UpdateSignalDisplay(simulation, cilSignal, CilSignal.RED, false); + } + } + /** * 信号机接近区段占用 */ @@ -50,7 +62,8 @@ public class CilSignalLogicService { CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class); CommonRepository commonRepository = rtSimulation.getRepository(CommonRepository.NAME, CommonRepository.class); CilSignal cilSignal = cilRepository.getSignalById(signalId); - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(cilSignal.isForbidAspect(), + CommonSignal commonSignal = commonRepository.getSignalById(signalId); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(cilSignal.isForbidAspect(commonSignal.isShunting()), "信号未关闭,无需重开"); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertHasText(cilSignal.getRouteId(), "无已办理的进路"); CommonRoute commonRoute = commonRepository.getRouteById(cilSignal.getRouteId()); @@ -83,8 +96,10 @@ public class CilSignalLogicService { } if (signal.sufficientLevel(aspect, false)) { srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect); + return true; + } else { + return false; } - return true; } public void UpdateSignalDisplay(RtSimulation rtSimulation, CilSignal signal, int aspect, boolean ctcMode) { 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 b4162ef72..b50214351 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 @@ -101,7 +101,7 @@ public class CilRepository extends SimulationRepository { public CilSignal getSignalById(String id) { CilSignal cilSignal = this.signalMap.get(id); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(cilSignal); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(cilSignal, String.format("无id为[%s]的信号机", id)); return cilSignal; } 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 b0a36ae53..b4fd796fc 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 @@ -5,7 +5,6 @@ import club.joylink.rtss.vo.client.map.MapSwitchVO; import club.joylink.rtss.vo.client.map.MapVO; import club.joylink.rtss.vo.client.map.newmap.*; import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; import java.util.*; 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 2e40cf077..e221d9cd8 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 @@ -20,10 +20,10 @@ public class CilSignal extends CilDevice { 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 A = 10; // 蓝 public static final int B = 11; // 白 public static final int HS = 12; // 红闪 - boolean logic = true; + boolean logic; boolean forceLight; // 强制点灯 @Setter boolean bl; // 封锁 @@ -49,10 +49,15 @@ public class CilSignal extends CilDevice { super(id, name); } + public CilSignal(String id, String name, int aspect) { + this(id, name); + this.signalAspect = aspect; + } + @Override public void init() { signalAspect = RED; - logic = true; + logic = false; forceLight = false; bl = false; rbl = false; @@ -73,8 +78,12 @@ public class CilSignal extends CilDevice { } } - public boolean isForbidAspect() { - return this.signalAspect == RED; + public boolean isForbidAspect(boolean shunting) { + if (shunting) { + return this.signalAspect == A; + } else { + return this.signalAspect == RED; + } } public void updateLevel(int level) { diff --git a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java index fd6246e5b..15a98be8e 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/RtSimulationService.java @@ -11,6 +11,7 @@ import club.joylink.rtss.simulation.rt.SRD.SrdLogicService; import club.joylink.rtss.simulation.rt.repo.CommonRepoService; import club.joylink.rtss.simulation.rt.repo.CommonRepository; import club.joylink.rtss.simulation.rt.repo.CommonStation; +import club.joylink.rtss.simulation.rt.vo.SimulationBasicInfo; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.map.MapVO; import org.springframework.beans.factory.annotation.Autowired; @@ -80,12 +81,9 @@ public class RtSimulationService { this.atsLogicService.init(rtSimulation, mapVO); } - public SimulationVO getBasicInfo(String id) { + public SimulationBasicInfo getBasicInfo(String id) { RtSimulation rtSimulation = simulationManager.getById(id, RtSimulation.class); - SimulationVO.SimulationVOBuilder builder = SimulationVO.builder(); - builder.map(rtSimulation.mapVO.buildBasicInfo()); - builder.prodType(rtSimulation.prdType != null ? rtSimulation.prdType.getCode() : null); - return builder.build(); + return new SimulationBasicInfo(rtSimulation); } public MapVO getMapData(String 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 5635b9b1c..43bd90994 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 @@ -50,7 +50,7 @@ public class CommonFls extends CommonDevice { } if (this.ps != null) { CilSignal cilSignal = cilRepository.getSignalById(this.ps.getId()); - if (cilSignal.isForbidAspect()) { + if (cilSignal.isForbidAspect(this.ps.isShunting())) { cilSignal.flankLock(); } else { flag = false; diff --git a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRoute.java b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRoute.java index 0f962205a..81559700b 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRoute.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRoute.java @@ -1,6 +1,7 @@ package club.joylink.rtss.simulation.rt.repo; import lombok.Getter; +import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; @@ -43,6 +44,15 @@ public class CommonRoute extends CommonDevice { this.standList = new ArrayList<>(); } + public boolean isCombinedRoute() { + return !CollectionUtils.isEmpty(multiRouteAspectList); + } + + public boolean contains(String routeId) { + return isCombinedRoute() && this.multiRouteAspectList + .stream().anyMatch(mra -> mra.getRoute().getId().equals(routeId)); + } + @Getter public static class MultiRouteAspect { CommonRoute route; diff --git a/src/main/java/club/joylink/rtss/simulation/rt/vo/SimulationBasicInfo.java b/src/main/java/club/joylink/rtss/simulation/rt/vo/SimulationBasicInfo.java new file mode 100644 index 000000000..4e254b37a --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/vo/SimulationBasicInfo.java @@ -0,0 +1,30 @@ +package club.joylink.rtss.simulation.rt.vo; + +import club.joylink.rtss.simulation.Simulation; +import club.joylink.rtss.simulation.rt.RtSimulation; +import club.joylink.rtss.vo.UserVO; +import club.joylink.rtss.vo.client.map.MapVO; +import lombok.Getter; + +@Getter +public class SimulationBasicInfo { + private String id; + + private int state; + + private int speed; + + private String prodType; + + private MapVO map; + + public SimulationBasicInfo(RtSimulation simulation) { + this.id = simulation.getId(); + this.state = simulation.getState(); + this.speed = simulation.getSpeed(); + this.prodType = simulation.getPrdType() == null ? null : simulation.getPrdType().getCode(); + if (simulation.getMapVO() != null) { + this.map = simulation.getMapVO().buildBasicInfo(); + } + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapSignalNewVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapSignalNewVO.java index e713e3816..917d23b11 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapSignalNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapSignalNewVO.java @@ -2,6 +2,7 @@ package club.joylink.rtss.vo.client.map.newmap; import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.vo.client.Point; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; @@ -193,4 +194,9 @@ public class MapSignalNewVO { @ApiModelProperty(value = "传输信号机关联的信号机") private String linkSignalCode; + + @JsonIgnore + public boolean isShunting() { + return Signal.SignalType.SHUNTING.equals(this.type); + } }