From 430bc45881d6bd3ab5c472d608419820076babc8 Mon Sep 17 00:00:00 2001 From: Jade Date: Tue, 7 Sep 2021 14:03:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B8=E6=9C=BA=E9=A9=BE=E9=A9=B6=20?= =?UTF-8?q?=E9=97=A8=E6=A8=A1=E5=BC=8F=E3=80=81=E9=97=A8=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/operation/Operation.java | 4 ++ .../handler/DriverOperateHandler.java | 31 +++++++++-- .../communication/vo/TrainHmiDisplay.java | 20 +++++++ .../cbtc/data/vr/VirtualRealityTrain.java | 53 +++++++++++++++++++ .../cbtc/onboard/ATP/ATPLogicLoop.java | 3 +- .../cbtc/onboard/ATP/ATPService.java | 8 +++ 6 files changed, 114 insertions(+), 5 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java index 3820c3b64..535ee0d97 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java @@ -410,6 +410,10 @@ public class Operation { Driver_Change_Head, /** 列车车门开关 */ Driver_Door_On_Off, + /** 列车门模式 */ + Driver_Door_Mode, + /** 列车门选择 */ + Driver_Door_Selection, //--------------------------- 方向杆 --------------------------- /** 方向转换 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java index e04e6b107..5b0ff8369 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java @@ -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); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainHmiDisplay.java b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainHmiDisplay.java index ecf76a436..36640ea07 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainHmiDisplay.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainHmiDisplay.java @@ -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; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index 422bfeabd..8192be605 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -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)); + } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java index c96d8afee..b5b915f8f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java @@ -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; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPService.java index 95adfdafc..3f55cd295 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPService.java @@ -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 standList = train.getHeadPosition().getSection().getStandList(); VirtualRealityTrain.Door door = train.getDoorByDirection(right); if (open) {