From 318ccb915e102177c1c9e3a7e29dc16fd55d42d9 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Sun, 24 Apr 2022 15:20:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=A7=E9=93=81CTC?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/CTC/CTCLogicLoop.java | 33 ++++++++++++------- .../cbtc/CTC/data/CtcStationPlan.java | 5 +++ .../simulation/cbtc/CTC/data/TrackView.java | 8 ++++- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java index b26463e21..8dbae12d9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java @@ -25,6 +25,7 @@ import org.springframework.util.CollectionUtils; import java.time.LocalTime; import java.util.*; +import java.util.stream.Collectors; @Component public class CTCLogicLoop { @@ -106,6 +107,8 @@ public class CTCLogicLoop { Section receivingSection = receivingPlan.getSection(); VirtualRealityTrain train = repository.getOnlineTrainBy(ctcStationPlan.getTrainInfo().getGroupNumber()); SectionPosition headPosition = train.getHeadPosition(); + //轨道占用 + ctcStationPlan.setReceivingSectionOccupied(receivingSection.isOccupied()); //发点 Signal departureSignal = receivingSection.getSignalOf(planRight); //发车信号机 if (headPosition.isAheadOf(departureSignal.getPosition(), planRight)) { @@ -120,7 +123,7 @@ public class CTCLogicLoop { Route departureRoute = ctcStationPlan.getDepartureRoute(); if (departureRoute.isLock()) { ctcStationPlan.setDepartureRouteLock(true); - } else if (ctcStationPlan.isDepartureRouteAutoTrigger()){ + } else if (ctcStationPlan.isDepartureRouteAutoTrigger()) { if (systemTime.isAfter(ctcStationPlan.getReceivingPlan().getLeaveTime())) { //晚于发车时间 ciApiService.settingRoute(simulation, departureRoute.getCode()); } @@ -130,11 +133,13 @@ public class CTCLogicLoop { ctcStationPlan.updateProcess(CtcStationPlan.Process.DEPARTURE); } //发预 - if (ctcStationPlan.isDepartureNotice() && ctcStationPlan.getDeparturePlan() != null) { //邻站发车预告 + if (ctcStationPlan.isDepartureNotice()) { ctcStationPlan.updateProcess(CtcStationPlan.Process.DEPARTURE_ROUTE); - CtcStationPlan departureCtcStationPlan = ctcRepository - .getCtcStationPlan(ctcStationPlan.getDeparturePlan().getStation().getCode(), ctcStationPlan.getTripNumber()); - departureCtcStationPlan.updateProcess(CtcStationPlan.Process.RECEIVING); + if (ctcStationPlan.getDeparturePlan() != null) { //邻站发车预告 + CtcStationPlan departureCtcStationPlan = ctcRepository + .getCtcStationPlan(ctcStationPlan.getDeparturePlan().getStation().getCode(), ctcStationPlan.getTripNumber()); + departureCtcStationPlan.updateProcess(CtcStationPlan.Process.RECEIVING); + } } //到点 if (ctcStationPlan.getTrainInfo().isParkingAt(receivingPlan.getSection())) { @@ -178,10 +183,12 @@ public class CTCLogicLoop { TripPlan tripPlan = repository.getTripPlan(trainInfo.getServiceNumber(), trainInfo.getTripNumber()); VirtualRealityTrain train = repository.getOnlineTrainBy(trainInfo.getGroupNumber()); StationPlan stationPlan = tripPlan.queryStationPlanByStationCode(trainInfo.getStationCode()); - Section previousSection = train.getHeadPosition().getSection(); //前一个的停车区段 + Section headSection = train.getHeadPosition().getSection(); while (stationPlan != null) { - Section headSection = train.getHeadPosition().getSection(); - List paths = repository.queryRoutePathsByEndAndContainsSection(stationPlan.getSection(), previousSection); + List paths = repository.queryRoutePathsByEndAndContainsSection(stationPlan.getSection(), headSection); + if (!CollectionUtils.isEmpty(paths)) { + paths = paths.stream().filter(routePath -> Objects.equals(routePath.isRight(), tripPlan.isRight())).collect(Collectors.toList()); + } if (!CollectionUtils.isEmpty(paths)) { CtcStationPlan ctcStationPlan = new CtcStationPlan(trainInfo, stationPlan); ctcRepository.addCtcStationPlan(ctcStationPlan); @@ -192,7 +199,7 @@ public class CTCLogicLoop { ctcStationPlan.setArrive(true); ctcStationPlan.updateProcess(CtcStationPlan.Process.DEPARTURE_BLOCK); } else { //没到站 - RoutePath routePath = atsRouteSelectService.selectRoutePath(paths); + RoutePath routePath = selectRoutePath(paths); Route receivingRoute = routePath.getLastRoute(); ctcStationPlan.setReceivingRoute(receivingRoute); ctcStationPlan.updateProcess(CtcStationPlan.Process.RECEIVING_BLOCK); @@ -206,17 +213,21 @@ public class CTCLogicLoop { } else { routePaths = repository.getRoutePaths(stationPlan.getSection(), tripPlan.getEndSection()); } - RoutePath routePath = atsRouteSelectService.selectRoutePath(routePaths); + RoutePath routePath = selectRoutePath(routePaths); Route departureRoute = routePath.getFirstRoute(); ctcStationPlan.setDepartureRoute(departureRoute); } - previousSection = stationPlan.getSection(); stationPlan = tripPlan.queryNextStationPlan(stationPlan.getStation()); } } } } + public RoutePath selectRoutePath(List routePaths) { + Optional min = routePaths.stream().min((rp1, rp2) -> rp1.getReverseSwitchQuantity() < rp2.getReverseSwitchQuantity() ? -1 : 1); + return min.orElse(null); + } + public void addJobs(Simulation simulation) { simulation.addJob(NAME, () -> this.run(simulation), RATE); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationPlan.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationPlan.java index eea2ea222..f50a47599 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationPlan.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationPlan.java @@ -25,6 +25,11 @@ public class CtcStationPlan { */ private StationPlan departurePlan; + /** + * 接车股道占用 + */ + private boolean receivingSectionOccupied; + private boolean receivingNotice; private Route receivingRoute; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/TrackView.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/TrackView.java index 4daa825cc..021592ef9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/TrackView.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/TrackView.java @@ -20,10 +20,15 @@ public class TrackView { @Setter public static class Line { /** - * 轨道名 + * 股道名 */ private String trackName; + /** + * 股道占用 + */ + private boolean occupied; + /** * 车次号 */ @@ -89,6 +94,7 @@ public class TrackView { public Line(CtcStationPlan plan) { this.trackName = plan.getReceivingPlan().getSection().getName(); + this.occupied = plan.isReceivingSectionOccupied(); this.tripNumber = plan.getTripNumber(); // this.trainType = // this.trainDistanceInfo