From 1b5a6cc68eeb1a6eeb4f5006ee25bcc2cd8fe1e7 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 13 Jul 2021 14:58:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E5=89=8D=E6=96=B9?= =?UTF-8?q?=E5=88=97=E8=BD=A6=E7=9A=84=E7=A7=BB=E5=8A=A8=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATP/ground/ZCLogicLoop.java | 37 +++++++++------ .../cbtc/data/CalculateService.java | 11 +---- .../cbtc/data/support/MovementAuthority.java | 46 ++++++++++--------- 3 files changed, 50 insertions(+), 44 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 0afe01fc7..a55ce1141 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 @@ -175,6 +175,8 @@ public class ZCLogicLoop { MovementAuthority.End end = checkSwitch(section, right); if (end != null) endList.add(end); + //前方列车 + MovementAuthority.End trainEnd = checkSectionOccupied(section); // 轨道尽头/问题道岔 Section temp = section.getNextRunningSectionOf(right); if (Objects.isNull(temp)) { // 到尽头 @@ -198,22 +200,31 @@ public class ZCLogicLoop { section = temp; } - // 前方列车 - VirtualRealityTrain frontTrain = this.queryFrontTrain(train, trainList); - if (Objects.nonNull(frontTrain)) { - Section baseSection; - if (Objects.equals(frontTrain.isRight(), train.isRight())) { - baseSection = frontTrain.calculateTailPosition().getSection(); - } else { - baseSection = frontTrain.getHeadPosition().getSection(); - } - endList.add(new MovementAuthority.End(frontTrain, - MovementAuthority.EndType.FRONT_TRAIN, - baseSection)); - } +// // 前方列车 +// VirtualRealityTrain frontTrain = this.queryFrontTrain(train, trainList); +// if (Objects.nonNull(frontTrain)) { +// Section baseSection; +// if (Objects.equals(frontTrain.isRight(), train.isRight())) { +// baseSection = frontTrain.calculateTailPosition().getSection(); +// } else { +// baseSection = frontTrain.getHeadPosition().getSection(); +// } +// endList.add(new MovementAuthority.End(frontTrain, +// MovementAuthority.EndType.FRONT_TRAIN, +// baseSection)); +// } return endList; } + private MovementAuthority.End checkSectionOccupied(Section section) { + for (Section logic : section.getLogicList()) { + if (logic.isCtOccupied()) { + return new MovementAuthority.End(section, MovementAuthority.EndType.FRONT_TRAIN, null); + } + } + return null; + } + private MovementAuthority.End checkSwitch(Section tailSection, Section headSection, boolean right) { Section section = tailSection; for (int i = 0; i < 10; i++) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java index 9f9e2760f..25c2865d8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java @@ -1244,18 +1244,9 @@ public class CalculateService { if (section.isPhysical()) { return sectionPosition; } else { - int offset = 0; Section parent = section.getParent(); if (parent != null) { - for (Section logicSection : parent.getLogicList()) { - if (!logicSection.equals(section)) { - offset += logicSection.getLen(); - } else { - offset += sectionPosition.getOffset(); - break; - } - } - return new SectionPosition(parent, offset); + return new SectionPosition(parent, section.getMinOffset() + sectionPosition.getOffset()); } else { return 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 1ee79c6d2..ca44cbb41 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 @@ -109,26 +109,30 @@ public class MovementAuthority { return new SectionPosition(section, offset); } case FRONT_TRAIN: { - VirtualRealityTrain train = (VirtualRealityTrain) this.device; - boolean trainRight = train.isRight(); - SectionPosition headPosition = train.getHeadPosition(); - SectionPosition tailPosition = CalculateService - .calculateNextPositionByStartAndLen(headPosition, !right, train.getLen()); - float offset; - if (Objects.equals(trainRight, right)) { // 同向,取车尾 - offset = right - ? - tailPosition.getOffset() - 2 * SimulationConstants.TRAIN_SAFE_DISTANCE - : - tailPosition.getOffset() + 2 * SimulationConstants.TRAIN_SAFE_DISTANCE; - } else { // 方向相反,取车头 - offset = right - ? - headPosition.getOffset() - 2 * SimulationConstants.TRAIN_SAFE_DISTANCE - : - headPosition.getOffset() + 2 * SimulationConstants.TRAIN_SAFE_DISTANCE; - } - return new SectionPosition(this.baseSection, offset); + Section section = (Section) this.device; + return new SectionPosition(section.getParent(), right ? section.getMinOffset() : section.getMaxOffset()); + + +// VirtualRealityTrain train = (VirtualRealityTrain) this.device; +// boolean trainRight = train.isRight(); +// SectionPosition headPosition = train.getHeadPosition(); +// SectionPosition tailPosition = CalculateService +// .calculateNextPositionByStartAndLen(headPosition, !right, train.getLen()); +// float offset; +// if (Objects.equals(trainRight, right)) { // 同向,取车尾 +// offset = right +// ? +// tailPosition.getOffset() - 2 * SimulationConstants.TRAIN_SAFE_DISTANCE +// : +// tailPosition.getOffset() + 2 * SimulationConstants.TRAIN_SAFE_DISTANCE; +// } else { // 方向相反,取车头 +// offset = right +// ? +// headPosition.getOffset() - 2 * SimulationConstants.TRAIN_SAFE_DISTANCE +// : +// headPosition.getOffset() + 2 * SimulationConstants.TRAIN_SAFE_DISTANCE; +// } +// return new SectionPosition(this.baseSection, offset); } case END_TRACK: { Section section = (Section) this.device; @@ -138,7 +142,7 @@ public class MovementAuthority { case UNLOCKED_OVERLAP: case FAULT_SWITCH: { Section section = (Section) this.device; - float offset = right ? 0 : section.getLen(); + float offset = right ? section.getLen() : 0; SectionPosition stopPosition = new SectionPosition(section, offset); return CalculateService.calculateNextPositionByStartAndLen(stopPosition, !right, 100); }