From 86dce84b284e7e60040b1ba38055eb81e6088e47 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 16 Jul 2021 09:15:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E8=AE=A1=E7=AE=97bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATP/ground/ZCLogicLoop.java | 48 ++++++++++++++++--- .../cbtc/data/support/MovementAuthority.java | 4 +- 2 files changed, 44 insertions(+), 8 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 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;