From b409263cf8f4fb05cb5cec82b146e15392c5191e Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 15 Feb 2023 15:26:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9ATS=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=BC=80=E5=85=B3=E9=97=A8=E6=93=8D=E4=BD=9C=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=9B=B4=E7=9B=B4=E6=8E=A5=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/data/vr/VirtualRealityTrain.java | 2 +- .../cbtc/onboard/ATP/ATPService.java | 32 ++++++++++++------- .../cbtc/robot/SimulationRobotService.java | 2 +- 3 files changed, 23 insertions(+), 13 deletions(-) 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 1e36e7f0b..05673d476 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 @@ -1336,7 +1336,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { AA, ; - public boolean isAuto(boolean open) { + public boolean isManual(boolean open) { return (open && this.equals(MM)) || (!open && !this.equals(AA)); } } 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 9fd1af038..82c925e59 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 @@ -24,6 +24,7 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; 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.robot.SimulationRobotService; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -45,6 +46,8 @@ public class ATPService { @Autowired private CiApiService ciApiService; + @Autowired + private SimulationRobotService simulationRobotService; /** * 更新列车移动授权 @@ -302,7 +305,7 @@ public class ATPService { public void openOrCloseDoor(Simulation simulation, VirtualRealityTrain train, boolean right, boolean open) { BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(train.getSpeed() == 0, String.format("列车[%s]未停止,不能操作车门", train.getGroupNumber())); - BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(train.getDoorMode().isAuto(open), String.format("列车[%s]门模式自动,不能操作车门", train.getGroupNumber())); + BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(train.getDoorMode().isManual(open), String.format("列车[%s]门模式自动,不能操作车门", train.getGroupNumber())); BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(train.getDoorSelection().match(right),String.format("列车[%s]门选择与操作不匹配", train.getGroupNumber())); List standList = train.getHeadPosition().getSection().getStandList(); VirtualRealityTrain.Door door = train.getDoorByDirection(right); @@ -522,16 +525,23 @@ public class ATPService { } VirtualRealityTrain.Door door = train.getDoorByDirection(doorIsRight); if (!Objects.equals(door.isOpen(), open)) { - //修改门模式和门选以保证操作成功 - VirtualRealityTrain.DoorMode doorMode = train.getDoorMode(); - train.setDoorMode(VirtualRealityTrain.DoorMode.MM); - VirtualRealityTrain.DoorSelection doorSelection = train.getDoorSelection(); - train.setDoorSelection(doorIsRight ? VirtualRealityTrain.DoorSelection.R : VirtualRealityTrain.DoorSelection.L); - //操作 - openOrCloseDoor(simulation, train, doorIsRight, open); - //操作后将门模式和门选还原 - train.setDoorMode(doorMode); - train.setDoorSelection(doorSelection); + // 使用更简单粗暴的方式保证门可以打开,如果不合适再改 + if (open) { + ATOService.openTrainDoor(simulation, train, door); + } else { + ATOService.closeTrainDoor(simulation, train, door); + } + simulationRobotService.usePsl2ControlPsd(simulation, train, open); +// //修改门模式和门选以保证操作成功 +// VirtualRealityTrain.DoorMode doorMode = train.getDoorMode(); +// train.setDoorMode(VirtualRealityTrain.DoorMode.MM); +// VirtualRealityTrain.DoorSelection doorSelection = train.getDoorSelection(); +// train.setDoorSelection(doorIsRight ? VirtualRealityTrain.DoorSelection.R : VirtualRealityTrain.DoorSelection.L); +// //操作 +// openOrCloseDoor(simulation, train, doorIsRight, open); +// //操作后将门模式和门选还原 +// train.setDoorMode(doorMode); +// train.setDoorSelection(doorSelection); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/SimulationRobotService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/SimulationRobotService.java index 89f2d30e7..c14ebee79 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/SimulationRobotService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/SimulationRobotService.java @@ -110,7 +110,7 @@ public class SimulationRobotService { /** * 使用psl控制屏蔽门 */ - private void usePsl2ControlPsd(Simulation simulation, VirtualRealityTrain train, boolean open) { + public void usePsl2ControlPsd(Simulation simulation, VirtualRealityTrain train, boolean open) { SectionPosition headPosition = train.getHeadPosition(); Section section = headPosition.getSection(); List standList = section.getStandList();