From 30a16859353acb4bb72e742530c2df8eec183544 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 12 Mar 2021 17:44:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=97=E9=93=81=E9=99=A2=E5=B2=94=E5=BF=83?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=AE=A1=E8=BD=B4=E6=95=85=E9=9A=9C/?= =?UTF-8?q?=E9=A2=84=E5=A4=8D=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/SimulationV1Controller.java | 5 +- .../rtss/services/DraftMapService.java | 4 +- .../simulation/cbtc/CI/CiApiServiceImpl.java | 17 +- .../cbtc/GroupSimulationServiceImpl.java | 1 + .../cbtc/build/InterlockBuilder2.java | 12 + .../cbtc/build/MapDeviceBuilder.java | 237 ++++++++++-------- .../simulation/cbtc/data/map/Section.java | 49 +++- .../device/virtual/VRTrainRunningService.java | 3 + .../vo/client/map/newmap/MapSectionNewVO.java | 7 +- 9 files changed, 206 insertions(+), 129 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java b/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java index d1758b8ca..5f94e2ebd 100644 --- a/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java +++ b/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java @@ -64,7 +64,10 @@ public class SimulationV1Controller { public String simulation(Long mapId, String prdType, @ApiIgnore @RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO loginUserInfoVO) { - return this.groupSimulationService.simulation(mapId, prdType, loginUserInfoVO); + String simulation = this.groupSimulationService.simulation(mapId, prdType, loginUserInfoVO); + long end = System.currentTimeMillis(); + System.out.println(end); + return simulation; } @ApiOperation(value = "创建实训仿真") diff --git a/src/main/java/club/joylink/rtss/services/DraftMapService.java b/src/main/java/club/joylink/rtss/services/DraftMapService.java index 17e964de4..db1c70662 100644 --- a/src/main/java/club/joylink/rtss/services/DraftMapService.java +++ b/src/main/java/club/joylink/rtss/services/DraftMapService.java @@ -203,6 +203,7 @@ public class DraftMapService implements IDraftMapService { @Override public void saveMapElsDetail(Long id, String shapeData) { DraftMapWithBLOBs draftMap = draftMapDAO.selectByPrimaryKey(id); + System.out.println(shapeData); MapGraphDataNewVO graphDataNewVO = JsonUtils.read(shapeData, MapGraphDataNewVO.class); this.handleSectionData(graphDataNewVO); draftMap.setGraphData(JsonUtils.writeValueAsString(graphDataNewVO)); @@ -226,8 +227,7 @@ public class DraftMapService implements IDraftMapService { section.setDestinationCode(null); section.setDestinationCodePoint(null); } - if (Objects.equals(section.getType(), BusinessConsts.Section.SectionType.Type04) || - Objects.equals(section.getType(), BusinessConsts.Section.SectionType.Type05)) { + if (Objects.equals(section.getType(), BusinessConsts.Section.SectionType.Type04)) { section.setParentCode(null); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java index da5e54e82..8df73da68 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java @@ -624,18 +624,15 @@ public class CiApiServiceImpl implements CiApiService { */ private VirtualRealitySectionAxleCounter getAxleCounterAndCheck4Reset(Simulation simulation, String sectionCode) { Section section = simulation.getRepository().getByCode(sectionCode, Section.class); - Section chooseSection = section; - if (!section.isAxleCounter()) { - section = section.getParent(); - } + Section axleSection = section.findAxleCounterSection(); //条件检查 - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(section != null && section.isAxleCounter(), - chooseSection.debugStr() + "不是计轴区段"); - VirtualRealitySectionAxleCounter virtualAxleCounter = section.getVirtualAxleCounter(); - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(virtualAxleCounter.isOccupy(), chooseSection.debugStr() + "计轴未占用,无需预复位"); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(), + section.debugStr() + "不是计轴区段也不归属于任何计轴区段"); + VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter(); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(virtualAxleCounter.isOccupy(), section.debugStr() + "计轴未占用,无需预复位"); if (simulation.getRepository().getConfig().isStationPreResetBeforeAxlePreReset()) { - Station station = section.getStation(); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(station, chooseSection.debugStr() + "没有所属车站"); + Station station = axleSection.getStation(); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(station, section.debugStr() + "没有所属车站"); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(station.isPreReset(), station.debugStr() + "需处于预复位状态"); } return virtualAxleCounter; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java index 1a478e981..2fc49fc6a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java @@ -299,6 +299,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { Simulation simulation = this.create(loginUserInfoVO, mapId, prdType, Simulation.FunctionalType.SIMULATION); + if (Objects.equals(MapPrdTypeEnum.BIG_SCREEN, prdType)) { // 大屏仿真,直接按计划行车 RunAsPlanParam param = new RunAsPlanParam(); 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 4e0e4755b..55cce7703 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 @@ -34,6 +34,7 @@ public class InterlockBuilder2 { // ------------侧防end------------- // ------------延续保护start------------- + long overlapStart = System.currentTimeMillis(); List overlapList = logicData.getOverlapList(); for (MapOverlapVO mapOverlapVO : overlapList) { RouteOverlap routeOverlap = new RouteOverlap(mapOverlapVO.getCode(), mapOverlapVO.getName()); @@ -99,6 +100,7 @@ public class InterlockBuilder2 { } } } + log.debug("构建延续保护耗时:" + (System.currentTimeMillis() - overlapStart)); // ------------延续保护end------------- // 接近区段 List signalApproachSectionList = logicData.getSignalApproachSectionList(); @@ -128,6 +130,7 @@ public class InterlockBuilder2 { } } // ------------进路start------------- + long routeStart = System.currentTimeMillis(); List routeList = logicData.getRouteList(); for (MapRouteNewVO mapRouteVO : routeList) { Route route = new Route(mapRouteVO.getCode(), mapRouteVO.getName()); @@ -245,6 +248,7 @@ public class InterlockBuilder2 { } } } + log.debug("构建进路耗时:" + (System.currentTimeMillis() - routeStart)); // 敌对进路关系构建 for (MapRouteNewVO mapRouteVO : routeList) { Route route = (Route) elementMap.get(mapRouteVO.getCode()); @@ -485,6 +489,7 @@ public class InterlockBuilder2 { } private static Map checkAndBuildRouteFls(List flankProtectionList, Map elementMap) { + long start = System.currentTimeMillis(); Map map = new HashMap<>(); for (MapRouteFlankProtectionNewVO fpVO : flankProtectionList) { RouteFls routeFls = new RouteFls(fpVO.getCode(), new SwitchElement((Switch) elementMap.get(fpVO.getSource().getSwitchCode()), fpVO.getSource().isNormal())); @@ -494,6 +499,7 @@ public class InterlockBuilder2 { routeFls.setLevel2List(level2List); map.put(routeFls.getCode(), routeFls); } + log.debug("构建侧防耗时:" + (System.currentTimeMillis() - start)); return map; } @@ -861,6 +867,8 @@ public class InterlockBuilder2 { private static void buildRoutePathFromStationRunLevel(List stationRunLevelList, SimulationBuilder.SimulationDeviceBuildResult buildResult, List errMsgList) { + long start = System.currentTimeMillis(); + log.debug("构建进路路径开始:" + start); if (CollectionUtils.isEmpty(stationRunLevelList)) { return; } @@ -877,6 +885,7 @@ public class InterlockBuilder2 { routePathMap.put(routePaths.get(0).getKey(), routePaths); } } + log.debug("构建进路路径耗时:" + (System.currentTimeMillis() - start)); } // /** @@ -1291,6 +1300,8 @@ public class InterlockBuilder2 { } private static void checkBetweenRouteSameDirectionSignal(Map elementMap, List errMsgList) { + long start = System.currentTimeMillis(); + log.debug("构建自动折返进路开始"); if (!CollectionUtils.isEmpty(errMsgList)) { // 数据中本身存在错误,不检查 return; } @@ -1323,5 +1334,6 @@ public class InterlockBuilder2 { } } } + log.debug("构建自动折返进路耗时:" + (System.currentTimeMillis() - start)); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java index 56a8f149d..79586484d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java @@ -42,110 +42,7 @@ public class MapDeviceBuilder { buildStation(graphData, elementMap, errMsgList); // 区段 List sectionList = graphData.getSectionList(); - Map desCodeSectionMap = new HashMap<>(); - for (MapSectionNewVO sectionVO : sectionList) { - Section section = new Section(sectionVO.getCode(), sectionVO.getName()); - if (Objects.nonNull(elementMap.get(section.getCode()))) { - errMsgList.add(String.format("编码为[%s]的区段不唯一", section.getCode())); - } - elementMap.put(section.getCode(), section); - section.setRoadType(sectionVO.getRoadType()); - section.setPhysical(isPhysicalSection(sectionVO.getType())); - section.setAxleCounter(isAxleCounterSection(sectionVO.getType())); - section.setCross(isCross(sectionVO.getType())); - // 计轴区段和道岔区段,校验实际长度 - if (isPhysicalSection(sectionVO.getType()) && - (Objects.isNull(sectionVO.getLengthFact()) || - sectionVO.getLengthFact() <= 0 || - Float.isInfinite(sectionVO.getLengthFact()) || - Float.isNaN(sectionVO.getLengthFact()))) { - errMsgList.add(String.format("区段[%s(%s)]实际距离未设置或不为正数", sectionVO.getName(), sectionVO.getCode())); - } else if (isPhysicalSection(sectionVO.getType())) { - section.setLen(sectionVO.getLengthFact()); - } - if (Objects.equals(sectionVO.getType(), BusinessConsts.Section.SectionType.Type02)) { // 逻辑区段 - Float startOffset = sectionVO.getLogicSectionStartOffset(); - Float endOffset = sectionVO.getLogicSectionEndOffset(); - section.setLen(sectionVO.getLengthFact()); - if ((Objects.isNull(sectionVO.getLengthFact()) || sectionVO.getLengthFact() <= 0) && - (Objects.isNull(startOffset) || Objects.isNull(endOffset))) { - errMsgList.add(String.format("逻辑区段[%s(%s)]既没有设置实际长度且所在物理区段起始/终止偏移量也未设置", - section.getName(), section.getCode())); - } else { - float max = Math.max(startOffset, endOffset); - float min = Math.min(startOffset, endOffset); - section.setMaxOffset(max); - section.setMinOffset(min); - } - } - // 所属设备集中站 - Station deviceStation = (Station) elementMap.get(sectionVO.getStationCode()); - if (Objects.isNull(deviceStation)) { - errMsgList.add(String.format("区段[%s(%s)]未关联设备集中站或设备集中站不存在", section.getName(), section.getCode())); - } else { - section.setDeviceStation(deviceStation); - } - section.setStandTrack(sectionVO.isStandTrack()); - section.setTurnBackTrack(sectionVO.isReentryTrack()); - section.setFirstTurnBack(sectionVO.isFirstTurnBack()); - section.setTransferTrack(sectionVO.isTransferTrack()); - if (section.isTransferTrack()) { - if (section.isTurnBackTrack() || section.isStandTrack()) { - errMsgList.add(String.format("区段[%s(%s)]是转换轨,就不能再设置为站台轨或折返轨", - section.getName(), section.getCode())); - } - } - // 是站台轨/折返轨/转换轨,校验左右停车点 - if ((section.isStandTrack() || section.isTransferTrack() || section.isTurnBackTrack()) - && - (Objects.isNull(sectionVO.getLeftStopPointOffset()) || - Objects.isNull(sectionVO.getRightStopPointOffset()) || - (0 == sectionVO.getLeftStopPointOffset().floatValue() && - 0 == sectionVO.getRightStopPointOffset().floatValue()))) { - errMsgList.add(String.format("区段[%s(%s)]是站台轨/折返轨/转换轨,却未设置左右停车点偏移量或左右停车点偏移量都为0", sectionVO.getName(), sectionVO.getCode())); - } else { - section.setStopPointLeft(sectionVO.getLeftStopPointOffset()); - section.setStopPointRight(sectionVO.getRightStopPointOffset()); - } - // 转换轨/折返轨,构建关联车站,站台轨在后面处理站台逻辑里做了 - if (section.isStandTrack() || section.isTransferTrack() || section.isTurnBackTrack()) { - if (!StringUtils.hasText(sectionVO.getBelongStation())) { - errMsgList.add(String.format("区段[%s(%s)]是站台轨或转换轨或折返轨,却未设置关联车站", - sectionVO.getName(), sectionVO.getCode())); - } else { - //归属车站 - Station station = (Station) elementMap.get(sectionVO.getBelongStation()); - if (Objects.isNull(station)) { - errMsgList.add(String.format("折返轨/转换轨/站台轨区段[%s(%s)]关联的车站[(%s)]不存在", section.getName(), section.getCode(), sectionVO.getBelongStation())); - } else { - section.setStation(station); - if (section.isTransferTrack()) { - station.addTransferTrack(section); - } - if (section.isTurnBackTrack()) { - station.addTurnBackSection(section); - } - } - } - } - section.setDestinationCode(sectionVO.getDestinationCode()); - if (StringUtils.hasText(sectionVO.getDestinationCode())) { - Section section1 = desCodeSectionMap.get(sectionVO.getDestinationCode()); - if (Objects.nonNull(section1)) { - errMsgList.add(String.format("区段[%s(%s)]和区段[%s(%s)]目的地码相同[%s],目的地码必须唯一", - section.getName(), section.getCode(), - section1.getName(), section1.getCode(), - sectionVO.getDestinationCode())); - } - desCodeSectionMap.put(sectionVO.getDestinationCode(), section); - } - // 如果区段是计轴区段,构建区段虚拟真实计轴器 - if (section.isAxleCounter()) { - VirtualRealitySectionAxleCounter axleCounter = new VirtualRealitySectionAxleCounter(section.getCode(), section.getName()); - section.setVirtualAxleCounter(axleCounter); - deviceMap.put(axleCounter.getCode(), axleCounter); - } - } + buildSections(elementMap, deviceMap, errMsgList, sectionList); // 道岔 List switchList = graphData.getSwitchList(); switchList.forEach(switchVO -> { @@ -200,10 +97,11 @@ public class MapDeviceBuilder { sectionList.forEach(sectionVO -> { Section section = (Section) elementMap.get(sectionVO.getCode()); if (Objects.equals(BusinessConsts.Section.SectionType.Type02, sectionVO.getType()) || - Objects.equals(BusinessConsts.Section.SectionType.Type03, sectionVO.getType())) { // 逻辑区段/道岔区段 + Objects.equals(BusinessConsts.Section.SectionType.Type03, sectionVO.getType()) || + isCross(sectionVO.getType())) { // 逻辑区段/道岔区段/岔心 Section parent = (Section) elementMap.get(sectionVO.getParentCode()); if (Objects.isNull(parent)) { - errMsgList.add(String.format("逻辑区段/道岔区段[%s(%s)]没用关联(道岔)计轴区段或关联的(道岔)计轴区段不存在", + errMsgList.add(String.format("逻辑区段/道岔区段/岔心[%s(%s)]没用关联(道岔)计轴区段或关联的(道岔)计轴区段不存在", section.getName(), section.getCode())); } else { parent.addLogicSection(section); @@ -256,8 +154,8 @@ public class MapDeviceBuilder { if (Objects.isNull(physicalSectionOfCross)) { errMsgList.add(String.format("岔心[%s(%s)]关联的物理区段[(%s)]不存在", section.getName(), section.getCode(), s)); - } else if (!physicalSectionOfCross.isAxleCounterSection()) { - errMsgList.add(String.format("岔心[%s(%s)]关联的区段[%s(%s)]不是一般计轴物理区段", + } else if (!physicalSectionOfCross.isPhysical()) { + errMsgList.add(String.format("岔心[%s(%s)]关联的区段[%s(%s)]不是物理区段", section.getName(), section.getCode(), physicalSectionOfCross.getName(), s)); } }); @@ -846,6 +744,117 @@ public class MapDeviceBuilder { buildResponderDataRef(graphData, elementMap, errMsgList, mapDataBuildResult.getSectionRespondersMap()); } + /** + * 构建区段数据 + */ + private static void buildSections(Map elementMap, Map deviceMap, + List errMsgList, List sectionList) { + Map desCodeSectionMap = new HashMap<>(); + for (MapSectionNewVO sectionVO : sectionList) { + Section section = new Section(sectionVO.getCode(), sectionVO.getName()); + if (Objects.nonNull(elementMap.get(section.getCode()))) { + errMsgList.add(String.format("编码为[%s]的区段不唯一", section.getCode())); + } + elementMap.put(section.getCode(), section); + section.setRoadType(sectionVO.getRoadType()); + section.setPhysical(isPhysicalSection(sectionVO.getType())); + section.setAxleCounter(isAxleCounterSection(sectionVO, sectionList)); + section.setCross(isCross(sectionVO.getType())); + // 计轴区段和道岔区段,校验实际长度 + if (isPhysicalSection(sectionVO.getType()) && + (Objects.isNull(sectionVO.getLengthFact()) || + sectionVO.getLengthFact() <= 0 || + Float.isInfinite(sectionVO.getLengthFact()) || + Float.isNaN(sectionVO.getLengthFact()))) { + errMsgList.add(String.format("区段[%s(%s)]实际距离未设置或不为正数", sectionVO.getName(), sectionVO.getCode())); + } else if (isPhysicalSection(sectionVO.getType())) { + section.setLen(sectionVO.getLengthFact()); + } + if (Objects.equals(sectionVO.getType(), BusinessConsts.Section.SectionType.Type02)) { // 逻辑区段 + Float startOffset = sectionVO.getLogicSectionStartOffset(); + Float endOffset = sectionVO.getLogicSectionEndOffset(); + section.setLen(sectionVO.getLengthFact()); + if ((Objects.isNull(sectionVO.getLengthFact()) || sectionVO.getLengthFact() <= 0) && + (Objects.isNull(startOffset) || Objects.isNull(endOffset))) { + errMsgList.add(String.format("逻辑区段[%s(%s)]既没有设置实际长度且所在物理区段起始/终止偏移量也未设置", + section.getName(), section.getCode())); + } else { + float max = Math.max(startOffset, endOffset); + float min = Math.min(startOffset, endOffset); + section.setMaxOffset(max); + section.setMinOffset(min); + } + } + // 所属设备集中站 + Station deviceStation = (Station) elementMap.get(sectionVO.getStationCode()); + if (Objects.isNull(deviceStation)) { + errMsgList.add(String.format("区段[%s(%s)]未关联设备集中站或设备集中站不存在", section.getName(), section.getCode())); + } else { + section.setDeviceStation(deviceStation); + } + section.setStandTrack(sectionVO.isStandTrack()); + section.setTurnBackTrack(sectionVO.isReentryTrack()); + section.setFirstTurnBack(sectionVO.isFirstTurnBack()); + section.setTransferTrack(sectionVO.isTransferTrack()); + if (section.isTransferTrack()) { + if (section.isTurnBackTrack() || section.isStandTrack()) { + errMsgList.add(String.format("区段[%s(%s)]是转换轨,就不能再设置为站台轨或折返轨", + section.getName(), section.getCode())); + } + } + // 是站台轨/折返轨/转换轨,校验左右停车点 + if ((section.isStandTrack() || section.isTransferTrack() || section.isTurnBackTrack()) + && + (Objects.isNull(sectionVO.getLeftStopPointOffset()) || + Objects.isNull(sectionVO.getRightStopPointOffset()) || + (0 == sectionVO.getLeftStopPointOffset().floatValue() && + 0 == sectionVO.getRightStopPointOffset().floatValue()))) { + errMsgList.add(String.format("区段[%s(%s)]是站台轨/折返轨/转换轨,却未设置左右停车点偏移量或左右停车点偏移量都为0", sectionVO.getName(), sectionVO.getCode())); + } else { + section.setStopPointLeft(sectionVO.getLeftStopPointOffset()); + section.setStopPointRight(sectionVO.getRightStopPointOffset()); + } + // 转换轨/折返轨,构建关联车站,站台轨在后面处理站台逻辑里做了 + if (section.isStandTrack() || section.isTransferTrack() || section.isTurnBackTrack()) { + if (!StringUtils.hasText(sectionVO.getBelongStation())) { + errMsgList.add(String.format("区段[%s(%s)]是站台轨或转换轨或折返轨,却未设置关联车站", + sectionVO.getName(), sectionVO.getCode())); + } else { + //归属车站 + Station station = (Station) elementMap.get(sectionVO.getBelongStation()); + if (Objects.isNull(station)) { + errMsgList.add(String.format("折返轨/转换轨/站台轨区段[%s(%s)]关联的车站[(%s)]不存在", section.getName(), section.getCode(), sectionVO.getBelongStation())); + } else { + section.setStation(station); + if (section.isTransferTrack()) { + station.addTransferTrack(section); + } + if (section.isTurnBackTrack()) { + station.addTurnBackSection(section); + } + } + } + } + section.setDestinationCode(sectionVO.getDestinationCode()); + if (StringUtils.hasText(sectionVO.getDestinationCode())) { + Section section1 = desCodeSectionMap.get(sectionVO.getDestinationCode()); + if (Objects.nonNull(section1)) { + errMsgList.add(String.format("区段[%s(%s)]和区段[%s(%s)]目的地码相同[%s],目的地码必须唯一", + section.getName(), section.getCode(), + section1.getName(), section1.getCode(), + sectionVO.getDestinationCode())); + } + desCodeSectionMap.put(sectionVO.getDestinationCode(), section); + } + // 如果区段是计轴区段,构建区段虚拟真实计轴器 + if (section.isAxleCounter()) { + VirtualRealitySectionAxleCounter axleCounter = new VirtualRealitySectionAxleCounter(section.getCode(), section.getName()); + section.setVirtualAxleCounter(axleCounter); + deviceMap.put(axleCounter.getCode(), axleCounter); + } + } + } + private static void buildSignal(MapGraphDataNewVO graphData, Map elementMap, Map deviceMap, List errMsgList) { List signalList = graphData.getSignalList(); @@ -1186,8 +1195,16 @@ public class MapDeviceBuilder { return Objects.equals(type, BusinessConsts.Section.SectionType.Type01) || Objects.equals(type, BusinessConsts.Section.SectionType.Type03); } - private static boolean isAxleCounterSection(String type) { - return Objects.equals(type, BusinessConsts.Section.SectionType.Type01) || Objects.equals(type, BusinessConsts.Section.SectionType.Type04); + private static boolean isAxleCounterSection(MapSectionNewVO sectionVO, List sectionList) { + String type = sectionVO.getType(); + if (Objects.equals(type, BusinessConsts.Section.SectionType.Type04)) + return true; + if (Objects.equals(type, BusinessConsts.Section.SectionType.Type01)) { + String parentCode = sectionVO.getParentCode(); + return sectionList.stream().noneMatch(section -> isCross(section.getType()) && section.getCode().equals(parentCode)); + } else { + return false; + } } private static boolean isCross(String type) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java index 5d2c70be7..7dc6d05c3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java @@ -88,7 +88,7 @@ public class Section extends MayOutOfOrderDevice { private Section parent; /** - * 岔心关联的计轴区段;道岔计轴区段关联的道岔区段;物理区段关联的逻辑区段 + * 岔心关联的物理区段;道岔计轴区段关联的道岔区段、岔心;物理区段关联的逻辑区段 */ private List
logicList; @@ -740,6 +740,10 @@ public class Section extends MayOutOfOrderDevice { aSwitch.getC().setNctOccupied(true); } } + Section cross = queryCross(); + if (cross != null) { + cross.crossJudgeInvalid(); + } } else if (!CollectionUtils.isEmpty(this.logicList)) { for (Section logic : this.logicList) { logic.setNctOccupied(true); @@ -778,6 +782,21 @@ public class Section extends MayOutOfOrderDevice { // } } + /** + * 岔心判断失效 + */ + private void crossJudgeInvalid(){ + if (!this.cross) + return; + this.logicList.forEach(logic->{ + Section leftSection = logic.getLeftSection(); + boolean leftSectionNctOccupied = leftSection.isNctOccupied() && leftSection.getParent().equals(this.parent); + Section rightSection = logic.getRightSection(); + boolean rightSectionNctOccupied = rightSection.isNctOccupied() && rightSection.getParent().equals(this.parent); + logic.setNctOccupied(leftSectionNctOccupied || rightSectionNctOccupied); + }); + } + /** * 判定为有效 */ @@ -806,6 +825,13 @@ public class Section extends MayOutOfOrderDevice { } } + /** + * 查询道岔计轴区段关联的岔心 + */ + private Section queryCross() { + return this.logicList.stream().filter(Section::isCross).limit(1).findAny().orElse(null); + } + /** * 确认计轴有效 */ @@ -952,12 +978,25 @@ public class Section extends MayOutOfOrderDevice { if (switchTrack) { return false; } - if (virtualAxleCounter == null) { - if (parent != null) - return parent.isPreReset(); + Section axleCounterSection = findAxleCounterSection(); + if (axleCounterSection != null) { + return axleCounterSection.getVirtualAxleCounter().isPreReset() && this.isNctOccupied(); + } else{ return false; + } + } + + /** + * 查找计轴区段 + * @return + */ + public Section findAxleCounterSection() { + if (this.isAxleCounter()) { + return this; + } else if (parent != null) { + return parent.findAxleCounterSection(); } else { - return virtualAxleCounter.isPreReset(); + return null; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRTrainRunningService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRTrainRunningService.java index d5fff7df3..d6ff41fdc 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRTrainRunningService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRTrainRunningService.java @@ -128,6 +128,9 @@ public class VRTrainRunningService { if (!headAxleCounterSectionNew.isAxleCounter()) { headAxleCounterSectionNew = headAxleCounterSectionNew.getParent(); } + if (!headAxleCounterSectionNew.isAxleCounter()) { //当是——物理区段-岔心-道岔计轴区段三层结构的时候需要多这次判断 + headAxleCounterSectionNew = headAxleCounterSectionNew.getParent(); + } if (headAxleCounterSectionNew != null && headAxleCounterSectionNew.isAxleCounter()) { //新的区段是计轴区段 Section headSectionOld = headPosition.getSection(); if (!headAxleCounterSectionNew.equals(headSectionOld) && !headAxleCounterSectionNew.equals(headSectionOld.getParent())) { //新计轴区段和老区段不一样 diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapSectionNewVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapSectionNewVO.java index 6d148173d..a13a5fd14 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapSectionNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapSectionNewVO.java @@ -167,9 +167,14 @@ public class MapSectionNewVO { /** * 岔心关联计轴区段列表 */ - @ApiModelProperty(value = "岔心关联计轴区段列表") + @ApiModelProperty(value = "岔心关联物理区段列表") List relateSectionList; + /** + * 道岔计轴区段关联的岔心区段 + */ + String relCrossSection; + /** * 是否站台轨 */