From c6fff223122b3823634ec0b14810bfcd59423ec2 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Thu, 10 Dec 2020 18:17:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=89=E7=BB=B4=E7=AB=99?= =?UTF-8?q?=E5=8F=B0TDT=E7=8A=B6=E6=80=81=E6=94=B6=E9=9B=86=E5=8F=91?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/SimulationMainThread.java | 1 + .../Joylink3DMessageService.java | 27 ++++++++ .../cbtc/data/SimulationDataRepository.java | 21 ++++++ .../simulation/cbtc/data/vo/TdtStatusVO.java | 66 +++++++++++++++++++ .../rtss/vo/client/WebSocketMessageType.java | 2 + .../client/factory/SocketMessageFactory.java | 14 ++-- 6 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TdtStatusVO.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java index 386ba5802..82bf1ad8a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java @@ -412,6 +412,7 @@ public class SimulationMainThread { } case MESSAGE_3D: { this.joylink3DMessageService.collectAndSendTrainHmiDisplayMessage(simulation); + this.joylink3DMessageService.tdtStatusCollectAndSend(simulation); break; } case TRAIN_POSITION_3D: { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java index 05b2990b2..2f2f039e5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java @@ -7,7 +7,9 @@ import club.joylink.rtss.simulation.cbtc.communication.vo.*; import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; +import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.status.TrainStatus; +import club.joylink.rtss.simulation.cbtc.data.vo.TdtStatusVO; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; @@ -57,6 +59,29 @@ public class Joylink3DMessageService { } } + public void tdtStatusCollectAndSend(Simulation simulation) { + List list = new ArrayList<>(); + SimulationDataRepository repository = simulation.getRepository(); + for (Stand stand : repository.getStandList()) { + if (!stand.isSmall()) { + TdtStatusVO statusVO = repository.queryTdtStatus(stand.getCode()); + if (Objects.isNull(statusVO)) { + statusVO = new TdtStatusVO(stand); + repository.addTdtStatus(statusVO); + list.add(statusVO); + } else { + if (statusVO.compareAndChange(stand)) { + list.add(statusVO); + } + } + TdtStatusVO tdtStatusVO = new TdtStatusVO(stand); + list.add(tdtStatusVO); + } + } + SocketMessageVO message = SocketMessageFactory.buildTrainIsAbout2ArriveMessage(simulation.getGroup(), list); + this.stompMessageService.sendToUser(simulation.getSimulationUserIds(), message); + } + /** * 构建并发送列车状态信息 * @@ -305,4 +330,6 @@ public class Joylink3DMessageService { Set users = simulation.getSimulationUserIds(); this.collectAndSend3DInitDeviceList(simulation, users); } + + } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java index c230d2f9e..e5c8de1b6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java @@ -9,6 +9,7 @@ import club.joylink.rtss.simulation.cbtc.data.status.IbpStatus; import club.joylink.rtss.simulation.cbtc.data.status.TrainStatus; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; +import club.joylink.rtss.simulation.cbtc.data.vo.TdtStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; @@ -77,6 +78,13 @@ public class SimulationDataRepository { */ private Map trainHmiMap = new ConcurrentHashMap<>(); + /** + * TDT(train depart timer)状态数据 + * key-站台code + * val-tdt状态对象 + */ + private Map tdtStatusMap = new ConcurrentHashMap<>(); + /** * ATS监控的列车信息map * key-车组号 @@ -643,6 +651,7 @@ public class SimulationDataRepository { // 清空设备状态 this.deviceInfoMap.clear(); this.trainHmiMap.clear(); + this.tdtStatusMap.clear(); } /** @@ -904,6 +913,18 @@ public class SimulationDataRepository { this.trainHmiMap.remove(code); } + public TdtStatusVO queryTdtStatus(String code) { + return this.tdtStatusMap.get(code); + } + + public void addTdtStatus(TdtStatusVO tdtStatusVO) { + this.tdtStatusMap.put(tdtStatusVO.getStandCode(), tdtStatusVO); + } + + public void removeTdtStatus(String code) { + this.tdtStatusMap.remove(code); + } + /** * 获取该车站某个方向的相邻车站 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TdtStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TdtStatusVO.java new file mode 100644 index 000000000..1d878acba --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TdtStatusVO.java @@ -0,0 +1,66 @@ +package club.joylink.rtss.simulation.cbtc.data.vo; + +import club.joylink.rtss.simulation.cbtc.data.map.Stand; +import lombok.Getter; +import lombok.Setter; + +import java.util.Objects; + +@Getter +@Setter +public class TdtStatusVO { + /** + * 站台code + */ + private String standCode; + /** + * 是否扣车 + */ + private boolean hold; + /** + * 是否跳停 + */ + private boolean jump; + /** + * 倒计时剩余时间 + */ + private int remain; + /** + * 是否有停靠列车 + */ + private boolean parking; + + public TdtStatusVO(Stand stand) { + this.standCode = stand.getCode(); + boolean trainParking = stand.isTrainParking(); + this.parking = trainParking; + if (trainParking) { + this.remain = stand.getRemainTime() / 1000; + } + this.hold = stand.isHoldTrain(); + this.jump = stand.isJumpStop(); + } + + public boolean compareAndChange(Stand stand) { + boolean change = false; + boolean trainParking = stand.isTrainParking(); + if (!Objects.equals(this.parking, trainParking)) { + change = true; + this.parking = trainParking; + } + int remainTime = stand.getRemainTime() / 1000; + if (trainParking && !Objects.equals(this.remain, remainTime)) { + change = true; + this.remain = remainTime; + } + if (!Objects.equals(this.jump, stand.isJumpStop())) { + change = true; + this.jump = stand.isJumpStop(); + } + if (!Objects.equals(this.hold, stand.isHoldTrain())) { + change = true; + this.hold = stand.isHoldTrain(); + } + return change; + } +} 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 9b7e931af..79338105c 100644 --- a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java +++ b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java @@ -141,6 +141,8 @@ public enum WebSocketMessageType { DeviceCtrl_3D, /** 列车即将进站消息 */ BeAbout2Arrive_3D, + /** 列车即将进站消息 */ + TDT_3D, /** 3D设备故障设置消息 */ Device_Fault_Set_3D, /** 3D设备故障解决消息 */ 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 65bff510c..2b2593011 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 @@ -6,10 +6,7 @@ import club.joylink.rtss.simulation.cbtc.communication.vo.TrainPosition; import club.joylink.rtss.simulation.cbtc.conversation.Conversation; import club.joylink.rtss.simulation.cbtc.conversation.ConversationMessage; import club.joylink.rtss.simulation.cbtc.data.status.IbpStatus; -import club.joylink.rtss.simulation.cbtc.data.vo.ConversationSocketMessageVO; -import club.joylink.rtss.simulation.cbtc.data.vo.DeviceStatusVO; -import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO; -import club.joylink.rtss.simulation.cbtc.data.vo.TrainIsAbout2ArriveVO; +import club.joylink.rtss.simulation.cbtc.data.vo.*; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.member.SimulationUser; import club.joylink.rtss.vo.client.SocketMessageVO; @@ -139,6 +136,7 @@ public class SocketMessageFactory { } case Device_Load_Destroy_3D: case DeviceCtrl_3D: + case TDT_3D: case BeAbout2Arrive_3D: { topicList.add(String.format(WebSocketSubscribeTopic.Sandbox3D, group)); topicList.add(String.format(WebSocketSubscribeTopic.TrainDrive3D, group)); @@ -320,6 +318,14 @@ public class SocketMessageFactory { return build(WebSocketMessageType.BeAbout2Arrive_3D, group, arriveVO); } + /** + * 构建列车即将到站消息 + * @return + */ + public static SocketMessageVO> buildTrainIsAbout2ArriveMessage(String group, List list) { + return build(WebSocketMessageType.TDT_3D, group, list); + } + /** * 构建VR同步消息 */