添加切换预选模式指令、移除切换驾驶模式指令
This commit is contained in:
parent
d7b5df2b3b
commit
2c5b139ff8
@ -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.vo.TrainInfo;
|
||||
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.SimulationExceptionType;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
@ -181,7 +184,7 @@ public class CommandBO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
public Step execute(Simulation simulation, CommandBO command) {
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
|
||||
//如果列车没停到目标位置,先想办法开过去---
|
||||
List<Step> steps = command.getStepByType(Step.StepType.DRIVE);
|
||||
@ -219,7 +222,7 @@ public class CommandBO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
public Step execute(Simulation simulation, CommandBO command) {
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
|
||||
if (!DriveMode.CM.equals(train.getDriveMode()) && !DriveMode.AM.equals(train.getDriveMode())) { //如果列车不处于CM/AM运行级别
|
||||
return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM);
|
||||
@ -254,7 +257,7 @@ public class CommandBO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
public Step execute(Simulation simulation, CommandBO command) {
|
||||
String switchCode = (String) command.getParams().get(ParamName.switchCode.name());
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
boolean normal = (boolean) command.getParams().get(ParamName.normal.name());
|
||||
@ -288,7 +291,7 @@ public class CommandBO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
public Step execute(Simulation simulation, CommandBO command) {
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
|
||||
List<Step> steps = command.getStepByType(Step.StepType.DRIVE);
|
||||
Step driveStep = steps.get(0);
|
||||
@ -340,7 +343,7 @@ public class CommandBO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
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();
|
||||
@ -351,8 +354,11 @@ public class CommandBO {
|
||||
return step;
|
||||
}
|
||||
}
|
||||
if (!DriveMode.RM.equals(train.getDriveMode())) {
|
||||
return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.RM);
|
||||
if (!PreselectionMode.RM.equals(train.getPreselectionMode())) {
|
||||
PreselectionMode tempMode = train.getTempPreselectionMode();
|
||||
if (!PreselectionMode.RM.equals(tempMode)) {
|
||||
|
||||
}
|
||||
}
|
||||
List<Step> steps = command.getStepByType(Step.StepType.DRIVE);
|
||||
Step driveStep = steps.get(0);
|
||||
@ -407,7 +413,7 @@ public class CommandBO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
public Step execute(Simulation simulation, CommandBO command) {
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
|
||||
List<Step> steps = command.getStepByType(Step.StepType.OPERATION);
|
||||
Step step = steps.get(0);
|
||||
@ -428,23 +434,16 @@ public class CommandBO {
|
||||
Set_Speed_Limit(List.of(ParamName.speedLimit), SimulationMember.Type.DRIVER) {
|
||||
@Override
|
||||
public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
|
||||
if (!SimulationMember.Type.DRIVER.equals(targetMember.getType())) {
|
||||
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;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
public Step execute(Simulation simulation, CommandBO command) {
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
|
||||
Step step = command.getStepList().get(0);
|
||||
train.setSpeedLimit(step.getSpeedLimit() / 3.6f);
|
||||
float speedLimit = Float.parseFloat((String) command.getParams().get(ParamName.speedLimit.name()));
|
||||
if (speedLimit < 0)
|
||||
speedLimit = Float.MAX_VALUE;
|
||||
train.setSpeedLimit(speedLimit / 3.6f);
|
||||
command.getTargetMember().setCommand(null);
|
||||
return null;
|
||||
}
|
||||
@ -463,7 +462,7 @@ public class CommandBO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
public Step execute(Simulation simulation, CommandBO command) {
|
||||
SimulationMember targetMember = command.getTargetMember();
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
|
||||
if (Objects.equals(train.isRight(), command.getParams().get(ParamName.trainRight.name()))) {
|
||||
@ -483,7 +482,7 @@ public class CommandBO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
public Step execute(Simulation simulation, CommandBO command) {
|
||||
SimulationMember targetMember = command.getTargetMember();
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
|
||||
String sectionCode = (String) command.getParams().get(ParamName.sectionCode.name());
|
||||
@ -498,98 +497,98 @@ public class CommandBO {
|
||||
}
|
||||
},
|
||||
|
||||
/** 转URM模式 */
|
||||
Apply_URM_Mode(List.of(), SimulationMember.Type.DRIVER) {
|
||||
@Override
|
||||
public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
|
||||
if (train.isNRMMode()) {
|
||||
command.getTargetMember().setCommand(null);
|
||||
return null;
|
||||
} else {
|
||||
return buildDriverATPChangeOperationStep(train.getGroupNumber(), true);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** 转RM模式 */
|
||||
Apply_RM_Mode(List.of(), SimulationMember.Type.DRIVER){
|
||||
@Override
|
||||
public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
SimulationMember targetMember = command.getTargetMember();
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
|
||||
if (DriveMode.RM.equals(train.getPreselectionMode())) {
|
||||
targetMember.setCommand(null);
|
||||
return null;
|
||||
} else {
|
||||
if (!train.isAtpOn()) {
|
||||
return buildDriverATPChangeOperationStep(train.getGroupNumber(), false);
|
||||
}
|
||||
targetMember.setCommand(null);
|
||||
return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.RM);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** 转CM模式 */
|
||||
Apply_CM_Mode(List.of(), SimulationMember.Type.DRIVER){
|
||||
@Override
|
||||
public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
SimulationMember targetMember = command.getTargetMember();
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
|
||||
targetMember.setCommand(null);
|
||||
if (DriveMode.CM.equals(train.getPreselectionMode())) {
|
||||
return null;
|
||||
} else {
|
||||
if (!train.isAtpOn()) {
|
||||
return buildDriverATPChangeOperationStep(train.getGroupNumber(), false);
|
||||
}
|
||||
return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** 转AM模式 */
|
||||
Apply_AM_Mode(List.of(), SimulationMember.Type.DRIVER){
|
||||
@Override
|
||||
public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
SimulationMember targetMember = command.getTargetMember();
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
|
||||
if (DriveMode.AM.equals(train.getPreselectionMode())) {
|
||||
targetMember.setCommand(null);
|
||||
return null;
|
||||
}
|
||||
if (!train.isAtpOn()) {
|
||||
return buildDriverATPChangeOperationStep(train.getGroupNumber(), false);
|
||||
}
|
||||
if (!train.isCMMode()) {
|
||||
return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM);
|
||||
} else {
|
||||
targetMember.setCommand(null);
|
||||
return buildDriverAtoOpenOperationStep(train.getGroupNumber());
|
||||
}
|
||||
}
|
||||
},
|
||||
// /** 转URM模式 */
|
||||
// Apply_URM_Mode(List.of(), SimulationMember.Type.DRIVER) {
|
||||
// @Override
|
||||
// public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
|
||||
// return List.of();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
// VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
|
||||
// if (train.isNRMMode()) {
|
||||
// command.getTargetMember().setCommand(null);
|
||||
// return null;
|
||||
// } else {
|
||||
// return buildDriverATPChangeOperationStep(train.getGroupNumber(), true);
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
//
|
||||
// /** 转RM模式 */
|
||||
// Apply_RM_Mode(List.of(), SimulationMember.Type.DRIVER){
|
||||
// @Override
|
||||
// public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
|
||||
// return List.of();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
// SimulationMember targetMember = command.getTargetMember();
|
||||
// VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
|
||||
// if (DriveMode.RM.equals(train.getPreselectionMode())) {
|
||||
// targetMember.setCommand(null);
|
||||
// return null;
|
||||
// } else {
|
||||
// if (!train.isAtpOn()) {
|
||||
// return buildDriverATPChangeOperationStep(train.getGroupNumber(), false);
|
||||
// }
|
||||
// targetMember.setCommand(null);
|
||||
// return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.RM);
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
//
|
||||
// /** 转CM模式 */
|
||||
// Apply_CM_Mode(List.of(), SimulationMember.Type.DRIVER){
|
||||
// @Override
|
||||
// public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
|
||||
// return List.of();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
// SimulationMember targetMember = command.getTargetMember();
|
||||
// VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
|
||||
// targetMember.setCommand(null);
|
||||
// if (DriveMode.CM.equals(train.getPreselectionMode())) {
|
||||
// return null;
|
||||
// } else {
|
||||
// if (!train.isAtpOn()) {
|
||||
// return buildDriverATPChangeOperationStep(train.getGroupNumber(), false);
|
||||
// }
|
||||
// return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM);
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
//
|
||||
// /** 转AM模式 */
|
||||
// Apply_AM_C(List.of(), SimulationMember.Type.DRIVER){
|
||||
// @Override
|
||||
// public List<Step> buildStepList(Simulation simulation, SimulationMember targetMember, Map<String, Object> params) {
|
||||
// return List.of();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
// SimulationMember targetMember = command.getTargetMember();
|
||||
// VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
|
||||
// if (DriveMode.AM.equals(train.getPreselectionMode())) {
|
||||
// targetMember.setCommand(null);
|
||||
// return null;
|
||||
// }
|
||||
// if (!train.isAtpOn()) {
|
||||
// return buildDriverATPChangeOperationStep(train.getGroupNumber(), false);
|
||||
// }
|
||||
// if (!train.isCMMode()) {
|
||||
// return buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM);
|
||||
// } else {
|
||||
// targetMember.setCommand(null);
|
||||
// return buildDriverAtoOpenOperationStep(train.getGroupNumber());
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
|
||||
/** 回库 */
|
||||
Inbound(List.of(), SimulationMember.Type.DRIVER) {
|
||||
@ -599,7 +598,7 @@ public class CommandBO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step executeOrReturnStep(Simulation simulation, CommandBO command) {
|
||||
public Step execute(Simulation simulation, CommandBO command) {
|
||||
SimulationMember driver = command.getTargetMember();
|
||||
driver.setCommand(null);
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) driver.getDevice();
|
||||
@ -614,6 +613,52 @@ public class CommandBO {
|
||||
}
|
||||
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,
|
||||
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操作”步骤
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Step buildDriverAtoOpenOperationStep(String groupNumber) {
|
||||
Map<String, Object> operationParams = new HashMap<>();
|
||||
@ -770,6 +814,47 @@ public class CommandBO {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建“在目标位置停车”步骤
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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);
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) command.getTargetMember().getDevice();
|
||||
SectionPosition headPosition = train.getHeadPosition();
|
||||
boolean right = train.isRight();
|
||||
Step step = steps.get(0);
|
||||
if (step.isFinish() && DriveMode.CM.equals(train.getDriveMode())) { //如果步骤已经完成(指越过正常开放的信号机或站台停车)且列车为CM模式
|
||||
command.getTargetMember().setCommand(null);
|
||||
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检测)---
|
||||
if (RunLevel.ITC.equals(train.getRunLevel()) || RunLevel.CBTC.equals(train.getRunLevel())) {
|
||||
step.finish();
|
||||
@ -861,55 +904,5 @@ public class CommandBO {
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class CommandExecuteService {
|
||||
log.info(String.format("成员[%s]由用户[%s]扮演,指令[%s]不执行", member.getId(), member.getUserId(), command.getCommandType()));
|
||||
} else {
|
||||
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) {
|
||||
log.debug(String.format("指令[%s]执行到%s", command.getCommandType(), step.debugStr()));
|
||||
execute(step, simulation, command.getTargetMember());
|
||||
|
@ -7,14 +7,15 @@ public enum DriveMode {
|
||||
/** 列车自动驾驶模式:司机监控下的列车自动驾驶 */
|
||||
AM {
|
||||
@Override
|
||||
public boolean notLowerThan(DriveMode driveMode) {
|
||||
public boolean isNotLowerThan(DriveMode driveMode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
},
|
||||
/** ATP防护下的人工驾驶模式:司机在列车自动防护设备监控下驾驶列车 */
|
||||
CM {
|
||||
@Override
|
||||
public boolean notLowerThan(DriveMode driveMode) {
|
||||
public boolean isNotLowerThan(DriveMode driveMode) {
|
||||
switch (driveMode) {
|
||||
case AM:
|
||||
return false;
|
||||
@ -26,11 +27,12 @@ public enum DriveMode {
|
||||
throw new IllegalStateException("Unexpected value: " + driveMode);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
/** 限制人工驾驶模式:地面设备故障或未设置地面信息设备的线路,列车按规定限速运行,超速时实时制动,直至停车 */
|
||||
RM {
|
||||
@Override
|
||||
public boolean notLowerThan(DriveMode driveMode) {
|
||||
public boolean isNotLowerThan(DriveMode driveMode) {
|
||||
switch (driveMode) {
|
||||
case AM:
|
||||
case CM:
|
||||
@ -42,11 +44,12 @@ public enum DriveMode {
|
||||
throw new IllegalStateException("Unexpected value: " + driveMode);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
/** 无限制人工驾驶模式:列车在运行中没有车载ATP的保护,司机根据行车调度员的指示,按地面信号机的显示或手信号(口令)指示行车 */
|
||||
NRM {
|
||||
@Override
|
||||
public boolean notLowerThan(DriveMode driveMode) {
|
||||
public boolean isNotLowerThan(DriveMode driveMode) {
|
||||
switch (driveMode) {
|
||||
case AM:
|
||||
case CM:
|
||||
@ -58,7 +61,13 @@ public enum 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public enum RunLevel {
|
||||
*/
|
||||
CBTC {
|
||||
@Override
|
||||
public boolean notLowerThan(RunLevel runLevel) {
|
||||
public boolean isNotLowerThan(RunLevel runLevel) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
@ -18,7 +18,7 @@ public enum RunLevel {
|
||||
*/
|
||||
ITC {
|
||||
@Override
|
||||
public boolean notLowerThan(RunLevel runLevel) {
|
||||
public boolean isNotLowerThan(RunLevel runLevel) {
|
||||
switch (runLevel) {
|
||||
case CBTC:
|
||||
return false;
|
||||
@ -35,7 +35,7 @@ public enum RunLevel {
|
||||
*/
|
||||
IL {
|
||||
@Override
|
||||
public boolean notLowerThan(RunLevel runLevel) {
|
||||
public boolean isNotLowerThan(RunLevel runLevel) {
|
||||
switch (runLevel) {
|
||||
case CBTC:
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1051,15 +1051,15 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInATOGear() {
|
||||
return Handwheel.ATO.equals(this.gear);
|
||||
public boolean isInTheGear(Handwheel gear) {
|
||||
return gear.equals(this.gear);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在空挡?
|
||||
*/
|
||||
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) {
|
||||
return confirmationMessages.contains(message);
|
||||
}
|
||||
@ -1124,6 +1113,26 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
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
|
||||
@Setter
|
||||
public static class Door extends ControllableVrDevice<Door.Operation> {
|
||||
@ -1403,17 +1412,24 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
public abstract PreselectionMode findNext(boolean up);
|
||||
|
||||
/**
|
||||
* 该预选模式与该驾驶模式匹配
|
||||
* 该预选模式与该驾驶模式匹配(即允许升到该模式)
|
||||
*/
|
||||
public boolean isMatchTheDriveMode(DriveMode driveMode) {
|
||||
return this.driveMode.notLowerThan(driveMode);
|
||||
return this.driveMode.isNotLowerThan(driveMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 该预选模式与该运行级别匹配
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,10 +66,10 @@ public class ATPLogicLoop {
|
||||
* 更新列车运行级别
|
||||
*/
|
||||
private void updateRunLevel(Simulation simulation, VirtualRealityTrain train, VirtualRealityTrain.PreselectionMode preselectionMode) {
|
||||
//如果当前级别高于预选,降至IL
|
||||
if (!preselectionMode.isMatchTheRunLevel(train.getRunLevel())) {
|
||||
atpService.updateRunLevel(train, RunLevel.IL, preselectionMode);
|
||||
}
|
||||
// //如果当前级别高于预选,降至IL
|
||||
// if (!preselectionMode.isMatchTheRunLevel(train.getRunLevel())) {
|
||||
// atpService.updateRunLevel(train, RunLevel.IL, preselectionMode);
|
||||
// }
|
||||
|
||||
RunLevel defaultRunLevel = simulation.getRepository().getConfig().getRunMode();
|
||||
//更新移动授权丢失时长
|
||||
@ -212,7 +212,9 @@ public class ATPLogicLoop {
|
||||
* 关闭ATO,如果状态不正确
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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.SectionPosition;
|
||||
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.service.ATOService;
|
||||
import lombok.NonNull;
|
||||
@ -137,10 +138,10 @@ public class ATPService {
|
||||
if (!train.isAtpOn()) {
|
||||
return;
|
||||
}
|
||||
// newATOService.closeATO(train);
|
||||
train.setSignalEB(true);
|
||||
log.warn(String.format("列车[%s]触发信号EB", train.getGroupNumber()));
|
||||
train.emergencyBreak();
|
||||
closeATO(train);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -331,6 +332,9 @@ public class ATPService {
|
||||
* 改变工况手轮档位
|
||||
*/
|
||||
public void changeGear(VirtualRealityTrain train, @NonNull VirtualRealityTrain.Handwheel gear) {
|
||||
if (VirtualRealityTrain.Handwheel.REVERSE == gear && !train.isStop()) {
|
||||
return;
|
||||
}
|
||||
train.setGear(gear);
|
||||
if (!VirtualRealityTrain.Handwheel.ATO.equals(train.getGear())) {
|
||||
closeATO(train);
|
||||
@ -356,7 +360,7 @@ public class ATPService {
|
||||
}
|
||||
train.setAtoOn(false);
|
||||
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) {
|
||||
VirtualRealityTrain.PreselectionMode next = train.getTempPreselectionMode().findNext(true);
|
||||
PreselectionMode next = train.getTempPreselectionMode().findNext(true);
|
||||
if (next != null) {
|
||||
train.setTempPreselectionMode(next);
|
||||
train.addMessage(VirtualRealityTrain.ConfirmationMessage.Confirm_Preselection);
|
||||
@ -393,7 +397,7 @@ public class ATPService {
|
||||
}
|
||||
|
||||
public void preselectionModeDown(VirtualRealityTrain train) {
|
||||
VirtualRealityTrain.PreselectionMode next = train.getTempPreselectionMode().findNext(false);
|
||||
PreselectionMode next = train.getTempPreselectionMode().findNext(false);
|
||||
if (next != null) {
|
||||
train.setTempPreselectionMode(next);
|
||||
train.addMessage(VirtualRealityTrain.ConfirmationMessage.Confirm_Preselection);
|
||||
@ -437,7 +441,7 @@ public class ATPService {
|
||||
}
|
||||
|
||||
public void updateRunLevel(VirtualRealityTrain train, @NonNull RunLevel runLevel,
|
||||
VirtualRealityTrain.PreselectionMode preselectionMode) {
|
||||
PreselectionMode preselectionMode) {
|
||||
if (!preselectionMode.isMatchTheRunLevel(runLevel)) {
|
||||
return;
|
||||
}
|
||||
@ -445,13 +449,27 @@ public class ATPService {
|
||||
switch (runLevel) {
|
||||
case CBTC:
|
||||
case ITC:
|
||||
train.setDriveMode(train.isAtoOn() ? DriveMode.AM : DriveMode.CM);
|
||||
updateDriveMode(train, train.isAtoOn() ? DriveMode.AM : DriveMode.CM, preselectionMode);
|
||||
break;
|
||||
case IL:
|
||||
train.setDriveMode(DriveMode.RM);
|
||||
updateDriveMode(train, DriveMode.RM, preselectionMode);
|
||||
break;
|
||||
default:
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user