司机驾驶 门模式、门选择

This commit is contained in:
Jade 2021-09-07 14:03:53 +08:00
parent 0fa5d54b7a
commit 430bc45881
6 changed files with 114 additions and 5 deletions

View File

@ -410,6 +410,10 @@ public class Operation {
Driver_Change_Head,
/** 列车车门开关 */
Driver_Door_On_Off,
/** 列车门模式 */
Driver_Door_Mode,
/** 列车门选择 */
Driver_Door_Selection,
//--------------------------- 方向杆 ---------------------------
/** 方向转换 */

View File

@ -5,11 +5,9 @@ import club.joylink.rtss.simulation.cbtc.ATP.ground.ZCLogicLoop;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.ControlGear;
import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
@ -18,7 +16,6 @@ import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Objects;
/**
@ -171,5 +168,33 @@ public class DriverOperateHandler {
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);
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);
train.setDoorSelection(doorSelection);
}
}

View File

@ -163,6 +163,16 @@ public class TrainHmiDisplay {
/** 牵引、制动力百分比 */
private int forcePercent;
/**
* 门模式
*/
private String doorMode;
/**
* 门选择
*/
private String doorSelection;
public TrainHmiDisplay(VirtualRealityTrain train) {
this.code = train.getCode();
this.groupNumber = train.getGroupNumber();
@ -217,6 +227,8 @@ public class TrainHmiDisplay {
this.inTheStandArea = train.isInTheStandArea();
this.tow = getTow(train);
this.forcePercent = getForcePercent(train);
this.doorMode = train.getDoorMode().toString();
this.doorSelection = train.getDoorSelection().toString();
}
private int getForcePercent(VirtualRealityTrain train) {
@ -392,6 +404,14 @@ public class TrainHmiDisplay {
this.forcePercent = forcePercent;
map.put("forcePercent", forcePercent);
}
if (!Objects.equals(this.doorMode, train.getDoorMode().toString())) {
this.doorMode = train.getDoorMode().toString();
map.put("doorMode", this.doorMode);
}
if (!Objects.equals(this.doorSelection, train.getDoorSelection().toString())) {
this.doorSelection = train.getDoorSelection().toString();
map.put("doorSelection", this.doorSelection);
}
if (map.size() > 0) {
map.put("code", this.code);
return map;

View File

@ -324,6 +324,16 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
*/
private Door door2;
/**
* 门模式
*/
private DoorMode doorMode;
/**
* 门选
*/
private DoorSelection doorSelection;
/**
* 牵引力,单位kN
* 公式 fk = 350 (0 <= v <= 36km/h)
@ -488,6 +498,8 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
this.atpOn = true;
this.door1 = new Door("1");
this.door2 = new Door("2");
this.doorMode = DoorMode.AM;
this.doorSelection = DoorSelection.Z;
}
@Override
@ -553,6 +565,8 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
this.autoOpenATO = false;
this.fault = null;
this.released = false;
this.doorMode = DoorMode.AM;
this.doorSelection = DoorSelection.Z;
}
public boolean isEB() {
@ -1274,4 +1288,43 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
ACCELERATE,
}
public enum DoorMode {
/**
* 自动开手动关
*/
AM,
/**
* 手动开手动关
*/
MM,
/**
* 自动开自动关
*/
AA,
;
public boolean isAuto(boolean open) {
return (open && this.equals(MM)) || (!open && !this.equals(AA));
}
}
public enum DoorSelection {
/**
*
*/
L,
/**
*
*/
R,
/**
* 零位
*/
Z,
;
public boolean match(boolean right) {
return (right && this.equals(R)) || (!right && this.equals(L));
}
}
}

View File

@ -295,7 +295,7 @@ public class ATPLogicLoop {
train.nextParkedTrainActivity();
break;
case OPEN_DOOR: // 开门
if (train.isAtoOn()) {
if (train.isAtoOn() && !train.getDoorMode().equals(VirtualRealityTrain.DoorMode.MM)) { // 不是自动开门
this.atoService.syncOpenDoor(simulation, train);
}
if (this.isAllDoorOpen(simulation, train)) {
@ -305,7 +305,6 @@ public class ATPLogicLoop {
train.setAutoOpenATO(true);
}
}
// }
break;
case BOARD: // 乘客乘降
break;

View File

@ -293,6 +293,14 @@ public class ATPService {
log.warn(String.format("列车[%s]未停止,不能操作车门", train.getGroupNumber()));
return;
}
if (!train.getDoorMode().isAuto(right)) {
log.warn(String.format("列车[%s]门模式自动,不能操作车门", train.getGroupNumber()));
return;
}
if (!train.getDoorSelection().match(right)) {
log.warn(String.format("列车[%s]门选择与操作不匹配", train.getGroupNumber()));
return;
}
List<Stand> standList = train.getHeadPosition().getSection().getStandList();
VirtualRealityTrain.Door door = train.getDoorByDirection(right);
if (open) {