修改越引导信号指令逻辑(忽略大铁的调车信号机)

This commit is contained in:
joylink_zhangsai 2022-05-26 18:28:30 +08:00
parent 9cbd1057d9
commit 8a52efacdf
4 changed files with 38 additions and 45 deletions

View File

@ -313,7 +313,7 @@ public class CommandBO {
List<Step> stepList = new ArrayList<>(); List<Step> stepList = new ArrayList<>();
VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice(); VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
stepList.add(buildDriveStep(train.calculateStepPosition4CrossTheGuideSignal())); stepList.add(buildDriveStep(calculateStepPosition4CrossTheGuideSignal(train)));
stepList.add(buildCrossSignalStep(train.getHeadPosition().getSection().getSignalOf(train.isRight()))); stepList.add(buildCrossSignalStep(train.getHeadPosition().getSection().getSignalOf(train.isRight())));
return stepList; return stepList;
@ -322,16 +322,6 @@ public class CommandBO {
@Override @Override
public Step execute(Simulation simulation, CommandBO command) { public Step execute(Simulation simulation, CommandBO command) {
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice(); 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切换预选模式 if (!train.isRMMode() && !train.isNRMMode()) { //既不是RM也不是NRM切换预选模式
return getStep4ChangePreselectionMode(train, PreselectionMode.RM); return getStep4ChangePreselectionMode(train, PreselectionMode.RM);
} }
@ -889,5 +879,35 @@ public class CommandBO {
} }
return null; 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;
}
} }
} }

View File

@ -665,6 +665,13 @@ public class Signal extends DelayUnlockDevice {
return SignalType.SHUNTING2.equals(type); return SignalType.SHUNTING2.equals(type);
} }
/**
* 是调车信号机
*/
public boolean isShunting() {
return SignalType.SHUNTING.equals(type);
}
/** /**
* 引导信号延时关闭开始计时 * 引导信号延时关闭开始计时
*/ */

View File

@ -891,34 +891,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
String.format("信号机[%s]前方未找到站台轨、折返轨或转换轨", signal.getName())); 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个区段 * 计算车头到下一个正常开放的信号机的距离找2个区段
*/ */

View File

@ -233,12 +233,6 @@ public class RobotLogicLoop {
switch (train.getDriveMode()) { switch (train.getDriveMode()) {
case AM: //AM模式下不需要司机驾驶 case AM: //AM模式下不需要司机驾驶
return; return;
// TrainInfo trainInfo = repository.getSupervisedTrainByGroup(train.getGroupNumber());
// if (trainInfo.isManualTrain()) {
// train.setTarget(train.getRobotTargetPosition().getSection());
// train.setRobotTargetPosition(null);
// }
// break;
case CM: case CM:
MaService.Ma ma = train.getMa2(); MaService.Ma ma = train.getMa2();
if (ma != null) { if (ma != null) {