添加切换预选模式指令、移除切换驾驶模式指令

This commit is contained in:
joylink_zhangsai 2021-09-27 14:45:10 +08:00
parent d7b5df2b3b
commit 2c5b139ff8
7 changed files with 292 additions and 250 deletions

View File

@ -14,6 +14,9 @@ import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.ConfirmationMessage;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.Handwheel;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.PreselectionMode;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
@ -181,7 +184,7 @@ public class CommandBO {
} }
@Override @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { public Step execute(Simulation simulation, CommandBO command) {
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice(); VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
//如果列车没停到目标位置先想办法开过去--- //如果列车没停到目标位置先想办法开过去---
List<Step> steps = command.getStepByType(Step.StepType.DRIVE); List<Step> steps = command.getStepByType(Step.StepType.DRIVE);
@ -219,7 +222,7 @@ public class CommandBO {
} }
@Override @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { public Step execute(Simulation simulation, CommandBO command) {
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice(); VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
if (!DriveMode.CM.equals(train.getDriveMode()) && !DriveMode.AM.equals(train.getDriveMode())) { //如果列车不处于CM/AM运行级别 if (!DriveMode.CM.equals(train.getDriveMode()) && !DriveMode.AM.equals(train.getDriveMode())) { //如果列车不处于CM/AM运行级别
return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM); return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM);
@ -254,7 +257,7 @@ public class CommandBO {
} }
@Override @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { public Step execute(Simulation simulation, CommandBO command) {
String switchCode = (String) command.getParams().get(ParamName.switchCode.name()); String switchCode = (String) command.getParams().get(ParamName.switchCode.name());
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
boolean normal = (boolean) command.getParams().get(ParamName.normal.name()); boolean normal = (boolean) command.getParams().get(ParamName.normal.name());
@ -288,7 +291,7 @@ public class CommandBO {
} }
@Override @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { public Step execute(Simulation simulation, CommandBO command) {
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice(); VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
List<Step> steps = command.getStepByType(Step.StepType.DRIVE); List<Step> steps = command.getStepByType(Step.StepType.DRIVE);
Step driveStep = steps.get(0); Step driveStep = steps.get(0);
@ -340,7 +343,7 @@ public class CommandBO {
} }
@Override @Override
public Step executeOrReturnStep(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); Step crossSignalStep = command.getStepByType(Step.StepType.CROSS_SIGNAL).get(0);
Signal signal = crossSignalStep.getCrossSignal(); Signal signal = crossSignalStep.getCrossSignal();
@ -351,8 +354,11 @@ public class CommandBO {
return step; return step;
} }
} }
if (!DriveMode.RM.equals(train.getDriveMode())) { if (!PreselectionMode.RM.equals(train.getPreselectionMode())) {
return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.RM); PreselectionMode tempMode = train.getTempPreselectionMode();
if (!PreselectionMode.RM.equals(tempMode)) {
}
} }
List<Step> steps = command.getStepByType(Step.StepType.DRIVE); List<Step> steps = command.getStepByType(Step.StepType.DRIVE);
Step driveStep = steps.get(0); Step driveStep = steps.get(0);
@ -407,7 +413,7 @@ public class CommandBO {
} }
@Override @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { public Step execute(Simulation simulation, CommandBO command) {
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice(); VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
List<Step> steps = command.getStepByType(Step.StepType.OPERATION); List<Step> steps = command.getStepByType(Step.StepType.OPERATION);
Step step = steps.get(0); Step step = steps.get(0);
@ -428,23 +434,16 @@ public class CommandBO {
Set_Speed_Limit(List.of(ParamName.speedLimit), SimulationMember.Type.DRIVER) { Set_Speed_Limit(List.of(ParamName.speedLimit), SimulationMember.Type.DRIVER) {
@Override @Override
public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) { public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
if (!SimulationMember.Type.DRIVER.equals(targetMember.getType())) { return Collections.emptyList();
throw new SimulationException(SimulationExceptionType.Member_Is_Not_Driver);
}
List<Step> stepList = new ArrayList<>();
float speedLimit = Float.parseFloat((String) params.get(ParamName.speedLimit.name()));
if (speedLimit < 0)
speedLimit = Float.MAX_VALUE;
stepList.add(buildSetSpeedLimitStep(speedLimit));
return stepList;
} }
@Override @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { public Step execute(Simulation simulation, CommandBO command) {
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice(); VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
Step step = command.getStepList().get(0); float speedLimit = Float.parseFloat((String) command.getParams().get(ParamName.speedLimit.name()));
train.setSpeedLimit(step.getSpeedLimit() / 3.6f); if (speedLimit < 0)
speedLimit = Float.MAX_VALUE;
train.setSpeedLimit(speedLimit / 3.6f);
command.getTargetMember().setCommand(null); command.getTargetMember().setCommand(null);
return null; return null;
} }
@ -463,7 +462,7 @@ public class CommandBO {
} }
@Override @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { public Step execute(Simulation simulation, CommandBO command) {
SimulationMember targetMember = command.getTargetMember(); SimulationMember targetMember = command.getTargetMember();
VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice(); VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
if (Objects.equals(train.isRight(), command.getParams().get(ParamName.trainRight.name()))) { if (Objects.equals(train.isRight(), command.getParams().get(ParamName.trainRight.name()))) {
@ -483,7 +482,7 @@ public class CommandBO {
} }
@Override @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { public Step execute(Simulation simulation, CommandBO command) {
SimulationMember targetMember = command.getTargetMember(); SimulationMember targetMember = command.getTargetMember();
VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice(); VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
String sectionCode = (String) command.getParams().get(ParamName.sectionCode.name()); String sectionCode = (String) command.getParams().get(ParamName.sectionCode.name());
@ -498,98 +497,98 @@ public class CommandBO {
} }
}, },
/** 转URM模式 */ // /** 转URM模式 */
Apply_URM_Mode(List.of(), SimulationMember.Type.DRIVER) { // Apply_URM_Mode(List.of(), SimulationMember.Type.DRIVER) {
@Override // @Override
public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) { // public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
return List.of(); // return List.of();
} // }
//
@Override // @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { // public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice(); // VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
if (train.isNRMMode()) { // if (train.isNRMMode()) {
command.getTargetMember().setCommand(null); // command.getTargetMember().setCommand(null);
return null; // return null;
} else { // } else {
return buildDriverATPChangeOperationStep(train.getGroupNumber(), true); // return buildDriverATPChangeOperationStep(train.getGroupNumber(), true);
} // }
} // }
}, // },
//
/** 转RM模式 */ // /** 转RM模式 */
Apply_RM_Mode(List.of(), SimulationMember.Type.DRIVER){ // Apply_RM_Mode(List.of(), SimulationMember.Type.DRIVER){
@Override // @Override
public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) { // public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
return List.of(); // return List.of();
} // }
//
@Override // @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { // public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
SimulationMember targetMember = command.getTargetMember(); // SimulationMember targetMember = command.getTargetMember();
VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice(); // VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
if (DriveMode.RM.equals(train.getPreselectionMode())) { // if (DriveMode.RM.equals(train.getPreselectionMode())) {
targetMember.setCommand(null); // targetMember.setCommand(null);
return null; // return null;
} else { // } else {
if (!train.isAtpOn()) { // if (!train.isAtpOn()) {
return buildDriverATPChangeOperationStep(train.getGroupNumber(), false); // return buildDriverATPChangeOperationStep(train.getGroupNumber(), false);
} // }
targetMember.setCommand(null); // targetMember.setCommand(null);
return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.RM); // return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.RM);
} // }
} // }
}, // },
//
/** 转CM模式 */ // /** 转CM模式 */
Apply_CM_Mode(List.of(), SimulationMember.Type.DRIVER){ // Apply_CM_Mode(List.of(), SimulationMember.Type.DRIVER){
@Override // @Override
public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) { // public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
return List.of(); // return List.of();
} // }
//
@Override // @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { // public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
SimulationMember targetMember = command.getTargetMember(); // SimulationMember targetMember = command.getTargetMember();
VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice(); // VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
targetMember.setCommand(null); // targetMember.setCommand(null);
if (DriveMode.CM.equals(train.getPreselectionMode())) { // if (DriveMode.CM.equals(train.getPreselectionMode())) {
return null; // return null;
} else { // } else {
if (!train.isAtpOn()) { // if (!train.isAtpOn()) {
return buildDriverATPChangeOperationStep(train.getGroupNumber(), false); // return buildDriverATPChangeOperationStep(train.getGroupNumber(), false);
} // }
return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM); // return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM);
} // }
} // }
}, // },
//
/** 转AM模式 */ // /** 转AM模式 */
Apply_AM_Mode(List.of(), SimulationMember.Type.DRIVER){ // Apply_AM_C(List.of(), SimulationMember.Type.DRIVER){
@Override // @Override
public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) { // public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
return List.of(); // return List.of();
} // }
//
@Override // @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { // public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
SimulationMember targetMember = command.getTargetMember(); // SimulationMember targetMember = command.getTargetMember();
VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice(); // VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
if (DriveMode.AM.equals(train.getPreselectionMode())) { // if (DriveMode.AM.equals(train.getPreselectionMode())) {
targetMember.setCommand(null); // targetMember.setCommand(null);
return null; // return null;
} // }
if (!train.isAtpOn()) { // if (!train.isAtpOn()) {
return buildDriverATPChangeOperationStep(train.getGroupNumber(), false); // return buildDriverATPChangeOperationStep(train.getGroupNumber(), false);
} // }
if (!train.isCMMode()) { // if (!train.isCMMode()) {
return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM); // return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM);
} else { // } else {
targetMember.setCommand(null); // targetMember.setCommand(null);
return buildDriverAtoOpenOperationStep(train.getGroupNumber()); // return buildDriverAtoOpenOperationStep(train.getGroupNumber());
} // }
} // }
}, // },
/** 回库 */ /** 回库 */
Inbound(List.of(), SimulationMember.Type.DRIVER) { Inbound(List.of(), SimulationMember.Type.DRIVER) {
@ -599,7 +598,7 @@ public class CommandBO {
} }
@Override @Override
public Step executeOrReturnStep(Simulation simulation, CommandBO command) { public Step execute(Simulation simulation, CommandBO command) {
SimulationMember driver = command.getTargetMember(); SimulationMember driver = command.getTargetMember();
driver.setCommand(null); driver.setCommand(null);
VirtualRealityTrain train = (VirtualRealityTrain) driver.getDevice(); VirtualRealityTrain train = (VirtualRealityTrain) driver.getDevice();
@ -614,6 +613,52 @@ public class CommandBO {
} }
return null; return null;
} }
},
/** 修改预选模式 */
Change_Preselection_Mode(List.of(ParamName.preselectionMode), SimulationMember.Type.DRIVER){
@Override
public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
return Collections.emptyList();
}
@Override
public Step execute(Simulation simulation, CommandBO command) {
SimulationMember driver = command.getTargetMember();
VirtualRealityTrain train = (VirtualRealityTrain) driver.getDevice();
PreselectionMode preselectionMode =
PreselectionMode.valueOf((String) command.getParams().get(ParamName.preselectionMode.name()));
PreselectionMode trainMode = train.getPreselectionMode();
PreselectionMode tempMode = train.getTempPreselectionMode();
String groupNumber = train.getGroupNumber();
if (trainMode != preselectionMode) { //预选级别不对
if (tempMode != preselectionMode) {
if (preselectionMode.isHigherThan(tempMode)) {
return buildPreselectionModeUpOperationStep(groupNumber);
} else {
return buildPreselectionModeDownOperationStep(groupNumber);
}
} else if (ConfirmationMessage.Confirm_Preselection.equals(train.findFirstMessage())){
return buildConfirmOperationStep(groupNumber);
}
} else if (trainMode.isMatchTheDriveMode(DriveMode.AM) && !train.isAMMode()){
if (!train.isAtpOn()) {
return buildDriverATPChangeOperationStep(groupNumber, false);
}
if (!train.isInTheGear(Handwheel.ATO)) {
return buildGearChangeStep(groupNumber, Handwheel.ATO);
}
if (!train.isCoasting()) {
return buildDriverForceChangeOperationStep(groupNumber, 0);
}
if (!train.isAtoOn()) {
return buildDriverAtoOpenOperationStep(groupNumber);
}
} else {
driver.setCommand(null);
}
return null;
}
} }
; ;
@ -641,6 +686,7 @@ public class CommandBO {
*/ */
trainRight, trainRight,
sectionCode, sectionCode,
preselectionMode,
; ;
} }
@ -661,7 +707,7 @@ public class CommandBO {
/** /**
* 执行指令返回无法直接完成的指令 * 执行指令返回无法直接完成的指令
*/ */
public abstract Step executeOrReturnStep(Simulation simulation, CommandBO command); public abstract Step execute(Simulation simulation, CommandBO command);
/** /**
* 构建改变列车牵引/制动力操作步骤 * 构建改变列车牵引/制动力操作步骤
@ -707,8 +753,6 @@ public class CommandBO {
/** /**
* 构建开启ATO操作步骤 * 构建开启ATO操作步骤
*
* @return
*/ */
public Step buildDriverAtoOpenOperationStep(String groupNumber) { public Step buildDriverAtoOpenOperationStep(String groupNumber) {
Map<String, Object> operationParams = new HashMap<>(); Map<String, Object> operationParams = new HashMap<>();
@ -770,6 +814,47 @@ public class CommandBO {
return step; return step;
} }
public Step buildPreselectionModeUpOperationStep(String groupNumber) {
Map<String, Object> params = new HashMap<>();
params.put("groupNumber", groupNumber);
Step step = new Step();
step.setType(Step.StepType.OPERATION);
step.setOperationType(Operation.Type.Driver_Preselection_Mode_Up);
step.setOperationParams(params);
return step;
}
public Step buildPreselectionModeDownOperationStep(String groupNumber) {
Map<String, Object> params = new HashMap<>();
params.put("groupNumber", groupNumber);
Step step = new Step();
step.setType(Step.StepType.OPERATION);
step.setOperationType(Operation.Type.Driver_Preselection_Mode_Down);
step.setOperationParams(params);
return step;
}
public Step buildConfirmOperationStep(String groupNumber) {
Map<String, Object> params = new HashMap<>();
params.put("groupNumber", groupNumber);
Step step = new Step();
step.setType(Step.StepType.OPERATION);
step.setOperationType(Operation.Type.Driver_Confirm);
step.setOperationParams(params);
return step;
}
public Step buildGearChangeStep(String groupNumber, Handwheel gear) {
Map<String, Object> params = new HashMap<>();
params.put("groupNumber", groupNumber);
params.put("gear", gear);
Step step = new Step();
step.setType(Step.StepType.OPERATION);
step.setOperationType(Operation.Type.Driver_Gear_Change);
step.setOperationParams(params);
return step;
}
/** /**
* 构建驾驶步骤 * 构建驾驶步骤
*/ */
@ -799,59 +884,17 @@ public class CommandBO {
return step; return step;
} }
/**
* 构建在目标位置停车步骤
*/
public Step buildStopAtTerminalStep(SectionPosition sectionPosition) {
Step step = new Step();
step.setType(Step.StepType.STOP_AT_TERMINAL);
step.setTargetPosition(sectionPosition);
return step;
}
public Step buildAtoTurnDirectionStep() {
Step step = new Step();
step.setType(Step.StepType.ATO_CHANGE_DIRECTION);
return step;
}
/**
* 构建设置限速步骤
*/
public Step buildSetSpeedLimitStep(float speedLimit) {
Step step = new Step();
step.setType(Step.StepType.SET_SPEED_LIMIT);
step.setSpeedLimit(speedLimit);
return step;
}
/** /**
* 检查是否可以将rm升为bm并开启ATO * 检查是否可以将rm升为bm并开启ATO
*/ */
public Step getStepOfRm2BmAndOpenAto(CommandBO command) { public Step getStepOfRm2BmAndOpenAto(CommandBO command) {
// Step step = this.getStepOfRm2BmAndOpenAtoWhileParking(command);
// if (step != null) {
// return step;
// }
// return this.getStepOfRm2BmAndOpenAtoWhileRunLevelItcOrCbtc(command);
List<Step> steps = command.getStepByType(Step.StepType.RM_TO_BM); List<Step> steps = command.getStepByType(Step.StepType.RM_TO_BM);
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice(); VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
SectionPosition headPosition = train.getHeadPosition();
boolean right = train.isRight();
Step step = steps.get(0); Step step = steps.get(0);
if (step.isFinish() && DriveMode.CM.equals(train.getDriveMode())) { //如果步骤已经完成指越过正常开放的信号机或站台停车且列车为CM模式 if (step.isFinish() && DriveMode.CM.equals(train.getDriveMode())) { //如果步骤已经完成指越过正常开放的信号机或站台停车且列车为CM模式
command.getTargetMember().setCommand(null); command.getTargetMember().setCommand(null);
return buildDriverAtoOpenOperationStep(train.getGroupNumber()); return buildDriverAtoOpenOperationStep(train.getGroupNumber());
} }
// //---站台停车升级检测---
// if (train.isParking()) {
// step.finish();
// if (!DriveMode.CM.equals(train.getDriveMode())) { //如果列车不是CM/BM/SM模式
// return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM);
// }
// }
//---越信号机升级检测暂时改为列车级别为ITC/CBTC检测--- //---越信号机升级检测暂时改为列车级别为ITC/CBTC检测---
if (RunLevel.ITC.equals(train.getRunLevel()) || RunLevel.CBTC.equals(train.getRunLevel())) { if (RunLevel.ITC.equals(train.getRunLevel()) || RunLevel.CBTC.equals(train.getRunLevel())) {
step.finish(); step.finish();
@ -861,55 +904,5 @@ public class CommandBO {
} }
return null; return null;
} }
/**
* 检查是否可以将rm升为bm并开启ATO列车运行级别是ITC或CBTC
*/
public Step getStepOfRm2BmAndOpenAtoWhileRunLevelItcOrCbtc(CommandBO command) {
List<Step> steps = command.getStepByType(Step.StepType.RM_TO_BM);
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
Step step = steps.get(0);
if (step.isFinish() && DriveMode.CM.equals(train.getDriveMode())) { //如果步骤已经完成指越过正常开放的信号机且列车为CM模式
command.getTargetMember().setCommand(null);
return buildDriverAtoOpenOperationStep(train.getGroupNumber());
}
//---越信号机升级检测暂时改为列车级别为ITC/CBTC检测---
if (RunLevel.ITC.equals(train.getRunLevel()) || RunLevel.CBTC.equals(train.getRunLevel())) {
step.finish();
if (!DriveMode.CM.equals(train.getDriveMode())) { //如果列车不是CM/BM/SM模式
return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM);
}
}
return null;
}
/**
* 检查是否可以将rm升为bm并开启ATO停车点升级
*/
public Step getStepOfRm2BmAndOpenAtoWhileStopAtStopPosition(CommandBO command) {
List<Step> steps = command.getStepByType(Step.StepType.RM_TO_BM);
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
SectionPosition headPosition = train.getHeadPosition();
boolean right = train.isRight();
Step step = steps.get(0);
if (DriveMode.AM.equals(train.getDriveMode())) {
return null;
} else if (step.isFinish() && DriveMode.CM.equals(train.getDriveMode())) { //如果步骤已经完成指站台停车且列车为CM模式
return buildDriverAtoOpenOperationStep(train.getGroupNumber());
}
//---站台停车升级检测---
Section section = headPosition.getSection();
if (section.isStandTrack() || section.isTurnBackTrack() || section.isTransferTrack()) {
SectionPosition stopPosition = new SectionPosition(section, section.getStopPointByDirection(right));
if (train.isStopAtThePosition(stopPosition)) {
step.finish();
if (!DriveMode.CM.equals(train.getDriveMode())) { //如果列车不是CM/BM/SM模式
return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM);
}
}
}
return null;
}
} }
} }

View File

@ -37,7 +37,7 @@ public class CommandExecuteService {
log.info(String.format("成员[%s]由用户[%s]扮演,指令[%s]不执行", member.getId(), member.getUserId(), command.getCommandType())); log.info(String.format("成员[%s]由用户[%s]扮演,指令[%s]不执行", member.getId(), member.getUserId(), command.getCommandType()));
} else { } else {
log.info(String.format("机器人代为执行指令[%s]", command.getCommandType())); log.info(String.format("机器人代为执行指令[%s]", command.getCommandType()));
CommandBO.Step step = command.getCommandType().executeOrReturnStep(simulation, command); CommandBO.Step step = command.getCommandType().execute(simulation, command);
if (step != null) { if (step != null) {
log.debug(String.format("指令[%s]执行到%s", command.getCommandType(), step.debugStr())); log.debug(String.format("指令[%s]执行到%s", command.getCommandType(), step.debugStr()));
execute(step, simulation, command.getTargetMember()); execute(step, simulation, command.getTargetMember());

View File

@ -7,14 +7,15 @@ public enum DriveMode {
/** 列车自动驾驶模式:司机监控下的列车自动驾驶 */ /** 列车自动驾驶模式:司机监控下的列车自动驾驶 */
AM { AM {
@Override @Override
public boolean notLowerThan(DriveMode driveMode) { public boolean isNotLowerThan(DriveMode driveMode) {
return true; return true;
} }
}, },
/** ATP防护下的人工驾驶模式司机在列车自动防护设备监控下驾驶列车 */ /** ATP防护下的人工驾驶模式司机在列车自动防护设备监控下驾驶列车 */
CM { CM {
@Override @Override
public boolean notLowerThan(DriveMode driveMode) { public boolean isNotLowerThan(DriveMode driveMode) {
switch (driveMode) { switch (driveMode) {
case AM: case AM:
return false; return false;
@ -26,11 +27,12 @@ public enum DriveMode {
throw new IllegalStateException("Unexpected value: " + driveMode); throw new IllegalStateException("Unexpected value: " + driveMode);
} }
} }
}, },
/** 限制人工驾驶模式:地面设备故障或未设置地面信息设备的线路,列车按规定限速运行,超速时实时制动,直至停车 */ /** 限制人工驾驶模式:地面设备故障或未设置地面信息设备的线路,列车按规定限速运行,超速时实时制动,直至停车 */
RM { RM {
@Override @Override
public boolean notLowerThan(DriveMode driveMode) { public boolean isNotLowerThan(DriveMode driveMode) {
switch (driveMode) { switch (driveMode) {
case AM: case AM:
case CM: case CM:
@ -42,11 +44,12 @@ public enum DriveMode {
throw new IllegalStateException("Unexpected value: " + driveMode); throw new IllegalStateException("Unexpected value: " + driveMode);
} }
} }
}, },
/** 无限制人工驾驶模式列车在运行中没有车载ATP的保护司机根据行车调度员的指示按地面信号机的显示或手信号口令指示行车 */ /** 无限制人工驾驶模式列车在运行中没有车载ATP的保护司机根据行车调度员的指示按地面信号机的显示或手信号口令指示行车 */
NRM { NRM {
@Override @Override
public boolean notLowerThan(DriveMode driveMode) { public boolean isNotLowerThan(DriveMode driveMode) {
switch (driveMode) { switch (driveMode) {
case AM: case AM:
case CM: case CM:
@ -58,7 +61,13 @@ public enum DriveMode {
throw new IllegalStateException("Unexpected value: " + driveMode); throw new IllegalStateException("Unexpected value: " + driveMode);
} }
} }
}; };
public abstract boolean notLowerThan(DriveMode driveMode); public abstract boolean isNotLowerThan(DriveMode driveMode);
public boolean isHigherThan(DriveMode driveMode) {
return this.isNotLowerThan(driveMode) && !this.equals(driveMode);
}
} }

View File

@ -9,7 +9,7 @@ public enum RunLevel {
*/ */
CBTC { CBTC {
@Override @Override
public boolean notLowerThan(RunLevel runLevel) { public boolean isNotLowerThan(RunLevel runLevel) {
return true; return true;
} }
}, },
@ -18,7 +18,7 @@ public enum RunLevel {
*/ */
ITC { ITC {
@Override @Override
public boolean notLowerThan(RunLevel runLevel) { public boolean isNotLowerThan(RunLevel runLevel) {
switch (runLevel) { switch (runLevel) {
case CBTC: case CBTC:
return false; return false;
@ -35,7 +35,7 @@ public enum RunLevel {
*/ */
IL { IL {
@Override @Override
public boolean notLowerThan(RunLevel runLevel) { public boolean isNotLowerThan(RunLevel runLevel) {
switch (runLevel) { switch (runLevel) {
case CBTC: case CBTC:
case ITC: case ITC:
@ -48,5 +48,9 @@ public enum RunLevel {
} }
}; };
public abstract boolean notLowerThan(RunLevel runLevel); public abstract boolean isNotLowerThan(RunLevel runLevel);
public boolean isHigherThan(RunLevel runLevel) {
return this.isNotLowerThan(runLevel) && !this.equals(runLevel);
}
} }

View File

@ -1051,15 +1051,15 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
} }
} }
public boolean isInATOGear() { public boolean isInTheGear(Handwheel gear) {
return Handwheel.ATO.equals(this.gear); return gear.equals(this.gear);
} }
/** /**
* 在空挡 * 在空挡
*/ */
public boolean isInNeutralGear() { public boolean isInNeutralGear() {
return gear == null || Handwheel.WASH.equals(gear) || Handwheel.DISCONNECT.equals(gear); return Handwheel.WASH.equals(gear) || Handwheel.DISCONNECT.equals(gear);
} }
/** /**
@ -1082,17 +1082,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
} }
} }
public ConfirmationMessage removeFirstMessage() {
Iterator<ConfirmationMessage> iterator = confirmationMessages.iterator();
if (iterator.hasNext()) {
ConfirmationMessage next = iterator.next();
iterator.remove();
return next;
} else {
return null;
}
}
public boolean containsMessage(ConfirmationMessage message) { public boolean containsMessage(ConfirmationMessage message) {
return confirmationMessages.contains(message); return confirmationMessages.contains(message);
} }
@ -1124,6 +1113,26 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
return getAtoSpeed() * 3.6 < 20; return getAtoSpeed() * 3.6 < 20;
} }
/** 是否惰行 */
public boolean isCoasting() {
return controlLeaver == 0;
}
/**
* 是否自动开门
*/
public boolean isAutoOpenDoor() {
return isCBTC() && (VirtualRealityTrain.DoorMode.AM.equals(doorMode)
|| VirtualRealityTrain.DoorMode.AA.equals(doorMode));
}
/**
* 是否自动关门
*/
public boolean isAutoCloseDoor() {
return isCBTC() && VirtualRealityTrain.DoorMode.AA.equals(doorMode);
}
@Getter @Getter
@Setter @Setter
public static class Door extends ControllableVrDevice<Door.Operation> { public static class Door extends ControllableVrDevice<Door.Operation> {
@ -1403,17 +1412,24 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
public abstract PreselectionMode findNext(boolean up); public abstract PreselectionMode findNext(boolean up);
/** /**
* 该预选模式与该驾驶模式匹配 * 该预选模式与该驾驶模式匹配即允许升到该模式
*/ */
public boolean isMatchTheDriveMode(DriveMode driveMode) { public boolean isMatchTheDriveMode(DriveMode driveMode) {
return this.driveMode.notLowerThan(driveMode); return this.driveMode.isNotLowerThan(driveMode);
} }
/** /**
* 该预选模式与该运行级别匹配 * 该预选模式与该运行级别匹配
*/ */
public boolean isMatchTheRunLevel(RunLevel runLevel) { public boolean isMatchTheRunLevel(RunLevel runLevel) {
return this.runLevel.notLowerThan(runLevel); return this.runLevel.isNotLowerThan(runLevel);
}
/**
* 是否比该模式级别更高
*/
public boolean isHigherThan(PreselectionMode mode) {
return this.runLevel.isHigherThan(mode.runLevel) && this.driveMode.isHigherThan(mode.driveMode);
} }
} }

View File

@ -66,10 +66,10 @@ public class ATPLogicLoop {
* 更新列车运行级别 * 更新列车运行级别
*/ */
private void updateRunLevel(Simulation simulation, VirtualRealityTrain train, VirtualRealityTrain.PreselectionMode preselectionMode) { private void updateRunLevel(Simulation simulation, VirtualRealityTrain train, VirtualRealityTrain.PreselectionMode preselectionMode) {
//如果当前级别高于预选降至IL // //如果当前级别高于预选降至IL
if (!preselectionMode.isMatchTheRunLevel(train.getRunLevel())) { // if (!preselectionMode.isMatchTheRunLevel(train.getRunLevel())) {
atpService.updateRunLevel(train, RunLevel.IL, preselectionMode); // atpService.updateRunLevel(train, RunLevel.IL, preselectionMode);
} // }
RunLevel defaultRunLevel = simulation.getRepository().getConfig().getRunMode(); RunLevel defaultRunLevel = simulation.getRepository().getConfig().getRunMode();
//更新移动授权丢失时长 //更新移动授权丢失时长
@ -212,7 +212,9 @@ public class ATPLogicLoop {
* 关闭ATO如果状态不正确 * 关闭ATO如果状态不正确
*/ */
private void closeATOIfStatusIsIncorrect(VirtualRealityTrain train) { private void closeATOIfStatusIsIncorrect(VirtualRealityTrain train) {
if (train.isEB() || !train.isInATOGear() || !train.isAMMode()) if (!train.isAtoOn())
return;
if (train.isEB() || !train.isInTheGear(VirtualRealityTrain.Handwheel.ATO) || !train.isAMMode())
atpService.closeATO(train); atpService.closeATO(train);
} }

View File

@ -14,6 +14,7 @@ import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.support.MovementAuthority; import club.joylink.rtss.simulation.cbtc.data.support.MovementAuthority;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.PreselectionMode;
import club.joylink.rtss.simulation.cbtc.onboard.ATO.SpeedCurve; import club.joylink.rtss.simulation.cbtc.onboard.ATO.SpeedCurve;
import club.joylink.rtss.simulation.cbtc.onboard.ATO.service.ATOService; import club.joylink.rtss.simulation.cbtc.onboard.ATO.service.ATOService;
import lombok.NonNull; import lombok.NonNull;
@ -137,10 +138,10 @@ public class ATPService {
if (!train.isAtpOn()) { if (!train.isAtpOn()) {
return; return;
} }
// newATOService.closeATO(train);
train.setSignalEB(true); train.setSignalEB(true);
log.warn(String.format("列车[%s]触发信号EB", train.getGroupNumber())); log.warn(String.format("列车[%s]触发信号EB", train.getGroupNumber()));
train.emergencyBreak(); train.emergencyBreak();
closeATO(train);
} }
/** /**
@ -331,6 +332,9 @@ public class ATPService {
* 改变工况手轮档位 * 改变工况手轮档位
*/ */
public void changeGear(VirtualRealityTrain train, @NonNull VirtualRealityTrain.Handwheel gear) { public void changeGear(VirtualRealityTrain train, @NonNull VirtualRealityTrain.Handwheel gear) {
if (VirtualRealityTrain.Handwheel.REVERSE == gear && !train.isStop()) {
return;
}
train.setGear(gear); train.setGear(gear);
if (!VirtualRealityTrain.Handwheel.ATO.equals(train.getGear())) { if (!VirtualRealityTrain.Handwheel.ATO.equals(train.getGear())) {
closeATO(train); closeATO(train);
@ -356,7 +360,7 @@ public class ATPService {
} }
train.setAtoOn(false); train.setAtoOn(false);
if (DriveMode.AM.equals(train.getDriveMode())) { if (DriveMode.AM.equals(train.getDriveMode())) {
train.setDriveMode(DriveMode.CM); updateDriveMode(train, DriveMode.CM);
} }
} }
@ -385,7 +389,7 @@ public class ATPService {
} }
public void preselectionModeUp(VirtualRealityTrain train) { public void preselectionModeUp(VirtualRealityTrain train) {
VirtualRealityTrain.PreselectionMode next = train.getTempPreselectionMode().findNext(true); PreselectionMode next = train.getTempPreselectionMode().findNext(true);
if (next != null) { if (next != null) {
train.setTempPreselectionMode(next); train.setTempPreselectionMode(next);
train.addMessage(VirtualRealityTrain.ConfirmationMessage.Confirm_Preselection); train.addMessage(VirtualRealityTrain.ConfirmationMessage.Confirm_Preselection);
@ -393,7 +397,7 @@ public class ATPService {
} }
public void preselectionModeDown(VirtualRealityTrain train) { public void preselectionModeDown(VirtualRealityTrain train) {
VirtualRealityTrain.PreselectionMode next = train.getTempPreselectionMode().findNext(false); PreselectionMode next = train.getTempPreselectionMode().findNext(false);
if (next != null) { if (next != null) {
train.setTempPreselectionMode(next); train.setTempPreselectionMode(next);
train.addMessage(VirtualRealityTrain.ConfirmationMessage.Confirm_Preselection); train.addMessage(VirtualRealityTrain.ConfirmationMessage.Confirm_Preselection);
@ -437,7 +441,7 @@ public class ATPService {
} }
public void updateRunLevel(VirtualRealityTrain train, @NonNull RunLevel runLevel, public void updateRunLevel(VirtualRealityTrain train, @NonNull RunLevel runLevel,
VirtualRealityTrain.PreselectionMode preselectionMode) { PreselectionMode preselectionMode) {
if (!preselectionMode.isMatchTheRunLevel(runLevel)) { if (!preselectionMode.isMatchTheRunLevel(runLevel)) {
return; return;
} }
@ -445,13 +449,27 @@ public class ATPService {
switch (runLevel) { switch (runLevel) {
case CBTC: case CBTC:
case ITC: case ITC:
train.setDriveMode(train.isAtoOn() ? DriveMode.AM : DriveMode.CM); updateDriveMode(train, train.isAtoOn() ? DriveMode.AM : DriveMode.CM, preselectionMode);
break; break;
case IL: case IL:
train.setDriveMode(DriveMode.RM); updateDriveMode(train, DriveMode.RM, preselectionMode);
break; break;
default: default:
throw new IllegalStateException("Unexpected value: " + runLevel); throw new IllegalStateException("Unexpected value: " + runLevel);
} }
} }
private void updateDriveMode(VirtualRealityTrain train, DriveMode driveMode) {
updateDriveMode(train, driveMode, train.getPreselectionMode());
}
private void updateDriveMode(VirtualRealityTrain train, DriveMode driveMode, PreselectionMode preselectionMode) {
if (driveMode.equals(train.getDriveMode()))
return;
if (preselectionMode.isMatchTheDriveMode(driveMode)) {
train.setDriveMode(driveMode);
if (!train.isAMMode())
closeATO(train);
}
}
} }