From d4b8a99f503f93bbe57a4218a56769cd78aad321 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Mon, 9 May 2022 17:01:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=9F=E6=88=90=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E8=BF=9B=E8=B7=AF=E9=80=BB=E8=BE=91=EF=BC=88=E5=A4=A7?= =?UTF-8?q?=E9=93=81=EF=BC=89=EF=BC=9B=E4=BF=AE=E6=94=B9=E8=BF=9B=E8=B7=AF?= =?UTF-8?q?=E5=8A=9E=E7=90=86=E6=9D=A1=E4=BB=B6=E6=A3=80=E6=9F=A5=E5=8F=8A?= =?UTF-8?q?=E5=8A=9E=E7=90=86=E6=B5=81=E7=A8=8B=E4=BB=A5=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E8=BF=9B=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draftData/DraftMapRouteServiceImpl.java | 92 ++++++-- .../cbtc/CI/device/CiRouteService.java | 213 ++++++++++-------- .../cbtc/build/InterlockBuilder2.java | 194 +++++++++------- .../cbtc/data/CalculateService.java | 2 + .../rtss/simulation/cbtc/data/map/Route.java | 21 ++ .../rtss/simulation/cbtc/data/map/Signal.java | 7 + .../joylink/rtss/vo/map/MapRouteAspectVO.java | 5 + 7 files changed, 347 insertions(+), 187 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java index 983eaaf7f..091ca6e20 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java @@ -14,6 +14,7 @@ import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.map.MapDataVO; import club.joylink.rtss.vo.client.map.MapRouteQueryVO; import club.joylink.rtss.vo.map.MapGraphDataNewVO; +import club.joylink.rtss.vo.map.MapRouteAspectVO; import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.graph.MapSignalButtonVO; import club.joylink.rtss.vo.map.logic.MapRouteNewVO; @@ -237,6 +238,7 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { Map routeVOMap = new LinkedHashMap<>(); //k - startSignal.code + destinationSignal.code /* 列车进路 */ + long trainStart = System.currentTimeMillis(); List buttonVOS = type_button_map.get(MapSignalButtonVO.Type.PICK); if (!CollectionUtils.isEmpty(buttonVOS)) { for (MapSignalButtonVO vo : buttonVOS) { @@ -247,23 +249,28 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { routeCodeGenerator, signalCode_button_map, routeVOMap, 0); } } -// /* 通过进路 */ -// List passButtonVOS = type_button_map.get(MapSignalButtonVO.Type.PASS); -// if (!CollectionUtils.isEmpty(passButtonVOS)) { -// for (MapSignalButtonVO vo : passButtonVOS) { -// Signal signal = signalMap.get(vo.getSignalCode()); -// BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(signal, -// String.format("按钮[%s]关联的信号机[%s]不存在", vo.getCode(), vo.getSignalCode())); -// generatePassRoute(signal, vo, routeMap, -// routeCodeGenerator, signalCode_button_map, routeVOMap, 0); -// } -// } + long dioStart = System.currentTimeMillis(); + System.out.println("生成列车进路耗时:" + (dioStart - trainStart)); /* 调车进路(逻辑中不考虑调车终端按钮,因为暂时没遇到) */ signalMap.values().stream() .filter(Signal::hasShuntingFunction) .forEach(signal -> { generateShuntingRoute(signal, new ArrayList<>(), new ArrayList<>(), routeMap, routeCodeGenerator, routeVOMap, 0); }); + long passStart = System.currentTimeMillis(); + System.out.println("生成调车进路耗时:" + (passStart - dioStart)); + /* 通过进路 */ + List passButtonVOS = type_button_map.get(MapSignalButtonVO.Type.PASS); + if (!CollectionUtils.isEmpty(passButtonVOS)) { + for (MapSignalButtonVO vo : passButtonVOS) { + Signal signal = signalMap.get(vo.getSignalCode()); + BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(signal, + String.format("按钮[%s]关联的信号机[%s]不存在", vo.getCode(), vo.getSignalCode())); + generatePassRoute(signal, vo, routeMap, + routeCodeGenerator, signalCode_button_map, routeVOMap, 0); + } + } + System.out.println("生成通过进路耗时:" + (System.currentTimeMillis() - passStart)); routeVOMap.values().stream().map(MapRouteNewVO::convert2Draft).forEach(draftMapRoute -> { draftMapRoute.setMapId(mapId); @@ -428,13 +435,68 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { } } - private void generatePassRoute(Signal signal, MapSignalButtonVO vo, Map routeMap, + private void generatePassRoute(Signal signal, MapSignalButtonVO buttonVO, Map routeMap, DraftMapCiDataGeneratorImpl.CodeGenerator routeCodeGenerator, Map> signalCode_button_map, Map routeVOMap, int iter) { + MapRouteNewVO routeVO = new MapRouteNewVO(); + routeVO.setMultiRoute(true); + routeVO.setStartSignalCode(signal.getCode()); + List routeAspectVOS = new ArrayList<>(); + routeVO.setRouteAspectList(routeAspectVOS); + + Signal outboundSignal = null; //出站信号机 boolean right = signal.isRight(); Section section = signal.getSection(); - + section = section.getNextSection(right); + while (section != null) { + Signal destination = section.getSignalOf(!right); + if (destination != null) { + if (destination.isReceivingDepartureSignal()) { + routeVO.setCode(routeCodeGenerator.next()); + routeVO.setName("T_" + signal.getShowName() + "-" + destination.getShowName()); + String startEndSignalCode = outboundSignal.getCode() + destination.getCode(); + MapRouteNewVO departureRoute = routeVOMap.get(startEndSignalCode); //发车进路 + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(departureRoute.getName().startsWith("L"), + String.format("信号机[%s]的通过进路的发车进路[%s]不是列车进路", signal.getCode(), departureRoute.getCode())); + routeAspectVOS.add(new MapRouteAspectVO(departureRoute.getCode(), departureRoute.getSignalAspect())); + routeVO.setEndSectionCode(departureRoute.getEndSectionCode()); + List buttons = signalCode_button_map.get(destination.getCode()); + MapSignalButtonVO endButton = buttons.stream().filter(vo -> MapSignalButtonVO.Type.PICK.equals(vo.getType())) + .limit(1).findAny().orElse(null); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(endButton, + String.format("以信号机[%s]、[%s]为始终端的通过进路,终端信号机无列车信号按钮", signal.getCode(), destination.getCode())); + routeVO.setBtnCodeList(Arrays.asList(buttonVO.getCode(), endButton.getCode())); + routeVOMap.put(signal.getCode() + destination.getCode(), routeVO); + break; + } else if (destination.isShunting2()) { + String startEndSignalCode = signal.getCode() + destination.getCode(); + MapRouteNewVO receivingRoute = routeVOMap.get(startEndSignalCode); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(receivingRoute, + String.format("[%s]接车进路不存在", startEndSignalCode)); + routeVO.setStartSectionCode(receivingRoute.getStartSectionCode()); + routeAspectVOS.add(new MapRouteAspectVO(receivingRoute.getCode(), receivingRoute.getSignalAspect())); + outboundSignal = section.getSignalOf(right); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(outboundSignal, + String.format("股道[%s]无出站信号机", section.getCode())); + } + } + Section next = section.getNextSection(right); + if (next == null) { + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(section.isSwitchTrack() && section.getNextSection(!right) != null, + String.format("信号机[%s]未找到终端信号机", signal.getCode())); + Switch relSwitch = section.getRelSwitch(); + if (relSwitch.isA(section)) { + next = relSwitch.getB(); + } else if (relSwitch.isB(section)) { + next = relSwitch.getA(); + } else { + throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(String.format("信号机[%s]路径上的区段[%s]是道岔的C区段", + signal.getCode(), section.getCode())); + } + } + section = next; + } } /** @@ -446,6 +508,7 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { * 3.1.接车进路:经过反位道岔的是【黄黄】;否则是【黄】 * 3.2.发车进路:【绿】 * 4.如果始终端信号机有多条进路,反位道岔少的优先;其次反位道岔更靠后的优先(西贺村联锁表) + * 5.锁闭区段:接车进路锁闭到终端信号机所在区段;发车进路锁闭到终端信号机前一个区段 */ private void generateTrainRoute(Signal startSignal, MapSignalButtonVO startButton, List
sections, List switches, Map routeMap, @@ -478,6 +541,9 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { route.setInterlockStation(startSignal.getInterlockStation()); route.setStart(startSignal); route.setDestination(endSignal); + if (endSignal.isReceivingDepartureSignal()) { + sections.remove(sections.size() - 1); + } route.setSectionList(sections); // switches = switches.stream().distinct().collect(Collectors.toList()); route.setSwitchList(switches); 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 5077cbd54..1dc535d5b 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 @@ -35,85 +35,95 @@ public class CiRouteService { * @return */ public static Route.CheckFailMessage routeSetCheck(Simulation simulation, Route route) { - MapConfig config = simulation.getRepository().getConfig(); - Signal start = route.getStart(); - if (!config.isSignalBlockRouteSettable()) { - // 信号封锁,不能办理 - if (start.isBlockade()) { - return new Route.CheckFailMessage(Route.CheckFailReason.StartSignalBlockade, start); - } - } - // 进路中道岔没有被征用或锁定在相反位置 - Route.CheckFailMessage failMessage = setSwitchCheck(simulation, route.getSwitchList()); - if (failMessage != null) { - return failMessage; - } - // 进路中道岔是否存在和监控中进路延续保护冲突 - failMessage = monitorRouteOverlapConflictCheck(simulation, route); - if (failMessage != null) { - return failMessage; - } - // 进路内区段封锁/锁闭方向检查 - List
sectionList = route.getSectionList(); - for (Section section : sectionList) { - // 封锁状态 - if (section.isBlockade()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); - } else if (!CollectionUtils.isEmpty(section.getLogicList())) { - for (Section logicSection : section.getLogicList()) { - if (logicSection.isBlockade()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, logicSection); - } + if (!CollectionUtils.isEmpty(route.getMultiRouteAspects())) { + for (Route.MultiRouteAspect multiRouteAspect : route.getMultiRouteAspects()) { + Route.CheckFailMessage checkFailMessage = routeSetCheck(simulation, multiRouteAspect.getRoute()); + if (checkFailMessage != null) { + return checkFailMessage; } - } else if (section.getParent() != null) { - if (section.getParent().isCross() && section.getParent().isBlockade()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); - } - } - // 进路内区段锁闭方向不是此进路方向 - if ((section.isRouteLock() || section.isOverlapLock()) && - !Objects.equals(section.isLockRight(), start.isRight())) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionLockOppositeDirection, section); - } - // 故障占用 - for (int i = 0; i < 3; i++) { - if (section.getParent() == null || section.isAxleCounter()) - break; - section = section.getParent(); - } - if (Section.AxleFault.FAULT.equals(section.getFault())) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionFaultOccupied, section); - } - } - //敌对进路 - List conflictingRouteList = route.getConflictingRouteList(); - for (Route conflict : conflictingRouteList) { - if (conflict.isSetting() || conflict.isLock()) { - return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, conflict); - } - } - if (start.isCbtcMode()) { - // CBTC办理检查 - Section firstLogicSection = route.getFirstLogicSection(); - if (firstLogicSection.isOccupied()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, firstLogicSection); } } else { - // 后备办理检查 - // 区段占用 - for (Section section : sectionList) { - if (section.isOccupied()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); + MapConfig config = simulation.getRepository().getConfig(); + Signal start = route.getStart(); + if (!config.isSignalBlockRouteSettable()) { + // 信号封锁,不能办理 + if (start.isBlockade()) { + return new Route.CheckFailMessage(Route.CheckFailReason.StartSignalBlockade, start); } } - // 延续保护检查 - RouteOverlap overlap = route.getOverlap(); - if (Objects.nonNull(overlap)) { - SectionPath sectionPath = overlap.selectPath(); - failMessage = setSwitchCheck(simulation, sectionPath.getSwitchList()); + // 进路中道岔没有被征用或锁定在相反位置 + Route.CheckFailMessage failMessage = setSwitchCheck(simulation, route.getSwitchList()); + if (failMessage != null) { + return failMessage; } + // 进路中道岔是否存在和监控中进路延续保护冲突 + failMessage = monitorRouteOverlapConflictCheck(simulation, route); + if (failMessage != null) { + return failMessage; + } + // 进路内区段封锁/锁闭方向检查 + List
sectionList = route.getSectionList(); + for (Section section : sectionList) { + // 封锁状态 + if (section.isBlockade()) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); + } else if (!CollectionUtils.isEmpty(section.getLogicList())) { + for (Section logicSection : section.getLogicList()) { + if (logicSection.isBlockade()) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, logicSection); + } + } + } else if (section.getParent() != null) { + if (section.getParent().isCross() && section.getParent().isBlockade()) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); + } + } + // 进路内区段锁闭方向不是此进路方向 + if ((section.isRouteLock() || section.isOverlapLock()) && + !Objects.equals(section.isLockRight(), start.isRight())) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionLockOppositeDirection, section); + } + // 故障占用 + for (int i = 0; i < 3; i++) { + if (section.getParent() == null || section.isAxleCounter()) + break; + section = section.getParent(); + } + if (Section.AxleFault.FAULT.equals(section.getFault())) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionFaultOccupied, section); + } + } + //敌对进路 + List conflictingRouteList = route.getConflictingRouteList(); + for (Route conflict : conflictingRouteList) { + if (conflict.isSetting() || conflict.isLock()) { + return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, conflict); + } + } + if (start.isCbtcMode()) { + // CBTC办理检查 + Section firstLogicSection = route.getFirstLogicSection(); + if (firstLogicSection.isOccupied()) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, firstLogicSection); + } + } else { + // 后备办理检查 + // 区段占用 + for (Section section : sectionList) { + if (section.isOccupied()) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); + } + } + // 延续保护检查 + RouteOverlap overlap = route.getOverlap(); + if (Objects.nonNull(overlap)) { + SectionPath sectionPath = overlap.selectPath(); + failMessage = setSwitchCheck(simulation, sectionPath.getSwitchList()); + } + } + return failMessage; } - return failMessage; + return null; } private static Route.CheckFailMessage monitorRouteOverlapConflictCheck(Simulation simulation, Route route) { @@ -220,27 +230,44 @@ public class CiRouteService { return; } } - // 道岔位置转换 - boolean mainRouteSwitchOnPos = this.switchControlService.batchTurnRouteSwitch(simulation, route.getSwitchList()); - // 预先锁闭 - if (mainRouteSwitchOnPos || config.isLockFirst()) { - // 进路排列区段预先锁闭 - this.checkAndLockRouteMain(route); - } - // 侧防办理 - this.flsSetting(simulation, route.getFlsList()); - // 检查信号开放条件,开信号 - this.ciService.interlockCheck(simulation, route); - if (!route.getStart().isBlockade()) { - this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getAspect()); - } - if (route.isGuideSetting()) { - this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getStart().getGuideAspect()); - } - if ((route.getAspect().equals(route.getStart().getAspect())) || - (route.isGuideSetting() && route.getStart().isGuideAspect())) { - log.debug("进路[{}]信号开放,办理结束", route.debugStr()); - route.settingOver(); + List multiRouteAspects = route.getMultiRouteAspects(); + if (CollectionUtils.isEmpty(multiRouteAspects)) { + // 道岔位置转换 + boolean mainRouteSwitchOnPos = this.switchControlService.batchTurnRouteSwitch(simulation, route.getSwitchList()); + // 预先锁闭 + if (mainRouteSwitchOnPos || config.isLockFirst()) { + // 进路排列区段预先锁闭 + this.checkAndLockRouteMain(route); + } + // 侧防办理 + this.flsSetting(simulation, route.getFlsList()); + // 检查信号开放条件,开信号 + this.ciService.interlockCheck(simulation, route); + if (!route.getStart().isBlockade()) { + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getAspect()); + } + if (route.isGuideSetting()) { + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getStart().getGuideAspect()); + } + if ((route.getAspect().equals(route.getStart().getAspect())) || + (route.isGuideSetting() && route.getStart().isGuideAspect())) { + log.debug("进路[{}]信号开放,办理结束", route.debugStr()); + route.settingOver(); + } + } else { + //由远及近办理进路 + for (int i = multiRouteAspects.size() - 1; i >= 0; i--) { + Route.MultiRouteAspect routeAspect = multiRouteAspects.get(i); + Route subRoute = routeAspect.getRoute(); + if (!subRoute.isLock()) { + setRoute(simulation, subRoute); + break; + } + } + //最近的一条进路已经锁闭 + if (multiRouteAspects.get(0).getRoute().isLock()) { // + route.settingOver(); + } } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java index 1cfa78433..e480298c6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java @@ -262,92 +262,80 @@ public class InterlockBuilder2 { List routeList = logicData.getRouteList(); Map routeMap = new HashMap<>(); for (MapRouteNewVO routeVO : routeList) { + Route route; if (routeVO.isMultiRoute()) { - continue; + BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(routeMap.containsKey(routeVO.getCode()), + String.format("存在code重复的进路:[%s]", routeVO.getCode())); + route = new Route(routeVO.getCode(), routeVO.getName()); + elementMap.put(route.getCode(), route); + List multiRouteAspects = new ArrayList<>(); + route.setMultiRouteAspects(multiRouteAspects); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionNotEmpty(routeVO.getRouteAspectList(), + String.format("组合进路[%s]中进路列表不能为null", routeVO.getCode())); + for (MapRouteAspectVO mapRouteAspectVO : routeVO.getRouteAspectList()) { + Route subRoute = (Route) elementMap.get(mapRouteAspectVO.getRouteCode()); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(subRoute, + String.format("组合进路[%s]的子进路[%s]不存在", route.getCode(), mapRouteAspectVO.getRouteCode())); + multiRouteAspects.add(new Route.MultiRouteAspect(subRoute, getAspect(errMsgList, mapRouteAspectVO.getSignalAspect()))); + } + } else { + BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(routeMap.containsKey(routeVO.getCode()), + String.format("存在code重复的进路:[%s]", routeVO.getCode())); + route = new Route(routeVO.getCode(), routeVO.getName()); + elementMap.put(route.getCode(), route); + routeMap.put(route.getCode(), route); + route.setTurnBack(routeVO.isTurnBack()); + route.setAtp(routeVO.isAtp()); + route.setGround(routeVO.isGround()); + route.setGuide(routeVO.isGuide()); + route.setArs(routeVO.isArc()); + route.setFlt(routeVO.isFlt()); + SignalAspect aspect = getAspect(errMsgList, routeVO.getSignalAspect()); + route.setAspect(aspect); + List
sections = routeVO.getRouteSectionList().stream() + .map(sectionCode -> (Section) elementMap.get(sectionCode)) + .collect(Collectors.toList()); + route.setSectionList(sections); + List routeSwitchList = routeVO.getRouteSwitchList().stream().map(switchEle -> { + Switch aSwitch = (Switch) elementMap.get(switchEle.getSwitchCode()); + return new SwitchElement(aSwitch, switchEle.isNormal()); + }).collect(Collectors.toList()); + route.setSwitchList(routeSwitchList); + List flsListVO = routeVO.getFlsList(); + if (!CollectionUtils.isEmpty(flsListVO)) { + List flsList = flsListVO.stream().map(flsMap::get).collect(Collectors.toList()); + route.setFlsList(flsList); + } } - BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(routeMap.containsKey(routeVO.getCode()), - String.format("存在code重复的进路:[%s]", routeVO.getCode())); - Route route = new Route(routeVO.getCode(), routeVO.getName()); - elementMap.put(route.getCode(), route); - routeMap.put(route.getCode(), route); - route.setTurnBack(routeVO.isTurnBack()); - route.setAtp(routeVO.isAtp()); - route.setGround(routeVO.isGround()); - route.setGuide(routeVO.isGuide()); - route.setArs(routeVO.isArc()); - route.setFlt(routeVO.isFlt()); Signal start = (Signal) elementMap.get(routeVO.getStartSignalCode()); - BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(start, - String.format("进路[%s]的始端信号机[%s]不存在", routeVO.getId(), routeVO.getStartSignalCode())); - route.setStart(start); - start.getRouteList().add(route); - for (String bntCode : routeVO.getBtnCodeList()) { - Signal end; - MapSignalButtonVO signalButton = signalButtonMap.get(bntCode); - if (signalButton != null) { - String signalCode = signalButton.getSignalCode(); - end = (Signal) elementMap.get(signalCode); - } else { //选的是信号机 - end = (Signal) elementMap.get(bntCode); - } - if (!end.equals(start)) { - route.setDestination(end); - break; + Signal destination = null; + if (start == null) { + errMsgList.add(String.format("进路[%s]的始端信号机[%s]不存在", routeVO.getCode(), routeVO.getStartSignalCode())); + } else { + route.setStart(start); + if (StringUtils.hasText(routeVO.getEndSignalCode())) { + destination = (Signal) elementMap.get(routeVO.getEndSignalCode()); + } else { + start.getRouteList().add(route); + for (String bntCode : routeVO.getBtnCodeList()) { + Signal end; + MapSignalButtonVO signalButton = signalButtonMap.get(bntCode); + if (signalButton != null) { + String signalCode = signalButton.getSignalCode(); + end = (Signal) elementMap.get(signalCode); + } else { //选的是信号机 + end = (Signal) elementMap.get(bntCode); + } + if (!end.equals(start)) { + destination = end; + break; + } + } } } - SignalAspect aspect = null; - switch (routeVO.getSignalAspect()) { - case 1: - aspect = SignalAspect.R; - break; - case 2: - aspect = SignalAspect.G; - break; - case 3: - aspect = SignalAspect.Y; - break; - case 4: - aspect = SignalAspect.RY; - break; - case 5: - aspect = SignalAspect.GG; - break; - case 6: - aspect = SignalAspect.GY; - break; - case 7: - aspect = SignalAspect.YY; - break; - case 8: - aspect = SignalAspect.YF; - break; - case 10: - aspect = SignalAspect.B; - break; - case 11: - aspect = SignalAspect.W; - break; - case 12: - aspect = SignalAspect.RF; - break; - default: - errMsgList.add(String.format("未知的信号显示[%s]", routeVO.getSignalAspect())); - } - route.setAspect(aspect); - List
sections = routeVO.getRouteSectionList().stream() - .map(sectionCode -> (Section) elementMap.get(sectionCode)) - .collect(Collectors.toList()); - route.setSectionList(sections); - List routeSwitchList = routeVO.getRouteSwitchList().stream().map(switchEle -> { - Switch aSwitch = (Switch) elementMap.get(switchEle.getSwitchCode()); - return new SwitchElement(aSwitch, switchEle.isNormal()); - }).collect(Collectors.toList()); - route.setSwitchList(routeSwitchList); - List flsListVO = routeVO.getFlsList(); - if (!CollectionUtils.isEmpty(flsListVO)) { - List flsList = flsListVO.stream().map(flsMap::get).collect(Collectors.toList()); - route.setFlsList(flsList); - } + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(destination, + String.format("进路[%s]终端信号机不存在", route.getCode())); + route.setDestination(destination); } for (MapRouteNewVO routeVO : routeList) { Route route = routeMap.get(routeVO.getCode()); @@ -365,6 +353,48 @@ public class InterlockBuilder2 { } } + private static SignalAspect getAspect(List errMsgList, Integer signalAspect) { + SignalAspect aspect = null; + switch (signalAspect) { + case 1: + aspect = SignalAspect.R; + break; + case 2: + aspect = SignalAspect.G; + break; + case 3: + aspect = SignalAspect.Y; + break; + case 4: + aspect = SignalAspect.RY; + break; + case 5: + aspect = SignalAspect.GG; + break; + case 6: + aspect = SignalAspect.GY; + break; + case 7: + aspect = SignalAspect.YY; + break; + case 8: + aspect = SignalAspect.YF; + break; + case 10: + aspect = SignalAspect.B; + break; + case 11: + aspect = SignalAspect.W; + break; + case 12: + aspect = SignalAspect.RF; + break; + default: + errMsgList.add(String.format("未知的信号显示[%s]", signalAspect)); + } + return aspect; + } + private static void buildParkTimes(MapLogicDataNewVO logicData, Map elementMap, Map parkTimeMap, List errMsgList) { List vos = logicData.getParkingTimeList(); @@ -1531,6 +1561,8 @@ public class InterlockBuilder2 { .map(mapElement -> ((Route) mapElement)) .collect(Collectors.toList()); for (Route route : routeList) { + if (!CollectionUtils.isEmpty(route.getMultiRouteAspects())) + continue; List
sectionList = route.getSectionList(); for (Section section : sectionList) { if (Objects.equals(route.getLastRouteSection(), section)) { // 最后区段 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java index 8bfb50a84..7030d15c4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java @@ -811,6 +811,8 @@ public class CalculateService { Map> routeMap = new HashMap<>(); // 进路终端对应进路列表(ATP进路合并进正常进路终端) routeList.sort(Comparator.comparing(Route::isAtp)); // 将ATP进路排在最后处理 for (Route route : routeList) { + if (!CollectionUtils.isEmpty(route.getMultiRouteAspects())) + continue; Section lastRouteSection = route.getLastRouteSection(); List routes = routeMap.get(lastRouteSection); if (routes == null) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java index 93f5b2b07..a2338afec 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java @@ -26,6 +26,7 @@ public class Route extends MapNamedElement { this.psdList = new ArrayList<>(); this.espList = new ArrayList<>(); this.conflictingRouteList = new ArrayList<>(); + this.sectionList = new ArrayList<>(); this.switchList = new ArrayList<>(); } @@ -97,6 +98,11 @@ public class Route extends MapNamedElement { /**进路终端按钮信号机*/ private Signal destinationButtonSignal; + /** + * 组合进路中的所有单进路 + */ + private List multiRouteAspects; + // ------------------状态属性--------------------- /** ats自动控制 */ private boolean atsControl; @@ -718,4 +724,19 @@ public class Route extends MapNamedElement { } } + @Getter + public static class MultiRouteAspect { + private Route route; + + /** + * route在该组合进路中的信号显示。(暂时没用) + */ + private SignalAspect aspect; + + public MultiRouteAspect(Route route, SignalAspect aspect) { + this.route = route; + this.aspect = aspect; + } + } + } 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 b55be7396..73f42506f 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 @@ -650,6 +650,13 @@ public class Signal extends DelayUnlockDevice { return SignalType.RECEIVING.equals(type) || SignalType.DEPARTURE.equals(type); } + /** + * 是列车兼调车信号机? + */ + public boolean isShunting2() { + return SignalType.SHUNTING2.equals(type); + } + /** * 引导信号延时关闭开始计时 */ diff --git a/src/main/java/club/joylink/rtss/vo/map/MapRouteAspectVO.java b/src/main/java/club/joylink/rtss/vo/map/MapRouteAspectVO.java index b3cc4898a..a61be9443 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapRouteAspectVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/MapRouteAspectVO.java @@ -14,4 +14,9 @@ public class MapRouteAspectVO { * 1-红;2-绿;3-黄;4-黄红;5-绿绿;6-绿黄;7-黄黄;8-黄闪黄;9-白红;10-蓝;11-白;12-红闪; */ private Integer signalAspect; + + public MapRouteAspectVO(String routeCode, Integer signalAspect) { + this.routeCode = routeCode; + this.signalAspect = signalAspect; + } }