diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SectionGeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SectionGeneratorNew.java index 6a5e307b2..28d0c3551 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SectionGeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SectionGeneratorNew.java @@ -118,9 +118,9 @@ public class SectionGeneratorNew implements GeneratorNew { case Section_Confirm_Axis_Valid: // 设置计轴失效(ARB) if (Objects.nonNull(section.getParent())) { - section.getParent().judgeAsNctOccupied(); + section.getParent().judgeAsNctOccupied(simulation); } else { - section.judgeAsNctOccupied(); + section.judgeAsNctOccupied(simulation); } break; case Section_Fault_Unlock: diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SwitchGeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SwitchGeneratorNew.java index c892be4c6..895a0a907 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SwitchGeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SwitchGeneratorNew.java @@ -115,7 +115,7 @@ public class SwitchGeneratorNew implements GeneratorNew { } case Switch_Confirm_Axis_Valid:{ // 背景为道岔计轴失效 - aSwitch.getA().getParent().judgeAsNctOccupied(); + aSwitch.getA().getParent().judgeAsNctOccupied(simulation); break; } case Switch_Squeeze_Recovery: 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 cbce19f84..d20b60969 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 @@ -141,7 +141,7 @@ public class AtpSectionService { section.setFault(Section.AxleFault.FAULT); } } else if (Section.AxleFault.FAULT.equals(section.getFault()) && section.getVirtualAxleCounter().isOccupy()) { - section.judgeAsNctOccupied(); + section.judgeAsNctOccupied(simulation); } // if (/*!section.isInvalid() &&*/ section.isNctOccupied()) { // if (!sectionList.contains(section)) { 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 63771964a..a039ab7e3 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 @@ -1,6 +1,7 @@ package club.joylink.rtss.simulation.cbtc.data.map; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; @@ -824,14 +825,15 @@ public class Section extends DelayUnlockDevice { /** * 判定为非通信车占用 + * @param simulation */ - public void judgeAsNctOccupied() { + public void judgeAsNctOccupied(Simulation simulation) { if (!this.isAxleCounter()) { return; } this.setNctOccupied(true); if (this.isSwitchAxleCounterSection()) { // 道岔计轴区段 - nctOccupiedBySwitchPosition(); + nctOccupiedBySwitchPosition(simulation); } else if (!CollectionUtils.isEmpty(this.logicList)) { for (Section logic : this.logicList) { logic.setNctOccupied(true); @@ -841,25 +843,42 @@ public class Section extends DelayUnlockDevice { /** * 根据道岔位置设置非通信车占用 + * @param simulation */ - private void nctOccupiedBySwitchPosition() { + private void nctOccupiedBySwitchPosition(Simulation simulation) { List relSwitchList = this.getRelSwitchList(); - for (Switch aSwitch : relSwitchList) { - aSwitch.getA().setNctOccupied(true); - if (aSwitch.isPosN()) { - aSwitch.getB().setNctOccupied(true); - aSwitch.getC().setNctOccupied(false); - } else if (aSwitch.isPosR()) { - aSwitch.getC().setNctOccupied(true); - aSwitch.getB().setNctOccupied(false); - } else { - aSwitch.getB().setNctOccupied(true); - aSwitch.getC().setNctOccupied(true); + if (relSwitchList.size() == 2 && simulation.getRepository().getConfig().isSwitchSingleHandle()) { + // 道岔计轴区段两个道岔有一个反位 + if (!relSwitchList.stream().allMatch(Switch::isPosN)) { + for (Switch aSwitch : relSwitchList) { + if (aSwitch.isPosN()) { + continue; + } + setSwitchNctOccupied(aSwitch); + } + Section cross = queryCross(); + if (cross != null) { + cross.crossJudgeOccupied(); + } + return; } } - Section cross = queryCross(); - if (cross != null) { - cross.crossJudgeOccupied(); + for (Switch aSwitch : relSwitchList) { + setSwitchNctOccupied(aSwitch); + } + } + + private void setSwitchNctOccupied(Switch aSwitch) { + aSwitch.getA().setNctOccupied(true); + if (aSwitch.isPosN()) { + aSwitch.getB().setNctOccupied(true); + aSwitch.getC().setNctOccupied(false); + } else if (aSwitch.isPosR()) { + aSwitch.getC().setNctOccupied(true); + aSwitch.getB().setNctOccupied(false); + } else { + aSwitch.getB().setNctOccupied(true); + aSwitch.getC().setNctOccupied(true); } }