diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SwitchOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SwitchOperateHandler.java index b7419b1f2..cd5ab7ffd 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SwitchOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SwitchOperateHandler.java @@ -235,6 +235,7 @@ public class SwitchOperateHandler { /**道岔计轴预复位*/ @OperateHandlerMapping(type = Operation.Type.Switch_Axle_Pre_Reset) public void axlePreReset(Simulation simulation, String switchCode) { + ciApiService.switchAxlePreReset(simulation, switchCode); Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); ciApiService.axlePreReset(simulation, aSwitch.getA().getParent().getCode()); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CILogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CILogicLoop.java index 4515660e3..4d88dc055 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CILogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CILogicLoop.java @@ -266,6 +266,13 @@ public class CILogicLoop { section.axleCounterClear(); } section.judgeAsValid(); + //预复位 + if (!virtualAxleCounter.isPreReset()) { + List switchList = section.getRelSwitchList(); + if (!CollectionUtils.isEmpty(switchList)) { + switchList.forEach(aSwitch -> aSwitch.setPreReset(false)); + } + } }); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java index 4176a7dc1..79fcb6467 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java @@ -324,4 +324,9 @@ public interface CiApiService { * 计轴预复位 */ void axlePreReset(Simulation simulation, String sectionCode); + + /** + * 道岔计轴预复位 + */ + void switchAxlePreReset(Simulation simulation, String switchCode); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java index a8cdcb0c6..d0533675c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java @@ -502,4 +502,10 @@ public class CiApiServiceImpl implements CiApiService { BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(virtualAxleCounter.isOccupy(), chooseSection + "计轴未占用,无需预复位"); virtualAxleCounter.preReset(); } + + @Override + public void switchAxlePreReset(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + aSwitch.setPreReset(true); + } } 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 db1f67153..60bbfbb19 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 @@ -257,7 +257,13 @@ public class RouteService { List
sectionList = route.getSectionList(); for (Section section : sectionList) { if (section.isOccupied() && !section.isPreReset()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); + if (section.isSwitchTrack()) { + if (!section.getRelSwitch().isPreReset()) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); + } + } else { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); + } } } // 延续保护检查 @@ -751,6 +757,7 @@ public class RouteService { // 设置延时 route.getStart().setDelayTime(route.getDelayReleaseTime() * 1000); route.setDelayUnlocking(true); + route.getLogicSections().forEach(section -> section.setDelayUnlock(true)); return true; } @@ -770,6 +777,7 @@ public class RouteService { // 进路解锁完成 route.setDelayUnlocking(false); start.setDelayTime(0); + route.getLogicSections().forEach(section -> section.setDelayUnlock(false)); } else { start.setDelayTime(delayTime); } 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 4b9b6b985..691953ba2 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 @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.command; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.DriveMode; @@ -165,9 +166,11 @@ public class CommandBO { } } else { SectionPosition nextStopPosition = train.calculateNextStandStopPosition(); - if (nextStopPosition == null) { + if (nextStopPosition == null && train.getTarget() != null) { nextStopPosition = new SectionPosition(train.getTarget(), train.getTarget().getStopPointByDirection(right)); } + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(nextStopPosition, + train.debugStr() + "找不到下一个停车点"); stepList.add(buildDriveStep(nextStopPosition)); } stepList.add(buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM)); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java index 1e9114abc..aa14489ba 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java @@ -493,6 +493,21 @@ public class Route extends MapNamedElement { return false; } + /** + * 获取进路的所有子区段 + */ + public List
getLogicSections() { + List
sections = new ArrayList<>(); + for (Section section : sectionList) { + if (CollectionUtils.isEmpty(section.getLogicList())) { + sections.add(section); + } else { + sections.addAll(section.getLogicList()); + } + } + return sections; + } + /** * 进路检查失败原因 */ 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 d7f534c8a..f3abc871d 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 @@ -219,6 +219,11 @@ public class Section extends MayOutOfOrderDevice { */ private boolean noStatus; + /** + * 延时解锁 + */ + private boolean delayUnlock; + @Override public void reset() { super.reset(); @@ -234,6 +239,7 @@ public class Section extends MayOutOfOrderDevice { this.speedUpLimit = -1; this.delayTime = 0; this.noStatus = false; + this.delayUnlock = false; } /** @@ -919,6 +925,9 @@ public class Section extends MayOutOfOrderDevice { * 是否预复位 */ public boolean isPreReset() { + if (switchTrack) { + return false; + } if (virtualAxleCounter == null) { if (parent != null) return parent.isPreReset(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java index be2127799..ff201a14b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java @@ -99,6 +99,11 @@ public class Switch extends MayOutOfOrderDevice { */ private boolean noStatus; + /** + * 预复位 + */ + private boolean preReset; + @Override public void reset() { super.reset(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SectionStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SectionStatus.java index e0285a246..103b178c6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SectionStatus.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SectionStatus.java @@ -87,6 +87,9 @@ public class SectionStatus extends DeviceStatus { @JsonSerialize(using = Boolean2NumSerializer.class) private boolean preReset; + @JsonSerialize(using = Boolean2NumSerializer.class) + private boolean delayUnlock; + private String fault; public SectionStatus(Section section) { @@ -103,6 +106,7 @@ public class SectionStatus extends DeviceStatus { this.speedUpLimit = section.getSpeedUpLimit(); this.noStatus = section.isNoStatus(); this.preReset = section.isPreReset(); + this.delayUnlock = section.isDelayUnlock(); this.fault = section.getFault() == null ? null : section.getFault().toString(); } @@ -171,6 +175,11 @@ public class SectionStatus extends DeviceStatus { status.setPreReset(this.preReset); change = true; } + if (!Objects.equals(this.delayUnlock, section.isDelayUnlock())) { + this.delayUnlock = section.isDelayUnlock(); + status.setDelayUnlock(this.delayUnlock); + change = true; + } return change; } @@ -188,6 +197,7 @@ public class SectionStatus extends DeviceStatus { statusVO.setBlockade(blockade); statusVO.setNoStatus(noStatus); statusVO.setPreReset(preReset); + statusVO.setDelayUnlock(delayUnlock); return statusVO; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SwitchStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SwitchStatus.java index f14ae4b61..f65537db5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SwitchStatus.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SwitchStatus.java @@ -63,6 +63,9 @@ public class SwitchStatus extends DeviceStatus { @JsonSerialize(using = Boolean2NumSerializer.class) private boolean noStatus; + @JsonSerialize(using = Boolean2NumSerializer.class) + private boolean preReset; + /** * 故障 */ @@ -79,6 +82,7 @@ public class SwitchStatus extends DeviceStatus { this.reversePosition = aSwitch.isReversePosition(); this.delayTime = aSwitch.getDelayTime() / 1000; this.noStatus = aSwitch.isNoStatus(); + this.preReset = aSwitch.isPreReset(); } @Override @@ -132,6 +136,11 @@ public class SwitchStatus extends DeviceStatus { status.setNoStatus(this.noStatus); change = true; } + if (!Objects.equals(this.preReset, aSwitch.isPreReset())) { + this.preReset = aSwitch.isPreReset(); + status.setPreReset(this.preReset); + change = true; + } if (!Objects.equals(this.fault, aSwitch.getFault())) { this.fault = (Switch.SwitchFault) aSwitch.getFault(); status.setFault(this.fault != null ? this.fault.name() : null); @@ -151,6 +160,7 @@ public class SwitchStatus extends DeviceStatus { statusVO.setBlockade(blockade); statusVO.setSingleLock(singleLock); statusVO.setNoStatus(noStatus); + statusVO.setPreReset(preReset); statusVO.setFault(this.fault != null ? this.fault.name() : null); return statusVO; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SectionStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SectionStatusVO.java index f510a7274..3ec3ce965 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SectionStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SectionStatusVO.java @@ -58,6 +58,9 @@ public class SectionStatusVO extends DeviceStatusVO { @JsonSerialize(using = Boolean2NumSerializer.class) private Boolean preReset; + @JsonSerialize(using = Boolean2NumSerializer.class) + private Boolean delayUnlock; + private String fault; public SectionStatusVO(Section section) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SwitchStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SwitchStatusVO.java index bbba6e675..c660c08dd 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SwitchStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SwitchStatusVO.java @@ -52,6 +52,9 @@ public class SwitchStatusVO extends DeviceStatusVO { @JsonSerialize(using = Boolean2NumSerializer.class) private Boolean noStatus; + @JsonSerialize(using = Boolean2NumSerializer.class) + private Boolean preReset; + @JsonInclude private String fault; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySectionAxleCounter.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySectionAxleCounter.java index 4b8781cf5..42790c950 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySectionAxleCounter.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySectionAxleCounter.java @@ -68,6 +68,8 @@ public class VirtualRealitySectionAxleCounter extends VirtualRealityDevice { public void preReset() { if (occupy) { this.preReset = true; + this.leftCount = 0; + this.rightCount = 0; } } @@ -83,6 +85,7 @@ public class VirtualRealitySectionAxleCounter extends VirtualRealityDevice { * @param trainRight 列车运行方向 */ public void trainIn(boolean trainRight) { + System.out.println("列车进入计轴区段"); if (trainRight) { leftCount++; } else { @@ -97,6 +100,7 @@ public class VirtualRealitySectionAxleCounter extends VirtualRealityDevice { * @param trainRight 列车运行方向 */ public void trainOut(boolean trainRight) { + System.out.println("列车离开计轴区段"); if (trainRight) { leftCount--; } else { @@ -112,6 +116,7 @@ public class VirtualRealitySectionAxleCounter extends VirtualRealityDevice { public void judgePreResetSuccess() { if (preReset) { if (leftCount == 0 && rightCount == 0) { + preReset = false; if (Fault.FAULT.equals(this.fault)) { this.fault = null; }