From 239c3c9f08532d7acd3f3d5151ba3cc010c18122 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 27 Jul 2021 14:20:36 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9<=E8=B6=8A=E7=BA=A2?= =?UTF-8?q?=E7=81=AF><=E7=A1=AE=E8=AE=A4=E8=BF=90=E8=A1=8C=E8=87=B3?= =?UTF-8?q?=E5=89=8D=E6=96=B9=E7=AB=99>=E6=8C=87=E4=BB=A4=E5=AF=B9?= =?UTF-8?q?=E9=A9=BE=E9=A9=B6=E6=A8=A1=E5=BC=8F=E7=9A=84=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../club/joylink/rtss/simulation/cbtc/command/CommandBO.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 b2975b136..a352902c7 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 @@ -186,7 +186,7 @@ public class CommandBO { if (!train.isStopAtThePosition(driveStep.getTargetPosition())) { //如果列车没停到目标位置 if (!train.isStop()) return buildDriverForceChangeOperationStep(train.getGroupNumber(), -1); - if (!DriveMode.RM.equals(train.getDriveMode())) + if (!DriveMode.RM.equals(train.getDriveMode()) && !train.isNRMMode()) return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.RM); if (train.isEB()) return buildReleaseEBStep(train); @@ -305,7 +305,7 @@ public class CommandBO { // command.getTargetMember().setCommand(null); // } } else { - if (!DriveMode.RM.equals(train.getDriveMode())) { + if (!DriveMode.RM.equals(train.getDriveMode()) && !train.isNRMMode()) { return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.RM); } if (train.isSignalEB()) { From bbd36ea889c8c662d553c032c87ea4aba2f28652 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 27 Jul 2021 17:41:23 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=9D=9ECTC=E8=BF=9B?= =?UTF-8?q?=E8=B7=AF=E7=9A=84=E8=81=94=E9=94=81=E6=A3=80=E6=9F=A5=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/CI/service/RouteService.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java index 9cfcd2307..03be59ebf 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java @@ -280,15 +280,18 @@ public class RouteService { // 进路内区段占用检查 List
sectionList = route.getSectionList(); for (Section section : sectionList) { - if (section.isOccupied() && !section.isPreReset()) { - if (section.isSwitchTrack()) { - if (!section.getRelSwitch().isPreReset()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); - } - } else { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); - } + if (section.isOccupied()) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); } +// if (section.isOccupied() && !section.isPreReset()) { +// if (section.isSwitchTrack()) { +// if (!section.getRelSwitch().isPreReset()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); +// } +// } else { +// return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); +// } +// } } // 延续保护检查 RouteOverlap overlap = route.getOverlap(); From eaabfd124ecdd4a40b086d18c41882fde6cc541f Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 27 Jul 2021 18:01:55 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E9=97=A8=E7=9B=B8=E5=85=B3psl=E7=9B=98=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E3=80=81ats=E7=8A=B6=E6=80=81=E3=80=81=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java | 2 +- .../joylink/rtss/simulation/cbtc/data/status/PSDStatus.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java index 6efbd138f..a417b9014 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java @@ -696,7 +696,7 @@ public class ZCLogicLoop { if (section.isStandTrack()) { List standList = section.getStandList(); for (Stand stand : standList) { - if (!stand.isInterlockRelease() && stand.isPsdOpen()) { + if (!stand.isPsdSafe()) { return new MovementAuthority.End(stand, MovementAuthority.EndType.OPENED_PSD, section); } if (stand.isClosed()) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/PSDStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/PSDStatus.java index b79c42610..c5be435f3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/PSDStatus.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/PSDStatus.java @@ -38,7 +38,7 @@ public class PSDStatus extends DeviceStatus { public PSDStatus(PSD psd) { super(psd.getCode(), psd.getDeviceType()); - this.close = psd.isClose(); + this.close = psd.isCloseAndLock(); // this.lock = psd.isLock(); this.interlockRelease = psd.isInterlockRelease(); this.noStatus = psd.isNoStatus(); @@ -50,7 +50,7 @@ public class PSDStatus extends DeviceStatus { PSDStatusVO status = (PSDStatusVO)statusVO; boolean change = false; if (!Objects.equals(this.close, psd.isClose())) { - this.close = psd.isClose(); + this.close = psd.isCloseAndLock(); status.setClose(this.close); change = true; } From 55251a833ebf955ddf44707ec2d8f439574a76ea Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 27 Jul 2021 18:10:28 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=B0=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/simulation/cbtc/data/status/PSDStatus.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/PSDStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/PSDStatus.java index c5be435f3..b4cb13ecf 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/PSDStatus.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/PSDStatus.java @@ -49,7 +49,7 @@ public class PSDStatus extends DeviceStatus { PSD psd = (PSD) device; PSDStatusVO status = (PSDStatusVO)statusVO; boolean change = false; - if (!Objects.equals(this.close, psd.isClose())) { + if (!Objects.equals(this.close, psd.isCloseAndLock())) { this.close = psd.isCloseAndLock(); status.setClose(this.close); change = true; From da58bce36c1b798da9c344ceec94f468767ef851 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 28 Jul 2021 17:00:34 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E7=8E=B0=E5=9C=B0=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=A2=9E=E5=8A=A0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/club/joylink/rtss/vo/map/display/DisplayVO.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/club/joylink/rtss/vo/map/display/DisplayVO.java b/src/main/java/club/joylink/rtss/vo/map/display/DisplayVO.java index 460f85215..12cca72b4 100644 --- a/src/main/java/club/joylink/rtss/vo/map/display/DisplayVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/display/DisplayVO.java @@ -13,4 +13,7 @@ public class DisplayVO { private List stationCodeList; private List elementList; + + /** 可切换显示的车站 */ + private List switchStationCodeList; } From 0a7b17bee263bf5aff7c6131e2430bf9162e3908 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 28 Jul 2021 18:05:57 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=97=E8=BD=A6?= =?UTF-8?q?=E9=A9=BE=E9=A9=B6=E6=A8=A1=E5=BC=8F=E5=88=87=E6=8D=A2=E3=80=81?= =?UTF-8?q?=E5=8C=BA=E6=AE=B5=E5=8D=A0=E7=94=A8=E5=88=A4=E6=96=AD=E3=80=81?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E6=8E=88=E6=9D=83=E8=AE=A1=E7=AE=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATP/ground/AtpSectionService.java | 6 +- .../cbtc/ATP/ground/ZCLogicLoop.java | 33 +------- .../cbtc/ATS/data/AtsTrainInfo.java | 4 +- .../handler/DriverOperateHandler.java | 27 ++----- .../ATS/service/AtsRouteSettingService.java | 4 +- .../cbtc/ATS/service/AtsTrainLoadService.java | 2 +- .../cbtc/ATS/service/AtsTrainService.java | 1 + .../cbtc/data/support/RoutePath.java | 6 +- .../simulation/cbtc/data/vo/TrainInfo.java | 25 +++--- .../cbtc/data/vr/VirtualRealityTrain.java | 77 +++++++++++-------- .../cbtc/onboard/ATO/service/ATOService.java | 7 +- .../cbtc/onboard/ATP/ATPLogicLoop.java | 28 +++++++ .../onboard/ATP/OnboardAtpApiService.java | 5 -- .../onboard/ATP/OnboardAtpApiServiceImpl.java | 26 +------ 14 files changed, 114 insertions(+), 137 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java index 8ed28bccb..22940e3ae 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java @@ -86,9 +86,9 @@ public class AtpSectionService { for (VirtualRealityTrain train : onlineTrainList) { List
atpSectionList = trainAtpSectionMap.get(train.getGroupNumber()); List
physicalList = this.convert2PhysicalSectionList(atpSectionList); - if (train.isCBTC() && signal.containsApproachAtpSection(atpSectionList)) { //通信车在atp接近区段上 + if (train.isCommunicable() && signal.containsApproachAtpSection(atpSectionList)) { //通信车在atp接近区段上 approachMsg = SignalApproachMessage.ApproachMessage.CBTC; - } else if (!train.isCBTC() && signal.containsApproachPhysicalSection(physicalList)) { //非通信车在物理接近区段上 + } else if (!train.isCommunicable() && signal.containsApproachPhysicalSection(physicalList)) { //非通信车在物理接近区段上 approachMsg = SignalApproachMessage.ApproachMessage.NCT; nctApproachSignalMap.put(train, signal); } @@ -142,7 +142,7 @@ public class AtpSectionService { SimulationDataRepository repository = simulation.getRepository(); atpSectionList = CalculateService.getAtpSections(trainHeadPosition, trainTailPosition, right, repository.getConfig().isSwitchSingleHandle()); - if (train.isCBTC()) { // cbtc通信车占用 + if (train.isCommunicable()) { // 通信车占用 atpSectionList.forEach(atpSection -> atpSection.communicateTrainOccupy(right)); } else { // 非通信车 Set
collect = atpSectionList.stream().map(section -> { //找到列车占压区段所属的物理区段 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java index a417b9014..5c949a5a2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java @@ -74,35 +74,13 @@ public class ZCLogicLoop { })); } //更新CBTC ma - if (headPosition.getSection().anyZcWorking()) { + if (train.isCommunicable()) { this.calculateMAOfCBTC(simulation, train, trainList); } -// //更新CBTC ma -// if (!deviceStation.getZc().isFault()) { //如果列车头所在区段所属设备集中站zc未故障 -// this.calculateMAOfCBTC(simulation, train, trainList); -// } } }); } - /** - * 为升级CM而强制更新ma(简单处理) - * @return 是否更新成功 - */ - public boolean updateCbtcMa4CM(Simulation simulation, VirtualRealityTrain train) { - RunLevel defaultRunLevel = simulation.getRepository().getConfig().getRunMode(); - if (RunLevel.CBTC.equals(defaultRunLevel)) { - List trainList = simulation.getRepository().getOnlineTrainList(); - SectionPosition headPosition = train.getHeadPosition(); - if (headPosition.getSection().anyZcWorking()) { - List endList = this.findMaEnd(simulation, train, trainList); - MovementAuthority ma = this.compareAndBuildMa(train, endList); - return onboardAtpApiService.ignoreDriveModeUpdateMA4CBTC(train, ma); - } - } - return false; - } - private void calculateMAOfCBTC(Simulation simulation, VirtualRealityTrain train, List trainList) { // 查找移动授权终端列表 @@ -154,13 +132,8 @@ public class ZCLogicLoop { // } //非通信车占用区段 if (section.isNonCbtcOccupy() && !section.isInvalid()) { - VirtualRealitySectionAxleCounter axle = section.getVirtualAxleCounter(); - if (axle == null && section.getParent() != null) - axle = section.getParent().getVirtualAxleCounter(); - if (axle == null || axle.getLeftCount() > 1 || axle.getRightCount() > 1) { //以计轴器计数为1作为是当前列车导致区段非通信车占用的判断依据 - endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.NCT_OCCUPIED_SECTION)); - return endList; - } + endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.NCT_OCCUPIED_SECTION)); + return endList; } //通信车占用区段 List
occupiedLogicSectionList = simulation.getRepository().queryTrainOccupyAtpSectionList(train.getGroupNumber()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/data/AtsTrainInfo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/data/AtsTrainInfo.java index e53b39413..760b018c3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/data/AtsTrainInfo.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/data/AtsTrainInfo.java @@ -34,7 +34,7 @@ public class AtsTrainInfo { private String crewNumber; /** 车载服务通讯是否正常在线 */ - private boolean online; + private boolean communication; /** 所在物理区段 */ private Section headSection; /** 物理区段偏移量 */ @@ -151,7 +151,7 @@ public class AtsTrainInfo { * @param vrTrain */ public synchronized void trackFromVrTrain(VirtualRealityTrain vrTrain) { - this.online = vrTrain.isOnline(); + this.communication = vrTrain.isCommunication(); SectionPosition headPosition = vrTrain.getHeadPosition(); this.headSection = headPosition.getSection(); this.offset = headPosition.getOffset(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java index 168c7fd95..3951699a0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java @@ -1,9 +1,11 @@ package club.joylink.rtss.simulation.cbtc.ATS.operation.handler; +import club.joylink.rtss.simulation.cbtc.ATP.ground.GroundAtpApiService; import club.joylink.rtss.simulation.cbtc.ATP.ground.ZCLogicLoop; import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping; +import club.joylink.rtss.simulation.cbtc.CI.CILogicLoop; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.ControlGear; @@ -39,6 +41,9 @@ public class DriverOperateHandler { @Autowired private ZCLogicLoop zcLogicLoop; + @Autowired + private GroundAtpApiService groundAtpApiService; + @OperateHandlerMapping(type = Operation.Type.Driver_Force_Change) public void changeTrainForce(Simulation simulation, String groupNumber, Float percent) { Objects.requireNonNull(percent); @@ -114,28 +119,12 @@ public class DriverOperateHandler { public void changeTrainDriveMode(Simulation simulation, String groupNumber, DriveMode driveMode) { VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber); switch (driveMode) { - case CM: { - if (!train.isAtpOn()) { - throw new SimulationException(SimulationExceptionType.Invalid_Operation, - String.format("列车[%s]ATP未开启,无法升级CM驾驶模式", train.getGroupNumber())); - } - if (zcLogicLoop.updateCbtcMa4CM(simulation, train)) { - train.useCMMode(); - } - break; - } + case AM: + case CM: case RM: { - if (!train.isAtpOn()) { - throw new SimulationException(SimulationExceptionType.Invalid_Operation, - String.format("列车[%s]ATP未开启,无法升级RM驾驶模式", train.getGroupNumber())); - } - train.useRMMode(); + train.setPreDriveMode(driveMode); break; } - case NRM: - ATPService.cutOffAtp(train); -// train.useNRMMode(); - break; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java index 1c0192b65..c91716e78 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteSettingService.java @@ -752,8 +752,8 @@ public class AtsRouteSettingService { ++count; Signal signal = base.getSignalOf(right); if (Objects.isNull(signal) || !signal.isClose() || - (!train.isCbtcTrack() && signal.isVirtual())) { - // 指定方向信号机不存在,或已经开放,或非CTC列车碰到虚拟信号机,继续往下找 + (!train.isCommunication() && signal.isVirtual())) { + // 指定方向信号机不存在,或已经开放,或非通信车碰到虚拟信号机,继续往下找 base = base.getNextRunningSectionOf(right); continue; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java index 9bb7aa5b4..30d3fd4e1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java @@ -593,7 +593,7 @@ public class AtsTrainLoadService { Section end = viaSectionList.get(i); // 取相邻两区段的路径单元,查询进路 RoutePath routePath = this.selectDefaultRoutePath(repository, start, end); - Route route = routePath.queryRouteContainsSection(train.getRunLevel(), headSection, repository.getConfig()); + Route route = routePath.queryRouteContainsSection(train.isCommunicable(), headSection, repository.getConfig()); if (Objects.nonNull(route)) { // 排列好进路 this.deviceStatusModifyTool.openRouteDirect(simulation, route); 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 28d13e031..c6425d677 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 @@ -20,6 +20,7 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService; import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService; +import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/RoutePath.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/RoutePath.java index 54f07c07e..4a150f13c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/RoutePath.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/RoutePath.java @@ -290,7 +290,7 @@ public class RoutePath { return new SectionPosition(target, offset); } - public Route queryRouteContainsSection(RunLevel runLevel, Section section, MapConfig config) { + public Route queryRouteContainsSection(boolean communication, Section section, MapConfig config) { for (Signal signal : this.signalList) { List routeList = signal.getRouteList(); if (CollectionUtils.isEmpty(routeList)) { @@ -298,11 +298,11 @@ public class RoutePath { } for (Route route : routeList) { if (config.isRouteLikeHa1()) { - if (Objects.equals(runLevel, RunLevel.CBTC)) { // ctc级别列车找ATP进路 + if (communication) { // 通信车找ATP进路 if (!route.isAtp()) { continue; } - } else { // 非CTC列车找地面进路 + } else { // 非通信车找地面进路 if (!route.isGround()) { continue; } 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 6ff390c9d..0178e9547 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 @@ -242,27 +242,19 @@ public class TrainInfo extends MapElement { */ @Setter private String turnBackStatus = NON; - /** - * 无折返 - */ + /** 无折返 */ public static String NON = "NON"; - /** - * 初始化 - */ + /** 初始化 */ public static String INIT = "INIT"; - /** - * 开往折返轨 - */ + /** 开往折返轨 */ public static String TO = "TO"; - /** - * 到达折返轨停稳 - */ + /** 到达折返轨停稳 */ public static String STOP = "STOP"; - /** - * 开出折返轨 - */ + /** 开出折返轨 */ public static String EXIT = "EXIT"; + private boolean communication; + public TrainInfo(String groupNumber) { super(groupNumber, DeviceType.TRAIN); this.groupNumber = groupNumber; @@ -379,7 +371,7 @@ public class TrainInfo extends MapElement { this.offsetp = headPosition.getPercent(); if (headPosition.getSection().isSwitchTrack()) { this.section = headPosition.getSection().getParent().getCode(); - } else if (this.isCbtcTrack()) { + } else if (this.isCommunication()) { this.section = headPosition.getLogicSection().getCode(); } else { this.section = headPosition.getSection().getCode(); @@ -404,6 +396,7 @@ public class TrainInfo extends MapElement { } else if (speed != 0 && this.turnBackStatus.equals(STOP)) { this.turnBackStatus = EXIT; } + this.communication = train.isCommunication(); } public boolean isCbtcTrack() { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index 38d4f0ead..6bea1c33e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -9,7 +9,6 @@ import club.joylink.rtss.simulation.cbtc.data.support.MovementAuthority; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; -import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -100,7 +99,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * 车载服务通讯是否正常在线 */ - private boolean online; + private boolean communication; /** * 列车运行级别 @@ -112,6 +111,11 @@ public class VirtualRealityTrain extends VirtualRealityDevice { */ private DriveMode driveMode; + /** + * 预选驾驶模式 + */ + private DriveMode preDriveMode; + /** * 服务号 */ @@ -401,6 +405,12 @@ public class VirtualRealityTrain extends VirtualRealityDevice { */ private int runningTime; + public void setCommunication(boolean communication) { + if (Fault.COMMUNICATION_ABNORMAL.equals(this.fault) && communication) + return; + this.communication = communication; + } + public void setRunType(RunType runType) { this.runType = runType; switch (runType) { @@ -447,8 +457,10 @@ public class VirtualRealityTrain extends VirtualRealityDevice { @Override public void reset() { + this.communication = true; this.runLevel = null; this.driveMode = null; + this.preDriveMode = null; this.serviceNumber = null; this.tripNumber = null; this.destinationCode = null; @@ -569,11 +581,13 @@ public class VirtualRealityTrain extends VirtualRealityDevice { } private void init() { + this.communication = true; this.jump = false; this.hold = false; this.standParkedTrainActivity = null; this.runLevel = RunLevel.CBTC; this.driveMode = DriveMode.AM; + this.preDriveMode = DriveMode.AM; this.speed = 0; this.atoSpeed = 0; this.atpSpeed = 0; @@ -713,8 +727,9 @@ public class VirtualRealityTrain extends VirtualRealityDevice { // this.setSignalEB(false); this.setAtoOn(false); this.setDriveMode(DriveMode.RM); + setCommunication(false); //断开通信 // this.lossPosition(); - this.setCbtcMaMiss(); //通信断开 +// this.setCbtcMaMiss(); //通信断开 // this.lastTwoPassedResponders.clear(); // if (RunLevel.CBTC.equals(this.runLevel)) { // this.setCbtcMaMiss(); @@ -728,7 +743,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { public void useCMMode() { if (!this.isAtpOn()) { - throw new SimulationException(SimulationExceptionType.Invalid_Operation, String.format("列车[%s]未打开ATP", this.getCode())); + return; } this.atoOn = false; this.driveMode = DriveMode.CM; @@ -736,12 +751,13 @@ public class VirtualRealityTrain extends VirtualRealityDevice { public void useAMMode() { if (!atoOn) { - throw new SimulationException(SimulationExceptionType.Invalid_Operation, String.format("列车[%s]未打开ATO", this.getCode())); + return; } if (!this.isAtpOn()) { - throw new SimulationException(SimulationExceptionType.Invalid_Operation, String.format("列车[%s]未打开ATP", this.getCode())); + return; } this.driveMode = DriveMode.AM; + setCommunication(true); } public void useNRMMode() { @@ -755,9 +771,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { return; } this.driveMode = DriveMode.NRM; - if (RunLevel.CBTC.equals(this.runLevel)) { - this.setCbtcMaMiss(); - } + setCommunication(false); } public void setITCMode() { @@ -1109,13 +1123,15 @@ public class VirtualRealityTrain extends VirtualRealityDevice { public boolean isCommunicable() { Section section = headPosition.getSection(); - Station deviceStation = section.getDeviceStation(); - if (VirtualRealityTrain.Fault.COMMUNICATION_ABNORMAL == fault - || Station.Fault.INTERLOCK_MACHINE_FAULT == deviceStation.getFault() - || !section.anyZcWorking()) { - return false; - } - return true; + return communication && section.anyZcWorking(); + +// Station deviceStation = section.getDeviceStation(); +// if (VirtualRealityTrain.Fault.COMMUNICATION_ABNORMAL == fault +// || Station.Fault.INTERLOCK_MACHINE_FAULT == deviceStation.getFault() +// || !section.anyZcWorking()) { +// return false; +// } +// return true; } public boolean isCMMode() { @@ -1131,26 +1147,27 @@ public class VirtualRealityTrain extends VirtualRealityDevice { * 通信异常 */ COMMUNICATION_ABNORMAL { -// @Override -// public boolean apply(MapElement device) { -// VirtualRealityTrain train = (VirtualRealityTrain) device; -// if (Objects.equals(this, train.getFault())) { -// return false; -// } -// train.setFault(this); -// train.lossPosition(); -// return true; -// } + @Override + public boolean apply(MapElement device) { + if (super.apply(device)) { + VirtualRealityTrain train = (VirtualRealityTrain) device; + train.setCommunication(false); + return true; + } + return false; + } }, /** 驾驶异常 */ DRIVE_FAULT { @Override public boolean apply(MapElement device) { - super.apply(device); - VirtualRealityTrain train = (VirtualRealityTrain) device; - train.emergencyBreak(); //暂时就在这里直接处理,可能正常应该是ATP的责任 - return true; + if (super.apply(device)) { + VirtualRealityTrain train = (VirtualRealityTrain) device; + train.emergencyBreak(); //暂时就在这里直接处理,可能正常应该是ATP的责任 + return true; + } + return false; } }, diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java index 91ed6fee5..fcea4881f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java @@ -49,9 +49,10 @@ public class ATOService { } if (Objects.nonNull(train.getMa())) { train.setAtoOn(true); - if (DriveMode.CM.equals(train.getDriveMode())) { - train.useAMMode(); - } + train.setPreDriveMode(DriveMode.AM); +// if (DriveMode.CM.equals(train.getDriveMode())) { +// train.useAMMode(); +// } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java index 11885f2ab..23f4df92a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java @@ -107,6 +107,7 @@ public class ATPLogicLoop { private void onboardLogicRun2(Simulation simulation, VirtualRealityTrain train) { this.runLevelControl(simulation, train); + this.driveModeControl(simulation, train); boolean right = train.isRight(); SectionPosition headPosition = train.getHeadPosition(); @@ -181,6 +182,33 @@ public class ATPLogicLoop { this.atoService.ATO(train); } + private void driveModeControl(Simulation simulation, VirtualRealityTrain train) { + DriveMode preDriveMode = train.getPreDriveMode(); + DriveMode driveMode = train.getDriveMode(); + if (preDriveMode.equals(driveMode)) + return; + switch (preDriveMode) { + case AM: + train.setCommunication(true); //恢复列车通信 + if (train.isCMMode() && train.isAtoOn()) { + train.useAMMode(); + } + break; + case CM: + train.setCommunication(true); //恢复列车通信 + if (!train.isCbtcMaMiss() || !train.isItcMaMiss()) { //CBTC或ITC的移动授权未丢失 + Float distance = ATOService.calculateDistanceOfMa(train.getHeadPosition(), train.isRight(), train.getMa()); + if (distance != null && distance > 0) { //移动授权的距离为正 + train.useCMMode(); + } + } + break; + case RM: + train.useRMMode(); + break; + } + } + private void updateRunningTime(VirtualRealityTrain train) { if (train.isParkingAt()) { train.setRunningTime(0); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiService.java index e0fca90dc..18ffb01bc 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiService.java @@ -16,11 +16,6 @@ public interface OnboardAtpApiService { */ void updateMA4CBTC(VirtualRealityTrain train, MovementAuthority ma); - /** - * 忽略驾驶模式更新CBTC移动授权 - */ - boolean ignoreDriveModeUpdateMA4CBTC(VirtualRealityTrain train, MovementAuthority ma); - void updateMA4ITC(VirtualRealityTrain train, MovementAuthority ma); /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java index 863dfda4f..4d9edab6e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/OnboardAtpApiServiceImpl.java @@ -37,30 +37,10 @@ public class OnboardAtpApiServiceImpl implements OnboardAtpApiService { if (!train.isAtpOn()) { return; } - if (train.getFault() == VirtualRealityTrain.Fault.COMMUNICATION_ABNORMAL) { //列车通信故障 - return; - } - if (train.isRMMode() || train.isNRMMode()) - return; - if (train.isCBTC()) { + if (train.isCommunication()) { this.ATPService.updateMA(train, ma); + train.setCbtcMaMissDuration(0); } - train.setCbtcMaMissDuration(0); - } - - @Override - public boolean ignoreDriveModeUpdateMA4CBTC(VirtualRealityTrain train, MovementAuthority ma) { - if (ma == null) - return false; - if (!train.isAtpOn()) { - return false; - } - if (train.getFault() == VirtualRealityTrain.Fault.COMMUNICATION_ABNORMAL) { //列车通信故障 - return false; - } - this.ATPService.updateMA(train, ma); - train.setCbtcMaMissDuration(0); - return true; } @Override @@ -70,7 +50,7 @@ public class OnboardAtpApiServiceImpl implements OnboardAtpApiService { if (!train.isAtpOn()) { return; } - if (!train.isCBTC()) { + if (!train.isCommunication()) { this.ATPService.updateMA(train, ma); train.setItcMaMissDuration(0); }