From 2596ad30859e4f28d92ebcd7c738c8a86724e315 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 29 May 2023 11:14:54 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E3=80=90=E4=B8=8A=E7=94=B5=E8=A7=A3?= =?UTF-8?q?=E9=94=81=E6=8C=89=E9=92=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/vo/map/MapGraphDataNewVO.java | 7 +++++ .../vo/map/graph/MapPowerUnlockButtonVO.java | 26 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/main/java/club/joylink/rtss/vo/map/graph/MapPowerUnlockButtonVO.java diff --git a/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java b/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java index 580ce3d3d..038c0d491 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java @@ -254,6 +254,12 @@ public class MapGraphDataNewVO { */ private Map> mapClientVOMap = new HashMap<>(); + /** + * 上电解锁按钮 + */ + private List powerUnLockButtonList; + + public MapGraphDataNewVO() { this.bigScreenConfig = new BigScreenConfig(); this.generateConfig = new MapCiGenerateConfig(); @@ -288,6 +294,7 @@ public class MapGraphDataNewVO { this.arrowList = new ArrayList<>(); this.directionRodList = new ArrayList<>(); this.responderList = new ArrayList<>(); + this.powerUnLockButtonList = new ArrayList<>(); } public static MapGraphDataNewVO parse(String graphData) { diff --git a/src/main/java/club/joylink/rtss/vo/map/graph/MapPowerUnlockButtonVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapPowerUnlockButtonVO.java new file mode 100644 index 000000000..8248b1de2 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapPowerUnlockButtonVO.java @@ -0,0 +1,26 @@ +package club.joylink.rtss.vo.map.graph; + +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + * 上电解锁按钮 + */ +@Getter +@Setter +public class MapPowerUnlockButtonVO { + + @NotBlank(message = "code不能为空") + private String code; + + private String name; + + /** + * 所属设备集中站code + */ + private String stationCode; + + private Point position; +} From b505dcdbfe978d5efc9c445931963c43e074a21e Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 29 May 2023 14:13:09 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E3=80=90=E5=A4=9A=E4=BA=BA=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E5=BC=80=E5=A7=8B=E5=89=8D=E5=8F=91=E9=80=81=E5=AE=9E?= =?UTF-8?q?=E8=AE=ADID=E6=B6=88=E6=81=AF=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SimulationTrainingV2Controller.java | 10 ++++++++++ .../services/training2/Training2Service.java | 16 ++++++++++++++++ .../rtss/vo/client/WebSocketMessageType.java | 4 ++++ .../vo/client/factory/SocketMessageFactory.java | 1 + 4 files changed, 31 insertions(+) diff --git a/src/main/java/club/joylink/rtss/controller/simulation/SimulationTrainingV2Controller.java b/src/main/java/club/joylink/rtss/controller/simulation/SimulationTrainingV2Controller.java index ba5b9487f..e54d3e08a 100644 --- a/src/main/java/club/joylink/rtss/controller/simulation/SimulationTrainingV2Controller.java +++ b/src/main/java/club/joylink/rtss/controller/simulation/SimulationTrainingV2Controller.java @@ -109,4 +109,14 @@ public class SimulationTrainingV2Controller { public void jumpToStep(@PathVariable String group, @PathVariable Long stepId){ training2Service.jumpToStep(group, stepId); } + + /** + * 实训开始准备,给实训参与人员发送准备开始执行 + * @param group 仿真ID + * @param user 操作人 + */ + @PostMapping("/{group}/prepare/start") + public void prepareStart(@PathVariable String group, @RequestAttribute AccountVO user) { + training2Service.prepareStart(group, user); + } } diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java index 2d686062b..24512741d 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -4,6 +4,7 @@ import club.joylink.rtss.dao.DraftTraining2DAO; import club.joylink.rtss.dao.PublishedTraining2DAO; import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs; import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.training2.index.IndexAlgorithmService; import club.joylink.rtss.simulation.cbtc.ATS.ATSMessageCollectAndDispatcher; import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher; @@ -557,6 +558,21 @@ public class Training2Service { } } + /** + * 实训准备开始 + * @param group 仿真号 + * @param user 操作人 + */ + public void prepareStart(String group, AccountVO user) { + Simulation simulation = groupSimulationCache.getSimulationByGroup(group); + BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(simulation.getTraining2() != null, "未加载实训"); + SocketMessageVO message = SocketMessageFactory.build( + WebSocketMessageType.Simulation_Training_Prepare_Start, simulation.getId(), simulation.getTraining2().getId()); + Set userIdSet = simulation.getSimulationUserIds().stream() + .filter(id -> !Objects.equals(id, user.getId().toString())).collect(Collectors.toSet()); + stompMessageService.sendToUser(userIdSet, message); + } + /** * 实训时创建仿真对象 */ diff --git a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java index a52b2aee1..9231d46c9 100644 --- a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java +++ b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java @@ -377,6 +377,10 @@ public enum WebSocketMessageType { /** * ------------ 新实训消息 ----------- */ + /** + * 实训准备开始,其他成员加载实训内容消息 + */ + Simulation_Training_Prepare_Start, /** * 步骤开始时提示信息 */ diff --git a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java index 4410b690a..b280d66ac 100644 --- a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java +++ b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java @@ -155,6 +155,7 @@ public class SocketMessageFactory { break; } // 20220819 + case Simulation_Training_Prepare_Start: case Simulation_Training_Step_Tip: case Simulation_Training_Step_Finish: case Simulation_Training_Audio_MATCH_RESULT: From 07f8bcbd1651aef931fe5616ce7c2411c0e5cec6 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 29 May 2023 16:23:07 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E3=80=90=E4=B8=8A=E7=94=B5=E8=A7=A3?= =?UTF-8?q?=E9=94=81=E7=8A=B6=E6=80=81=E6=8F=90=E4=BA=A4=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/service/AtsStationService.java | 1 + .../simulation/cbtc/CI/CiApiServiceImpl2.java | 1 + .../simulation/cbtc/data/map/Station.java | 6 +++++ .../cbtc/data/status/StationStatus.java | 24 +++++++++++++++++++ .../cbtc/data/vo/StationStatusVO.java | 11 +++++++++ 5 files changed, 43 insertions(+) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java index 9d5fd1187..36fdcba8c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java @@ -507,6 +507,7 @@ public class AtsStationService { } station.setInterlockMachineStarting(true); station.setRestartTime(LocalTime.now()); + station.setPowerUnlockButtonShow(true); Station.Fault.INTERLOCK_FAULT.fix(station); //恢复联锁机故障 SimulationDataRepository repository = simulation.getRepository(); //该站范围内区段故障锁闭 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java index 99b05087e..d357f1d20 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java @@ -555,6 +555,7 @@ public class CiApiServiceImpl2 implements CiApiService { || Simulation.FunctionalType.EXAM.equals(simulation.getBuildParams().getFunctionalType())) ? true : deviceStation.getRestartTime().plusMinutes(8).isAfter(LocalTime.now())); if (hasCTCFlag || powerOnFlag) { + deviceStation.setPowerUnlockButtonShow(false); List
sections = simulation.getRepository().getSectionList(); sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), deviceStation)).forEach(Section::faultUnlock); return; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java index 2d8d07d5f..1cff2a7c7 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java @@ -241,6 +241,11 @@ public class Station extends MayOutOfOrderDevice { */ private OperationModeApplication operationModeApplication; + /** + * 上电解锁按钮显示状态 + */ + private boolean powerUnlockButtonShow; + @Override public void reset() { super.reset(); @@ -270,6 +275,7 @@ public class Station extends MayOutOfOrderDevice { planControl = true; routeSetMode = RouteSetMode.Plan_Set_Route; operationMode = OperationMode.Center; + powerUnlockButtonShow = false; } public List getStandOf(boolean right) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationStatus.java index de3d07393..7f75c7ec8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationStatus.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationStatus.java @@ -112,6 +112,16 @@ public class StationStatus extends DeviceStatus { */ private Station.OperationMode operationMode; + /** + * 车站故障状态 + */ + private String fault; + + /** + * 上电解锁按钮状态 + */ + private Boolean powerUnlockButtonShow; + public StationStatus(Station station) { super(station.getCode(), station.getDeviceType()); controlMode = station.getControlMode(); @@ -135,6 +145,7 @@ public class StationStatus extends DeviceStatus { planControl = station.isPlanControl(); routeSetMode = station.getRouteSetMode(); operationMode = station.getOperationMode(); + powerUnlockButtonShow = station.isPowerUnlockButtonShow(); } @Override @@ -242,6 +253,17 @@ public class StationStatus extends DeviceStatus { this.operationMode = station.getOperationMode(); status.setOperationMode(station.getOperationMode()); } + String fault = station.getFault() == null ? null : station.getFault().toString(); + if (!Objects.equals(this.fault, fault)) { + this.fault = fault; + status.setFault(fault); + change = true; + } + if (!Objects.equals(powerUnlockButtonShow, station.isPowerUnlockButtonShow())) { + this.powerUnlockButtonShow = station.isPowerUnlockButtonShow(); + status.setPowerUnlockButtonShow(station.isPowerUnlockButtonShow()); + change = true; + } return change; } @@ -266,6 +288,8 @@ public class StationStatus extends DeviceStatus { statusVO.setPlanControl(planControl); statusVO.setRouteSetMode(routeSetMode); statusVO.setOperationMode(operationMode); + statusVO.setFault(fault); + statusVO.setPowerUnlockButtonShow(powerUnlockButtonShow); return statusVO; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/StationStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/StationStatusVO.java index 03882bfa4..65297272c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/StationStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/StationStatusVO.java @@ -96,6 +96,17 @@ public class StationStatusVO extends DeviceStatusVO { private Station.OperationMode operationMode; + /** + * 车站故障状态 + */ + private String fault; + + /** + * 上电解锁按钮显示状态 + */ + @JsonSerialize(using = Boolean2NumSerializer.class) + private Boolean powerUnlockButtonShow; + public StationStatusVO(Station station) { super(station.getCode(), station.getDeviceType()); } From 06d4e5019293e4e0f6ea1618b3165b115f866290 Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Mon, 29 May 2023 16:46:06 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../club/joylink/rtss/services/paper/PaperUserService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java b/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java index 508fd44a7..830aec6b0 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PaperUserService.java @@ -214,12 +214,16 @@ public class PaperUserService { rsp.setCommonScore(scoreCommon); rsp.setTrainingScore(scoreTraining); rsp.setPassScore(composition.getPassScore()); + this.publishUserExam(); + return rsp; + } + + private void publishUserExam() { // UserExam ue = new UserExam(); // ue.setExamId(); // ue.setUserId(user.getAccount()); //TODO 需要将 UserExam 发送 {@link UserExamService.submit 方法} // this.applicationContext.publishEvent(new UserExamRecordEvent(userExam)); - return rsp; } /** From cda1272d08dd18d27a0b54610fdc1d610458b360 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 29 May 2023 17:52:53 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E3=80=90=E5=8F=91=E5=B8=83=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E5=AF=BC=E5=87=BA=E5=8E=BB=E9=99=A4=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?ID=E3=80=91=E3=80=90=E5=AE=9E=E8=AE=AD=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A8=A1=E5=BC=8F=E5=8F=82=E6=95=B0=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/SimulationTrainingV2Controller.java | 4 ++-- .../rtss/services/training2/Training2PublishService.java | 1 + .../rtss/services/training2/Training2Service.java | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/simulation/SimulationTrainingV2Controller.java b/src/main/java/club/joylink/rtss/controller/simulation/SimulationTrainingV2Controller.java index e54d3e08a..d868f842d 100644 --- a/src/main/java/club/joylink/rtss/controller/simulation/SimulationTrainingV2Controller.java +++ b/src/main/java/club/joylink/rtss/controller/simulation/SimulationTrainingV2Controller.java @@ -116,7 +116,7 @@ public class SimulationTrainingV2Controller { * @param user 操作人 */ @PostMapping("/{group}/prepare/start") - public void prepareStart(@PathVariable String group, @RequestAttribute AccountVO user) { - training2Service.prepareStart(group, user); + public void prepareStart(@PathVariable String group, @RequestAttribute AccountVO user, ScriptBO.Mode mode) { + training2Service.prepareStart(group, user, mode); } } diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java b/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java index 1173c001a..6f1f2fbb1 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java @@ -472,6 +472,7 @@ public class Training2PublishService { List training2WithBLOBsList = publishedDao.selectByExampleWithBLOBs(example); Map> mapTrainingMap = training2WithBLOBsList.stream().peek(t -> { t.setId(null); + t.setMapId(null); t.setUpdateTime(null); t.setCreateTime(null); }).collect(Collectors.groupingBy(PublishedTraining2WithBLOBs::getMapId)); diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java index 24512741d..347e5e8c8 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -563,11 +563,14 @@ public class Training2Service { * @param group 仿真号 * @param user 操作人 */ - public void prepareStart(String group, AccountVO user) { + public void prepareStart(String group, AccountVO user, ScriptBO.Mode mode) { Simulation simulation = groupSimulationCache.getSimulationByGroup(group); BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(simulation.getTraining2() != null, "未加载实训"); - SocketMessageVO message = SocketMessageFactory.build( - WebSocketMessageType.Simulation_Training_Prepare_Start, simulation.getId(), simulation.getTraining2().getId()); + Map messageMap = new HashMap<>(); + messageMap.put("id", simulation.getTraining2().getId()); + messageMap.put("mode", mode); + SocketMessageVO> message = SocketMessageFactory.build( + WebSocketMessageType.Simulation_Training_Prepare_Start, simulation.getId(), messageMap); Set userIdSet = simulation.getSimulationUserIds().stream() .filter(id -> !Objects.equals(id, user.getId().toString())).collect(Collectors.toSet()); stompMessageService.sendToUser(userIdSet, message); From 488ec0a7a44422ff8b43ad5bdb10a5058ee916f5 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 30 May 2023 10:43:40 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E5=BC=80=E5=A7=8B=E7=BB=93=E6=9D=9F=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/services/training2/Training2Service.java | 15 +++++++++++++-- .../rtss/vo/client/WebSocketMessageType.java | 6 +++++- .../vo/client/factory/SocketMessageFactory.java | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java index 347e5e8c8..b9ccb4f3a 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -143,6 +143,7 @@ public class Training2Service { if (training2 == null || !training2.isStarted() || training2.isFinish()) { // 结束并移除运行任务 removeTrainingJob(simulation); + trainingStatusMessage(simulation, 0); return; } // 获取运行步骤 @@ -275,7 +276,6 @@ public class Training2Service { // 创建者退出,则清理实训 if (simulation.getCreator().getId().equals(user.getId())) { training2.finish(); - removeTrainingJob(simulation); } } else { return List.of(); @@ -554,7 +554,6 @@ public class Training2Service { } catch (Exception e) { log.error("loadTrainingToStep is error", e); training2.finish(); - removeTrainingJob(simulation); } } @@ -930,6 +929,8 @@ public class Training2Service { addTrainingJob(simulation, training2); // 启动仿真 simulationLifeCycleService.resume(simulation); + // 发送开始消息 + trainingStatusMessage(simulation, 1); } /** @@ -940,4 +941,14 @@ public class Training2Service { simulation.getTraining2().setJumpToStep(null); simulation.getTraining2().finish(); } + + /** + * 实训状态消息 + * @param simulation 仿真 + * @param status 状态 + */ + private void trainingStatusMessage(Simulation simulation, int status) { + SocketMessageVO message = SocketMessageFactory.build(WebSocketMessageType.Simulation_Training_Status, simulation.getId(), status); + stompMessageService.sendToUser(simulation.getSimulationUserIds(), message); + } } diff --git a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java index 9231d46c9..d541c939d 100644 --- a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java +++ b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java @@ -381,6 +381,10 @@ public enum WebSocketMessageType { * 实训准备开始,其他成员加载实训内容消息 */ Simulation_Training_Prepare_Start, + /** + * 实训开始、结束状态 + */ + Simulation_Training_Status, /** * 步骤开始时提示信息 */ @@ -399,7 +403,7 @@ public enum WebSocketMessageType { /** * 实训完成 */ - Simulation_Training_Finish + Simulation_Training_Finish, /** ------------ 新实训消息 ----------- */ ; } diff --git a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java index b280d66ac..d795ee8e0 100644 --- a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java +++ b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java @@ -161,7 +161,8 @@ public class SocketMessageFactory { case Simulation_Training_Audio_MATCH_RESULT: // case Simulation_Training_Operate_Error: // case Simulation_Training_Operate_Finish: - case Simulation_Training_Finish: { + case Simulation_Training_Finish: + case Simulation_Training_Status: { topicList.add(String.format(WebSocketSubscribeTopic.AssistantSimulation, group)); topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group)); topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group)); From 0be6e02563bef979f082bf9b7b54880558df5b77 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 30 May 2023 13:48:43 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E3=80=90=E5=A4=84=E7=90=86=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E7=BB=93=E6=9D=9F=E6=93=8D=E4=BD=9C=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=9A=82=E5=81=9C=E5=AF=BC=E8=87=B4=E7=BB=93=E6=9D=9F=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E4=B8=8D=E5=8F=91=E9=80=81=E9=97=AE=E9=A2=98=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../club/joylink/rtss/services/training2/Training2Service.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java index b9ccb4f3a..0b74c4d55 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -276,6 +276,7 @@ public class Training2Service { // 创建者退出,则清理实训 if (simulation.getCreator().getId().equals(user.getId())) { training2.finish(); + simulation.start(); } } else { return List.of(); From d9812813d7ee1cb46a71caf9de010d4d23827841 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 30 May 2023 14:43:53 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E3=80=90=E5=A4=9A=E4=BA=BA=E4=BB=BF?= =?UTF-8?q?=E7=9C=9F=E8=B0=83=E7=94=A8=E6=8E=A5=E5=8F=A3=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9E=E8=AE=AD=E7=8A=B6=E6=80=81=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../club/joylink/rtss/services/training2/Training2Service.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java index 0b74c4d55..2fac6fd61 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -143,7 +143,6 @@ public class Training2Service { if (training2 == null || !training2.isStarted() || training2.isFinish()) { // 结束并移除运行任务 removeTrainingJob(simulation); - trainingStatusMessage(simulation, 0); return; } // 获取运行步骤 @@ -276,7 +275,7 @@ public class Training2Service { // 创建者退出,则清理实训 if (simulation.getCreator().getId().equals(user.getId())) { training2.finish(); - simulation.start(); + trainingStatusMessage(simulation, 0); } } else { return List.of(); From 0a8082ed97d4d2c24ffff08ecf0c9fa75e0fc71c Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 30 May 2023 15:52:41 +0800 Subject: [PATCH 09/15] =?UTF-8?q?=E3=80=90=E6=97=A0=E7=BE=A4=E7=BB=84?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=98=AF=E7=BB=99=E9=BB=98=E8=AE=A4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/simulation/cbtc/Simulation.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java index b8cee967b..ef0476e25 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java @@ -303,12 +303,17 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation conversationGroupVOList = buildParams.getMap().getGraphDataNew() .getConversationGroupMap().get(buildParams.getWorkParamVO().getType()); - Map groupMap = conversationGroupVOList.stream().filter(ConversationGroupVO::isValid) - .map(g ->{ - ConversationGroup group = new ConversationGroup(this, g); - group.initGroupType(); - return group; - }).collect(Collectors.toMap(ConversationGroup::getId, group -> group)); + Map groupMap = null; + if (CollectionUtils.isEmpty(conversationGroupVOList)) { + groupMap = new HashMap<>(); + } else { + groupMap = conversationGroupVOList.stream().filter(ConversationGroupVO::isValid) + .map(g ->{ + ConversationGroup group = new ConversationGroup(this, g); + group.initGroupType(); + return group; + }).collect(Collectors.toMap(ConversationGroup::getId, group -> group)); + } overCoverConversationGroupMap(groupMap); } From 25fbd9a7150f9997a1403c1e1d93239678a7c47c Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Tue, 30 May 2023 16:39:06 +0800 Subject: [PATCH 10/15] =?UTF-8?q?=E6=AD=A6=E6=B1=898?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ATS/service/TrainPositionService.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java index 2cdd98b1c..7effc19df 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java @@ -17,24 +17,25 @@ import javax.annotation.Resource; public class TrainPositionService { - @Resource - TrainPositionTimeOverService timeOverService; + @Resource + TrainPositionTimeOverService timeOverService; - /** - * 初始化或更新列车的位置 - * @param mapName - * @param json - */ + /** + * 初始化或更新列车的位置 + * + * @param mapName + * @param json + */ - public void initTrainOrUpdate(String mapName,String json){ - TrainPosition tp = JsonUtils.read(json, TrainPosition.class); - tp.setReceiveTime(System.currentTimeMillis()); - log.debug(json); + public void initTrainOrUpdate(String mapName, String json) { + TrainPosition tp = JsonUtils.read(json, TrainPosition.class); + tp.setReceiveTime(System.currentTimeMillis()); + log.info(json); // SocketMessageVO vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp); // this.messageService.send(vo); - this.timeOverService.addTrainAccept(mapName,tp); + this.timeOverService.addTrainAccept(mapName, tp); - } + } } From 72024821b0e92a7fe68d3c4a92ebf78e50801d59 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 30 May 2023 16:46:18 +0800 Subject: [PATCH 11/15] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0IBP=E8=AE=A1?= =?UTF-8?q?=E8=BD=B4=E5=A4=8D=E4=BD=8D=E9=A2=84=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/services/VirtualRealityIbpService.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java b/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java index 87853a935..0e3a011ee 100644 --- a/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java +++ b/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java @@ -263,12 +263,15 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService { if (ibp == null) continue; List buttons = ibp.queryByMean(VirtualRealityIbp.Mean.PRERESET_Z); - if (CollectionUtils.isEmpty(buttons)) - continue; - VirtualRealityIbp.SquareButton preResetButton = - (VirtualRealityIbp.SquareButton) buttons.get(0); - if (!preResetButton.isPressed()) - continue; + if (CollectionUtils.isEmpty(buttons)) { // 如果没有按钮,判断车站是否有预处理倒计时时间 20230530 wei + if (station.getPreResetValidDuration().get() <= 0) { + continue; + } + } else { + VirtualRealityIbp.SquareButton preResetButton = (VirtualRealityIbp.SquareButton) buttons.get(0); + if (!preResetButton.isPressed()) + continue; + } LocalDateTime now = LocalDateTime.now(); for (VirtualRealityIbp.IbpElement ibpElement : ibp.queryByMean(VirtualRealityIbp.Mean.AXLE_PRE_RESET)) { VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) ibpElement; From 38c30520f4f5c368620734537748da5de97cf846 Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Tue, 30 May 2023 16:49:45 +0800 Subject: [PATCH 12/15] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/simulation/cbtc/ATS/service/TrainPositionService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java index 7effc19df..ee039daba 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java @@ -31,7 +31,7 @@ public class TrainPositionService { public void initTrainOrUpdate(String mapName, String json) { TrainPosition tp = JsonUtils.read(json, TrainPosition.class); tp.setReceiveTime(System.currentTimeMillis()); - log.info(json); + log.debug(json); // SocketMessageVO vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp); // this.messageService.send(vo); this.timeOverService.addTrainAccept(mapName, tp); From 4e5e83202c1873a35f84f463033779682f385810 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 30 May 2023 17:30:53 +0800 Subject: [PATCH 13/15] =?UTF-8?q?=E3=80=90IBP=E6=8C=89=E9=92=AE=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E4=BD=BF=E7=94=A8=E4=BB=BF=E7=9C=9F=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=A4=84=E7=90=86=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../club/joylink/rtss/services/VirtualRealityIbpService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java b/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java index 0e3a011ee..457ad1bd2 100644 --- a/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java +++ b/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java @@ -154,7 +154,7 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService { VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element; if (!button.isEffective()) { button.setEffective(true); - button.setPressTime(LocalDateTime.now()); + button.setPressTime(simulation.getCorrectSystemTime()); } break; } @@ -272,7 +272,7 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService { if (!preResetButton.isPressed()) continue; } - LocalDateTime now = LocalDateTime.now(); + LocalDateTime now = simulation.getCorrectSystemTime(); for (VirtualRealityIbp.IbpElement ibpElement : ibp.queryByMean(VirtualRealityIbp.Mean.AXLE_PRE_RESET)) { VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) ibpElement; if (!button.isPressed() || !button.isEffective()) From a1a9929f4d15afdecd8484963a16963522d39ccd Mon Sep 17 00:00:00 2001 From: weizhihong Date: Wed, 31 May 2023 15:20:43 +0800 Subject: [PATCH 14/15] =?UTF-8?q?=E3=80=90=E5=AE=9E=E8=AE=AD=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=88=B0=E6=9F=90=E6=AD=A5=E5=87=BA=E7=8E=B0=E6=8F=90?= =?UTF-8?q?=E7=A4=BABUG=E3=80=91=20=E3=80=90=E8=A7=92=E8=89=B2=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E6=89=AE=E6=BC=94=E7=BD=AENULL=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=91=20=E3=80=90=E4=BF=A1=E5=8F=B7=E6=9C=BA=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BC=95=E5=AF=BC=E5=85=B3=E9=94=AE=E9=81=93=E5=B2=94?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/training2/Training2Service.java | 27 +++++++++++++++---- .../rtss/simulation/SimulationManager.java | 5 +++- .../cbtc/build/MapDeviceBuilder.java | 25 +++++++++++++++++ .../rtss/simulation/cbtc/data/map/Signal.java | 5 ++++ .../rtss/vo/map/graph/MapSignalNewVO.java | 6 +++++ 5 files changed, 62 insertions(+), 6 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java index 2fac6fd61..97d5f19f3 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -523,6 +523,7 @@ public class Training2Service { throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "实训不存在"); } Simulation simulation = groupSimulationCache.getSimulationByGroup(group); + loadTrainingPre(simulation); // 重置仿真状态 // groupSimulationService.planOver(group); simulationService.reset(group); @@ -603,6 +604,7 @@ public class Training2Service { * 加载实训数据 */ private void loadTraining(Simulation simulation, DraftTraining2WithBLOBs draftTraining2, LoginUserInfoVO loginUserInfoVO) { + loadTrainingPre(simulation); // 没有背景不做加载,加载的时候不做背景加载,开始的时候重新加载背景即可 if (!StringUtils.isEmpty(draftTraining2.getBgSceneJson())) { groupSimulationService.loadScenes(simulation.getId(), draftTraining2.getBgSceneJson()); @@ -623,6 +625,17 @@ public class Training2Service { simulationLifeCycleService.pause(simulation); } + /** + * 仿真加载实训时前置清空方法 + * @param simulation 仿真 + */ + private void loadTrainingPre(Simulation simulation) { + if (simulation.getTraining2() != null) { // 如果仿真存在旧的实训 + removeTrainingJob(simulation); + clearJumpStep(simulation); + } + } + /** * 判断实训步骤是否完成 */ @@ -674,7 +687,7 @@ public class Training2Service { } } // 发送步骤提示信息,需要跳过步骤不发消息 - if (!step.isPrompt() && !simulation.getTraining2().isJumpStep(step)) { + if (!step.isPrompt() && !simulation.getTraining2().haveJumpStep()) { step.setPrompt(true); // 标识已发送过消息 applicationContext.publishEvent(new SimulationStepTipEvent(this, simulation, step)); } @@ -929,8 +942,10 @@ public class Training2Service { addTrainingJob(simulation, training2); // 启动仿真 simulationLifeCycleService.resume(simulation); - // 发送开始消息 - trainingStatusMessage(simulation, 1); + // 发送开始消息,跳转不发送消息 + if (!training2.haveJumpStep()) { + trainingStatusMessage(simulation, 1); + } } /** @@ -938,8 +953,10 @@ public class Training2Service { */ private void clearJumpStep(Simulation simulation) { simulation.updateSpeed(Simulation.MIN_SPEED); - simulation.getTraining2().setJumpToStep(null); - simulation.getTraining2().finish(); + if (simulation.getTraining2() != null) { + simulation.getTraining2().setJumpToStep(null); + simulation.getTraining2().finish(); + } } /** diff --git a/src/main/java/club/joylink/rtss/simulation/SimulationManager.java b/src/main/java/club/joylink/rtss/simulation/SimulationManager.java index 507f4d58d..07674e7a0 100644 --- a/src/main/java/club/joylink/rtss/simulation/SimulationManager.java +++ b/src/main/java/club/joylink/rtss/simulation/SimulationManager.java @@ -185,8 +185,11 @@ public class SimulationManager { String oldMemberId = simulationUser.getMemberId(); if (oldMemberId != null) { SimulationMember old = simulation.getSimulationMemberById(oldMemberId); - this.memberPlayChange(simulation, old, null); + if (Objects.equals(old.getUserId(), userId)) { // 这里做同用户对比,防止角色替换时,置NULL问题 + this.memberPlayChange(simulation, old, null); + } } + log.info("memberId:" + memberId + ";userId:" + userId); this.memberPlayChange(simulation, simulationMember, simulationUser); } else { this.memberPlayChange(simulation, simulationMember, null); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java index 5ec2421f2..8b22929d1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java @@ -7,6 +7,7 @@ import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption; import club.joylink.rtss.simulation.cbtc.data.vr.*; +import club.joylink.rtss.vo.map.MapCISwitchVO; import club.joylink.rtss.vo.map.MapGraphDataNewVO; import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.RealLineConfigVO; @@ -114,6 +115,8 @@ public class MapDeviceBuilder { MapDeviceBuilder.buildCatenary(graphData, elementMap, errMsgList, mapDataBuildResult.getCatenaryMap()); //应答器 MapDeviceBuilder.buildResponderDataRef(graphData, elementMap, errMsgList, mapDataBuildResult.getSectionRespondersMap()); + // 设置信号机引导关键道岔信息 + initSignalGuideKeySwitch(graphData, elementMap, errMsgList); if (mapDataBuildResult.getErrMsgList().isEmpty()) { Map> sectionArriveMap = MapDeviceBuilder.buildNormalStandTrackAdjoinSections(mapDataBuildResult.getDeviceMap()); mapDataBuildResult.setSectionArriveNearMap(sectionArriveMap); @@ -1568,4 +1571,26 @@ public class MapDeviceBuilder { private static boolean isCross(String type) { return Objects.equals(type, BusinessConsts.Section.SectionType.Type05); } + + /** + * 初始化信号机的引导关键道岔设置(作用于引导信号的开放) + * @param graphData 地图信息 + * @param elementMap 设备信息 + * @param errMsgList 错误提示信息 + */ + private static void initSignalGuideKeySwitch(MapGraphDataNewVO graphData, Map elementMap, List errMsgList) { + graphData.getSignalList().stream().filter(s -> !CollectionUtils.isEmpty(s.getGuideKeySwitchList())).forEach(s -> { + List switchElementList = new ArrayList<>(s.getGuideKeySwitchList().size()); + for (MapCISwitchVO ciSwitchVO : s.getGuideKeySwitchList()) { + Switch aSwitch = (Switch) elementMap.get(ciSwitchVO.getSwitchCode()); + if (Objects.isNull(aSwitch)) { + errMsgList.add(String.format("编码为[%s]的道岔不存在", ciSwitchVO.getSwitchCode())); + } else { + switchElementList.add(new SwitchElement(aSwitch, ciSwitchVO.isNormal())); + } + } + Signal signal = (Signal) elementMap.get(s.getCode()); + signal.setGuideKeySwitchList(switchElementList); + }); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java index 2c6ec407f..d283a9b87 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java @@ -159,6 +159,11 @@ public class Signal extends DelayUnlockDevice { */ private List replaceSignals; + /** + * 信号机引导关键道岔列表 + */ + private List guideKeySwitchList; + // ------------------状态属性--------------------- private int mode; diff --git a/src/main/java/club/joylink/rtss/vo/map/graph/MapSignalNewVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapSignalNewVO.java index 824f523e4..5dc890d52 100644 --- a/src/main/java/club/joylink/rtss/vo/map/graph/MapSignalNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapSignalNewVO.java @@ -1,6 +1,7 @@ package club.joylink.rtss.vo.map.graph; import club.joylink.rtss.simulation.cbtc.data.map.Signal; +import club.joylink.rtss.vo.map.MapCISwitchVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.Setter; @@ -202,6 +203,11 @@ public class MapSignalNewVO { */ private String srCode; + /** + * 引导关键道岔列表 + */ + private List guideKeySwitchList; + @JsonIgnore public boolean isShunting() { return Signal.SignalType.SHUNTING.equals(this.type); From 3189b6b51a639d941770d622d647ba96e5b6787a Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Wed, 31 May 2023 16:05:48 +0800 Subject: [PATCH 15/15] =?UTF-8?q?=E5=8D=97=E5=AE=81=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../real/modbustcp/gxsd/GxsdService.java | 41 ++ .../real/modbustcp/gxsd/GxsdSignalConfig.java | 32 + .../modbustcp/gxsd/GxsdSignalServiceImpl.java | 126 ++++ .../real/modbustcp/gxsd/GxsdSwitchConfig.java | 97 +++ .../modbustcp/gxsd/GxsdSwitchServiceImpl.java | 118 ++++ .../vo/client/project/ProjectDeviceVO.java | 634 +++++++++--------- .../project/gxsd/GxsdSignalConfigVO.java | 53 ++ .../project/gxsd/GxsdSwitchConfigVO.java | 56 ++ 8 files changed, 855 insertions(+), 302 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdService.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSignalConfig.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSignalServiceImpl.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSwitchConfig.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSwitchServiceImpl.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/project/gxsd/GxsdSignalConfigVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/project/gxsd/GxsdSwitchConfigVO.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdService.java new file mode 100644 index 000000000..de7b28889 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdService.java @@ -0,0 +1,41 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.PlcGateway; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSignalConfig; +import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO; +import io.netty.buffer.ByteBuf; +import io.netty.channel.Channel; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; + +@Slf4j +public abstract class GxsdService implements RealDeviceService { + + @Autowired + @Getter + protected PlcGatewayService plcGatewayService; + + @Override + public void init(Simulation simulation, RealDeviceConfig deviceConfig) { + //设置plc 继电器的工作模式,此配置不在configVo中体现 + PlcGateway plcGateway = simulation.getPlcGateway(); + Channel channel = plcGateway.getChannel(); + log.info("设置plc继电器..."); + this.plcGatewayService.writeSingleCoil(0, 14, true, channel); + } + + /** + * 检测继电器 + */ + public boolean checkElectricRelay(ByteBuf signalStatus) { + boolean rReplay = RealDeviceConfig.getBitOf(signalStatus, 6); +// boolean outReplay = RealDeviceConfig.getBitOf(signalStatus, 14); + log.info("读取继电器... val:" + rReplay); + return rReplay; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSignalConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSignalConfig.java new file mode 100644 index 000000000..4358058b4 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSignalConfig.java @@ -0,0 +1,32 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd; + +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.ProjectDeviceVO; +import club.joylink.rtss.vo.client.project.gxsd.GxsdSignalConfigVO; +import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO; +import java.util.Objects; +import lombok.Getter; + +@Getter +public class GxsdSignalConfig extends RealDeviceConfig { + + private GxsdSignalConfigVO config; + + public GxsdSignalConfig(ProjectDeviceVO deviceVO) { + super(deviceVO); + if (Objects.nonNull(deviceVO.getConfig())) { + this.config = JsonUtils.read(deviceVO.getConfig(), GxsdSignalConfigVO.class); + } + } + + @Override + public String findDeviceCode() { + return config.findDeviceCode(); + } + + public static void main(String[] args) { + GxsdSignalConfigVO vo = new GxsdSignalConfigVO(); + System.out.println(JsonUtils.writeValueAsString(vo)); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSignalServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSignalServiceImpl.java new file mode 100644 index 000000000..35551bd9a --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSignalServiceImpl.java @@ -0,0 +1,126 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal.Fault; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.PlcGateway; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSignalConfig; +import club.joylink.rtss.vo.client.project.gxsd.GxsdSignalConfigVO; +import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO; +import io.netty.buffer.ByteBuf; +import io.netty.channel.Channel; +import java.util.Objects; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class GxsdSignalServiceImpl extends GxsdService { + + + @Override + public boolean canHandle(RealDeviceConfig deviceConfig) { + return deviceConfig instanceof GxsdSignalConfig; + } + + + @Override + public void init(Simulation simulation, RealDeviceConfig deviceConfig) { + super.init(simulation, deviceConfig); + GxsdSignalConfig switchConfig = (GxsdSignalConfig) deviceConfig; + GxsdSignalConfigVO config = switchConfig.getConfig(); + PlcGateway plcGateway = simulation.getPlcGateway(); + Channel channel = plcGateway.getChannel(); + int baseAddr = plcGateway.getConfig().getAddr() + config.getAddr(); + this.plcGatewayService.writeSingleCoil(baseAddr, config.getW5(), true, channel); + this.plcGatewayService.writeSingleCoil(baseAddr, config.getW3(), false, channel); + this.plcGatewayService.writeSingleCoil(baseAddr, config.getW4(), false, channel); + this.plcGatewayService.writeSingleCoil(baseAddr, config.getW7(), false, channel); + + } + + + @Override + public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { + PlcGateway plcGateway = simulation.queryPlcGatewayDevice(); + GxsdSignalConfig switchConfig = (GxsdSignalConfig) deviceConfig; + VirtualRealitySignal vrSignal = ((VirtualRealitySignal) switchConfig.getMapElement()); + + if (Objects.isNull(vrSignal)) { + return; + } + + GxsdSignalConfigVO config = switchConfig.getConfig(); + Channel channel = plcGateway.getChannel(); + int baseAddr = plcGateway.getConfig().getAddr() + config.getAddr(); + ByteBuf signalStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, config.getAddr(), config.getQuantity()); + + boolean br0 = RealDeviceConfig.getBitOf(signalStatus, config.getR1());//红灯 + boolean br3 = RealDeviceConfig.getBitOf(signalStatus, config.getR3());//绿灯或黄灯 + boolean w3 = RealDeviceConfig.getBitOf(signalStatus, config.getW3()); //输出 绿灯 + boolean w4 = RealDeviceConfig.getBitOf(signalStatus, config.getW4()); //输出 黄灯 + boolean w5 = RealDeviceConfig.getBitOf(signalStatus, config.getW5()); //输出 灭灯 开启 默认就是红灯 + boolean w7 = RealDeviceConfig.getBitOf(signalStatus, config.getW7()); //输出 红黄灯 + + SignalAspect aspect = null; + if (br0 && w5) { + aspect = SignalAspect.No; + } else if (br0) { + aspect = SignalAspect.R; + } else if (br3 && w3) { + aspect = SignalAspect.G; + } else if (br3 && w4) { + aspect = SignalAspect.Y; + } else if (w7) { + aspect = SignalAspect.RY; + } + log.info("当前信号灯状态 读红[{}],读绿黄[{}],写红[{}],写黄[{}],写灭灯[{}],写红黄[{}]", br0, br3, w3, w4, w5, w7); + if (Objects.nonNull(aspect)) { + vrSignal.apply(aspect); + } + if (!this.checkElectricRelay(signalStatus)) { + return; + } + if (!vrSignal.isTurning()) { + return; + } + switch (vrSignal.getCommand()) { + case RY: { + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW3(), w3, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW4(), w4, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW5(), w5, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW7(), w7, true, channel); + break; + } + + case G: { + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW3(), w3, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW4(), w4, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW5(), w5, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW7(), w7, false, channel); + break; + } + case Y: { + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW3(), w3, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW4(), w4, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW5(), w5, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW7(), w7, false, channel); + break; + } + case R: + case No: { + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW3(), w3, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW4(), w4, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW5(), w5, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW7(), w7, false, channel); + break; + } + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSwitchConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSwitchConfig.java new file mode 100644 index 000000000..7948930d7 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSwitchConfig.java @@ -0,0 +1,97 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd; + +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.ProjectDeviceVO; +import club.joylink.rtss.vo.client.project.gxsd.GxsdSignalConfigVO; +import club.joylink.rtss.vo.client.project.gxsd.GxsdSwitchConfigVO; +import club.joylink.rtss.vo.client.project.gzb.GzbSwitchConfigVO; +import java.time.LocalDateTime; +import java.util.Objects; +import lombok.Getter; + +@Getter +public class GxsdSwitchConfig extends RealDeviceConfig { + + private GxsdSwitchConfigVO config; + /** + * 下令定操 + */ + private boolean turnToN; + + /** + * 下令反操 + */ + private boolean turnToP; + + /** + * 定反操继电器接通时刻。 3s后断开继电器,防止继电器长期接通。 + */ + private LocalDateTime startTime; + + public GxsdSwitchConfig(ProjectDeviceVO deviceVO) { + super(deviceVO); + if (Objects.nonNull(deviceVO.getConfig())) { + this.config = JsonUtils.read(deviceVO.getConfig(), GxsdSwitchConfigVO.class); + } + } + + @Override + public String findDeviceCode() { + return config.findDeviceCode(); + } + + + /** + * 请求转向定位 + * + * @return 是否可以操作继电器以转向定位 + */ + public boolean turnToN() { + if (turnToN) { + return false; + } else { + turnToN = true; + turnToP = false; + startTime = LocalDateTime.now(); + return true; + } + } + + /** + * 请求转向反位 + * + * @return 是否可以操作继电器以转向反位 + */ + public boolean turnToP() { + if (turnToP) { + return false; + } else { + turnToN = false; + turnToP = true; + startTime = LocalDateTime.now(); + return true; + } + } + + /** + * 定反操的继电器操作是否可以结束。 + */ + public boolean isEnd() { + return startTime == null || LocalDateTime.now().isAfter(startTime.plusSeconds(3)); + } + + + /** + * 同步道岔状态表示以限定此时道岔可以进行的操作。 此方法是为了防止类似以下情况:通过仿真将道岔操到定位,再手摇道岔到反位,则此时仿真中道岔表示为反位, 只能执行定操,又因此处记录上一次操作也是定操,不予执行,导致死循环:仿真中无法再操作道岔了。 + */ + public void sync(boolean r_db, boolean r_fb) { + if (r_db) { + turnToN = true; + turnToP = false; + } else if (r_fb) { + turnToN = false; + turnToP = true; + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSwitchServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSwitchServiceImpl.java new file mode 100644 index 000000000..851bf5ad1 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gxsd/GxsdSwitchServiceImpl.java @@ -0,0 +1,118 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.PlcGateway; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSignalConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say.SaySwitchConfig; +import club.joylink.rtss.vo.client.project.gxsd.GxsdSwitchConfigVO; +import club.joylink.rtss.vo.client.project.say.SaySwitchConfigVO; +import io.netty.buffer.ByteBuf; +import io.netty.channel.Channel; +import java.util.Objects; +import lombok.Getter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class GxsdSwitchServiceImpl extends GxsdService { + + @Override + public boolean canHandle(RealDeviceConfig deviceConfig) { + return deviceConfig instanceof GxsdSwitchConfig; + } + + + @Override + public void init(Simulation simulation, RealDeviceConfig deviceConfig) { + super.init(simulation, deviceConfig); + PlcGateway plcGateway = simulation.queryPlcGatewayDevice(); + if (plcGateway == null) { + return; + } + GxsdSwitchConfig switchConfig = (GxsdSwitchConfig) deviceConfig; + GxsdSwitchConfigVO configVO = switchConfig.getConfig(); + int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); + Channel channel = plcGateway.getChannel(); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getWdc(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getWfc(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getWsj(), false, channel); + } + + @Override + public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { + PlcGateway plcGateway = simulation.queryPlcGatewayDevice(); + if (plcGateway == null) { + return; + } + + GxsdSwitchConfig config = (GxsdSwitchConfig) deviceConfig; + GxsdSwitchConfigVO configVO = config.getConfig(); + ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); + int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); + Channel channel = plcGateway.getChannel(); + VirtualRealitySwitch vrSwitch = (VirtualRealitySwitch) config.getMapElement(); + if (vrSwitch == null) { + release(deviceStatus, baseAddr, configVO, channel); //防止定反操继电器长时间接通 + return; + } + + boolean r_db = RealDeviceConfig.getBitOf(deviceStatus, configVO.getRdc()); + boolean r_fb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getRfc()); + vrSwitch.apply(r_db, r_fb); + if (!this.checkElectricRelay(deviceStatus)) { + return; + } + //以下操作实体设备的逻辑中,防止继电器长期接通的逻辑将定反操视为技能,共用3秒冷却,技能持续时间也是3秒 + if (config.isEnd()) { //此判断既可视为操作是否冷却,也可视为持续时间是否耗尽 + config.sync(r_db, r_fb); + release(deviceStatus, baseAddr, configVO, channel); //操作持续时间耗尽后断开所有继电器 + if (vrSwitch.isTurning()) { + switch (vrSwitch.getCommand()) { + case NP: + if (config.turnToN()) { + turnToN(deviceStatus, baseAddr, configVO, channel); + } + break; + case RP: + if (config.turnToP()) { + turnToP(deviceStatus, baseAddr, configVO, channel); + } + break; + } + } + } + + + } + + private void turnToN(ByteBuf deviceStatus, int baseAddr, GxsdSwitchConfigVO configVO, Channel channel) { + boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWsj()); + boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWdc()); + boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWfc()); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWsj(), w_sb, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWdc(), w_dc, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWfc(), w_fc, false, channel); + } + + private void turnToP(ByteBuf deviceStatus, int baseAddr, GxsdSwitchConfigVO configVO, Channel channel) { + boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWsj()); + boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWdc()); + boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWfc()); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWsj(), w_sb, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWdc(), w_dc, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWfc(), w_fc, true, channel); + } + + private void release(ByteBuf deviceStatus, int baseAddr, GxsdSwitchConfigVO configVO, Channel channel) { + boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWsj()); + boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWdc()); + boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWfc()); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWsj(), w_sb, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWdc(), w_dc, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWfc(), w_fc, false, channel); + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java b/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java index 956cf8c00..a9278d27d 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java @@ -5,6 +5,8 @@ import club.joylink.rtss.entity.ProjectDevice; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.PlcGateway; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd.GxsdSignalConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd.GxsdSwitchConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSignalConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSwitchConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.*; @@ -47,349 +49,377 @@ import java.util.Objects; @NoArgsConstructor public class ProjectDeviceVO { - private Long id; - /** - * 所属项目 - */ + private Long id; + /** + * 所属项目 + */ // @NotBlank(message = "所属项目编码不能为空") - private String project; + private String project; - /** - * 设备编号(或名称),一个项目下唯一 - */ - @NotBlank(message = "设备编号(或名称)不能为空") - private String code; + /** + * 设备编号(或名称),一个项目下唯一 + */ + @NotBlank(message = "设备编号(或名称)不能为空") + private String code; - /** - * 设备类型 - */ - private ProjectDeviceType type; + /** + * 设备类型 + */ + private ProjectDeviceType type; - /** - * 创建人 - */ - private Long creator; + /** + * 创建人 + */ + private Long creator; - /** - * 创建时间 - */ - private LocalDateTime createTime; + /** + * 创建时间 + */ + private LocalDateTime createTime; - /** - * 设备网关映射配置 - */ - private String config; + /** + * 设备网关映射配置 + */ + private String config; - public ProjectDeviceVO(ProjectDevice device) { - this.id = device.getId(); - this.project = device.getProjectCode(); - this.code = device.getCode(); - this.type = ProjectDeviceType.valueOf(device.getType()); - this.creator = device.getCreator(); - this.createTime = device.getCreateTime(); - this.config = device.getConfig(); + public ProjectDeviceVO(ProjectDevice device) { + this.id = device.getId(); + this.project = device.getProjectCode(); + this.code = device.getCode(); + this.type = ProjectDeviceType.valueOf(device.getType()); + this.creator = device.getCreator(); + this.createTime = device.getCreateTime(); + this.config = device.getConfig(); + } + + public static List convert2VOList(List list) { + List voList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(list)) { + list.forEach(projectDevice -> voList.add(new ProjectDeviceVO(projectDevice))); } + return voList; + } - public static List convert2VOList(List list) { - List voList = new ArrayList<>(); - if (!CollectionUtils.isEmpty(list)) { - list.forEach(projectDevice -> voList.add(new ProjectDeviceVO(projectDevice))); + public static List convert2RealDeviceList(List voList) { + List list = new ArrayList<>(); + if (!CollectionUtils.isEmpty(voList)) { + String project = voList.get(0).getProject(); + String projectCode = StringUtils.hasText(project) ? project.toUpperCase() : ""; + switch (projectCode) { + case "XTY": { + return xtyDeviceConfigConvert(voList); } - return voList; - } - - public static List convert2RealDeviceList(List voList) { - List list = new ArrayList<>(); - if (!CollectionUtils.isEmpty(voList)) { - String project = voList.get(0).getProject(); - switch (project) { - case "XTY": { - return xtyDeviceConfigConvert(voList); - } - case "GZB": { - return gzbDeviceConfigConvert(voList); - } - case "HEB": { - return heb1DeviceConfigConvert(voList); - } - case "SDY": { - return sdyDeviceConfigConvert(voList); - } - case "RICHOR_JOINT": { - return zjdDeviceConfigConvert(voList); - } - case "SR_SANDBOX": { - return srSandboxDeviceConfigConvert(voList); - } - case "RICHOR_HHCJ": { - return hhcjDeviceConfigConvert(voList); - } - case "SAY": { - return sayDeviceConfigConvert(voList); - } - } + case "GZB": { + return gzbDeviceConfigConvert(voList); } - - return list; - } - - private static List sayDeviceConfigConvert(List voList) { - List list = new ArrayList<>(); - for (ProjectDeviceVO deviceVO : voList) { - switch (deviceVO.getType()) { - case IBP: - list.add(new SayIbpConfig(deviceVO)); - break; - case PLC_GATEWAY: - list.add(new PlcGateway(deviceVO)); - break; - case PSD: - list.add(new SayPsdConfig(deviceVO)); - break; - case SIGNAL: - list.add(new SaySignalConfig(deviceVO)); - break; - case SWITCH: - list.add(new SaySwitchConfig(deviceVO)); - break; - case SECTION: - list.add(new SaySectionConfig(deviceVO)); - break; - } + case "HEB": { + return heb1DeviceConfigConvert(voList); } - return list; - } - - private static List hhcjDeviceConfigConvert(List voList) { - List list = new ArrayList<>(); - for (ProjectDeviceVO deviceVO : voList) { - switch (deviceVO.getType()) { - case IBP: - list.add(new HhcjIbpConfig(deviceVO)); - break; - case PSD: - list.add(new HhcjPsdConfig(deviceVO)); - break; - case PLC_GATEWAY: - list.add(new PlcGateway(deviceVO)); - break; - } + case "SDY": { + return sdyDeviceConfigConvert(voList); } - return list; - } - - private static List srSandboxDeviceConfigConvert(List voList) { - List list = new ArrayList<>(); - for (ProjectDeviceVO deviceVO : voList) { - switch (deviceVO.getType()) { - case UDP_LOW: - list.add(new UDPLowConfig(deviceVO)); - break; - case UDP_CLIENT: - list.add(new UDPClientConfig(deviceVO)); - break; - case SIGNAL: - list.add(new SrSignalConfig(deviceVO)); - break; - case SECTION: - list.add(new SrSectionConfig(deviceVO)); - break; - case SWITCH: - list.add(new SrSwitchConfig(deviceVO)); - break; - case TRAIN: - list.add(new SrTrainConfig(deviceVO)); - break; - } + case "RICHOR_JOINT": { + return zjdDeviceConfigConvert(voList); } - return list; - } - - private static List zjdDeviceConfigConvert(List voList) { - List list = new ArrayList<>(); - for (ProjectDeviceVO deviceVO : voList) { - switch (deviceVO.getType()) { - case IBP: - list.add(new ZjdIbpConfig(deviceVO)); - break; - case PLC_GATEWAY: - list.add(new PlcGateway(deviceVO)); - break; - case PSD: - list.add(new ZjdPsdConfig(deviceVO)); - break; - case PSL: - list.add(new ZjdPslConfig(deviceVO)); - break; - } + case "SR_SANDBOX": { + return srSandboxDeviceConfigConvert(voList); } - return list; - } - - private static List sdyDeviceConfigConvert(List voList) { - List list = new ArrayList<>(); - for (ProjectDeviceVO deviceVO : voList) { - switch (deviceVO.getType()) { - case PSD: - list.add(new SdyPsdConfig(deviceVO)); - break; - case PLC_GATEWAY: - list.add(new PlcGateway(deviceVO)); - break; - case PSL: - list.add(new SdyPslConfig(deviceVO)); - break; - } + case "RICHOR_HHCJ": { + return hhcjDeviceConfigConvert(voList); } - return list; - } - - private static List heb1DeviceConfigConvert(List voList) { - List list = new ArrayList<>(); - for (ProjectDeviceVO deviceVO : voList) { - switch (deviceVO.getType()) { - case SWITCH: - list.add(new Heb1SwitchConfig(deviceVO)); - break; - case SIGNAL: - list.add(new Heb1SignalConfig(deviceVO)); - break; - case PSC: - list.add(new Heb1PscConfig(deviceVO)); - break; - case PSL: - list.add(new Heb1PslConfig(deviceVO)); - break; - case IBP: - list.add(new Heb1IbpConfig(deviceVO)); - break; - case PLC_GATEWAY: - list.add(new PlcGateway(deviceVO)); - break; - default: { - log.warn(String.format("设备[%s]不是PLC可连接控制设备", deviceVO)); - break; - } - } + case "SAY": { + return sayDeviceConfigConvert(voList); } - return list; - } - - private static List gzbDeviceConfigConvert(List voList) { - List list = new ArrayList<>(); - for (ProjectDeviceVO deviceVO : voList) { - switch (deviceVO.getType()) { - case SWITCH: - list.add(new GzbSwitchConfig(deviceVO)); - break; - case SIGNAL: - list.add(new GzbSignalConfig(deviceVO)); - break; - case PLC_GATEWAY: - list.add(new PlcGateway(deviceVO)); - break; - default: { - log.warn(String.format("设备[%s]不是PLC可连接控制设备", deviceVO)); - break; - } - } + case "GXSD": { + return gxsdDeviceConfigConvert(voList); } - return list; + } } - private static List xtyDeviceConfigConvert(List voList) { - List list = new ArrayList<>(); - for (ProjectDeviceVO deviceVO : voList) { - switch (deviceVO.getType()) { - case PSD: - list.add(new XtyPsdConfig(deviceVO)); - break; - case PLC_GATEWAY: - list.add(new PlcGateway(deviceVO)); - break; - } + return list; + } + + private static List gxsdDeviceConfigConvert(List voList) { + List list = new ArrayList<>(); + for (ProjectDeviceVO deviceVO : voList) { + switch (deviceVO.getType()) { + case SWITCH: + list.add(new GxsdSwitchConfig(deviceVO)); + break; + case SIGNAL: + list.add(new GxsdSignalConfig(deviceVO)); + break; + case PLC_GATEWAY: + list.add(new PlcGateway(deviceVO)); + break; + default: { + log.warn(String.format("设备[%s]不是PLC可连接控制设备", deviceVO)); + break; } - return list; + } } + return list; + } - @JsonIgnore - public ProjectDevice buildDB() { - ProjectDevice device = new ProjectDevice(); - device.setProjectCode(this.getProject()); - device.setCode(this.getCode()); - device.setType(this.getType().name()); - return device; + private static List sayDeviceConfigConvert(List voList) { + List list = new ArrayList<>(); + for (ProjectDeviceVO deviceVO : voList) { + switch (deviceVO.getType()) { + case IBP: + list.add(new SayIbpConfig(deviceVO)); + break; + case PLC_GATEWAY: + list.add(new PlcGateway(deviceVO)); + break; + case PSD: + list.add(new SayPsdConfig(deviceVO)); + break; + case SIGNAL: + list.add(new SaySignalConfig(deviceVO)); + break; + case SWITCH: + list.add(new SaySwitchConfig(deviceVO)); + break; + case SECTION: + list.add(new SaySectionConfig(deviceVO)); + break; + } } + return list; + } - @Override - public String toString() { - return "ProjectDeviceVO{" + - "project=" + project + - ", code='" + code + '\'' + - ", type=" + type + - '}'; + private static List hhcjDeviceConfigConvert(List voList) { + List list = new ArrayList<>(); + for (ProjectDeviceVO deviceVO : voList) { + switch (deviceVO.getType()) { + case IBP: + list.add(new HhcjIbpConfig(deviceVO)); + break; + case PSD: + list.add(new HhcjPsdConfig(deviceVO)); + break; + case PLC_GATEWAY: + list.add(new PlcGateway(deviceVO)); + break; + } } + return list; + } - public LwConfigVO buildLwConfig() { - BusinessExceptionAssertEnum - .SYSTEM_EXCEPTION - .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.LW), "设备不是[现地工作站]"); - return JsonUtils.read(this.config, LwConfigVO.class); + private static List srSandboxDeviceConfigConvert(List voList) { + List list = new ArrayList<>(); + for (ProjectDeviceVO deviceVO : voList) { + switch (deviceVO.getType()) { + case UDP_LOW: + list.add(new UDPLowConfig(deviceVO)); + break; + case UDP_CLIENT: + list.add(new UDPClientConfig(deviceVO)); + break; + case SIGNAL: + list.add(new SrSignalConfig(deviceVO)); + break; + case SECTION: + list.add(new SrSectionConfig(deviceVO)); + break; + case SWITCH: + list.add(new SrSwitchConfig(deviceVO)); + break; + case TRAIN: + list.add(new SrTrainConfig(deviceVO)); + break; + } } + return list; + } - public VrIbpConfigVO buildVrIbpConfig() { - BusinessExceptionAssertEnum - .SYSTEM_EXCEPTION - .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.IBP), "设备不是[IBP盘]"); - return JsonUtils.read(this.config, VrIbpConfigVO.class); + private static List zjdDeviceConfigConvert(List voList) { + List list = new ArrayList<>(); + for (ProjectDeviceVO deviceVO : voList) { + switch (deviceVO.getType()) { + case IBP: + list.add(new ZjdIbpConfig(deviceVO)); + break; + case PLC_GATEWAY: + list.add(new PlcGateway(deviceVO)); + break; + case PSD: + list.add(new ZjdPsdConfig(deviceVO)); + break; + case PSL: + list.add(new ZjdPslConfig(deviceVO)); + break; + } } + return list; + } - public LswConfigVO buildLswConfig() { - BusinessExceptionAssertEnum - .SYSTEM_EXCEPTION - .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.LSW), "设备不是[大屏工作站]"); - return JsonUtils.read(this.config, LswConfigVO.class); + private static List sdyDeviceConfigConvert(List voList) { + List list = new ArrayList<>(); + for (ProjectDeviceVO deviceVO : voList) { + switch (deviceVO.getType()) { + case PSD: + list.add(new SdyPsdConfig(deviceVO)); + break; + case PLC_GATEWAY: + list.add(new PlcGateway(deviceVO)); + break; + case PSL: + list.add(new SdyPslConfig(deviceVO)); + break; + } } + return list; + } - public RelationLoginConfigVO buildRelationLoginConfig() { - if (StringUtils.isEmpty(this.config)) { - return null; + private static List heb1DeviceConfigConvert(List voList) { + List list = new ArrayList<>(); + for (ProjectDeviceVO deviceVO : voList) { + switch (deviceVO.getType()) { + case SWITCH: + list.add(new Heb1SwitchConfig(deviceVO)); + break; + case SIGNAL: + list.add(new Heb1SignalConfig(deviceVO)); + break; + case PSC: + list.add(new Heb1PscConfig(deviceVO)); + break; + case PSL: + list.add(new Heb1PslConfig(deviceVO)); + break; + case IBP: + list.add(new Heb1IbpConfig(deviceVO)); + break; + case PLC_GATEWAY: + list.add(new PlcGateway(deviceVO)); + break; + default: { + log.warn(String.format("设备[%s]不是PLC可连接控制设备", deviceVO)); + break; } - return JsonUtils.read(this.config, RelationLoginConfigVO.class); + } } + return list; + } - public SwitchConfigVO buildSwitchConfig() { - BusinessExceptionAssertEnum - .SYSTEM_EXCEPTION - .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.SWITCH), "设备不是[道岔]"); - return JsonUtils.read(this.config, SwitchConfigVO.class); + private static List gzbDeviceConfigConvert(List voList) { + List list = new ArrayList<>(); + for (ProjectDeviceVO deviceVO : voList) { + switch (deviceVO.getType()) { + case SWITCH: + list.add(new GzbSwitchConfig(deviceVO)); + break; + case SIGNAL: + list.add(new GzbSignalConfig(deviceVO)); + break; + case PLC_GATEWAY: + list.add(new PlcGateway(deviceVO)); + break; + default: { + log.warn(String.format("设备[%s]不是PLC可连接控制设备", deviceVO)); + break; + } + } } + return list; + } - public PslConfigVO buildPslConfig() { - BusinessExceptionAssertEnum - .SYSTEM_EXCEPTION - .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.PSL), "设备不是[端头屏蔽门控制盒]"); - return JsonUtils.read(this.config, PslConfigVO.class); + private static List xtyDeviceConfigConvert(List voList) { + List list = new ArrayList<>(); + for (ProjectDeviceVO deviceVO : voList) { + switch (deviceVO.getType()) { + case PSD: + list.add(new XtyPsdConfig(deviceVO)); + break; + case PLC_GATEWAY: + list.add(new PlcGateway(deviceVO)); + break; + } } + return list; + } - public IbpConfigVO buildIbpConfig() { - BusinessExceptionAssertEnum - .SYSTEM_EXCEPTION - .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.IBP), "设备不是[IBP]"); - return JsonUtils.read(this.config, IbpConfigVO.class); - } + @JsonIgnore + public ProjectDevice buildDB() { + ProjectDevice device = new ProjectDevice(); + device.setProjectCode(this.getProject()); + device.setCode(this.getCode()); + device.setType(this.getType().name()); + return device; + } - public PscConfigVO buildPscConfig() { - BusinessExceptionAssertEnum - .SYSTEM_EXCEPTION - .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.PSC), "设备不是[PSC]"); - return JsonUtils.read(this.config, PscConfigVO.class); - } + @Override + public String toString() { + return "ProjectDeviceVO{" + + "project=" + project + + ", code='" + code + '\'' + + ", type=" + type + + '}'; + } - public PlcGatewayConfigVO buildPlcGatewayConfig() { - BusinessExceptionAssertEnum - .SYSTEM_EXCEPTION - .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.PLC_GATEWAY), "设备不是[PLC网关]"); - return JsonUtils.read(this.config, PlcGatewayConfigVO.class); + public LwConfigVO buildLwConfig() { + BusinessExceptionAssertEnum + .SYSTEM_EXCEPTION + .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.LW), "设备不是[现地工作站]"); + return JsonUtils.read(this.config, LwConfigVO.class); + } + + public VrIbpConfigVO buildVrIbpConfig() { + BusinessExceptionAssertEnum + .SYSTEM_EXCEPTION + .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.IBP), "设备不是[IBP盘]"); + return JsonUtils.read(this.config, VrIbpConfigVO.class); + } + + public LswConfigVO buildLswConfig() { + BusinessExceptionAssertEnum + .SYSTEM_EXCEPTION + .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.LSW), "设备不是[大屏工作站]"); + return JsonUtils.read(this.config, LswConfigVO.class); + } + + public RelationLoginConfigVO buildRelationLoginConfig() { + if (StringUtils.isEmpty(this.config)) { + return null; } + return JsonUtils.read(this.config, RelationLoginConfigVO.class); + } + + public SwitchConfigVO buildSwitchConfig() { + BusinessExceptionAssertEnum + .SYSTEM_EXCEPTION + .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.SWITCH), "设备不是[道岔]"); + return JsonUtils.read(this.config, SwitchConfigVO.class); + } + + public PslConfigVO buildPslConfig() { + BusinessExceptionAssertEnum + .SYSTEM_EXCEPTION + .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.PSL), + "设备不是[端头屏蔽门控制盒]"); + return JsonUtils.read(this.config, PslConfigVO.class); + } + + public IbpConfigVO buildIbpConfig() { + BusinessExceptionAssertEnum + .SYSTEM_EXCEPTION + .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.IBP), "设备不是[IBP]"); + return JsonUtils.read(this.config, IbpConfigVO.class); + } + + public PscConfigVO buildPscConfig() { + BusinessExceptionAssertEnum + .SYSTEM_EXCEPTION + .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.PSC), "设备不是[PSC]"); + return JsonUtils.read(this.config, PscConfigVO.class); + } + + public PlcGatewayConfigVO buildPlcGatewayConfig() { + BusinessExceptionAssertEnum + .SYSTEM_EXCEPTION + .assertTrue(Objects.equals(this.getType(), ProjectDeviceType.PLC_GATEWAY), + "设备不是[PLC网关]"); + return JsonUtils.read(this.config, PlcGatewayConfigVO.class); + } } diff --git a/src/main/java/club/joylink/rtss/vo/client/project/gxsd/GxsdSignalConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/gxsd/GxsdSignalConfigVO.java new file mode 100644 index 000000000..76f744837 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/project/gxsd/GxsdSignalConfigVO.java @@ -0,0 +1,53 @@ +package club.joylink.rtss.vo.client.project.gxsd; + +import club.joylink.rtss.vo.client.project.RealConfigVO; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +/** + *广西水利电力职业技术学院项目信号机配置 + */ +public class GxsdSignalConfigVO extends RealConfigVO { + + /** + * 信号输入位 红灯 + */ + private Integer r1 = 1; + + /** + * 信号输入位 绿灯或黄灯 + */ + private Integer r3 = 3; + + + /** + * 信号输出控制位 绿灯 + */ + private Integer w3 = 11; + + /** + * 信号输出控制位 黄灯 + */ + private Integer w4 = 12; + + /** + * 信号输出控制位 灭灯 开启 默认就是红灯 + */ + private Integer w5 = 13; + + /** + * 信号输出控制位 红黄灯 + */ + private Integer w7 = 15; + + public GxsdSignalConfigVO() { + super(0, 16); + } + + @Override + public String findDeviceCode() { + return null; + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/project/gxsd/GxsdSwitchConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/gxsd/GxsdSwitchConfigVO.java new file mode 100644 index 000000000..000500cf4 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/project/gxsd/GxsdSwitchConfigVO.java @@ -0,0 +1,56 @@ +package club.joylink.rtss.vo.client.project.gxsd; + +import club.joylink.rtss.vo.client.project.RealConfigVO; +import lombok.Getter; +import lombok.Setter; + +/** + * 广西水利电力职业技术学院项目道岔配置 + */ +@Getter +@Setter +public class GxsdSwitchConfigVO extends RealConfigVO { + + /** + * 设置定反位锁机 + * 道岔定位/反位 + * 设置锁接 + * 设置道岔定位/反位3秒后取消定反操 + * 道岔到位 取消锁接 + */ + + /** + * 读反位 + */ + private Integer rfc = 0; + + /** + * 读定位 + */ + private Integer rdc = 2; + + + /** + * 写反操 + */ + private Integer wfc = 10; + + /** + * 写定操 + */ + private Integer wdc = 9; + + /** + * 锁接 + */ + private Integer wsj = 8; + + public GxsdSwitchConfigVO() { + super(0, 16); + } + + @Override + public String findDeviceCode() { + return null; + } +}