From 0c1e5f22689ba859e8efc3057e4cf71184910369 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 22 Apr 2022 13:47:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E9=93=81CTC=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=88=E6=9C=AA=E5=AE=8C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mvnw | 2 +- .../rtss/constants/MapPrdTypeEnum.java | 1 + .../controller/draft/DraftMapController.java | 10 +- .../rtss/services/MapSystemService.java | 14 +- .../cbtc/ATS/operation/Operation.java | 5 + .../simulation/cbtc/CTC/CTCLogicLoop.java | 203 ++++++++++++++---- .../rtss/simulation/cbtc/CTC/CTCService.java | 8 + .../simulation/cbtc/CTC/data/BusyBoard.java | 8 +- .../cbtc/CTC/data/CtcRepository.java | 28 ++- .../cbtc/CTC/data/CtcStationPlan.java | 73 +++++-- .../cbtc/CTC/data/RouteSequence.java | 49 ++++- .../simulation/cbtc/CTC/data/TrackView.java | 57 ++++- .../operation/BusyBoardOperateHandler.java | 4 + .../rtss/simulation/cbtc/Simulation.java | 1 + .../cbtc/build/InterlockBuilder2.java | 28 ++- .../cbtc/build/UserConfigDataBuilder.java | 12 +- .../cbtc/constant/SimulationModule.java | 5 - .../cbtc/data/SimulationDataRepository.java | 7 + .../rtss/simulation/cbtc/data/map/Route.java | 4 + .../cbtc/data/plan/StationPlan.java | 4 + .../cbtc/data/status/RouteStatus.java | 12 ++ .../cbtc/data/support/RoutePath.java | 12 ++ .../cbtc/data/vo/RouteStatusVO.java | 3 + .../rtss/vo/client/WebSocketMessageType.java | 4 +- .../client/factory/SocketMessageFactory.java | 6 + 25 files changed, 431 insertions(+), 129 deletions(-) diff --git a/mvnw b/mvnw index a16b5431b..61a449885 100644 --- a/mvnw +++ b/mvnw @@ -161,7 +161,7 @@ fi CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher -# traverses directory structure from process work directory to filesystem root +# traverses directory structure from mean work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { diff --git a/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java b/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java index d4c1d3a87..89be3f646 100644 --- a/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java +++ b/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java @@ -13,6 +13,7 @@ public enum MapPrdTypeEnum { BIG_SCREEN("07", "大屏工作站"), RUN_PLAN_MAKE("08", "运行图编制工作站"), DEPOT_IL("09", "车辆段联锁工作站"), + CTC("10", "CTC工作站") ; private String code; diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapController.java index 3b363180b..3eb4ec0a9 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapController.java @@ -769,9 +769,9 @@ public class DraftMapController { iDraftMapService.deleteOperationDefinition(mapId, code); } -// //临时接口 -// @PostMapping("/handle/ctc/{id}") -// public void handle(@PathVariable Long id) { -// iDraftMapService.handle(id); -// } + //临时接口 + @PostMapping("/handle/ctc/{id}") + public void handle(@PathVariable Long id) { + iDraftMapService.handle(id); + } } diff --git a/src/main/java/club/joylink/rtss/services/MapSystemService.java b/src/main/java/club/joylink/rtss/services/MapSystemService.java index 819eb429e..4218e85c3 100644 --- a/src/main/java/club/joylink/rtss/services/MapSystemService.java +++ b/src/main/java/club/joylink/rtss/services/MapSystemService.java @@ -5,8 +5,6 @@ import club.joylink.rtss.dao.MapSystemDAO; import club.joylink.rtss.entity.MapSystem; import club.joylink.rtss.entity.MapSystemExample; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import club.joylink.rtss.services.org.IOrgLessonService; -import club.joylink.rtss.services.org.IOrgService; import club.joylink.rtss.services.org.IOrgUserService; import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.LoginUserInfoVO; @@ -58,12 +56,6 @@ public class MapSystemService implements IMapSystemService { @Autowired private IOrgUserService iOrgUserService; - @Autowired - private IOrgService iOrgService; - - @Autowired - private IOrgLessonService iOrgLessonService; - @Autowired private IExamService iExamService; @@ -73,6 +65,12 @@ public class MapSystemService implements IMapSystemService { BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(iMapService.isExist(mapId), String.format("id为[%s]的地图不存在", mapId)); for (MapPrdTypeEnum value : MapPrdTypeEnum.values()) { + if (MapPrdTypeEnum.CTC.equals(value)) { + MapVO mapDetail = iMapService.getMapDetail(mapId); + if (!mapDetail.getConfigVO().isHasCTC()) { + continue; + } + } generate(mapId, value); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java index e7301da3a..ef2e5e1ea 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java @@ -455,6 +455,11 @@ public class Operation { */ CTC_DEPARTURE_NOTICE, + /** + * CTC进路自触 + */ + CTC_ROUTE_AUTO_TRIGGER, + //---------------------------- 改方、辅助操作 ------------------------- /** * 按下改方按钮 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 dac199ba2..efdb87ed8 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 @@ -1,26 +1,145 @@ package club.joylink.rtss.simulation.cbtc.CTC; -import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository; -import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationPlan; +import club.joylink.rtss.simulation.cbtc.ATS.service.ars.AtsRouteSelectService; +import club.joylink.rtss.simulation.cbtc.CTC.data.*; import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; -import club.joylink.rtss.simulation.cbtc.data.map.Routing; +import club.joylink.rtss.simulation.cbtc.data.map.Route; 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.plan.StationPlan; import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; +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.vo.client.SocketMessageVO; +import club.joylink.rtss.vo.client.factory.SocketMessageFactory; +import club.joylink.rtss.websocket.StompMessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; -import java.util.List; +import java.util.*; @Component public class CTCLogicLoop { + public static final String NAME = "CTC"; + public static final int RATE = 1000; + + @Autowired + @Qualifier(value = "atsPlanTrainRouteSelectServiceImpl") + private AtsRouteSelectService atsRouteSelectService; + + @Autowired + private StompMessageService stompMessageService; + public void run(Simulation simulation) { + buildNewCtcStationPlan(simulation); + updateCtcStationPlan(simulation); + sendMessage(simulation); + } + + private void sendMessage(Simulation simulation) { + CtcRepository ctcRepository = simulation.getCtcRepository(); + List list = new ArrayList<>(); + Map> map = ctcRepository.getCtcStationPlanMap(); + for (Map.Entry> entry : map.entrySet()) { + String stationCode = entry.getKey(); + BusyBoard busyBoard = new BusyBoard(stationCode); + list.add(busyBoard); + TrackView trackView = busyBoard.getTrackView(); + RouteSequence routeSequence = busyBoard.getRouteSequence(); + for (CtcStationPlan value : entry.getValue().values()) { + trackView.addLine(new TrackView.Line(value)); + RouteSequence.Line receivingLine = RouteSequence.Line.buildReceivingLine(value); + if (receivingLine != null) { + receivingLine.setStartTime(simulation.getCorrectSystemTime().toLocalTime()); + routeSequence.addLine(receivingLine); + } + RouteSequence.Line departureLine = RouteSequence.Line.buildDepartureLine(value); + if (departureLine != null) { + departureLine.setStartTime(simulation.getCorrectSystemTime().toLocalTime()); + routeSequence.addLine(departureLine); + } + } + routeSequence.getLines().sort((o1, o2) -> o1.getPlanTime().isBefore(o2.getPlanTime()) ? -1 : 1); + } + if (!CollectionUtils.isEmpty(list)) { + SocketMessageVO> message = SocketMessageFactory.buildRailCtcMessage(simulation.getId(), list); + Set userIds = simulation.getSimulationUserIds(); + stompMessageService.sendToUser(userIds, message); + } + } + + private void updateCtcStationPlan(Simulation simulation) { + SimulationDataRepository repository = simulation.getRepository(); + CtcRepository ctcRepository = simulation.getCtcRepository(); + Map deleteMap = new HashMap<>(); + for (Map ctcStationPlanMap : ctcRepository.getCtcStationPlanMap().values()) { + Collection ctcStationPlans = ctcStationPlanMap.values(); + for (CtcStationPlan ctcStationPlan : ctcStationPlans) { + if (ctcStationPlan.getDeleteRemain() != 0) { //流程终止、准备删除 + int deleteRemain = ctcStationPlan.getDeleteRemain(); + deleteRemain -= RATE; + if (deleteRemain <= 0) { + deleteMap.put(ctcStationPlan.getStationCode(), ctcStationPlan.getTripNumber()); + } + } + /* 按接发车流程倒序检查 */ + StationPlan receivingPlan = ctcStationPlan.getReceivingPlan(); + boolean planRight = receivingPlan.isRight(); + Section receivingSection = receivingPlan.getSection(); + VirtualRealityTrain train = repository.getOnlineTrainBy(ctcStationPlan.getTrainInfo().getGroupNumber()); + SectionPosition headPosition = train.getHeadPosition(); + //发点 + Signal departureSignal = receivingSection.getSignalOf(planRight); //发车信号机 + if (headPosition.isAheadOf(departureSignal.getPosition(), planRight)) { + ctcStationPlan.updateProcess(CtcStationPlan.Process.FINISH); + ctcStationPlan.setDeleteRemain(CtcStationPlan.DEFAULT_REMAIN); + } + //发车进路办理 + if (!ctcStationPlan.isDepartureRouteLock()) { + if (ctcStationPlan.getDepartureRoute().isLock()) { + ctcStationPlan.setDepartureRouteLock(true); + } + } + if (ctcStationPlan.isDepartureRouteLock()) { + ctcStationPlan.updateProcess(CtcStationPlan.Process.DEPARTURE); + } + //发预 + if (ctcStationPlan.isDepartureNotice() && ctcStationPlan.getDeparturePlan() != null) { //邻站发车预告 + CtcStationPlan departureCtcStationPlan = ctcRepository + .getCtcStationPlan(ctcStationPlan.getDeparturePlan().getStation().getCode(), ctcStationPlan.getTripNumber()); + departureCtcStationPlan.updateProcess(CtcStationPlan.Process.RECEIVING); + } + //到点 + Signal receivingSignal = receivingSection.getSignalOf(!planRight); //接车信号机 + if (headPosition.isAheadOf(receivingSignal.getPosition(), planRight)) { + ctcStationPlan.setArrive(true); + } + //接车进路办理 + if (!ctcStationPlan.isReceivingRouteLock()) { + if (ctcStationPlan.getReceivingRoute().isLock()) { + ctcStationPlan.setReceivingRouteLock(true); + } + } + if (ctcStationPlan.isReceivingRouteLock()) { + ctcStationPlan.updateProcess(CtcStationPlan.Process.ARRIVE); + } + //接预 + if (ctcStationPlan.isReceivingNotice()) { + ctcStationPlan.updateProcess(CtcStationPlan.Process.RECEIVING_ROUTE); + } + } + } + for (Map.Entry entry : deleteMap.entrySet()) { + ctcRepository.deleteCtcStationPlan(entry.getKey(), entry.getValue()); + } + } + + private void buildNewCtcStationPlan(Simulation simulation) { SimulationDataRepository repository = simulation.getRepository(); CtcRepository ctcRepository = simulation.getCtcRepository(); List superviseTrainList = repository.getSuperviseTrainList(); @@ -31,47 +150,47 @@ public class CTCLogicLoop { } TripPlan tripPlan = repository.getTripPlan(trainInfo.getServiceNumber(), trainInfo.getTripNumber()); VirtualRealityTrain train = repository.getOnlineTrainBy(trainInfo.getGroupNumber()); - SectionPosition headPosition = train.getHeadPosition(); - CtcStationPlan ctcStationPlan = new CtcStationPlan(); - ctcStationPlan.setTripNumber(tripPlan.getTripNumber()); - if (trainInfo.isParking()) { - //接车信息(已完成) - Section headSection = headPosition.getSection(); - StationPlan currentStationPlan = tripPlan.queryStationPlan(headSection); - ctcStationPlan.setReceivingPlan(currentStationPlan); - ctcStationPlan.setReceivingRouteLock(true); - ctcStationPlan.setArrive(true); - //发车信息 - StationPlan nextStationPlan = tripPlan.queryNextStationPlan(headSection); - ctcStationPlan.setDeparturePlan(nextStationPlan); - Signal signal = headSection.getSignalOf(tripPlan.isRight()); - List routings = repository.getRoutings(tripPlan.getStartSection(), tripPlan.getEndSection(), tripPlan.isRight()); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionNotEmpty(routings); - Routing routing = routings.get(0); + StationPlan stationPlan = tripPlan.queryNextStationPlanByStationCode(trainInfo.getStationCode()); + Section previousSection = train.getHeadPosition().getSection(); //前一个的停车区段 + while (stationPlan != null) { + CtcStationPlan ctcStationPlan = new CtcStationPlan(trainInfo, stationPlan); + ctcRepository.addCtcStationPlan(ctcStationPlan); + Section headSection = train.getHeadPosition().getSection(); + List paths = repository.queryRoutePathsByEndAndContainsSection(stationPlan.getSection(), previousSection); + if (!CollectionUtils.isEmpty(paths)) { + /* 接车 */ + if (headSection.equals(stationPlan.getSection())) { //到站了 + ctcStationPlan.setReceivingNotice(true); + ctcStationPlan.setReceivingRouteLock(true); + ctcStationPlan.setArrive(true); + ctcStationPlan.updateProcess(CtcStationPlan.Process.ARRIVE); + } else { //没到站 + RoutePath routePath = atsRouteSelectService.selectRoutePath(paths); + Route receivingRoute = routePath.getLastRoute(); + ctcStationPlan.setReceivingRoute(receivingRoute); + ctcStationPlan.updateProcess(CtcStationPlan.Process.RECEIVING); + } + /* 发车 */ + List routePaths; + StationPlan nextStationPlan = tripPlan.queryNextStationPlan(stationPlan.getStation()); + if (nextStationPlan != null) { + routePaths = repository.getRoutePaths(stationPlan.getSection(), nextStationPlan.getSection()); + ctcStationPlan.setDeparturePlan(nextStationPlan); + } else { + routePaths = repository.getRoutePaths(stationPlan.getSection(), tripPlan.getEndSection()); + } + RoutePath routePath = atsRouteSelectService.selectRoutePath(routePaths); + Route departureRoute = routePath.getFirstRoute(); + ctcStationPlan.setDepartureRoute(departureRoute); + } + previousSection = stationPlan.getSection(); + stationPlan = tripPlan.queryNextStationPlan(stationPlan.getStation()); } } } - - -// CtcRepository ctcRepository = new CtcRepository(); //添加到simulation中 -// if (CollectionUtils.isEmpty(ctcRepository.getStationBusyBoardMap())) { -// List allTripPlanList = simulation.getRepository().getAllTripPlanList(); -// Map> stationPlanMap = allTripPlanList.stream() -// .flatMap(tripPlan -> tripPlan.getPlanList().stream()) -// .collect(Collectors.groupingBy(StationPlan::getStation)); -// for (Map.Entry> entry : stationPlanMap.entrySet()) { -// Station station = entry.getKey(); -// List plans = entry.getValue(); -// BusyBoard busyBoard = new BusyBoard(); -// busyBoard.setStationCode(station.getCode()); -// -// ctcRepository.addBusyBoard(busyBoard); -// } -// } - } public void addJobs(Simulation simulation) { - simulation.addJob(SimulationModule.CTC.name(), () -> this.run(simulation), SimulationModule.CTC.getRateMs()); + simulation.addJob(NAME, () -> this.run(simulation), RATE); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCService.java index 22648de04..723e4dc8d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCService.java @@ -4,6 +4,8 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository; import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationPlan; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.Route; import org.springframework.stereotype.Component; @Component @@ -29,4 +31,10 @@ public class CTCService { CtcStationPlan ctcStationPlan = ctcRepository.findCtcStationPlan(stationCode, tripNumber); ctcStationPlan.setDepartureNotice(true); } + + public void routeAutoTrigger(Simulation simulation, String routeCode, boolean trigger) { + SimulationDataRepository repository = simulation.getRepository(); + Route route = repository.getRoute(routeCode); + route.setCtcControl(trigger); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/BusyBoard.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/BusyBoard.java index bbd5d8766..74bde90f6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/BusyBoard.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/BusyBoard.java @@ -10,10 +10,14 @@ public class BusyBoard { /** * 股道视图 */ - private TrackView trackView; + private TrackView trackView = new TrackView(); /** * 进路序列 */ - private RouteSequence routeSequence; + private RouteSequence routeSequence = new RouteSequence(); + + public BusyBoard(String stationCode) { + this.stationCode = stationCode; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java index 07569e2c6..c4bfe8a77 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.CTC.data; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import lombok.Getter; import org.springframework.util.CollectionUtils; @@ -8,22 +9,12 @@ import java.util.concurrent.ConcurrentHashMap; @Getter public class CtcRepository { - private final Map stationBusyBoardMap = new ConcurrentHashMap<>(); - /** * k - stationCode * k-tripNumber */ private final Map> ctcStationPlanMap = new ConcurrentHashMap<>(); - public void addBusyBoard(BusyBoard busyBoard) { - stationBusyBoardMap.put(busyBoard.getStationCode(), busyBoard); - } - - public BusyBoard getBusyBoard(String stationCode) { - return stationBusyBoardMap.get(stationCode); - } - public void addCtcStationPlan(CtcStationPlan stationPlan) { Map map = ctcStationPlanMap.computeIfAbsent(stationPlan.getReceivingPlan().getStation().getCode(), (k) -> new ConcurrentHashMap<>()); @@ -42,4 +33,21 @@ public class CtcRepository { return ctcStationPlanMap.entrySet().stream() .anyMatch(entry -> entry.getValue().containsKey(tripNumber)); } + + public CtcStationPlan getCtcStationPlan(String stationCode, String tripNumber) { + CtcStationPlan plan = findCtcStationPlan(stationCode, tripNumber); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(plan); + return plan; + } + + public void deleteCtcStationPlan(String stationCode, String tripNumber) { + Map map = ctcStationPlanMap.get(stationCode); + if (!CollectionUtils.isEmpty(map)) { + map.remove(tripNumber); + } + } + + public void reset() { + this.ctcStationPlanMap.clear(); + } } 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 2bee7f582..d68e9f4df 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 @@ -2,6 +2,8 @@ package club.joylink.rtss.simulation.cbtc.CTC.data; import club.joylink.rtss.simulation.cbtc.data.map.Route; import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan; +import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; @@ -11,7 +13,7 @@ import lombok.Setter; @Getter @Setter public class CtcStationPlan { - private String tripNumber; + private TrainInfo trainInfo; /** * 该车站的接车计划 @@ -23,11 +25,6 @@ public class CtcStationPlan { */ private StationPlan departurePlan; - /** - * 邻站的发车预告 - */ - private boolean adjacentDepartureNotice; - private boolean receivingNotice; private Route receivingRoute; @@ -50,20 +47,60 @@ public class CtcStationPlan { private boolean departure; - @Getter - public enum Process { - RECEIVING_NOTICE("接预"), //接预 - RECEIVING_ROUTE("接路"), //接路 - ARRIVE("到点"), //到点 - DEPARTURE_NOTICE("发预"), //发预 - DEPARTURE_ROUTE("发路"), //发路 - DEPARTURE("发点"), //发点 - ; + @Setter(AccessLevel.NONE) + private Process process; - private final String name; + /** + * 删除倒计时(流程终止后10秒删除) + */ + private int deleteRemain; + public static final int DEFAULT_REMAIN = 10 * 1000; - Process(String name) { - this.name = name; + public CtcStationPlan(TrainInfo trainInfo, StationPlan receivingPlan) { + this.trainInfo = trainInfo; + this.receivingPlan = receivingPlan; + } + + public String getTripNumber() { + return trainInfo.getTripNumber(); + } + + public void updateProcess(Process process) { + if (this.process == null) { + this.process = process; + } else { + if (this.process.ordinal() < process.ordinal()) { + this.process = process; + } } } + + public String getStationCode() { + return receivingPlan.getStation().getCode(); + } + + public enum Process { + RECEIVING, //准备接车 + RECEIVING_ROUTE, //办理接车进路 + ARRIVE, //列车到达(通过)报点 + DEPARTURE, //发车进路办理、发车报点 + FINISH //流程终止 + } + +// @Getter +// public enum Mean { +// RECEIVING_NOTICE("接预"), //接预 +// RECEIVING_ROUTE("接路"), //接路 +// ARRIVE("到点"), //到点 +// DEPARTURE_NOTICE("发预"), //发预 +// DEPARTURE_ROUTE("发路"), //发路 +// DEPARTURE("发点"), //发点 +// ; +// +// private final String name; +// +// Mean(String name) { +// this.name = name; +// } +// } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/RouteSequence.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/RouteSequence.java index 305308441..c9bc35c6d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/RouteSequence.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/RouteSequence.java @@ -1,26 +1,31 @@ package club.joylink.rtss.simulation.cbtc.CTC.data; -import lombok.Builder; import lombok.Getter; import lombok.Setter; import java.time.LocalTime; +import java.util.ArrayList; import java.util.List; /** * 进路序列 */ +@Getter +@Setter public class RouteSequence { /** * 进路序列模式:可修改/只读 */ - private String mode; + private boolean readOnly; - private List lines; + private List lines = new ArrayList<>(); + + public void addLine(Line line) { + this.lines.add(line); + } @Getter @Setter - @Builder public static class Line { /** * 车次 @@ -32,10 +37,10 @@ public class RouteSequence { */ private String trackName; - /** - * 自触? - */ - private boolean autoTrigger; +// /** +// * 自触? +// */ +// private boolean autoTrigger; /** * 类型 @@ -55,6 +60,32 @@ public class RouteSequence { /** * 序列描述(大概是进路名称吧) */ - private String routeName; + private String routeCode; + + public static Line buildReceivingLine(CtcStationPlan plan) { + if (plan.getReceivingRoute() != null) { + Line line = new Line(); + line.tripNumber = plan.getTripNumber(); + line.trackName = plan.getReceivingPlan().getSection().getName(); + line.type = "接车"; + line.planTime = plan.getReceivingPlan().getArriveTime(); + line.routeCode = plan.getReceivingRoute().getCode(); + return line; + } + return null; + } + + public static Line buildDepartureLine(CtcStationPlan plan) { + if (plan.getDepartureRoute() != null) { + Line line = new Line(); + line.tripNumber = plan.getTripNumber(); + line.trackName = plan.getReceivingPlan().getSection().getName(); + line.type = "发车"; + line.planTime = plan.getReceivingPlan().getLeaveTime(); + line.routeCode = plan.getDepartureRoute().getCode(); + return line; + } + return null; + } } } 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 9f5f264bf..6cda997ea 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 @@ -1,19 +1,23 @@ package club.joylink.rtss.simulation.cbtc.CTC.data; -import lombok.Builder; import lombok.Getter; import lombok.Setter; import java.time.LocalTime; +import java.util.ArrayList; import java.util.List; @Getter @Setter public class TrackView { + private List lines = new ArrayList<>(); + + public void addLine(Line line) { + this.lines.add(line); + } @Getter @Setter - @Builder public static class Line { /** * 轨道名 @@ -38,12 +42,26 @@ public class TrackView { /** * 接发车流程 */ - private Process process; + private CtcStationPlan.Process process; /** - * 接预、发预等按钮 + * 接预 */ - private List