From d1f6e14f42a6729e5eb85e408bf79e2b8d44c407 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 28 Sep 2022 17:44:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=8E=E4=BB=BF=E7=9C=9F?= =?UTF-8?q?=E4=B8=AD=E8=8E=B7=E5=8F=96iscs=E7=8A=B6=E6=80=81=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=9B=E5=A2=9E=E5=8A=A0=E9=97=B8=E6=9C=BA=E8=AE=BE?= =?UTF-8?q?=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/ISCS/IscsLogicLoop.java | 99 ++++++++++++++++++- .../ISCS/IscsMessageCollectAndDispatcher.java | 2 +- .../cbtc/SimulationLifeCycleServiceImpl.java | 2 +- .../cbtc/build/MapDeviceBuilder.java | 10 +- .../data/SimulationIscsDataRepository.java | 11 ++- .../simulation/cbtc/data/map/MapElement.java | 2 + .../simulation/cbtc/data/map/Station.java | 6 ++ .../cbtc/data/vo/iscs/IscsGateStatusVO.java | 29 ++++++ .../cbtc/data/vo/iscs/IscsIbpStatusVO.java | 86 ++++++++++++++-- .../cbtc/data/vo/iscs/IscsPsdStatusVO.java | 38 ++++++- .../cbtc/data/vo/iscs/IscsPslStatusVO.java | 29 ++++++ .../cbtc/data/vo/iscs/IscsStatusVO.java | 1 + .../cbtc/data/vr/VirtualRealityGate.java | 19 ++++ .../modbustcp/hhcj/HhcjIbpServiceImpl.java | 3 + .../real/modbustcp/zjd/ZjdIbpServiceImpl.java | 2 +- .../real/modbustcp/zjd/ZjdPsdServiceImpl.java | 2 +- .../real/modbustcp/zjd/ZjdPslServiceImpl.java | 2 +- .../rt/iscs/IscsStatusPublisher.java | 16 ++- 18 files changed, 332 insertions(+), 27 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsGateStatusVO.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityGate.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsLogicLoop.java index 24f9de957..e3aa32e0c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsLogicLoop.java @@ -6,18 +6,31 @@ import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; import club.joylink.rtss.simulation.cbtc.data.iscs.Audio; +import club.joylink.rtss.simulation.cbtc.data.map.MapConfig; +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.map.Station; +import club.joylink.rtss.simulation.cbtc.data.vo.iscs.*; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityGate; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; +import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; import club.joylink.rtss.vo.client.iscs.PlayParamVO; import club.joylink.rtss.vo.client.iscs.TimedPlayParamVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import java.time.LocalDateTime; import java.util.List; +import java.util.Map; @Component public class IscsLogicLoop { public static final String JOB_NAME = "ISCS_LOGIC_LOOP"; public static final int RATE = 1000; + public static final String MESSAGE_JOB_NAME = "ISCS_MESSAGE_SENDER"; @Autowired private IscsInteractiveService iscsInteractiveService; @@ -65,7 +78,91 @@ public class IscsLogicLoop { } } - public void addJob(Simulation simulation) { + public void UpdateStatusAndSend(Simulation simulation) { + SimulationDataRepository repository = simulation.getRepository(); + MapConfig config = repository.getConfig(); + SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository(); + Map statusVOMap = iscsRepository.getStatusVOMap(); + //IBP + List vrIbpList = repository.getVrListByType(MapElement.DeviceType.IBP, VirtualRealityIbp.class); + for (VirtualRealityIbp vrIbp : vrIbpList) { + IscsStatusVO iscsStatusVO = statusVOMap.get(vrIbp.getCode()); + if (iscsStatusVO == null) { + IscsIbpStatusVO iscsIbpStatusVO = new IscsIbpStatusVO(vrIbp); + IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class); + simulation.watch(iscsIbpStatusVO, watcher); + statusVOMap.put(iscsIbpStatusVO.getCode(), iscsIbpStatusVO); + iscsIbpStatusVO.fireWatcher(null, null); + } else { + IscsIbpStatusVO iscsIbpStatusVO = (IscsIbpStatusVO) iscsStatusVO; + boolean change = iscsIbpStatusVO.compareAndChange(vrIbp); + if (change) iscsIbpStatusVO.fireWatcher(null, null); + } + } + //PSD + for (Station station : repository.getStationList()) { + boolean upRight = config.isUpRight(); + List rightStands = station.getNormalStand(true); + Stand rightStand = null; + if (!CollectionUtils.isEmpty(rightStands)) + rightStand = rightStands.get(0); + List leftStands = station.getNormalStand(false); + Stand leftStand = null; + if (!CollectionUtils.isEmpty(leftStands)) + leftStand = leftStands.get(0); + Stand upStand = upRight ? rightStand : leftStand; + Stand downStand = upRight ? leftStand : rightStand; + + //PSD + String iscsPsdCode = station.getCode() + "_ISCS_PSD"; + VirtualRealityScreenDoor upPsd = upStand == null ? null : upStand.getPsd().getVirtualScreenDoor(); + VirtualRealityScreenDoor downPsd = downStand == null ? null : downStand.getPsd().getVirtualScreenDoor(); + IscsPsdStatusVO iscsPsdStatusVO = (IscsPsdStatusVO) statusVOMap.get(iscsPsdCode); + if (iscsPsdStatusVO == null) { + iscsPsdStatusVO = new IscsPsdStatusVO(iscsPsdCode, station.getCode(), upPsd, downPsd); + IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class); + simulation.watch(iscsPsdStatusVO, watcher); + statusVOMap.put(iscsPsdStatusVO.getCode(), iscsPsdStatusVO); + iscsPsdStatusVO.fireWatcher(null, null); + } else { + boolean change = iscsPsdStatusVO.compareAndChange(upPsd, downPsd); + if (change) iscsPsdStatusVO.fireWatcher(null, null); + } + //PSL + String iscsPslCode = station.getCode() + "_ISCS_PSL"; + VirtualRealityPsl upPsl = upStand == null ? null : upStand.getVrPsl(); + VirtualRealityPsl downPsl = downStand == null ? null : downStand.getVrPsl(); + IscsPslStatusVO iscsPslStatusVO = (IscsPslStatusVO) statusVOMap.get(iscsPslCode); + if (iscsPslStatusVO == null) { + iscsPslStatusVO = new IscsPslStatusVO(iscsPslCode, station.getCode(), upPsl, downPsl); + IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class); + simulation.watch(iscsPslStatusVO, watcher); + statusVOMap.put(iscsPslStatusVO.getCode(), iscsPslStatusVO); + iscsPslStatusVO.fireWatcher(null, null); + } else { + boolean change = iscsPslStatusVO.compareAndChange(upPsl, downPsl); + if (change) iscsPslStatusVO.fireWatcher(null, null); + } + //GATE + VirtualRealityGate vrGate = station.getVrGate(); + IscsGateStatusVO iscsGateStatusVO = (IscsGateStatusVO) statusVOMap.get(vrGate.getCode()); + if (iscsGateStatusVO == null) { + iscsGateStatusVO = new IscsGateStatusVO(vrGate.getCode(), station.getCode(), vrGate); + IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class); + simulation.watch(iscsGateStatusVO, watcher); + statusVOMap.put(iscsGateStatusVO.getCode(), iscsGateStatusVO); + iscsGateStatusVO.fireWatcher(null, null); + } else { + boolean change = iscsGateStatusVO.compareAndChange(vrGate); + if (change) iscsGateStatusVO.fireWatcher(null, null); + } + } + + iscsRepository.getStatusStream(IscsStatusVO.DeviceType.GATE, "Station61238").forEach(vo -> System.out.println(vo.getStationCode())); + } + + public void addJobs(Simulation simulation) { simulation.addJob(JOB_NAME, () -> run(simulation), RATE); + simulation.addJob(MESSAGE_JOB_NAME, () -> UpdateStatusAndSend(simulation), RATE); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsMessageCollectAndDispatcher.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsMessageCollectAndDispatcher.java index b36071f56..375eeadd0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsMessageCollectAndDispatcher.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/IscsMessageCollectAndDispatcher.java @@ -24,7 +24,7 @@ public class IscsMessageCollectAndDispatcher { if (status == null) { status = new IscsAudioStatusVO(audio); iscsRepository.addStatus(status); - IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class); + IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class); simulation.watch(status, watcher); status.fireWatcher(null, null); } else { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java index ead1c14dd..482ef9aae 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java @@ -210,7 +210,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic powerSupplyService.addJobs(simulation); iVirtualRealityPslService.addJobs(simulation); iscsMessageCollectAndDispatcher.addJob(simulation); - iscsLogicLoop.addJob(simulation); + iscsLogicLoop.addJobs(simulation); pisLogicLoop.addJobs(simulation); } atpLogicLoop.addJobs(simulation); 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 1dc33a437..406803cc3 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 @@ -1354,14 +1354,6 @@ public class MapDeviceBuilder { elementMap.put(station.getCode(), station); station.setCentralized(stationVO.isCentralized()); station.setDepot(stationVO.isDepot()); -// if (station.isCentralized() && !station.isDepot()) { -// ZC zc = (ZC) elementMap.get(stationVO.getZcCode()); -// if (Objects.isNull(zc)) { -// errMsgList.add(String.format("车站[%s(%s)]未关联ZC或ZC不存在,请在ZC设备处选择管理的集中站列表", station.getName(), station.getCode())); -// } else { -// station.setZc(zc); -// } -// } if (Objects.isNull(stationVO.getKmRange())) { errMsgList.add(String.format("车站[%s(%s)]未设置距离", stationVO.getName(), stationVO.getCode())); } else { @@ -1384,6 +1376,7 @@ public class MapDeviceBuilder { if (station.isHasControlMode()) { // 有控制模式,初始化为中控 station.setControlMode(Station.ControlMode.Center); } + station.setVrGate(new VirtualRealityGate(station.getCode() + "_GATE", station.getName() + "闸机")); }); // 设备集中站下的车站关联ZC,联锁站下的车站关联联锁站 stationList.forEach(stationVO -> { @@ -1398,7 +1391,6 @@ public class MapDeviceBuilder { station.getName(), station.getCode(), code)); } else { normal.setDeviceStation(station); -// normal.setZc(station.getZc()); } }); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationIscsDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationIscsDataRepository.java index 3ff158505..daed449c9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationIscsDataRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationIscsDataRepository.java @@ -85,9 +85,18 @@ public class SimulationIscsDataRepository { } public List getStatusByDeviceType(IscsStatusVO.DeviceType type) { + return getStatusStream(type).collect(Collectors.toList()); + } + + public Stream getStatusStream(IscsStatusVO.DeviceType type) { + return statusVOMap.values().stream() + .filter(vo -> Objects.equals(type, vo.getDeviceType())); + } + + public Stream getStatusStream(IscsStatusVO.DeviceType type, String stationCode) { return statusVOMap.values().stream() .filter(vo -> Objects.equals(type, vo.getDeviceType())) - .collect(Collectors.toList()); + .filter(vo -> Objects.equals(stationCode, vo.getStationCode())); } public List querySystemResources(String system, String type) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapElement.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapElement.java index 06eebcde9..1de40b79c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapElement.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapElement.java @@ -141,6 +141,8 @@ public abstract class MapElement { LCD, /** iscs LED */ LED, + /** 闸机 */ + GATE, } /** 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 342833177..89ec1af7d 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 @@ -6,6 +6,7 @@ import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.constant.TurnBackStrategyType; import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityGate; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; @@ -121,6 +122,11 @@ public class Station extends MayOutOfOrderDevice { */ private VirtualRealityIbp vrIbp; + /** + * 虚拟真实闸机 + */ + private VirtualRealityGate vrGate; + //---------------------状态属性------------------------ /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsGateStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsGateStatusVO.java new file mode 100644 index 000000000..e90618932 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsGateStatusVO.java @@ -0,0 +1,29 @@ +package club.joylink.rtss.simulation.cbtc.data.vo.iscs; + +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityGate; +import lombok.Getter; + +@Getter +public class IscsGateStatusVO extends IscsStatusVO{ + /** + * -1未定义;0故障;1正常 + */ + private int status; + private static final int UNDEFINED = -1; + private static final int FAULT = 0; + private static final int NORMAL = 1; + + public IscsGateStatusVO(String code, String stationCode, VirtualRealityGate vrGate) { + super(code, DeviceType.GATE, stationCode); + status = vrGate.isFault() ? FAULT : NORMAL; + } + + public boolean compareAndChange(VirtualRealityGate vrGate) { + int i = vrGate.isFault() ? FAULT : NORMAL; + if (status != i) { + status = i; + return true; + } + return false; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsIbpStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsIbpStatusVO.java index 77a58d735..b95859b4e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsIbpStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsIbpStatusVO.java @@ -1,14 +1,20 @@ package club.joylink.rtss.simulation.cbtc.data.vo.iscs; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; @Getter public class IscsIbpStatusVO extends IscsStatusVO { - /** 上行状态 */ + /** + * 上行状态 + */ private DirectionalStatus upStatus; - /** 下行状态 */ + /** + * 下行状态 + */ private DirectionalStatus downStatus; public IscsIbpStatusVO(String code, String stationCode, @@ -18,19 +24,83 @@ public class IscsIbpStatusVO extends IscsStatusVO { this.downStatus = downStatus; } + public IscsIbpStatusVO(VirtualRealityIbp vrIbp) { + super(vrIbp.getCode(), DeviceType.IBP, vrIbp.getStation().getCode()); + upStatus = new DirectionalStatus(); + downStatus = new DirectionalStatus(); + for (VirtualRealityIbp.IbpElement element : vrIbp.getAllElements()) { + if (element.getUp() == null) + continue; + DirectionalStatus dirStatus = element.getUp() ? upStatus : downStatus; + VirtualRealityIbp.Mean mean = element.getMean(); + if (mean == null) + continue; + switch (mean) { + case KM: + dirStatus.setOpenCommand(element.isOn()); + break; + case PSD_SMKM: + dirStatus.setOpenSideCommand(element.isOn()); + break; + case GM: + dirStatus.setCloseCommand(element.isOn()); + break; + case PSD_CZYX_LIGHT: + dirStatus.setOperate(element.isOn()); + break; + } + } + } + + public boolean compareAndChange(VirtualRealityIbp vrIbp) { + DirectionalStatus upStatus = new DirectionalStatus(); + DirectionalStatus downStatus = new DirectionalStatus(); + for (VirtualRealityIbp.IbpElement element : vrIbp.getAllElements()) { + if (element.getUp() == null) + continue; + DirectionalStatus dirStatus = element.getUp() ? upStatus : downStatus; + if (element.getMean() == null) + continue; + switch (element.getMean()) { + case KM: + dirStatus.setOpenCommand(element.isOn()); + break; + case PSD_SMKM: + dirStatus.setOpenSideCommand(element.isOn()); + break; + case GM: + dirStatus.setCloseCommand(element.isOn()); + break; + case PSD_CZYX_LIGHT: + dirStatus.setOperate(element.isOn()); + break; + } + } + return this.upStatus.compareAndChange(upStatus) || this.downStatus.compareAndChange(downStatus); + } + @Getter + @Setter @NoArgsConstructor public static class DirectionalStatus { - /** 操作允许 */ + /** + * 操作允许 + */ private boolean operate = true; - /** 开门命令 */ + /** + * 开门命令 + */ private boolean openCommand = true; - /** 开边门命令 */ + /** + * 开边门命令 + */ private boolean openSideCommand = true; - /** 关门命令 */ + /** + * 关门命令 + */ private boolean closeCommand = true; public DirectionalStatus(boolean operate, boolean openCommand, @@ -41,6 +111,10 @@ public class IscsIbpStatusVO extends IscsStatusVO { this.closeCommand = closeCommand; } + public boolean compareAndChange(DirectionalStatus dirStatus) { + return this.compareAndChange(dirStatus.isOperate(), dirStatus.isOpenCommand(), dirStatus.isOpenSideCommand(), dirStatus.isCloseCommand()); + } + public boolean compareAndChange(boolean operate, boolean openCommand, boolean openSideCommand, boolean closeCommand) { boolean change = false; if (this.operate != operate) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPsdStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPsdStatusVO.java index fb9422a69..852bc96f4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPsdStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPsdStatusVO.java @@ -1,10 +1,11 @@ package club.joylink.rtss.simulation.cbtc.data.vo.iscs; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; import lombok.Getter; import lombok.NoArgsConstructor; @Getter -public class IscsPsdStatusVO extends IscsStatusVO{ +public class IscsPsdStatusVO extends IscsStatusVO { private DirectionalStatus upStatus; private DirectionalStatus downStatus; @@ -16,6 +17,23 @@ public class IscsPsdStatusVO extends IscsStatusVO{ this.downStatus = downStatus; } + public IscsPsdStatusVO(String code, String stationCode, VirtualRealityScreenDoor upPsd, VirtualRealityScreenDoor downPsd) { + super(code, IscsStatusVO.DeviceType.SLIDING_DOOR, stationCode); + if (upPsd != null) + upStatus = new DirectionalStatus(upPsd); + if (downPsd != null) + downStatus = new DirectionalStatus(downPsd); + } + + public boolean compareAndChange(VirtualRealityScreenDoor upPsd, VirtualRealityScreenDoor downPsd) { + boolean change = false; + if (upPsd != null) + change = change || upStatus.compareAndChange(upPsd); + if (downPsd != null) + change = change || downStatus.compareAndChange(downPsd); + return change; + } + public enum Status { OPEN, CLOSE, @@ -28,13 +46,25 @@ public class IscsPsdStatusVO extends IscsStatusVO{ public static class DirectionalStatus { private Status status = Status.CLOSE; - private boolean isolationMode = true; + /** + * 隔离模式 + */ + private boolean isolationMode = false; + + public DirectionalStatus(VirtualRealityScreenDoor vrPsd) { + status = getStatus(vrPsd); + } public DirectionalStatus(Status status, boolean isolationMode) { this.status = status; this.isolationMode = isolationMode; } + public boolean compareAndChange(VirtualRealityScreenDoor vrPsd) { + Status status = getStatus(vrPsd); + return compareAndChange(status, false); + } + public boolean compareAndChange(Status status, boolean isolationMode) { boolean change = false; if (this.status != status) { @@ -47,5 +77,9 @@ public class IscsPsdStatusVO extends IscsStatusVO{ } return change; } + + private Status getStatus(VirtualRealityScreenDoor vrPsd) { + return vrPsd.isLockAndClose() ? Status.CLOSE : Status.OPEN; + } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPslStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPslStatusVO.java index 9ab356c07..e9a390014 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPslStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPslStatusVO.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.data.vo.iscs; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl; import lombok.Getter; import lombok.NoArgsConstructor; @@ -16,6 +17,23 @@ public class IscsPslStatusVO extends IscsStatusVO{ this.downStatus = downStatus; } + public IscsPslStatusVO(String code, String stationCode, VirtualRealityPsl upPsl, VirtualRealityPsl downPsl) { + super(code, DeviceType.PSL, stationCode); + if (upPsl != null) + upStatus = new DirectionalStatus(upPsl); + if (downPsl != null) + downStatus = new DirectionalStatus(downPsl); + } + + public boolean compareAndChange(VirtualRealityPsl upPsl, VirtualRealityPsl downPsl) { + boolean change = false; + if (upPsl != null) + change = change || upStatus.compareAndChange(upPsl); + if (downPsl != null) + change = change || downStatus.compareAndChange(downPsl); + return change; + } + @Getter @NoArgsConstructor public static class DirectionalStatus { @@ -39,6 +57,17 @@ public class IscsPslStatusVO extends IscsStatusVO{ this.interlockRelease = interlockRelease; } + public DirectionalStatus(VirtualRealityPsl vrPsl) { + this.operate = vrPsl.isPslczLight(); + this.openCommand = vrPsl.isKmButton(); + this.closeCommand = vrPsl.isGmButton(); + this.interlockRelease = vrPsl.isHsjcLight(); + } + + public boolean compareAndChange(VirtualRealityPsl vrPsl) { + return compareAndChange(vrPsl.isPslczLight(), vrPsl.isKmButton(), vrPsl.isGmButton(), vrPsl.isHsjcLight()); + } + public boolean compareAndChange(boolean operate, boolean openCommand, boolean closeCommand, boolean interlockRelease) { boolean change = false; if (this.operate != operate) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsStatusVO.java index b47dc2190..f4f248356 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsStatusVO.java @@ -27,5 +27,6 @@ public class IscsStatusVO extends Watchable { /** 广播 */ AUDIO, VR_AUDIO, + GATE, } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityGate.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityGate.java new file mode 100644 index 000000000..fd14491cb --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityGate.java @@ -0,0 +1,19 @@ +package club.joylink.rtss.simulation.cbtc.data.vr; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class VirtualRealityGate extends VirtualRealityDevice{ + private boolean fault; + + public VirtualRealityGate(String code, String name) { + super(code, name, DeviceType.GATE); + } + + @Override + public void reset() { + fault = false; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/hhcj/HhcjIbpServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/hhcj/HhcjIbpServiceImpl.java index 5808a59bd..871da46d8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/hhcj/HhcjIbpServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/hhcj/HhcjIbpServiceImpl.java @@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj; import club.joylink.rtss.services.IVirtualRealityIbpService; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.map.Station; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService; @@ -496,6 +497,8 @@ public class HhcjIbpServiceImpl implements RealDeviceService { } else if (r_xfsb_tzxfb2){ config.setXfsb_yxxfb2(false); } + Station station = vrIbp.getStation(); + station.getVrGate().setFault(r_zj_jjsf); boolean w_zdft_l101 = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_zdft_l101()); boolean w_zdft_l102 = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_zdft_l102()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdIbpServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdIbpServiceImpl.java index d11c80ecd..db4de40cc 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdIbpServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdIbpServiceImpl.java @@ -154,7 +154,7 @@ public class ZjdIbpServiceImpl implements RealDeviceService { iscsStatus = new IscsIbpStatusVO(iscsCode, vrIbp.getStation().getCode(), null, downStatus); iscsRepository.addStatus(iscsStatus); - IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class); + IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class); simulation.watch(iscsStatus, watcher); change = true; } else { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPsdServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPsdServiceImpl.java index 5b4d19de7..d5ed64399 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPsdServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPsdServiceImpl.java @@ -67,7 +67,7 @@ public class ZjdPsdServiceImpl implements RealDeviceService { IscsPsdStatusVO.DirectionalStatus downStatus = new IscsPsdStatusVO.DirectionalStatus(status, r_sx_glms); iscsStatus = new IscsPsdStatusVO(iscsCode, configVO.getStationCode(), null, downStatus); iscsRepository.addStatus(iscsStatus); - IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class); + IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class); simulation.watch(iscsStatus, watcher); change = true; } else { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPslServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPslServiceImpl.java index eac446b87..ec4bf00d4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPslServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/zjd/ZjdPslServiceImpl.java @@ -59,7 +59,7 @@ public class ZjdPslServiceImpl implements RealDeviceService { iscsStatus = new IscsPslStatusVO(iscsCode, vrPsl.getStand().getStation().getCode(), null, downStatus); iscsRepository.addStatus(iscsStatus); - IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class); + IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class); simulation.watch(iscsStatus, watcher); change = true; } else { diff --git a/src/main/java/club/joylink/rtss/simulation/rt/iscs/IscsStatusPublisher.java b/src/main/java/club/joylink/rtss/simulation/rt/iscs/IscsStatusPublisher.java index 53582414e..01d8634c8 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/iscs/IscsStatusPublisher.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/iscs/IscsStatusPublisher.java @@ -11,17 +11,19 @@ import java.util.*; import java.util.stream.Collectors; public class IscsStatusPublisher extends SimulationTriggerMessagePublisher { - public static final String Name = "iscs"; + public static final String NAME = "iscs"; public static final String PSD_PATH = "psd"; public static final String PSD_PATTERN = String.format("%s/%s/%s/%s", Simulation.MESSAGE_SUB_PREFIX, "iscs", PSD_PATH, "{stationCode}"); public static final String PA_PATH = "pa"; public static final String PA_PATTERN = String.format("%s/%s/%s", Simulation.MESSAGE_SUB_PREFIX, "iscs", PA_PATH); public static final String PIS_PATH = "pis"; public static final String PIS_PATTERN = String.format("%s/%s/%s", Simulation.MESSAGE_SUB_PREFIX, "iscs", PIS_PATH); + public static final String GATE_PATH = "gate"; + public static final String GATE_PATTERN = String.format("%s/%s/%s/%s", Simulation.MESSAGE_SUB_PREFIX, "iscs", GATE_PATH, "{stationCode}"); club.joylink.rtss.simulation.cbtc.Simulation simulation; public IscsStatusPublisher(club.joylink.rtss.simulation.cbtc.Simulation simulation) { - super(Name, Arrays.asList(PSD_PATTERN, PA_PATTERN, PIS_PATTERN)); + super(NAME, Arrays.asList(PSD_PATTERN, PA_PATTERN, PIS_PATTERN, GATE_PATTERN)); this.simulation = simulation; } @@ -36,10 +38,19 @@ public class IscsStatusPublisher extends SimulationTriggerMessagePublisher { result = buildPaMessage(); } else if (destination.contains(PIS_PATH)) { result = buildPisMessage(); + } else if (destination.contains(GATE_PATH)) { + String s = list.get(1); + result = buildGateMessage(s); } return result; } + private Object buildGateMessage(String stationCode) { + SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository(); + List collect = iscsRepository.getStatusStream(IscsStatusVO.DeviceType.GATE, stationCode).collect(Collectors.toList()); + return collect; + } + private Object buildPaMessage() { List audioStatus = simulation.getIscsRepository().getStatusByDeviceType(IscsStatusVO.DeviceType.AUDIO); audioStatus = audioStatus.stream() @@ -75,7 +86,6 @@ public class IscsStatusPublisher extends SimulationTriggerMessagePublisher { collect.add(new IscsIbpStatusVO("", stationCode, new IscsIbpStatusVO.DirectionalStatus(), new IscsIbpStatusVO.DirectionalStatus())); } - iscsRepository.addStatus(collect); return collect; }