From 8a52efacdf70dc8c60789d574fa62a1f0858c4cb Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Thu, 26 May 2022 18:28:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B6=8A=E5=BC=95=E5=AF=BC?= =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E6=8C=87=E4=BB=A4=E9=80=BB=E8=BE=91=EF=BC=88?= =?UTF-8?q?=E5=BF=BD=E7=95=A5=E5=A4=A7=E9=93=81=E7=9A=84=E8=B0=83=E8=BD=A6?= =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E6=9C=BA=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/command/CommandBO.java | 42 ++++++++++++++----- .../rtss/simulation/cbtc/data/map/Signal.java | 7 ++++ .../cbtc/data/vr/VirtualRealityTrain.java | 28 ------------- .../simulation/cbtc/robot/RobotLogicLoop.java | 6 --- 4 files changed, 38 insertions(+), 45 deletions(-) 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 2c8c12a57..cbd13ab0d 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 @@ -313,7 +313,7 @@ public class CommandBO { List stepList = new ArrayList<>(); VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice(); - stepList.add(buildDriveStep(train.calculateStepPosition4CrossTheGuideSignal())); + stepList.add(buildDriveStep(calculateStepPosition4CrossTheGuideSignal(train))); stepList.add(buildCrossSignalStep(train.getHeadPosition().getSection().getSignalOf(train.isRight()))); return stepList; @@ -322,16 +322,6 @@ public class CommandBO { @Override public Step execute(Simulation simulation, CommandBO command) { VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice(); -// Step crossSignalStep = command.getStepByType(Step.StepType.CROSS_SIGNAL).get(0); -// Signal signal = crossSignalStep.getCrossSignal(); -// SectionPosition signalPosition = new SectionPosition(signal.getSection(), signal.getOffset()); -// if (train.getHeadPosition().isAheadOf(signalPosition, train.isRight())) { //如果已经越过了信号机 -// if (train.isAMMode()) { -// command.getTargetMember().setCommand(null); -// } else { -// return getStep4ChangePreselectionMode(train, PreselectionMode.AM_C); -// } -// } if (!train.isRMMode() && !train.isNRMMode()) { //既不是RM也不是NRM,切换预选模式 return getStep4ChangePreselectionMode(train, PreselectionMode.RM); } @@ -889,5 +879,35 @@ public class CommandBO { } return null; } + + /** + * 计算越引导信号行驶的停车位置 + */ + public SectionPosition calculateStepPosition4CrossTheGuideSignal(VirtualRealityTrain train) { + boolean right = train.isRight(); + SectionPosition headPosition = train.getHeadPosition(); + Section section = headPosition.getSection(); + Signal trainHeadSignal = section.getSignalOf(right); + if (trainHeadSignal == null || !trainHeadSignal.isGuideAspect()) { + throw new SimulationException(SimulationExceptionType.Invalid_Operation, "指令要求:列车车头所在区段有同向信号机并且开放引导信号"); + } + + SectionPosition sectionPosition = null; + for (int i = 0; i < 30; i++) { + section = section.getNextRunningSectionOf(right); + Signal signal = section.getSignalOf(right); + if (section.isStandTrack() || section.isTurnBackTrack()) { + sectionPosition = new SectionPosition(section, section.getStopPointByDirection(right)); + break; + } else if (signal != null && !signal.isShunting() && !signal.isMainAspect()) { //同向信号机未正常开放 + sectionPosition = new SectionPosition(section, signal.getOffset()); + break; + } + } + if (sectionPosition == null) { + throw new SimulationException(SimulationExceptionType.Invalid_Operation, "引导信号前方未找到停车位置"); + } + return sectionPosition; + } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java index 64025cc04..0a2d91cb0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java @@ -665,6 +665,13 @@ public class Signal extends DelayUnlockDevice { return SignalType.SHUNTING2.equals(type); } + /** + * 是调车信号机? + */ + public boolean isShunting() { + return SignalType.SHUNTING.equals(type); + } + /** * 引导信号延时关闭开始计时 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index 816498be6..533f40c60 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -891,34 +891,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice { String.format("信号机[%s]前方未找到站台轨、折返轨或转换轨", signal.getName())); } - /** - * 计算越引导信号行驶的停车位置 - */ - public SectionPosition calculateStepPosition4CrossTheGuideSignal() { - boolean right = this.right; - Section section = this.headPosition.getSection(); - Signal signal = section.getSignalOf(right); - if (signal == null || !signal.isGuideAspect()) { - throw new SimulationException(SimulationExceptionType.Invalid_Operation, "指令要求:列车车头所在区段有同向信号机并且开放引导信号"); - } - - SectionPosition sectionPosition = null; - for (int i = 0; i < 30; i++) { - section = section.getNextRunningSectionOf(right); - if (section.isStandTrack() || section.isTurnBackTrack()) { - sectionPosition = new SectionPosition(section, section.getStopPointByDirection(right)); - break; - } else if (section.getSignalOf(right) != null && !section.getSignalOf(right).isMainAspect()) { //同向信号机未正常开放 - sectionPosition = new SectionPosition(section, section.getSignalOf(right).getOffset()); - break; - } - } - if (sectionPosition == null) { - throw new SimulationException(SimulationExceptionType.Invalid_Operation, "引导信号前方未找到停车位置"); - } - return sectionPosition; - } - /** * 计算车头到下一个正常开放的信号机的距离(找2个区段) */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java index 442efe1c4..6c4ad44c0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java @@ -233,12 +233,6 @@ public class RobotLogicLoop { switch (train.getDriveMode()) { case AM: //AM模式下不需要司机驾驶 return; -// TrainInfo trainInfo = repository.getSupervisedTrainByGroup(train.getGroupNumber()); -// if (trainInfo.isManualTrain()) { -// train.setTarget(train.getRobotTargetPosition().getSection()); -// train.setRobotTargetPosition(null); -// } -// break; case CM: MaService.Ma ma = train.getMa2(); if (ma != null) {