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 af594347b..d700f2a35 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 @@ -140,6 +140,25 @@ public class ZCLogicLoop { endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.NCT_OCCUPIED_SECTION)); return endList; } + //通信车占用区段 + List
logicList = section.getLogicList(); + if (!CollectionUtils.isEmpty(logicList)) { + Section logicSection = headPosition.getLogicSection(); + int index = logicList.indexOf(logicSection); + if (right) { + for (int i = index + 1; i < logicList.size(); i++) { + MovementAuthority.End end = checkSectionOccupied(logicList.get(i), right); + if (end != null) + endList.add(end); + } + } else { + for (int i = index - 1; i >= 0; i--) { + MovementAuthority.End end = checkSectionOccupied(logicList.get(i), right); + if (end != null) + endList.add(end); + } + } + } int count = 0; while (count < 50) { ++count; @@ -183,8 +202,8 @@ public class ZCLogicLoop { } break; } - //前方列车 - MovementAuthority.End trainEnd = checkSectionOccupied(temp); + //通信车占用区段 + MovementAuthority.End trainEnd = checkSectionOccupied(temp, right); if (trainEnd != null) endList.add(trainEnd); //非通信车占用区段 @@ -196,10 +215,9 @@ public class ZCLogicLoop { if (cs != null) endList.add(cs); - if (!CollectionUtils.isEmpty(endList) && endList.size() == 1 && !endList.get(0).getType().equals(MovementAuthority.EndType.CLOSED_SIGNAL)) { + if (endList.stream().anyMatch(end2 -> !MovementAuthority.EndType.CLOSED_SIGNAL.equals(end2.getType()))) { break; } - section = temp; } // // 前方列车 @@ -218,9 +236,25 @@ public class ZCLogicLoop { return endList; } - private MovementAuthority.End checkSectionOccupied(Section section) { - for (Section logic : section.getLogicList()) { - if (logic.isCtOccupied()) { + private MovementAuthority.End checkSectionOccupied(Section section, boolean right) { + List
logicList = section.getLogicList(); + if (!CollectionUtils.isEmpty(logicList)) { + if (right) { + for (Section logic : logicList) { + if (logic.isCtOccupied()) { + return new MovementAuthority.End(logic, MovementAuthority.EndType.FRONT_TRAIN, null); + } + } + } else { + for (int i = logicList.size() - 1; i >= 0; i--) { + Section logic = logicList.get(i); + if (logic.isCtOccupied()) { + return new MovementAuthority.End(logic, MovementAuthority.EndType.FRONT_TRAIN, null); + } + } + } + } else { + if (section.isCtOccupied()) { return new MovementAuthority.End(section, MovementAuthority.EndType.FRONT_TRAIN, null); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/MovementAuthority.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/MovementAuthority.java index ca44cbb41..9469a470b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/MovementAuthority.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/MovementAuthority.java @@ -110,7 +110,9 @@ public class MovementAuthority { } case FRONT_TRAIN: { Section section = (Section) this.device; - return new SectionPosition(section.getParent(), right ? section.getMinOffset() : section.getMaxOffset()); + SectionPosition sectionPosition = new SectionPosition(section.getParent(), right ? section.getMinOffset() : section.getMaxOffset()); + CalculateService.calculateNextPositionByStartAndLen(sectionPosition, !right, 2 * SimulationConstants.TRAIN_SAFE_DISTANCE); + return sectionPosition; // VirtualRealityTrain train = (VirtualRealityTrain) this.device;