diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java index b8a5a84e5..fd8295ab1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java @@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.ATS.service; import club.joylink.rtss.entity.PlanRouting; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.ATS.service.stage.AtsHeadTrainStageService; import club.joylink.rtss.simulation.cbtc.ATS.service.stage.AtsPlanTrainStageService; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.Simulation; @@ -58,6 +59,9 @@ public class AtsTrainService { @Autowired private AtsPlanTrainStageService atsPlanTrainStageService; + @Autowired + private AtsHeadTrainStageService atsHeadTrainStageService; + /** * 添加列车追踪 * @@ -332,6 +336,7 @@ public class AtsTrainService { needParking = false; } supervisedTrain.change2HeadCode(destinationCode, serviceNumber, tripNumber); + atsHeadTrainStageService.updatePlanSection(simulation, supervisedTrain); this.onboardAtpApiService.update2HeadTrainServiceNumber(simulation, groupNumber, serviceNumber, tripNumber, destinationCode, needParking); supervisedTrain.updateEstimatedArriveInfo(null, null); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsHeadTrainStageService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsHeadTrainStageService.java index cdf773856..64daa42e4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsHeadTrainStageService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsHeadTrainStageService.java @@ -40,16 +40,12 @@ public class AtsHeadTrainStageService implements AtsStageService { @Override public void handleTransferTrackParking(Simulation simulation, TrainInfo trainInfo, Section parkSection) { - Boolean right = trainInfo.getRight(); - if (right == null) - return; SimulationDataRepository repository = simulation.getRepository(); DestinationCodeDefinition dcd = repository.findDestinationCodeDefinition(trainInfo.getDestinationCode()); if (dcd == null) return; if (Objects.equals(dcd.getSection(), parkSection)) { // 列车到达目的地 - trainInfo.finishPlanPrepareInbound(); handleArriveDestination(simulation, trainInfo); } else { this.updatePlanSection(simulation, trainInfo); @@ -95,7 +91,7 @@ public class AtsHeadTrainStageService implements AtsStageService { } } - private void updatePlanSection(Simulation simulation, TrainInfo trainInfo) { + public void updatePlanSection(Simulation simulation, TrainInfo trainInfo) { boolean planRight = trainInfo.getHctPath().isRight(); SimulationDataRepository repository = simulation.getRepository(); SectionPosition headPosition = repository.buildHeadPositionOfTrainInfo(trainInfo); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsManualTrainStageService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsManualTrainStageService.java index 2a812308c..c0c3c5180 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsManualTrainStageService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsManualTrainStageService.java @@ -31,9 +31,7 @@ public class AtsManualTrainStageService implements AtsStageService { if (routePathList.get(0).isRight() == trainInfo.getRight().booleanValue()) { in = true; } - if (in) { - trainInfo.finishPlanPrepareInbound(); - } else { // 出库,查询计划,是否此轨道有出库计划 + if (!in) { // 出库,查询计划,是否此轨道有出库计划 if (simulation.isPlanRunning()) { this.checkAndApplyTripPlan(simulation, trainInfo, parkSection); } 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 2fc35e6b2..b31fa93f0 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 @@ -40,7 +40,10 @@ public class AtsPlanTrainStageService implements AtsStageService { public void handleTransferTrackParking(Simulation simulation, TrainInfo trainInfo, Section parkSection) { SimulationDataRepository repository = simulation.getRepository(); TripPlan tripPlan = repository.getTripPlan(trainInfo.getServiceNumber(), trainInfo.getTripNumber()); - if (tripPlan.getEndSection().equals(parkSection) || + List routePathList = repository.queryRoutePathsByEnd(parkSection); + if (routePathList.get(0).isRight() == trainInfo.getRight()) { //准备回库 + trainInfo.finishPlanPrepareInbound(); + } else if (tripPlan.getEndSection().equals(parkSection) || tripPlan.getEndSection().getStation().equals(parkSection.getStation())) { // 列车到达计划终点,准备回库 trainInfo.finishPlanPrepareInbound(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsTrainStageHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsTrainStageHandler.java index 752b18968..4359c09b2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsTrainStageHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsTrainStageHandler.java @@ -60,10 +60,6 @@ public class AtsTrainStageHandler { AtsStageService stageService = this.getStageService(trainInfo); if (parkSection.isTransferTrack()) { // 转换轨 stageService.handleTransferTrackParking(simulation, trainInfo, parkSection); - List routePathList = repository.queryRoutePathsByEnd(parkSection); - if (routePathList.get(0).isRight() == trainInfo.getRight()) { //准备回库 - trainInfo.finishPlanPrepareInbound(); - } } else if (parkSection.isNormalStandTrack()) { // 正常站台轨 stageService.handleNormalStandParking(simulation, trainInfo, parkSection); List standList = parkSection.getStandList(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/command/CommandBO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/command/CommandBO.java index ed2e7b100..697c404b5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/command/CommandBO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/command/CommandBO.java @@ -5,11 +5,14 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.DriveMode; import club.joylink.rtss.simulation.cbtc.constant.RunLevel; +import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.map.Switch; +import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; 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 club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; @@ -586,6 +589,31 @@ public class CommandBO { return buildDriverAtoOpenOperationStep(train.getGroupNumber()); } } + }, + + /** 回库 */ + Inbound(List.of(), SimulationMember.Type.DRIVER) { + @Override + public List buildStepList(Simulation simulation, SimulationMember targetMember, Map params) { + return List.of(); + } + + @Override + public Step executeOrReturnStep(Simulation simulation, CommandBO command) { + SimulationMember driver = command.getTargetMember(); + driver.setCommand(null); + VirtualRealityTrain train = (VirtualRealityTrain) driver.getDevice(); + Section headSection = train.getHeadPosition().getSection(); + if (headSection.isTransferTrack() && train.isStop()) { //列车停在折返轨 + SimulationDataRepository repository = simulation.getRepository(); + TrainInfo trainInfo = repository.getSupervisedTrainByGroup(train.getGroupNumber()); + List routePathList = repository.queryRoutePathsByEnd(headSection); + if (routePathList.get(0).isRight() == trainInfo.getRight()) { //准备回库 + trainInfo.finishPlanPrepareInbound(); + } + } + return null; + } } ; 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 c42bf97cc..849ffdb8a 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 @@ -1144,6 +1144,8 @@ public class Section extends MayOutOfOrderDevice { @Override public void fix(MayOutOfOrderDevice device) { Section section = (Section) device; + if (this != section.getFault()) + return; if (!section.isAxleCounter()) { section = section.getParent(); } @@ -1224,6 +1226,8 @@ public class Section extends MayOutOfOrderDevice { @Override public void fix(MayOutOfOrderDevice device) { Section section = (Section) device; + if (this != section.getFault()) + return; List
sections; if (!section.isAxleCounter()) { if (section.getParent() != null && section.getParent().isAxleCounter()) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java index 0239c9ca9..74c1628b6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java @@ -556,6 +556,7 @@ public class TrainInfo extends MapElement { this.planRoutingType = null; this.type = TrainType.HEAD; this.routing = null; + this.atsTriggerRouteMap.clear(); } public void frontTurnBackStart() {