diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/FoshanTramRunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/FoshanTramRunPlanNew.java index f7264246b..144a33fe8 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/FoshanTramRunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/FoshanTramRunPlanNew.java @@ -80,7 +80,7 @@ public class FoshanTramRunPlanNew implements IRunPlanStrategyNew { tripVO.setDestinationCode("BF"); break; case "雷岗": - if (tripVO.getServiceNumber().equals("09")) { //据观察,服务号09是调试车 + if (tripVO.getServiceNumber().equals("02")) { //据观察,服务号02是备用车 tripVO.setStartSectionCode("T38"); //G2109 tripVO.setDestinationCode("AA"); } else { @@ -108,7 +108,7 @@ public class FoshanTramRunPlanNew implements IRunPlanStrategyNew { tripVO.setDestinationCode("BF"); break; case "雷岗": - if (tripVO.getServiceNumber().equals("09")) { //据观察,服务号09是调试车 + if (tripVO.getServiceNumber().equals("02")) { //据观察,服务号02是备用车 tripVO.setEndSectionCode("T38"); //G2109 tripVO.setDestinationCode("AA"); } else { @@ -117,6 +117,9 @@ public class FoshanTramRunPlanNew implements IRunPlanStrategyNew { } break; } + if (tripVO.getServiceNumber().equals("02")) { + tripVO.setIsBackUp(true); + } } /** @@ -133,7 +136,7 @@ public class FoshanTramRunPlanNew implements IRunPlanStrategyNew { return; } if ("雷岗".equals(stationVO.getRunPlanName())) { - if (runPlanImport.getServiceNumber().equals("09")) { //据观察,服务号09是调试车 + if (runPlanImport.getServiceNumber().equals("02")) { //据观察,服务号02是备用车 timeVO.setSectionCode("T38"); //G2109 } else { timeVO.setSectionCode("T39"); //G2103 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/MaService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/MaService.java index 711985f47..a3dfcd5d5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/MaService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/MaService.java @@ -105,7 +105,8 @@ public class MaService { public float calculateDistanceOfEbTriggerEnd() { if (this.type.equals(MaType.ITC_Signal)) { boolean right = this.train.isRight(); - Float distance = CalculateService.calculateDistance(this.train.getHeadPosition(), this.eoaPosition, right); +// Float distance = CalculateService.calculateDistance(this.train.getHeadPosition(), this.eoaPosition, right); + Float distance = CalculateService.calculateDistanceIgnoreSwitch(this.train.getHeadPosition(), this.eoaPosition, right); if (distance == null) { distance = 0f; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsPlanTrainStageService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsPlanTrainStageService.java index 4d4ec24a7..8a1e1c933 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsPlanTrainStageService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsPlanTrainStageService.java @@ -163,6 +163,9 @@ public class AtsPlanTrainStageService implements AtsStageService { return; } if (tripPlan.isLastPlan(stationPlan)) { + if (tripPlan.isBackup() && parkSection.equals(tripPlan.getEndSection())) { + return; + } // 到达终点站,准备折返 log.debug(String.format("列车[%s]折返初始化", trainInfo.getGroupNumber())); List routePaths = repository.getRoutePaths(parkSection, tripPlan.getEndSection()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/tools/TrainOutboundLoadTool.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/tools/TrainOutboundLoadTool.java index 9685301f9..5a1ab21c6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/tools/TrainOutboundLoadTool.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/tools/TrainOutboundLoadTool.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.ATS.tools; +import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.RunLevel; import club.joylink.rtss.simulation.cbtc.constant.TrainType; @@ -12,6 +13,7 @@ import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.time.LocalDateTime; @@ -23,6 +25,9 @@ import java.util.Objects; @Component public class TrainOutboundLoadTool { + @Autowired + private MaService maService; + public void loadOutboundTrain(Simulation simulation) { if (!simulation.isPlanRunning()) { // 未开始计划运行 return; @@ -76,7 +81,10 @@ public class TrainOutboundLoadTool { SectionPosition headPosition = new SectionPosition(startSection, offset); train.initManualTrain(headPosition, right); if (Objects.equals(RunLevel.ITC, repository.getConfig().getRunMode())) { + train.setCommunication(false); + train.setNoCommunicateDevice(true); train.setITCMode(); + this.maService.calculateAndUpdateItcMa(simulation, train); } repository.addOnlineTrain(train); 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 5279f10b4..5077cbd54 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 @@ -120,7 +120,7 @@ public class CiRouteService { SimulationDataRepository repository = simulation.getRepository(); List settingRoutes = repository.getSettingRoutes(); for (Route sr : settingRoutes) { - if (sr.isSettingOverlap() && !repository.isTrainParking(sr.getOverlap().getSection())) { + if (sr.isSettingOverlap() && (sr.getOverlap().isSetting() || sr.getOverlap().isLock())/*&& !repository.isTrainParking(sr.getOverlap().getSection())*/) { SectionPath sectionPath = sr.getOverlap().selectPath(); for (SwitchElement switchElement : sectionPath.getSwitchList()) { if (route.isConflictSwitch(switchElement)) { @@ -492,10 +492,10 @@ public class CiRouteService { continue; } if (relSwitch.isLinkedSwitch(aSwitch) || relSwitch.isBConnectTo(aSwitch)) { - if (!aSwitch.getA().isRouteLock()) { +// if (!aSwitch.getA().isRouteLock()) { //当两条进路锁闭同一个道岔时,一条进路解锁,道岔的A区段可能仍旧被另一条进路锁闭着,导致无法解锁,故去掉此判断 aSwitch.routeUnlock(route); - aSwitch.overlapUnLock(); - } +// aSwitch.overlapUnLock(); //应该不需要,暂时注掉 +// } } } } else { 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 7c876f550..e49d30756 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 @@ -1317,14 +1317,14 @@ public class MapDeviceBuilder { elementMap.put(station.getCode(), station); station.setCentralized(stationVO.isCentralized()); station.setDepot(stationVO.isDepot()); - if (station.isCentralized() && !station.isDepot()) { - ZC zc = (ZC) elementMap.get(stationVO.getZcCode()); - if (Objects.isNull(zc)) { - errMsgList.add(String.format("车站[%s(%s)]未关联ZC或ZC不存在,请在ZC设备处选择管理的集中站列表", station.getName(), station.getCode())); - } else { - station.setZc(zc); - } - } +// if (station.isCentralized() && !station.isDepot()) { +// ZC zc = (ZC) elementMap.get(stationVO.getZcCode()); +// if (Objects.isNull(zc)) { +// errMsgList.add(String.format("车站[%s(%s)]未关联ZC或ZC不存在,请在ZC设备处选择管理的集中站列表", station.getName(), station.getCode())); +// } else { +// station.setZc(zc); +// } +// } if (Objects.isNull(stationVO.getKmRange())) { errMsgList.add(String.format("车站[%s(%s)]未设置距离", stationVO.getName(), stationVO.getCode())); } else { @@ -1361,7 +1361,7 @@ public class MapDeviceBuilder { station.getName(), station.getCode(), code)); } else { normal.setDeviceStation(station); - normal.setZc(station.getZc()); +// normal.setZc(station.getZc()); } }); } 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 38651ab9d..8bfb50a84 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 @@ -234,7 +234,7 @@ public class CalculateService { } /** - * 递归计算起始区段到目标区段之间的距离 + * 递归计算起始区段到目标区段之间的距离(包含起始区段长度、不包含终点区段长度) */ private static Float recursiveCalculate(Section startSection, Section endSection, boolean isRight, byte frequency) { if (startSection.equals(endSection)) { @@ -1234,6 +1234,35 @@ public class CalculateService { return routes; } + /** + * 无视道岔位置计算距离(单向) + */ + public static Float calculateDistanceIgnoreSwitch(SectionPosition startPosition, SectionPosition endPosition, boolean right) { + if (startPosition.getSection().equals(endPosition.getSection())) { + float offset; + if (right) { + offset = endPosition.getOffset() - startPosition.getOffset(); + } else { + offset = startPosition.getOffset() - endPosition.getOffset(); + } + if (offset > 0) { + return offset; + } else { + return null; + } + } else { + Float distance = recursiveCalculate(startPosition.getSection(), endPosition.getSection(), right, (byte) 51); + if (distance != null) { + if (right) { + distance += endPosition.getOffset(); + } else { + distance += endPosition.getSection().getLen() - endPosition.getOffset(); + } + } + return distance; + } + } + /** * 计算加速段的时间 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java index 234e1bd16..442efe1c4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java @@ -66,28 +66,32 @@ public class RobotLogicLoop { private void robotOpenATO(Simulation simulation, VirtualRealityTrain train) { StandParkedTrainActivity activity = train.getStandParkedTrainActivity(); - if (activity == null) - return; - switch (activity) { - case OPEN_DOOR: - if (!train.isAutoOpenDoor()) { - atoService.syncOpenDoor(simulation, train); - usePsl2ControlPsd(simulation, train, true); - } - break; - case CLOSE_DOOR: - if (!train.isAutoCloseDoor()) { - atoService.syncCloseDoor(simulation, train); - usePsl2ControlPsd(simulation, train, false); - } - break; - case START: - if (train.isAtoCanOpen()) { - atpService.openATO(train); - } else if (train.isITC()) { - atpService.confirmMessage(train, Confirm_Release_Speed); - } - break; + if (activity != null) { + switch (activity) { + case OPEN_DOOR: + if (!train.isAutoOpenDoor()) { + atoService.syncOpenDoor(simulation, train); + usePsl2ControlPsd(simulation, train, true); + } + break; + case CLOSE_DOOR: + if (!train.isAutoCloseDoor()) { + atoService.syncCloseDoor(simulation, train); + usePsl2ControlPsd(simulation, train, false); + } + break; + case START: + if (train.isAtoCanOpen()) { + atpService.openATO(train); + } + break; + } + } + if (train.isStop() && train.isITC() && train.isAtoOn()) { + Signal signal = train.getHeadPosition().getSection().getSignalOf(train.isRight()); + if (signal != null && signal.isMainAspect()) { + atpService.confirmMessage(train, Confirm_Release_Speed); + } } }