修改设置备用车时列车级别不正确的bug;修改机器人驾驶及ATS界面的修改预选模式操作逻辑;挤岔恢复操作增加等待
This commit is contained in:
parent
376590f5d1
commit
67175c5919
@ -12,11 +12,10 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATO.service.ATOService;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
|
||||
import club.joylink.rtss.simulation.cbtc.robot.SimulationRobotService;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 司机操作处理
|
||||
*/
|
||||
@ -24,59 +23,63 @@ import java.util.Objects;
|
||||
@Slf4j
|
||||
public class DriverOperateHandler {
|
||||
|
||||
@Autowired
|
||||
private ATOService ATOService;
|
||||
@Autowired
|
||||
private ATOService ATOService;
|
||||
|
||||
@Autowired
|
||||
private ATPService ATPService;
|
||||
@Autowired
|
||||
private ATPService ATPService;
|
||||
|
||||
@Autowired
|
||||
private SimulationRobotService simulationRobotService;
|
||||
@Autowired
|
||||
private SimulationRobotService simulationRobotService;
|
||||
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Force_Change)
|
||||
public void changeTrainForce(Simulation simulation, String groupNumber, Float percent) {
|
||||
Objects.requireNonNull(percent);
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train))
|
||||
return;
|
||||
ATPService.changeTrainForce(train, percent);
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Force_Change)
|
||||
public void changeTrainForce(Simulation simulation, String groupNumber, Float percent) {
|
||||
Objects.requireNonNull(percent);
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train)) {
|
||||
return;
|
||||
}
|
||||
ATPService.changeTrainForce(train, percent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 紧急制动
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_EB)
|
||||
public void trainEB(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train)) {
|
||||
return;
|
||||
}
|
||||
if (train.isCircuitEB()) {
|
||||
this.ATPService.cancelCircuitEB(train);
|
||||
} else {
|
||||
this.ATPService.triggerCircuitEB(train);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 紧急制动
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_EB)
|
||||
public void trainEB(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train))
|
||||
return;
|
||||
if (train.isCircuitEB()) {
|
||||
this.ATPService.cancelCircuitEB(train);
|
||||
} else {
|
||||
this.ATPService.triggerCircuitEB(train);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 修改工况手轮档位
|
||||
*
|
||||
* @param simulation
|
||||
* @param groupNumber
|
||||
* @param gear
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Gear_Change)
|
||||
public void changeTrainGear(Simulation simulation, String groupNumber,
|
||||
VirtualRealityTrain.Handwheel gear) {
|
||||
Objects.requireNonNull(gear);
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train)) {
|
||||
return;
|
||||
}
|
||||
ATPService.changeGear(train, gear);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改工况手轮档位
|
||||
*
|
||||
* @param simulation
|
||||
* @param groupNumber
|
||||
* @param gear
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Gear_Change)
|
||||
public void changeTrainGear(Simulation simulation, String groupNumber, VirtualRealityTrain.Handwheel gear) {
|
||||
Objects.requireNonNull(gear);
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train))
|
||||
return;
|
||||
ATPService.changeGear(train, gear);
|
||||
}
|
||||
|
||||
// 场景旧数据反序列化需要
|
||||
@Deprecated
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Drive_Mode_Change)
|
||||
public void changeTrainDriveMode(Simulation simulation, String groupNumber, DriveMode driveMode) {
|
||||
// 场景旧数据反序列化需要
|
||||
@Deprecated
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Drive_Mode_Change)
|
||||
public void changeTrainDriveMode(Simulation simulation, String groupNumber, DriveMode driveMode) {
|
||||
// VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
// switch (driveMode) {
|
||||
// case AM:
|
||||
@ -87,182 +90,194 @@ public class DriverOperateHandler {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_ATO_Open)
|
||||
public void openAto(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train))
|
||||
return;
|
||||
ATPService.openATO(train);
|
||||
}
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_ATO_Open)
|
||||
public void openAto(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train)) {
|
||||
return;
|
||||
}
|
||||
ATPService.openATO(train);
|
||||
}
|
||||
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_ATP_Change)
|
||||
public void changeAtpStatus(Simulation simulation, String groupNumber, boolean cutOff) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train))
|
||||
return;
|
||||
if (cutOff) {
|
||||
this.ATPService.cutOffAtp(train);
|
||||
} else {
|
||||
this.ATPService.openAtp(train);
|
||||
}
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_ATP_Change)
|
||||
public void changeAtpStatus(Simulation simulation, String groupNumber, boolean cutOff) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train)) {
|
||||
return;
|
||||
}
|
||||
if (cutOff) {
|
||||
this.ATPService.cutOffAtp(train);
|
||||
} else {
|
||||
this.ATPService.openAtp(train);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Change_Head)
|
||||
public void changeHead(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train))
|
||||
return;
|
||||
if (train.isStop()) {
|
||||
this.ATPService.turnDirectionImmediately(train);
|
||||
}
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Change_Head)
|
||||
public void changeHead(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train)) {
|
||||
return;
|
||||
}
|
||||
if (train.isStop()) {
|
||||
this.ATPService.turnDirectionImmediately(train);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开/关门
|
||||
*
|
||||
* @param groupNumber 要开/关门的列车的车组号
|
||||
* @param right 要开/关右边的门吗
|
||||
* @param open 要开门吗
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Door_On_Off)
|
||||
public void onOrOffDoor(Simulation simulation, String groupNumber, Boolean right, Boolean open) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train))
|
||||
return;
|
||||
ATPService.openOrCloseDoor(simulation, train, right, open);
|
||||
}
|
||||
/**
|
||||
* 开/关门
|
||||
*
|
||||
* @param groupNumber 要开/关门的列车的车组号
|
||||
* @param right 要开/关右边的门吗
|
||||
* @param open 要开门吗
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Door_On_Off)
|
||||
public void onOrOffDoor(Simulation simulation, String groupNumber, Boolean right, Boolean open) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train)) {
|
||||
return;
|
||||
}
|
||||
ATPService.openOrCloseDoor(simulation, train, right, open);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置门模式
|
||||
*
|
||||
* @param groupNumber 车组号
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Door_Mode)
|
||||
public void setDriverDoorMode(Simulation simulation, String groupNumber,
|
||||
VirtualRealityTrain.DoorMode doorMode) {
|
||||
if (Objects.isNull(doorMode)) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "门模式不能为空");
|
||||
}
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train))
|
||||
return;
|
||||
train.setDoorMode(doorMode);
|
||||
/**
|
||||
* 设置门模式
|
||||
*
|
||||
* @param groupNumber 车组号
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Door_Mode)
|
||||
public void setDriverDoorMode(Simulation simulation, String groupNumber,
|
||||
VirtualRealityTrain.DoorMode doorMode) {
|
||||
if (Objects.isNull(doorMode)) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "门模式不能为空");
|
||||
}
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train)) {
|
||||
return;
|
||||
}
|
||||
train.setDoorMode(doorMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置门选择
|
||||
*
|
||||
* @param groupNumber 车组号
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Door_Selection)
|
||||
public void setDriverDoorSelection(Simulation simulation, String groupNumber,
|
||||
VirtualRealityTrain.DoorSelection doorSelection) {
|
||||
if (Objects.isNull(doorSelection)) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "门选择不能为空");
|
||||
}
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train))
|
||||
return;
|
||||
train.setDoorSelection(doorSelection);
|
||||
/**
|
||||
* 设置门选择
|
||||
*
|
||||
* @param groupNumber 车组号
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Door_Selection)
|
||||
public void setDriverDoorSelection(Simulation simulation, String groupNumber,
|
||||
VirtualRealityTrain.DoorSelection doorSelection) {
|
||||
if (Objects.isNull(doorSelection)) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "门选择不能为空");
|
||||
}
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train)) {
|
||||
return;
|
||||
}
|
||||
train.setDoorSelection(doorSelection);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模式升
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Preselection_Mode_Up)
|
||||
public void beforehandModeUp(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train))
|
||||
return;
|
||||
ATPService.preselectionModeUp(train);
|
||||
}
|
||||
/**
|
||||
* 模式升
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Preselection_Mode_Up)
|
||||
public void beforehandModeUp(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train)) {
|
||||
return;
|
||||
}
|
||||
ATPService.preselectionModeUp(train);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模式降
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Preselection_Mode_Down)
|
||||
public void beforehandModeDown(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train))
|
||||
return;
|
||||
ATPService.preselectionModeDown(train);
|
||||
}
|
||||
/**
|
||||
* 模式降
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Preselection_Mode_Down)
|
||||
public void beforehandModeDown(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train)) {
|
||||
return;
|
||||
}
|
||||
ATPService.preselectionModeDown(train);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Confirm)
|
||||
public void confirmMessage(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train))
|
||||
return;
|
||||
ATPService.confirmMessage(train);
|
||||
}
|
||||
/**
|
||||
* 确认
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Confirm)
|
||||
public void confirmMessage(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
if (!validate(train)) {
|
||||
return;
|
||||
}
|
||||
ATPService.confirmMessage(train);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接管列车
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_TakeOver)
|
||||
public void takeOver(Simulation simulation, String groupNumber, Boolean takeOver) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
train.setTakeOver(takeOver);
|
||||
}
|
||||
/**
|
||||
* 接管列车
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_TakeOver)
|
||||
public void takeOver(Simulation simulation, String groupNumber, Boolean takeOver) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
|
||||
train.setTakeOver(takeOver);
|
||||
}
|
||||
|
||||
/**
|
||||
* ATS停车
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Stop)
|
||||
public void stopTrain(Simulation simulation, SimulationMember simulationMember, String groupNumber, Boolean eb) {
|
||||
simulationRobotService.stopTrain(simulation, simulationMember, groupNumber, eb);
|
||||
}
|
||||
/**
|
||||
* ATS停车
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Stop)
|
||||
public void stopTrain(Simulation simulation, SimulationMember simulationMember,
|
||||
String groupNumber, Boolean eb) {
|
||||
simulationRobotService.stopTrain(simulation, simulationMember, groupNumber, eb);
|
||||
}
|
||||
|
||||
/**
|
||||
* ATS开关门
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Open_Or_Close_Door)
|
||||
public void openOrCloseDoor(Simulation simulation, String groupNumber) {
|
||||
ATPService.openOrCloseDoor(simulation, groupNumber);
|
||||
}
|
||||
/**
|
||||
* ATS开关门
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Open_Or_Close_Door)
|
||||
public void openOrCloseDoor(Simulation simulation, String groupNumber) {
|
||||
ATPService.openOrCloseDoor(simulation, groupNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回库
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Inbound)
|
||||
public void inbound(Simulation simulation,String groupNumber) {
|
||||
ATPService.inbound(simulation, groupNumber);
|
||||
}
|
||||
/**
|
||||
* 回库
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Inbound)
|
||||
public void inbound(Simulation simulation, String groupNumber) {
|
||||
ATPService.inbound(simulation, groupNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* ATS修改预选模式
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Change_Preselection_Mode)
|
||||
public void changePreselectionMode(Simulation simulation, String groupNumber
|
||||
, VirtualRealityTrain.PreselectionMode preselectionMode) {
|
||||
ATPService.changePreselectionMode(simulation, groupNumber, preselectionMode);
|
||||
}
|
||||
/**
|
||||
* ATS修改预选模式
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Change_Preselection_Mode)
|
||||
public void changePreselectionMode(Simulation simulation, String groupNumber
|
||||
, VirtualRealityTrain.PreselectionMode preselectionMode) {
|
||||
ATPService.changePreselectionMode(simulation, groupNumber, preselectionMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* ATS转NRM模式
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Apply_NRM)
|
||||
public void applyNRM(Simulation simulation, String groupNumber) {
|
||||
ATPService.applyNRM(simulation, groupNumber);
|
||||
}
|
||||
/**
|
||||
* ATS转NRM模式
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Apply_NRM)
|
||||
public void applyNRM(Simulation simulation, String groupNumber) {
|
||||
ATPService.applyNRM(simulation, groupNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* ATS操作打开 ATO
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Try_Open_Ato)
|
||||
public void tryOpenAto(Simulation simulation, String groupNumber) {
|
||||
ATPService.openAto(simulation, groupNumber);
|
||||
}
|
||||
/**
|
||||
* ATS操作打开 ATO
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Try_Open_Ato)
|
||||
public void tryOpenAto(Simulation simulation, String groupNumber) {
|
||||
VirtualRealityTrain train = simulation.getRepository()
|
||||
.getVRByCode(groupNumber, VirtualRealityTrain.class);
|
||||
ATPService.openATO(train);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户可操作的前提条件
|
||||
*/
|
||||
private boolean validate(VirtualRealityTrain train) {
|
||||
return train.isTakeOver();
|
||||
}
|
||||
/**
|
||||
* 校验用户可操作的前提条件
|
||||
*/
|
||||
private boolean validate(VirtualRealityTrain train) {
|
||||
return train.isTakeOver();
|
||||
}
|
||||
}
|
||||
|
@ -15,341 +15,353 @@ import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Switch;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@OperateHandler
|
||||
@Slf4j
|
||||
public class SwitchOperateHandler {
|
||||
|
||||
@Autowired
|
||||
private CiApiService ciApiService;
|
||||
@Autowired
|
||||
private CiApiService ciApiService;
|
||||
|
||||
@Autowired
|
||||
private AtsSectionService atsSectionService;
|
||||
@Autowired
|
||||
private AtsSectionService atsSectionService;
|
||||
|
||||
@Autowired
|
||||
private GroundAtpApiService groundAtpApiService;
|
||||
@Autowired
|
||||
private GroundAtpApiService groundAtpApiService;
|
||||
|
||||
/**
|
||||
* 道岔转动
|
||||
*
|
||||
* @param simulation
|
||||
* @param switchCode
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Turn)
|
||||
public void turn(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
BusinessExceptionAssertEnum.SIMULATION_EXCEPTION_FOR_SHOW.assertTrue(!aSwitch.isLocked(),
|
||||
String.format("联锁操作被取消,道岔%s被锁定", aSwitch.getName()));
|
||||
SwitchIndication pos = this.ciApiService.turn(simulation, switchCode);
|
||||
/**
|
||||
* 道岔转动
|
||||
*
|
||||
* @param simulation
|
||||
* @param switchCode
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Turn)
|
||||
public void turn(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
BusinessExceptionAssertEnum.SIMULATION_EXCEPTION_FOR_SHOW.assertTrue(!aSwitch.isLocked(),
|
||||
String.format("联锁操作被取消,道岔%s被锁定", aSwitch.getName()));
|
||||
SwitchIndication pos = this.ciApiService.turn(simulation, switchCode);
|
||||
|
||||
waitResult(simulation, aSwitch, pos);
|
||||
waitResult(simulation, aSwitch, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔定操
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Normal_Position)
|
||||
public void turn2Normal(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
if (!aSwitch.canTurn()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
"道岔锁闭或占用,无法转动");
|
||||
}
|
||||
if (aSwitch.isPosN()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
"道岔已经在定位,无需转动");
|
||||
}
|
||||
this.ciApiService.turn2NormalPosition(simulation, switchCode);
|
||||
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
|
||||
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
|
||||
if (Objects.nonNull(linkedSwitch)) {
|
||||
this.ciApiService.turn2NormalPosition(simulation, linkedSwitch.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔反操
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Reverse_Position)
|
||||
public void turn2Reverse(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
if (!aSwitch.canTurn()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
"道岔锁闭或占用,无法转动");
|
||||
}
|
||||
if (aSwitch.isPosR()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
"道岔已经在反位,无需转动");
|
||||
}
|
||||
this.ciApiService.turn2ReversePosition(simulation, switchCode);
|
||||
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
|
||||
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
|
||||
if (Objects.nonNull(linkedSwitch)) {
|
||||
this.ciApiService.turn2ReversePosition(simulation, linkedSwitch.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔单锁
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Single_Lock)
|
||||
public void singleLockSwitch(Simulation simulation, String switchCode) {
|
||||
ciApiService.singleLockSwitch(simulation, switchCode);
|
||||
//联动
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
if (repository.getConfig().isSwitchSingleLockChain()) {
|
||||
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
|
||||
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
|
||||
if (Objects.nonNull(linkedSwitch)) {
|
||||
this.ciApiService.singleLockSwitch(simulation, linkedSwitch.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔单解
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Single_Unlock)
|
||||
public void singleUnlockSwitch(Simulation simulation, String switchCode) {
|
||||
ciApiService.singleUnlockSwitch(simulation, switchCode);
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
if (repository.getConfig().isSwitchSingleLockChain()) {
|
||||
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
|
||||
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
|
||||
if (Objects.nonNull(linkedSwitch)) {
|
||||
this.ciApiService.singleUnlockSwitch(simulation, linkedSwitch.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔初始化封锁
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Initialize_Block)
|
||||
public void initializeBlock(Simulation simulation, String switchCode) {
|
||||
ciApiService.initializeBlock(simulation, switchCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔封锁l
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Block)
|
||||
public void blockadeSwitch(Simulation simulation, String switchCode) {
|
||||
ciApiService.blockadeSwitch(simulation, switchCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔解锁l
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Unblock)
|
||||
public void unblockSwitch(Simulation simulation, String switchCode) {
|
||||
ciApiService.unblockSwitch(simulation, switchCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔区段封锁l
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Section_Block)
|
||||
public void blockadeSwitchSection(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
ciApiService.blockadeSwitchSection(simulation, aSwitch.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔区段解封l
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Section_Unblock)
|
||||
public void unblockSwitchSection(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
ciApiService.unblockSwitchSection(simulation, aSwitch.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔跟踪切除
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Cut_Off)
|
||||
public void cutoff(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
this.atsSectionService.cutoff(simulation, aSwitch.getA());
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔跟踪激活
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Active)
|
||||
public void active(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
this.atsSectionService.active(simulation, aSwitch.getA());
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认计轴有效c
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Confirm_Axis_Valid)
|
||||
public void confirmAxisValid(Simulation simulation, String switchCode) {
|
||||
//ZC 系统
|
||||
log.debug("仿真[{}] : 道岔[{}]确认计轴有效", simulation.getId(), switchCode);
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
this.atsSectionService.confirmAxleValid(simulation, aSwitch.getA());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置临时限速/轨区设限
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Set_Limit_Speed)
|
||||
public void setLimitSpeed(Simulation simulation, String switchCode, String speedLimitValue) {
|
||||
int limitSpeed;
|
||||
try {
|
||||
limitSpeed = Integer.parseInt(speedLimitValue);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
"速度值必须为数字!");
|
||||
}
|
||||
this.groundAtpApiService.setSwitchLimitSpeed(simulation, switchCode, limitSpeed);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消临时限速/轨区消限
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Cancel_Limit_Speed)
|
||||
public void cancelLimitSpeed(Simulation simulation, String switchCode) {
|
||||
this.groundAtpApiService.cancelSwitchLimitSpeed(simulation, switchCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔计轴预复位
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Axle_Pre_Reset)
|
||||
public void axlePreReset(Simulation simulation, String switchCode) {
|
||||
ciApiService.switchAxlePreReset(simulation, switchCode);
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
ciApiService.axlePreReset(simulation, aSwitch.getA().getParent().getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 区故解
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Fault_Unlock)
|
||||
public void switchSectionFaultUnlock(Simulation simulation, String switchCode) {
|
||||
log.debug("仿真[{}] : 道岔[{}]区故解", simulation.getId(), switchCode);
|
||||
ciApiService.switchSectionFaultUnlock(simulation, switchCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔钩锁
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Hook_Lock)
|
||||
public void switchHookLock(Simulation simulation, String switchCode, Boolean normal) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
|
||||
if (normal) {
|
||||
aSwitch.getVirtualSwitch().setP(SwitchIndication.N);
|
||||
} else {
|
||||
aSwitch.getVirtualSwitch().setP(SwitchIndication.R);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔定操
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Normal_Position)
|
||||
public void turn2Normal(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
if (!aSwitch.canTurn()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
"道岔锁闭或占用,无法转动");
|
||||
}
|
||||
if (aSwitch.isPosN()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
"道岔已经在定位,无需转动");
|
||||
}
|
||||
this.ciApiService.turn2NormalPosition(simulation, switchCode);
|
||||
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
|
||||
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
|
||||
if (Objects.nonNull(linkedSwitch)) {
|
||||
this.ciApiService.turn2NormalPosition(simulation, linkedSwitch.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔反操
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Reverse_Position)
|
||||
public void turn2Reverse(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
if (!aSwitch.canTurn()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
"道岔锁闭或占用,无法转动");
|
||||
}
|
||||
if (aSwitch.isPosR()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
"道岔已经在反位,无需转动");
|
||||
}
|
||||
this.ciApiService.turn2ReversePosition(simulation, switchCode);
|
||||
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
|
||||
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
|
||||
if (Objects.nonNull(linkedSwitch)) {
|
||||
this.ciApiService.turn2ReversePosition(simulation, linkedSwitch.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔单锁
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Single_Lock)
|
||||
public void singleLockSwitch(Simulation simulation, String switchCode) {
|
||||
ciApiService.singleLockSwitch(simulation, switchCode);
|
||||
//联动
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
if (repository.getConfig().isSwitchSingleLockChain()) {
|
||||
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
|
||||
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
|
||||
if (Objects.nonNull(linkedSwitch)) {
|
||||
this.ciApiService.singleLockSwitch(simulation, linkedSwitch.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔单解
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Single_Unlock)
|
||||
public void singleUnlockSwitch(Simulation simulation, String switchCode) {
|
||||
ciApiService.singleUnlockSwitch(simulation, switchCode);
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
if (repository.getConfig().isSwitchSingleLockChain()) {
|
||||
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
|
||||
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
|
||||
if (Objects.nonNull(linkedSwitch)) {
|
||||
this.ciApiService.singleUnlockSwitch(simulation, linkedSwitch.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔初始化封锁
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Initialize_Block)
|
||||
public void initializeBlock(Simulation simulation, String switchCode) {
|
||||
ciApiService.initializeBlock(simulation, switchCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔封锁l
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Block)
|
||||
public void blockadeSwitch(Simulation simulation, String switchCode) {
|
||||
ciApiService.blockadeSwitch(simulation, switchCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔解锁l
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Unblock)
|
||||
public void unblockSwitch(Simulation simulation, String switchCode) {
|
||||
ciApiService.unblockSwitch(simulation, switchCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔区段封锁l
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Section_Block)
|
||||
public void blockadeSwitchSection(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
ciApiService.blockadeSwitchSection(simulation, aSwitch.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔区段解封l
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Section_Unblock)
|
||||
public void unblockSwitchSection(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
ciApiService.unblockSwitchSection(simulation, aSwitch.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔跟踪切除
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Cut_Off)
|
||||
public void cutoff(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
this.atsSectionService.cutoff(simulation, aSwitch.getA());
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔跟踪激活
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Active)
|
||||
public void active(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
this.atsSectionService.active(simulation, aSwitch.getA());
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认计轴有效c
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Confirm_Axis_Valid)
|
||||
public void confirmAxisValid(Simulation simulation, String switchCode) {
|
||||
//ZC 系统
|
||||
log.debug("仿真[{}] : 道岔[{}]确认计轴有效", simulation.getId(), switchCode);
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
this.atsSectionService.confirmAxleValid(simulation, aSwitch.getA());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置临时限速/轨区设限
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Set_Limit_Speed)
|
||||
public void setLimitSpeed(Simulation simulation, String switchCode, String speedLimitValue) {
|
||||
int limitSpeed;
|
||||
try {
|
||||
limitSpeed = Integer.parseInt(speedLimitValue);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "速度值必须为数字!");
|
||||
}
|
||||
this.groundAtpApiService.setSwitchLimitSpeed(simulation, switchCode, limitSpeed);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消临时限速/轨区消限
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Cancel_Limit_Speed)
|
||||
public void cancelLimitSpeed(Simulation simulation, String switchCode) {
|
||||
this.groundAtpApiService.cancelSwitchLimitSpeed(simulation, switchCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔计轴预复位
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Axle_Pre_Reset)
|
||||
public void axlePreReset(Simulation simulation, String switchCode) {
|
||||
ciApiService.switchAxlePreReset(simulation, switchCode);
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
ciApiService.axlePreReset(simulation, aSwitch.getA().getParent().getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* 区故解
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Fault_Unlock)
|
||||
public void switchSectionFaultUnlock(Simulation simulation, String switchCode) {
|
||||
log.debug("仿真[{}] : 道岔[{}]区故解", simulation.getId(), switchCode);
|
||||
ciApiService.switchSectionFaultUnlock(simulation, switchCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔钩锁
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Hook_Lock)
|
||||
public void switchHookLock(Simulation simulation, String switchCode, Boolean normal) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
|
||||
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
|
||||
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
|
||||
if (linkedSwitch != null) {
|
||||
if (normal) {
|
||||
aSwitch.getVirtualSwitch().setP(SwitchIndication.N);
|
||||
linkedSwitch.getVirtualSwitch().setP(SwitchIndication.N);
|
||||
} else {
|
||||
aSwitch.getVirtualSwitch().setP(SwitchIndication.R);
|
||||
linkedSwitch.getVirtualSwitch().setP(SwitchIndication.R);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
|
||||
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
|
||||
if (linkedSwitch != null) {
|
||||
if (normal) {
|
||||
linkedSwitch.getVirtualSwitch().setP(SwitchIndication.N);
|
||||
} else {
|
||||
linkedSwitch.getVirtualSwitch().setP(SwitchIndication.R);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 强行转岔
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Force_Turn)
|
||||
public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) {
|
||||
SwitchIndication pos = ciApiService.switchForceTurn(simulation, switchCode);
|
||||
|
||||
waitResult(simulation, simulation.getRepository().getByCode(switchCode, Switch.class), pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 挤岔恢复
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Squeeze_Recovery)
|
||||
public void switchSqueezeRecovery(Simulation simulation, String switchCode) {
|
||||
ciApiService.switchSqueezeRecovery(simulation, switchCode);
|
||||
|
||||
waitResult(simulation, simulation.getRepository().getByCode(switchCode, Switch.class),
|
||||
SwitchIndication.N, SwitchIndication.R);
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令【泰雷兹】
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Command)
|
||||
public void switchCommand(Simulation simulation, String switchCode, Boolean auto, Boolean reserve,
|
||||
Boolean normal) {
|
||||
ciApiService.switchCommand(simulation, switchCode, auto, reserve, normal);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 道岔分路不良
|
||||
*
|
||||
* @param simulation 仿真实体
|
||||
* @param switchCode 道岔编码
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Defective_Shunting)
|
||||
public void defectiveShunting(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
List<Section.ShuntingType> shuntingTypeList = Arrays.asList(
|
||||
Section.ShuntingType.SWITCH_FRONT_SHUNTING,
|
||||
Section.ShuntingType.FIXED_POSITION_SHUNTING,
|
||||
Section.ShuntingType.REVERSE_POSITION_SHUNTING);
|
||||
atsSectionService.defectiveShunting(simulation, aSwitch.getA().getCode(), shuntingTypeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消道岔分路不良
|
||||
*
|
||||
* @param simulation 仿真实体
|
||||
* @param switchCode 道岔编码
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Cancel_Defective_Shunting)
|
||||
public void cancelDefectiveShunting(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
atsSectionService.defectiveShunting(simulation, aSwitch.getA().getCode(), new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔只要处于{posArr}中任意一个位置就认为操作完成
|
||||
*/
|
||||
private static void waitResult(Simulation simulation, Switch aSwitch,
|
||||
SwitchIndication... posArr) {
|
||||
//等待转动完成
|
||||
LocalDateTime timeoutTime = simulation.getSystemTime().plusSeconds(13);
|
||||
CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> {
|
||||
while (true) {
|
||||
for (SwitchIndication pos : posArr) {
|
||||
if (Objects.equals(aSwitch.getPos(), pos)) {
|
||||
return true;
|
||||
}
|
||||
if (simulation.getSystemTime().isAfter(timeoutTime)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 强行转岔
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Force_Turn)
|
||||
public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) {
|
||||
SwitchIndication pos = ciApiService.switchForceTurn(simulation, switchCode);
|
||||
|
||||
waitResult(simulation, simulation.getRepository().getByCode(switchCode, Switch.class), pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 挤岔恢复
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Squeeze_Recovery)
|
||||
public void switchSqueezeRecovery(Simulation simulation, String switchCode) {
|
||||
ciApiService.switchSqueezeRecovery(simulation, switchCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令【泰雷兹】
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Command)
|
||||
public void switchCommand(Simulation simulation, String switchCode, Boolean auto, Boolean reserve, Boolean normal) {
|
||||
ciApiService.switchCommand(simulation, switchCode, auto, reserve, normal);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 道岔分路不良
|
||||
*
|
||||
* @param simulation 仿真实体
|
||||
* @param switchCode 道岔编码
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Defective_Shunting)
|
||||
public void defectiveShunting(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
List<Section.ShuntingType> shuntingTypeList = Arrays.asList(Section.ShuntingType.SWITCH_FRONT_SHUNTING,
|
||||
Section.ShuntingType.FIXED_POSITION_SHUNTING, Section.ShuntingType.REVERSE_POSITION_SHUNTING);
|
||||
atsSectionService.defectiveShunting(simulation, aSwitch.getA().getCode(), shuntingTypeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消道岔分路不良
|
||||
*
|
||||
* @param simulation 仿真实体
|
||||
* @param switchCode 道岔编码
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Switch_Cancel_Defective_Shunting)
|
||||
public void cancelDefectiveShunting(Simulation simulation, String switchCode) {
|
||||
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
||||
atsSectionService.defectiveShunting(simulation, aSwitch.getA().getCode(), new ArrayList<>());
|
||||
}
|
||||
|
||||
private static void waitResult(Simulation simulation, Switch aSwitch, SwitchIndication pos) {
|
||||
//等待转动完成
|
||||
LocalDateTime timeoutTime = simulation.getSystemTime().plusSeconds(13);
|
||||
CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> {
|
||||
while (true) {
|
||||
if (Objects.equals(aSwitch.getPos(), pos)) {
|
||||
return true;
|
||||
}
|
||||
if (simulation.getSystemTime().isAfter(timeoutTime)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (Exception e) {
|
||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception();
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
Boolean success = future.get();
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(success, "道岔转动失败");
|
||||
} catch (BaseException be) {
|
||||
throw be;
|
||||
Thread.sleep(100);
|
||||
} catch (Exception e) {
|
||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e);
|
||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception();
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
Boolean success = future.get();
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(success, "道岔转动失败");
|
||||
} catch (BaseException be) {
|
||||
throw be;
|
||||
} catch (Exception e) {
|
||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -192,14 +192,6 @@ public interface CiApiService {
|
||||
*/
|
||||
void switchSectionFaultUnlock(Simulation simulation, String switchCode);
|
||||
|
||||
/**
|
||||
* 设置自动通过进路
|
||||
*
|
||||
* @param simulation
|
||||
* @param routeCode
|
||||
*/
|
||||
void setFleetRoute(Simulation simulation, String routeCode);
|
||||
|
||||
/**
|
||||
* 取消自动通过进路
|
||||
*
|
||||
@ -208,22 +200,6 @@ public interface CiApiService {
|
||||
*/
|
||||
void cancelFleetRoute(Simulation simulation, String routeCode);
|
||||
|
||||
/**
|
||||
* 设置进路CI自动触发
|
||||
*
|
||||
* @param simulation
|
||||
* @param routeCode
|
||||
*/
|
||||
void setCIAutoTriggerRoute(Simulation simulation, String routeCode);
|
||||
|
||||
/**
|
||||
* 取消进路CI自动触发
|
||||
*
|
||||
* @param simulation
|
||||
* @param routeCode
|
||||
*/
|
||||
void cancelCIAutoTriggerRoute(Simulation simulation, String routeCode);
|
||||
|
||||
/**
|
||||
* 根据始端信号机查询锁闭进路
|
||||
*
|
||||
@ -233,24 +209,6 @@ public interface CiApiService {
|
||||
*/
|
||||
Route findLockedRouteByStartSignal(Simulation simulation, String signalCode);
|
||||
|
||||
/**
|
||||
* 根据始端、终端信号机查询进路(根据延续保护自动筛选出一条进路)
|
||||
*
|
||||
* @param simulation
|
||||
* @param startSignalCode
|
||||
* @param endSignalCode
|
||||
* @return
|
||||
*/
|
||||
Route findRouteByStartAndEndSignal(Simulation simulation, String startSignalCode, String endSignalCode);
|
||||
|
||||
/**
|
||||
* 办理引导进路
|
||||
*
|
||||
* @param simulation
|
||||
* @param routeCode
|
||||
*/
|
||||
void settingGuideRoute(Simulation simulation, String routeCode);
|
||||
|
||||
/**
|
||||
* 开站台屏蔽门
|
||||
*
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,7 @@
|
||||
package club.joylink.rtss.simulation.cbtc.robot;
|
||||
|
||||
import static club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.ConfirmationMessage.Confirm_Release_Speed;
|
||||
|
||||
import club.joylink.rtss.services.psl.IVirtualRealityPslService;
|
||||
import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher;
|
||||
@ -10,32 +12,46 @@ import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.command.CommandBO;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
|
||||
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.PSD;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferReplyVO;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.StandParkedTrainActivity;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
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.ATP.ATPService;
|
||||
import club.joylink.rtss.simulation.cbtc.training2.Training2;
|
||||
import club.joylink.rtss.vo.client.operation.DriveParamVO;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.ConfirmationMessage.Confirm_Release_Speed;
|
||||
|
||||
/**
|
||||
* 仿真机器人逻辑循环
|
||||
*/
|
||||
@ -94,9 +110,7 @@ public class SimulationRobotService {
|
||||
}
|
||||
break;
|
||||
case START:
|
||||
if (train.isAtoCanOpen()) {
|
||||
atpService.openATO(train);
|
||||
}
|
||||
atpService.openATO(train);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -158,43 +172,74 @@ public class SimulationRobotService {
|
||||
List<SimulationMember> drivers = simulation.querySimulationMembersOfRole(
|
||||
SimulationMember.Type.DRIVER);
|
||||
for (SimulationMember driver : drivers) {
|
||||
// if (!driver.isRobot())
|
||||
// continue;
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) driver.getDevice();
|
||||
if (train.isTakeOver() || !repository.isVrTrainOnline(train.getGroupNumber())) { //如果列车被接管或不在线
|
||||
continue;
|
||||
}
|
||||
//判断是否需要转换手轮档位到ATO
|
||||
robotOpenATOAfterCheck(train);
|
||||
//准备发车
|
||||
robotReadyForDeparture(simulation, train);
|
||||
//机器人驾驶
|
||||
if (train.isRobotNeedStop()) {
|
||||
if (train.isStop()) {
|
||||
train.getRobotDriveParam().setStop(false);
|
||||
} else {
|
||||
if (!train.isInTheGear(VirtualRealityTrain.Handwheel.MANUAL)) { //确保当前在手动档位
|
||||
CommandBO.Step step = CommandBO.buildGearChangeStep(train.getGroupNumber(),
|
||||
VirtualRealityTrain.Handwheel.MANUAL);
|
||||
atsOperationDispatcher.execute(simulation, driver, step.getOperationType().name(),
|
||||
step.getOperationParams());
|
||||
}
|
||||
doBreakMax(simulation, train);
|
||||
}
|
||||
} else if (train.isRobotNeedRun()) {
|
||||
if ((train.isRMMode() || train.isNRMMode())) { //RM或NRM
|
||||
VirtualRealityTrain linkTrain = train.getLinkTrain();
|
||||
if (linkTrain == null) {
|
||||
Optional<SectionPosition> targetPositionOptional = calculateTargetPosition(simulation,
|
||||
train);
|
||||
targetPositionOptional.ifPresent(tp -> robotDrive(simulation, driver, train, tp));
|
||||
} else {
|
||||
robotDrive(simulation, driver, train, train.getRobotTargetPosition());
|
||||
}
|
||||
} else if (train.isCMMode()) { //CM
|
||||
SpeedCurve speedCurve = train.getMa2().getAtoStopCurve();
|
||||
atoService.doControlBySpeedCurve(train, speedCurve, speedCurve.getTotalDistance(), train.getAtoSpeed());
|
||||
}
|
||||
//机器人人工驾驶
|
||||
robotManualDrive(simulation, driver, train);
|
||||
}
|
||||
}
|
||||
|
||||
private void robotManualDrive(Simulation simulation, SimulationMember driver,
|
||||
VirtualRealityTrain train) {
|
||||
if (train.isRobotNeedStop()) {
|
||||
if (train.isStop()) {
|
||||
train.getRobotDriveParam().setStop(false);
|
||||
} else {
|
||||
ensureTrainInTheGear(train, VirtualRealityTrain.Handwheel.MANUAL);
|
||||
doBreakMax(simulation, train);
|
||||
}
|
||||
} else if (train.isRobotNeedRun()) {
|
||||
if ((train.isRMMode() || train.isNRMMode())) { //RM或NRM
|
||||
ensureTrainInTheGear(train, VirtualRealityTrain.Handwheel.MANUAL);
|
||||
VirtualRealityTrain linkTrain = train.getLinkTrain();
|
||||
if (linkTrain == null) {
|
||||
Optional<SectionPosition> targetPositionOptional = calculateTargetPosition(simulation,
|
||||
train);
|
||||
targetPositionOptional.ifPresent(tp -> robotDrive(simulation, driver, train, tp));
|
||||
} else {
|
||||
robotDrive(simulation, driver, train, train.getRobotTargetPosition());
|
||||
}
|
||||
} else if (train.isCMMode()) { //CM
|
||||
ensureTrainInTheGear(train, VirtualRealityTrain.Handwheel.MANUAL);
|
||||
SpeedCurve speedCurve = train.getMa2().getAtoStopCurve();
|
||||
atoService.doControlBySpeedCurve(train, speedCurve, speedCurve.getTotalDistance(),
|
||||
train.getAtoSpeed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 在检查通过后开启ATO
|
||||
*/
|
||||
private void robotOpenATOAfterCheck(VirtualRealityTrain train) {
|
||||
//停站时的情况可能比较特殊,保险起见停站时不做处理
|
||||
if (train.isParkingAt()) {
|
||||
return;
|
||||
}
|
||||
//列车的预选模式支持到达AM驾驶模式,并且列车的ATO推荐速度大于0
|
||||
if (train.getPreselectionMode().isNotLowerThanTheDriveMode(DriveMode.AM)
|
||||
&& train.getAtoSpeed() > 0) {
|
||||
ensureTrainInTheGear(train, VirtualRealityTrain.Handwheel.ATO);
|
||||
atpService.openATO(train);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确保列车在指定挡
|
||||
*/
|
||||
private void ensureTrainInTheGear(VirtualRealityTrain train, VirtualRealityTrain.Handwheel gear) {
|
||||
if (!train.isInTheGear(gear)) {
|
||||
train.setGear(gear);
|
||||
// CommandBO.Step step = CommandBO.buildGearChangeStep(train.getGroupNumber(), gear);
|
||||
// atsOperationDispatcher.execute(simulation, driver, step.getOperationType().name(),
|
||||
// step.getOperationParams()); 机器人驾驶逻辑中有很多操作都不是通过仿真操作执行的,所以这里也不需要了吧
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,7 +290,8 @@ public class SimulationRobotService {
|
||||
SignalAspect throughAspect = robotDriveParam.getThroughSignalAspect();
|
||||
Section section = headPosition.getSection();
|
||||
|
||||
if (throughSignal != null && !Objects.equals(section, throughSignal.getSection())) { //当车头与要越过的信号机不在同一区段
|
||||
if (throughSignal != null && !Objects.equals(section,
|
||||
throughSignal.getSection())) { //当车头与要越过的信号机不在同一区段
|
||||
throughSignal = null;
|
||||
throughAspect = null;
|
||||
robotDriveParam.setThrough(DriveParamVO.DRIVER_ROUTE_BLOCK);
|
||||
@ -257,10 +303,12 @@ public class SimulationRobotService {
|
||||
// 车头在正常的站台上
|
||||
if (section.isNormalStandTrack() && !section.equals(train.getParkSection())) { //正常站台轨且未在此处停过车
|
||||
// 如果计划停车区段为空或者计划停车区段中有包含当前区段
|
||||
if (CollectionUtils.isEmpty(plannedParkingSections) || plannedParkingSections.contains(section)) {
|
||||
if (CollectionUtils.isEmpty(plannedParkingSections) || plannedParkingSections.contains(
|
||||
section)) {
|
||||
SectionPosition stopPosition = section.buildStopPointPosition(right);
|
||||
SectionPosition maxStopPosition = CalculateService.calculateNextPositionByStartAndLen(stopPosition,
|
||||
right, SimulationConstants.PARK_POINT_MAX_OFFSET, true);
|
||||
SectionPosition maxStopPosition = CalculateService.calculateNextPositionByStartAndLen(
|
||||
stopPosition,
|
||||
right, SimulationConstants.PARK_POINT_MAX_OFFSET, true);
|
||||
if (maxStopPosition.isAheadOf(headPosition, right)) { //未越过最大停车点
|
||||
targetPosition = stopPosition;
|
||||
break;
|
||||
@ -280,11 +328,14 @@ public class SimulationRobotService {
|
||||
if (signal != null && !signal.isShunting()) { // 信号机不为调车信号机
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
SectionPosition signalPosition = signal.getPosition();
|
||||
if (vrSignal != null && (i != 0 || signalPosition.isAheadOf(headPosition, right))) { //有实体信号机且列车未越过信号机
|
||||
if (vrSignal != null && (i != 0 || signalPosition.isAheadOf(headPosition,
|
||||
right))) { //有实体信号机且列车未越过信号机
|
||||
if (Objects.equals(vrSignal.getAspect(), signal.getDefaultAspect()) //禁止信号
|
||||
|| Objects.equals(vrSignal.getAspect(), signal.getGuideAspect())) { //引导信号
|
||||
if (!Objects.equals(signal, throughSignal) || !Objects.equals(vrSignal.getAspect(), throughAspect)) {
|
||||
SectionPosition noPassPosition = CalculateService.calculateNextPositionByStartAndLen(signalPosition, !right, 2, true);
|
||||
if (!Objects.equals(signal, throughSignal) || !Objects.equals(vrSignal.getAspect(),
|
||||
throughAspect)) {
|
||||
SectionPosition noPassPosition = CalculateService.calculateNextPositionByStartAndLen(
|
||||
signalPosition, !right, 2, true);
|
||||
if (targetPosition == null || noPassPosition.isAheadOf(targetPosition, right)) {
|
||||
targetPosition = noPassPosition;
|
||||
}
|
||||
@ -294,7 +345,8 @@ public class SimulationRobotService {
|
||||
}
|
||||
|
||||
if (targetPosition == null) {
|
||||
if (selectedPosition != null && section.equals(selectedPosition.getSection())) { //不会有比选定位置更靠前的停车点了
|
||||
if (selectedPosition != null && section.equals(
|
||||
selectedPosition.getSection())) { //不会有比选定位置更靠前的停车点了
|
||||
targetPosition = selectedPosition;
|
||||
} else {
|
||||
Section tempSection = section.findNextRunningSectionBaseRealSwitch(right);
|
||||
|
Loading…
Reference in New Issue
Block a user