From dcdcf652d01e1486351feced45eba5c9be2d2b7b Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Sat, 18 Sep 2021 15:31:17 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E7=9C=9F=E5=AE=9E=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=BB=A7=E6=89=BF=EF=BC=9B=E4=B9=89=E4=B9=8C?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=85=8D=E7=BD=AE=E7=B1=BB=E9=87=8D=E5=91=BD?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/project/DeviceServiceImpl.java | 23 ++------ .../ProjectJointSimulationServiceImpl.java | 5 +- .../richor/RichorDcuServiceImpl.java | 57 ------------------- .../modbustcp/richor/RichorPslConfig.java | 24 -------- ...RichorPsdConfig.java => ZjdIbpConfig.java} | 10 ++-- ...erviceImpl.java => ZjdIbpServiceImpl.java} | 12 ++-- ...RichorDcuConfig.java => ZjdPsdConfig.java} | 12 ++-- ...erviceImpl.java => ZjdPsdServiceImpl.java} | 15 +++-- ...RichorIbpConfig.java => ZjdPslConfig.java} | 12 ++-- ...erviceImpl.java => ZjdPslServiceImpl.java} | 10 ++-- .../vo/client/project/ProjectDeviceVO.java | 18 ++---- .../rtss/vo/client/project/RealConfigVO.java | 30 ++++++++++ .../client/project/gzb/GzbSignalConfigVO.java | 19 ++----- .../client/project/gzb/GzbSwitchConfigVO.java | 19 ++----- .../project/richor/RichorDcuConfigVO.java | 35 ------------ ...orIbpConfigVO.java => ZjdIbpConfigVO.java} | 22 ++----- ...orPsdConfigVO.java => ZjdPsdConfigVO.java} | 22 ++----- ...orPslConfigVO.java => ZjdPslConfigVO.java} | 18 ++---- .../vo/client/project/sdy/SdyPsdConfigVO.java | 22 ++----- .../vo/client/project/sdy/SdyPslConfigVO.java | 17 ++---- .../vo/client/project/xty/XtyPsdConfigVO.java | 20 ++----- 21 files changed, 110 insertions(+), 312 deletions(-) delete mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuServiceImpl.java delete mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslConfig.java rename src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/{RichorPsdConfig.java => ZjdIbpConfig.java} (66%) rename src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/{RichorIbpServiceImpl.java => ZjdIbpServiceImpl.java} (95%) rename src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/{RichorDcuConfig.java => ZjdPsdConfig.java} (60%) rename src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/{RichorPsdServiceImpl.java => ZjdPsdServiceImpl.java} (87%) rename src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/{RichorIbpConfig.java => ZjdPslConfig.java} (58%) rename src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/{RichorPslServiceImpl.java => ZjdPslServiceImpl.java} (90%) create mode 100644 src/main/java/club/joylink/rtss/vo/client/project/RealConfigVO.java delete mode 100644 src/main/java/club/joylink/rtss/vo/client/project/richor/RichorDcuConfigVO.java rename src/main/java/club/joylink/rtss/vo/client/project/richor/{RichorIbpConfigVO.java => ZjdIbpConfigVO.java} (81%) rename src/main/java/club/joylink/rtss/vo/client/project/richor/{RichorPsdConfigVO.java => ZjdPsdConfigVO.java} (79%) rename src/main/java/club/joylink/rtss/vo/client/project/richor/{RichorPslConfigVO.java => ZjdPslConfigVO.java} (66%) diff --git a/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java b/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java index 07b3e804f..ac9b6fb9d 100644 --- a/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java @@ -12,10 +12,9 @@ import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.project.*; import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO; import club.joylink.rtss.vo.client.project.gzb.GzbSwitchConfigVO; -import club.joylink.rtss.vo.client.project.richor.RichorDcuConfigVO; -import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO; -import club.joylink.rtss.vo.client.project.richor.RichorPsdConfigVO; -import club.joylink.rtss.vo.client.project.richor.RichorPslConfigVO; +import club.joylink.rtss.vo.client.project.richor.ZjdIbpConfigVO; +import club.joylink.rtss.vo.client.project.richor.ZjdPsdConfigVO; +import club.joylink.rtss.vo.client.project.richor.ZjdPslConfigVO; import club.joylink.rtss.vo.client.project.sdy.SdyPsdConfigVO; import club.joylink.rtss.vo.client.project.sdy.SdyPslConfigVO; import club.joylink.rtss.vo.client.project.xty.XtyPsdConfigVO; @@ -418,7 +417,7 @@ public class DeviceServiceImpl implements DeviceService { psd.setType(ProjectDeviceType.PSD.name()); psd.setCreator(accountVO.getId()); psd.setCreateTime(now); - RichorPsdConfigVO psdConfigVO = new RichorPsdConfigVO(); + ZjdPsdConfigVO psdConfigVO = new ZjdPsdConfigVO(); psd.setConfig(psdConfigVO.toJson()); list.add(psd); // IBP盘 @@ -428,7 +427,7 @@ public class DeviceServiceImpl implements DeviceService { ibp.setType(ProjectDeviceType.IBP.name()); ibp.setCreator(accountVO.getId()); ibp.setCreateTime(now); - RichorIbpConfigVO ibpConfigVO = new RichorIbpConfigVO(); + ZjdIbpConfigVO ibpConfigVO = new ZjdIbpConfigVO(); ibp.setConfig(ibpConfigVO.toJson()); list.add(ibp); // PSL @@ -438,19 +437,9 @@ public class DeviceServiceImpl implements DeviceService { psl.setType(ProjectDeviceType.PSL.name()); psl.setCreator(accountVO.getId()); psl.setCreateTime(now); - RichorPslConfigVO pslConfigVO = new RichorPslConfigVO(); + ZjdPslConfigVO pslConfigVO = new ZjdPslConfigVO(); psl.setConfig(pslConfigVO.toJson()); list.add(psl); -// // DCU -// ProjectDevice dcu = new ProjectDevice(); -// dcu.setProjectCode(Project.RICHOR_JOINT.name()); -// dcu.setCode("richorJoint-dcu"); -// dcu.setType(ProjectDeviceType.DCU.name()); -// dcu.setCreator(accountVO.getId()); -// dcu.setCreateTime(now); -// RichorDcuConfigVO dcuConfigVO = new RichorDcuConfigVO(); -// dcu.setConfig(dcuConfigVO.toJson()); -// list.add(dcu); return list; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java index efe75c1f8..edb50b349 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java @@ -14,8 +14,7 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDevice import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1IbpConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PscConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PslConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorIbpConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorPsdConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdIbpConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig; import club.joylink.rtss.simulation.cbtc.event.SimulationUserEnterEvent; import club.joylink.rtss.simulation.cbtc.member.MemberManager; @@ -140,7 +139,7 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation case RICHOR_JOINT: { switch (config.getDeviceType()) { case IBP: - return ((RichorIbpConfig) config).getConfigVO().getStationCode(); + return ((ZjdIbpConfig) config).getConfigVO().getStationCode(); } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuServiceImpl.java deleted file mode 100644 index 3077b5780..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuServiceImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; - -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; -import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsSafetyCircleStatusVO; -import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; -import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; -import club.joylink.rtss.vo.client.project.richor.RichorDcuConfigVO; -import io.netty.buffer.ByteBuf; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; - -@Slf4j -@Component -public class RichorDcuServiceImpl implements RealDeviceService { - @Autowired - private ApplicationContext applicationContext; - - @Override - public boolean canHandle(RealDeviceConfig deviceConfig) { - return deviceConfig instanceof RichorDcuConfig; - } - - @Override - public void init(Simulation simulation, RealDeviceConfig deviceConfig) { - } - - @Override - public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { - RichorDcuConfig config = (RichorDcuConfig) deviceConfig; - RichorDcuConfigVO configVO = config.getConfigVO(); - ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); - boolean aqhl = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_aqhl()); - SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository(); - String iscsCode = configVO.getIscsCode(); - IscsSafetyCircleStatusVO iscsStatus = (IscsSafetyCircleStatusVO) iscsRepository.findStatus(iscsCode); - boolean change; - if (iscsStatus == null) { - IscsSafetyCircleStatusVO.DirectionalStatus upStatus = new IscsSafetyCircleStatusVO.DirectionalStatus(true, true, aqhl); - iscsStatus = new IscsSafetyCircleStatusVO(iscsCode, IscsStatusVO.DeviceType.SAFETY_CIRCLE, upStatus, null); - iscsRepository.addStatus(iscsStatus); - IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class); - simulation.watch(iscsStatus, watcher); - change = true; - } else { - IscsSafetyCircleStatusVO.DirectionalStatus upStatus = iscsStatus.getUpStatus(); - change = upStatus.compareAndChange(true, true, aqhl); - } - if (change) { - iscsStatus.fireWatcher(null, null); - } - } -} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslConfig.java deleted file mode 100644 index 6e20eb9a0..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; - -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.richor.RichorPsdConfigVO; -import club.joylink.rtss.vo.client.project.richor.RichorPslConfigVO; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.util.Objects; - -@Getter -public class RichorPslConfig extends RealDeviceConfig { - private RichorPslConfigVO configVO; - - public RichorPslConfig(ProjectDeviceVO deviceVO) { - super(deviceVO); - if (Objects.nonNull(deviceVO.getConfig())) { - this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorPslConfigVO.class); - } - } -} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPsdConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpConfig.java similarity index 66% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPsdConfig.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpConfig.java index 12c9de475..1bdf7b076 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPsdConfig.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpConfig.java @@ -3,19 +3,19 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; 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.richor.RichorPsdConfigVO; +import club.joylink.rtss.vo.client.project.richor.ZjdIbpConfigVO; import lombok.Getter; import java.util.Objects; @Getter -public class RichorPsdConfig extends RealDeviceConfig { - private RichorPsdConfigVO configVO; +public class ZjdIbpConfig extends RealDeviceConfig { + private ZjdIbpConfigVO configVO; - public RichorPsdConfig(ProjectDeviceVO deviceVO) { + public ZjdIbpConfig(ProjectDeviceVO deviceVO) { super(deviceVO); if (Objects.nonNull(deviceVO.getConfig())) { - this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorPsdConfigVO.class); + this.configVO = JsonUtils.read(deviceVO.getConfig(), ZjdIbpConfigVO.class); } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorIbpServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java similarity index 95% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorIbpServiceImpl.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java index 5c157e38e..be99b7304 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorIbpServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java @@ -15,7 +15,7 @@ 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.rt.iscs.IscsStatusPublisher; -import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO; +import club.joylink.rtss.vo.client.project.richor.ZjdIbpConfigVO; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import lombok.extern.slf4j.Slf4j; @@ -27,7 +27,7 @@ import java.util.List; @Slf4j @Component -public class RichorIbpServiceImpl implements RealDeviceService { +public class ZjdIbpServiceImpl implements RealDeviceService { @Autowired private PlcGatewayService plcGatewayService; @@ -40,13 +40,13 @@ public class RichorIbpServiceImpl implements RealDeviceService { @Override public boolean canHandle(RealDeviceConfig deviceConfig) { - return deviceConfig instanceof RichorIbpConfig; + return deviceConfig instanceof ZjdIbpConfig; } @Override public void init(Simulation simulation, RealDeviceConfig deviceConfig) { PlcGateway plcGateway = simulation.getPlcGateway(); - RichorIbpConfigVO configVO = ((RichorIbpConfig) deviceConfig).getConfigVO(); + ZjdIbpConfigVO configVO = ((ZjdIbpConfig) deviceConfig).getConfigVO(); Channel channel = plcGateway.getChannel(); int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_sx_kcd(), false, channel); @@ -66,11 +66,11 @@ public class RichorIbpServiceImpl implements RealDeviceService { PlcGateway plcGateway = simulation.queryPlcGatewayDevice(); if (plcGateway == null) return; - RichorIbpConfig config = (RichorIbpConfig) deviceConfig; + ZjdIbpConfig config = (ZjdIbpConfig) deviceConfig; Station station = (Station) config.getMapElement(); if (station == null) return; - RichorIbpConfigVO configVO = config.getConfigVO(); + ZjdIbpConfigVO configVO = config.getConfigVO(); ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); boolean r_xx_jjtc = !RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_jjtc()); boolean r_xx_qxjt = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_qxjt()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPsdConfig.java similarity index 60% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuConfig.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPsdConfig.java index 474340e9a..03f40d844 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuConfig.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPsdConfig.java @@ -3,19 +3,19 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; 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.richor.RichorDcuConfigVO; -import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO; +import club.joylink.rtss.vo.client.project.richor.ZjdPsdConfigVO; import lombok.Getter; import java.util.Objects; @Getter -public class RichorDcuConfig extends RealDeviceConfig { - private RichorDcuConfigVO configVO; - public RichorDcuConfig(ProjectDeviceVO deviceVO) { +public class ZjdPsdConfig extends RealDeviceConfig { + private ZjdPsdConfigVO configVO; + + public ZjdPsdConfig(ProjectDeviceVO deviceVO) { super(deviceVO); if (Objects.nonNull(deviceVO.getConfig())) { - this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorDcuConfigVO.class); + this.configVO = JsonUtils.read(deviceVO.getConfig(), ZjdPsdConfigVO.class); } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPsdServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPsdServiceImpl.java similarity index 87% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPsdServiceImpl.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPsdServiceImpl.java index a3924604a..6edaa57ff 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPsdServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPsdServiceImpl.java @@ -2,13 +2,12 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; -import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsIbpStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsPsdStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; -import club.joylink.rtss.vo.client.project.richor.RichorPsdConfigVO; +import club.joylink.rtss.vo.client.project.richor.ZjdPsdConfigVO; import io.netty.buffer.ByteBuf; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -18,20 +17,20 @@ import org.springframework.util.StringUtils; @Slf4j @Component -public class RichorPsdServiceImpl implements RealDeviceService { +public class ZjdPsdServiceImpl implements RealDeviceService { @Autowired private ApplicationContext applicationContext; @Override public boolean canHandle(RealDeviceConfig deviceConfig) { - return deviceConfig instanceof RichorPsdConfig; + return deviceConfig instanceof ZjdPsdConfig; } @Override public void init(Simulation simulation, RealDeviceConfig deviceConfig) { // PlcGateway plcGateway = simulation.getPlcGateway(); -// RichorPsdConfig config = (RichorPsdConfig) deviceConfig; -// RichorPsdConfigVO configVO = config.getConfigVO(); +// ZjdPsdConfig config = (ZjdPsdConfig) deviceConfig; +// ZjdPsdConfigVO configVO = config.getConfigVO(); // Channel channel = plcGateway.getChannel(); // int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); // @@ -43,8 +42,8 @@ public class RichorPsdServiceImpl implements RealDeviceService { @Override public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { - RichorPsdConfig config = (RichorPsdConfig) deviceConfig; - RichorPsdConfigVO configVO = config.getConfigVO(); + ZjdPsdConfig config = (ZjdPsdConfig) deviceConfig; + ZjdPsdConfigVO configVO = config.getConfigVO(); ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); boolean km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_wgm()); boolean sj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_sj()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorIbpConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslConfig.java similarity index 58% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorIbpConfig.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslConfig.java index 9a625d591..27e18ec14 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorIbpConfig.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslConfig.java @@ -3,21 +3,19 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; 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.richor.RichorIbpConfigVO; -import club.joylink.rtss.vo.client.project.richor.RichorPsdConfigVO; +import club.joylink.rtss.vo.client.project.richor.ZjdPslConfigVO; import lombok.Getter; -import lombok.Setter; import java.util.Objects; @Getter -public class RichorIbpConfig extends RealDeviceConfig { - private RichorIbpConfigVO configVO; +public class ZjdPslConfig extends RealDeviceConfig { + private ZjdPslConfigVO configVO; - public RichorIbpConfig(ProjectDeviceVO deviceVO) { + public ZjdPslConfig(ProjectDeviceVO deviceVO) { super(deviceVO); if (Objects.nonNull(deviceVO.getConfig())) { - this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorIbpConfigVO.class); + this.configVO = JsonUtils.read(deviceVO.getConfig(), ZjdPslConfigVO.class); } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslServiceImpl.java similarity index 90% rename from src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslServiceImpl.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslServiceImpl.java index 1a70f1382..2a6ae963e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslServiceImpl.java @@ -10,19 +10,19 @@ import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; -import club.joylink.rtss.vo.client.project.richor.RichorPslConfigVO; +import club.joylink.rtss.vo.client.project.richor.ZjdPslConfigVO; import io.netty.buffer.ByteBuf; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component -public class RichorPslServiceImpl implements RealDeviceService { +public class ZjdPslServiceImpl implements RealDeviceService { @Autowired private CiStandService standService; @Override public boolean canHandle(RealDeviceConfig deviceConfig) { - return deviceConfig instanceof RichorPslConfig; + return deviceConfig instanceof ZjdPslConfig; } @Override @@ -32,8 +32,8 @@ public class RichorPslServiceImpl implements RealDeviceService { @Override public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { - RichorPslConfig config = (RichorPslConfig) deviceConfig; - RichorPslConfigVO configVO = config.getConfigVO(); + ZjdPslConfig config = (ZjdPslConfig) deviceConfig; + ZjdPslConfigVO configVO = config.getConfigVO(); ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); boolean r_sx_czyx = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_czyx()); boolean r_sx_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_km()); 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 e7e4d5abc..437226e03 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 @@ -9,16 +9,13 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDevice 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.*; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorDcuConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorIbpConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorPsdConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorPslConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdIbpConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPsdConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPslConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPsdConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPslConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig; import club.joylink.rtss.util.JsonUtils; -import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO; -import club.joylink.rtss.vo.client.project.richor.RichorPslConfigVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.NoArgsConstructor; @@ -124,19 +121,16 @@ public class ProjectDeviceVO { for (ProjectDeviceVO deviceVO : voList) { switch (deviceVO.getType()) { case IBP: - list.add(new RichorIbpConfig(deviceVO)); + list.add(new ZjdIbpConfig(deviceVO)); break; case PLC_GATEWAY: list.add(new PlcGateway(deviceVO)); break; case PSD: - list.add(new RichorPsdConfig(deviceVO)); + list.add(new ZjdPsdConfig(deviceVO)); break; case PSL: - list.add(new RichorPslConfig(deviceVO)); - break; - case DCU: - list.add(new RichorDcuConfig(deviceVO)); + list.add(new ZjdPslConfig(deviceVO)); break; } } diff --git a/src/main/java/club/joylink/rtss/vo/client/project/RealConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/RealConfigVO.java new file mode 100644 index 000000000..7750e1850 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/project/RealConfigVO.java @@ -0,0 +1,30 @@ +package club.joylink.rtss.vo.client.project; + +import club.joylink.rtss.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +public class RealConfigVO { + /** + * 网关位开始位置 + */ + private Integer addr; + + /** + * 位数量 + */ + private Integer quantity; + + public RealConfigVO(Integer addr, Integer quantity) { + this.addr = addr; + this.quantity = quantity; + } + + public String toJson() { + return JsonUtils.writeValueAsString(this); + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/project/gzb/GzbSignalConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/gzb/GzbSignalConfigVO.java index 2ac1867bf..e3a855f9b 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/gzb/GzbSignalConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/gzb/GzbSignalConfigVO.java @@ -1,6 +1,7 @@ package club.joylink.rtss.vo.client.project.gzb; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.RealConfigVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.Setter; @@ -10,18 +11,7 @@ import lombok.Setter; /** *贵州装备学院项目信号机配置 */ -public class GzbSignalConfigVO { - - /** - *网关位开始地址 - */ - private Integer addr = 0; - - /** - *位数量 - */ - private Integer quantity = 16; - +public class GzbSignalConfigVO extends RealConfigVO { // 0001: 黄灯, 0011: 绿灯, 0100: 黄红灯, 1000: 故障 // 4 -红灯 // 0+4 黄 @@ -76,8 +66,7 @@ public class GzbSignalConfigVO { */ private Integer w11 = 11; - @JsonIgnore - public String toJson() { - return JsonUtils.writeValueAsString(this); + public GzbSignalConfigVO() { + super(0, 16); } } diff --git a/src/main/java/club/joylink/rtss/vo/client/project/gzb/GzbSwitchConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/gzb/GzbSwitchConfigVO.java index 3fdf468f0..40651ab6a 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/gzb/GzbSwitchConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/gzb/GzbSwitchConfigVO.java @@ -1,6 +1,7 @@ package club.joylink.rtss.vo.client.project.gzb; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.RealConfigVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.Setter; @@ -10,18 +11,7 @@ import lombok.Setter; */ @Getter @Setter -public class GzbSwitchConfigVO { - - /** - *网关位开始地址 - */ - private Integer addr = 0; - - /** - *位数量 - */ - private Integer quantity = 16; - +public class GzbSwitchConfigVO extends RealConfigVO { // 定位为1且反位为1,即为故障状态 // 6 定 //5 反 @@ -53,8 +43,7 @@ public class GzbSwitchConfigVO { */ private Integer wsn = 15; - @JsonIgnore - public String toJson() { - return JsonUtils.writeValueAsString(this); + public GzbSwitchConfigVO() { + super(0, 16); } } diff --git a/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorDcuConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorDcuConfigVO.java deleted file mode 100644 index ef2515262..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorDcuConfigVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package club.joylink.rtss.vo.client.project.richor; - -import club.joylink.rtss.util.JsonUtils; -import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -/** - * 安全回路 - */ -@Getter -@Setter -@NoArgsConstructor -public class RichorDcuConfigVO { - private String iscsCode = "dcu"; - - /** - * 网关位开始地址 - */ - private Integer addr = 0; - /** - * 位数量 - */ - private Integer quantity = 80; - - /* ----------------------状态位---------------------- */ - /** 安全回路 */ - private Integer r_sx_aqhl = 68; - - @JsonIgnore - public String toJson() { - return JsonUtils.writeValueAsString(this); - } -} diff --git a/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorIbpConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdIbpConfigVO.java similarity index 81% rename from src/main/java/club/joylink/rtss/vo/client/project/richor/RichorIbpConfigVO.java rename to src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdIbpConfigVO.java index e821e9d6b..869734777 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorIbpConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdIbpConfigVO.java @@ -1,6 +1,7 @@ package club.joylink.rtss.vo.client.project.richor; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.RealConfigVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.NoArgsConstructor; @@ -8,22 +9,13 @@ import lombok.Setter; @Getter @Setter -@NoArgsConstructor -public class RichorIbpConfigVO { +public class ZjdIbpConfigVO extends RealConfigVO { /** * ibp盘绑定的车站 */ private String stationCode = "Station25166"; private String iscsCode = "ibp"; - /** - * 网关位开始地址 - */ - private Integer addr = 0; - /** - * 位数量 - */ - private Integer quantity = 80; /*---------------- 屏蔽门 ----------------*/ /** @@ -111,13 +103,7 @@ public class RichorIbpConfigVO { /** 关门命令 */ private Integer r_sx_gm = 76; - public RichorIbpConfigVO(Integer addr, Integer quantity) { - this.addr = addr; - this.quantity = quantity; - } - - @JsonIgnore - public String toJson() { - return JsonUtils.writeValueAsString(this); + public ZjdIbpConfigVO() { + super(0, 80); } } diff --git a/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorPsdConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdPsdConfigVO.java similarity index 79% rename from src/main/java/club/joylink/rtss/vo/client/project/richor/RichorPsdConfigVO.java rename to src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdPsdConfigVO.java index 4e0ebc7c8..067e61468 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorPsdConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdPsdConfigVO.java @@ -1,6 +1,7 @@ package club.joylink.rtss.vo.client.project.richor; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.RealConfigVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.NoArgsConstructor; @@ -10,8 +11,7 @@ import javax.validation.constraints.NotBlank; @Getter @Setter -@NoArgsConstructor -public class RichorPsdConfigVO { +public class ZjdPsdConfigVO extends RealConfigVO { // /** // * 关联的站台屏蔽门code // */ @@ -22,14 +22,6 @@ public class RichorPsdConfigVO { * 关联的ISCS元素的code */ private String iscsCode = "FuzhouPsd_33"; - /** - * 网关位开始地址 - */ - private Integer addr = 0; - /** - * 位数量 - */ - private Integer quantity = 144; /*---------------- 屏蔽门 ----------------*/ /** @@ -97,13 +89,7 @@ public class RichorPsdConfigVO { */ private Integer r_sx_dwgl = 132; - public RichorPsdConfigVO(Integer addr, Integer quantity) { - this.addr = addr; - this.quantity = quantity; - } - - @JsonIgnore - public String toJson() { - return JsonUtils.writeValueAsString(this); + public ZjdPsdConfigVO() { + super(0, 144); } } diff --git a/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorPslConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdPslConfigVO.java similarity index 66% rename from src/main/java/club/joylink/rtss/vo/client/project/richor/RichorPslConfigVO.java rename to src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdPslConfigVO.java index d24abfae8..234b55cde 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorPslConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdPslConfigVO.java @@ -1,6 +1,7 @@ package club.joylink.rtss.vo.client.project.richor; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.RealConfigVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.NoArgsConstructor; @@ -8,21 +9,11 @@ import lombok.Setter; @Getter @Setter -@NoArgsConstructor -public class RichorPslConfigVO { +public class ZjdPslConfigVO extends RealConfigVO { private String standCode = "PF59020"; private String iscsCode = "psl"; - /** - * 网关位开始地址 - */ - private Integer addr = 0; - /** - * 位数量 - */ - private Integer quantity = 64; - /** 状态位 */ /** 操作允许 */ private Integer r_sx_czyx = 52; @@ -36,8 +27,7 @@ public class RichorPslConfigVO { /** 互锁解除 */ private Integer r_sx_hsjc = 49; - @JsonIgnore - public String toJson() { - return JsonUtils.writeValueAsString(this); + public ZjdPslConfigVO() { + super(0, 64); } } diff --git a/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPsdConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPsdConfigVO.java index 27424cd8a..d75b92ae3 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPsdConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPsdConfigVO.java @@ -1,6 +1,7 @@ package club.joylink.rtss.vo.client.project.sdy; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.RealConfigVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.NoArgsConstructor; @@ -13,21 +14,12 @@ import javax.validation.constraints.NotBlank; */ @Getter @Setter -@NoArgsConstructor -public class SdyPsdConfigVO { +public class SdyPsdConfigVO extends RealConfigVO { /** * 关联的站台屏蔽门code */ @NotBlank(message = "关联的站台屏蔽门code不能为空") private String psdCode; - /** - * 网关位开始地址 - */ - private Integer addr = 0; - /** - * 位数量 - */ - private Integer quantity = 16; /*---------------- 屏蔽门 ----------------*/ /** @@ -50,13 +42,7 @@ public class SdyPsdConfigVO { */ private Integer w_jb = 9; - public SdyPsdConfigVO(Integer addr, Integer quantity) { - this.addr = addr; - this.quantity = quantity; - } - - @JsonIgnore - public String toJson() { - return JsonUtils.writeValueAsString(this); + public SdyPsdConfigVO() { + super(0, 16); } } diff --git a/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPslConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPslConfigVO.java index ab6858d1a..950465bbb 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPslConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPslConfigVO.java @@ -1,6 +1,7 @@ package club.joylink.rtss.vo.client.project.sdy; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.RealConfigVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.NoArgsConstructor; @@ -8,17 +9,8 @@ import lombok.Setter; @Getter @Setter -@NoArgsConstructor -public class SdyPslConfigVO { +public class SdyPslConfigVO extends RealConfigVO { private String psdCode; - /** - * 网关位开始地址 - */ - private Integer addr = 0; - /** - * 位数量 - */ - private Integer quantity = 16; /** * 试灯按钮 @@ -65,8 +57,7 @@ public class SdyPslConfigVO { */ private Integer w_hsjc_light = 13; - @JsonIgnore - public String toJson() { - return JsonUtils.writeValueAsString(this); + public SdyPslConfigVO() { + super(0, 16); } } diff --git a/src/main/java/club/joylink/rtss/vo/client/project/xty/XtyPsdConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/xty/XtyPsdConfigVO.java index 845d6e011..d5b4a576c 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/xty/XtyPsdConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/xty/XtyPsdConfigVO.java @@ -1,6 +1,7 @@ package club.joylink.rtss.vo.client.project.xty; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.RealConfigVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.NoArgsConstructor; @@ -13,25 +14,13 @@ import javax.validation.constraints.NotBlank; */ @Getter @Setter -@NoArgsConstructor -public class XtyPsdConfigVO { - +public class XtyPsdConfigVO extends RealConfigVO { /** *关联的站台屏蔽门code */ @NotBlank(message = "关联的站台屏蔽门code不能为空") private String psdCode = "Psd69543"; - /** - *网关位开始地址 - */ - private Integer addr = 0; - - /** - *位数量 - */ - private Integer quantity = 32; - // 门模式abc组合意义,111:自动模式,100:PSL模式,011:IBP模式,010:LCB操作模式,001LCB隔离模式 /** *门模式位a @@ -99,8 +88,7 @@ public class XtyPsdConfigVO { */ private Integer wvgm = 0x55; - @JsonIgnore - public String toJson() { - return JsonUtils.writeValueAsString(this); + public XtyPsdConfigVO() { + super(0, 32); } } From 8c9c952973be63cc9e3b03fa46697f89a1089885 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 22 Sep 2021 11:11:15 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E6=8A=A5=E9=94=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java index 1600d187e..034ab29b3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java @@ -11,6 +11,7 @@ import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.PSD; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.map.Station; @@ -107,7 +108,8 @@ public class RobotLogicLoop { List standList = section.getStandList(); if (!CollectionUtils.isEmpty(standList)) { for (Stand stand : standList) { - if (!stand.getPsd().isCloseAndLock()) { + PSD psd = stand.getPsd(); + if (psd != null && !psd.isCloseAndLock()) { VirtualRealityPsl vrPsl = stand.getVrPsl(); if (!vrPsl.isAllowOperation()) { //确保此时允许操作 iVirtualRealityPslService.pressTheButton(simulation.getId(), From 3cb47d957714f7305e24f83cdb59139b1bde16f1 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 22 Sep 2021 14:12:58 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=A0=E5=8A=A0?= =?UTF-8?q?=E8=BD=BDIBP=E6=95=B0=E6=8D=AE=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E7=BB=98=E5=88=B6=E6=95=B0=E6=8D=AE=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=BF=9D=E5=AD=98=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/SimulationLifeCycleServiceImpl.java | 2 +- .../cbtc/build/MapDeviceBuilder.java | 1 - .../cbtc/build/SimulationBuilder.java | 33 +++++++++++++++++++ .../rtss/vo/map/MapGraphDataNewVO.java | 5 --- .../java/club/joylink/rtss/vo/map/MapVO.java | 6 ++++ 5 files changed, 40 insertions(+), 7 deletions(-) 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 dac3c4656..eacc1f300 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java @@ -114,7 +114,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic public Simulation create(SimulationBuildParams params, String group) { // 构建仿真 List ibps = ibpService.queryEntities(params.getMap().getId()); - params.getMap().getGraphDataNew().setIbpList(ibps); + params.getMap().setIbpList(ibps); Simulation simulation = SimulationBuilder.build(group, params); // 缓存 simulationManager.save(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 1cc50502c..8fbf0850d 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 @@ -1270,7 +1270,6 @@ public class MapDeviceBuilder { */ private static void buildStation(MapGraphDataNewVO graphData, Map elementMap, Map deviceMap, List errMsgList) { List stationList = graphData.getStationList(); - Map ibpMap = graphData.getIbpList().stream().collect(Collectors.toMap(Ibp::getStationCode, Function.identity())); stationList.forEach(stationVO -> { Station station = new Station(stationVO.getCode(), stationVO.getName()); if (Objects.nonNull(elementMap.get(station.getCode()))) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java index 545bd5221..f180a0bf6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.build; +import club.joylink.rtss.entity.Ibp; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; @@ -8,6 +9,9 @@ import club.joylink.rtss.simulation.cbtc.data.plan.TerminalDeparturePlan; import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.ibp.IbpData; import club.joylink.rtss.vo.client.runplan.RunPlanVO; import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO; import club.joylink.rtss.vo.map.logic.MapStationParkingTimeVO; @@ -18,7 +22,10 @@ import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.springframework.util.CollectionUtils; +import javax.swing.text.Element; import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; @Slf4j public class SimulationBuilder { @@ -42,6 +49,8 @@ public class SimulationBuilder { .setSharingECStations(buildParams.getMap().getGraphDataNew().getGenerateConfig().getSharingECStations()); // 地图数据构建 SimulationDeviceBuildResult mapDataBuildResult = checkAndBuildMapData(buildParams.getMap()); + // ibp数据构建 + buildIbpData(mapDataBuildResult, buildParams.getMap().getIbpList()); simulation.getRepository().setDeviceMap(mapDataBuildResult.getDeviceMap()); simulation.getRepository().setSectionArriveNearMap(mapDataBuildResult.sectionArriveNearMap); simulation.getRepository().setVrDeviceMap(mapDataBuildResult.getVrDeviceMap()); @@ -69,6 +78,30 @@ public class SimulationBuilder { return simulation; } + private static void buildIbpData(SimulationDeviceBuildResult mapDataBuildResult, List ibpList) { + if (CollectionUtils.isEmpty(ibpList)) + return; + Map elementMap = mapDataBuildResult.getDeviceMap(); + Map ibpMap = ibpList.stream().collect(Collectors.toMap(Ibp::getStationCode, Function.identity())); + elementMap.values().stream() + .filter(element -> MapElement.DeviceType.STATION.equals(element.getDeviceType())) + .map(element -> (Station) element) + .forEach(station -> { + + //构建添加IBP + Ibp ibp = ibpMap.get(station.getCode()); + if (ibp == null) + ibp = ibpMap.get(null); + if (ibp != null) { + IbpData ibpData = JsonUtils.read(ibp.getData(), IbpData.class); + VirtualRealityIbp vrIbp = new VirtualRealityIbp(station.getCode() + "_IBP", station.getName() + "_IBP", ibpData, station); + station.setVrIbp(vrIbp); + elementMap.put(vrIbp.getCode(), vrIbp); + elementMap.put(vrIbp.getCode(), vrIbp); + } + }); + } + private static boolean isOverlapSettingByTrigger(Map deviceMap) { for (MapElement mapElement : deviceMap.values()) { if (mapElement.getDeviceType().equals(MapElement.DeviceType.OVERLAP)) { 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 882d7c6e3..3b6cca262 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java @@ -218,11 +218,6 @@ public class MapGraphDataNewVO { private List signalButtonList = new ArrayList<>(); - /** - * ibp列表 - */ - private List ibpList = new ArrayList<>(); - public MapGraphDataNewVO() { this.bigScreenConfig = new BigScreenConfig(); this.generateConfig = new MapCiGenerateConfig(); diff --git a/src/main/java/club/joylink/rtss/vo/map/MapVO.java b/src/main/java/club/joylink/rtss/vo/map/MapVO.java index 58c78ecc4..50f93f422 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/MapVO.java @@ -2,6 +2,7 @@ package club.joylink.rtss.vo.map; import club.joylink.rtss.entity.DraftMap; import club.joylink.rtss.entity.DraftMapWithBLOBs; +import club.joylink.rtss.entity.Ibp; import club.joylink.rtss.entity.MapInfo; import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.client.map.MapDataVO; @@ -108,6 +109,11 @@ public class MapVO { private Map3dDataVO map3dData; + /** + * ibp数据列表 + */ + private List ibpList = new ArrayList<>(); + public MapVO(DraftMap draftMap) { this.name = draftMap.getName(); this.lineCode = draftMap.getLineCode(); From 2463a962044a47b44aec75ddb675d4191ad59d49 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 22 Sep 2021 16:58:27 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E7=9C=9F=E5=AE=9EIBP/PSL=E7=9B=98=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E8=BF=9E=E6=8E=A5vrIBP/PSL=EF=BC=88=E4=BB=85=E4=B9=89?= =?UTF-8?q?=E4=B9=8C=E9=A1=B9=E7=9B=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/IVirtualRealityIbpService.java | 4 + .../services/VirtualRealityIbpService.java | 103 ++++++++------- .../psl/IVirtualRealityPslService.java | 2 + .../psl/VirtualRealityPslService.java | 59 +++++++-- .../rtss/simulation/cbtc/CI/CiApiService.java | 9 +- .../simulation/cbtc/CI/CiApiServiceImpl2.java | 11 +- .../cbtc/CI/device/CiStandService.java | 2 +- .../ProjectJointSimulationServiceImpl.java | 6 +- .../cbtc/build/MapDeviceBuilder.java | 12 +- .../cbtc/build/SimulationBuilder.java | 15 ++- .../cbtc/data/SimulationDataRepository.java | 10 -- .../cbtc/data/vr/VirtualRealityIbp.java | 21 +-- .../cbtc/data/vr/VirtualRealityPsl.java | 2 + .../SimulationRealDeviceConnectManager.java | 4 + .../modbustcp/richor/ZjdIbpServiceImpl.java | 120 ++++++++++-------- .../modbustcp/richor/ZjdPslServiceImpl.java | 18 ++- .../cbtc/onboard/ATO/service/ATOService.java | 5 +- .../cbtc/onboard/ATP/ATPService.java | 5 +- .../client/project/richor/ZjdIbpConfigVO.java | 6 +- .../client/project/richor/ZjdPslConfigVO.java | 2 +- 20 files changed, 243 insertions(+), 173 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/IVirtualRealityIbpService.java b/src/main/java/club/joylink/rtss/services/IVirtualRealityIbpService.java index 574f1fb13..5366f2a3d 100644 --- a/src/main/java/club/joylink/rtss/services/IVirtualRealityIbpService.java +++ b/src/main/java/club/joylink/rtss/services/IVirtualRealityIbpService.java @@ -2,6 +2,7 @@ package club.joylink.rtss.services; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.status.IbpStatus; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp; /** * 虚拟真实IBP服务 @@ -18,6 +19,9 @@ public interface IVirtualRealityIbpService { */ void pressTheButton(String group, String stationCode, String buttonCode); + void updateElementStatus(Simulation simulation, VirtualRealityIbp ibp, + VirtualRealityIbp.IbpElement element, boolean pressed); + /** * 收集并发送IBP的状态数据 * @param simulation diff --git a/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java b/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java index 7e2b464eb..6bc35285b 100644 --- a/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java +++ b/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java @@ -2,10 +2,9 @@ package club.joylink.rtss.services; import club.joylink.rtss.exception.BaseException; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import club.joylink.rtss.services.publishData.IbpService; -import club.joylink.rtss.services.publishData.IbpServiceImpl; import club.joylink.rtss.simulation.cbtc.ATS.operation.handler.StandOperateHandler; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; +import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService; import club.joylink.rtss.simulation.cbtc.GroupSimulationCache; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; @@ -18,12 +17,6 @@ import club.joylink.rtss.simulation.cbtc.data.map.Station; import club.joylink.rtss.simulation.cbtc.data.status.IbpStatus; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp; import club.joylink.rtss.simulation.cbtc.event.SimulationIbpStatusEvent; -import club.joylink.rtss.simulation.cbtc.exception.SimulationException; -import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; -import club.joylink.rtss.util.JsonUtils; -import club.joylink.rtss.vo.client.ibp.IbpData; -import club.joylink.rtss.vo.client.ibp.IbpQueryVO; -import club.joylink.rtss.vo.client.ibp.IbpVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; @@ -50,10 +43,7 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService { private ApplicationContext applicationContext; @Autowired - private IbpService ibpService; - - @Autowired - private IbpServiceImpl ibpServiceImpl; + private CiStandService ciStandService; @Override public IbpStatus getIbpStatus(String group, String stationCode) { @@ -76,79 +66,82 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService { Simulation simulation = groupSimulationCache.getSimulationByGroup(group); Station station = simulation.getRepository().getByCode(stationCode, Station.class); VirtualRealityIbp ibp = collect4Ibp(simulation, station); - MapConfig config = simulation.getRepository().getConfig(); - VirtualRealityIbp.IbpElement element = ibp.getByCode(buttonCode); + theButtonIsPressed(simulation, ibp, element); + } + + private void theButtonIsPressed(Simulation simulation, VirtualRealityIbp ibp, VirtualRealityIbp.IbpElement element) { + boolean change = false; if (VirtualRealityIbp.Type.KEY.equals(element.getType())) { element.setOn(!element.isOn()); return; - } - List stands = chooseStands(station, element, config); - boolean change = false; - VirtualRealityIbp.SquareButton button = null; - if (VirtualRealityIbp.Type.BUTTON.equals(element.getType())) { - button = (VirtualRealityIbp.SquareButton) element; - if (!button.isPressed()) + } else if (VirtualRealityIbp.Type.BUTTON.equals(element.getType())) { + VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element; + if (!button.isOn()) change = true; button.setPressed(true); - if (button.getMean() == null) { - button.setOn(true); - return; - } + element.setOn(true); } + if (change) + effective(simulation, ibp, element); + } + + /** + * IBP盘上元素对应的功能生效 + */ + private void effective(Simulation simulation, VirtualRealityIbp ibp, VirtualRealityIbp.IbpElement element) { + if (!element.isOn()) + return; + Station station = ibp.getStation(); + MapConfig config = simulation.getRepository().getConfig(); + List stands = chooseStands(station, element, config); switch (element.getMean()) { case KC: - element.setOn(true); stands.forEach(stand -> ciApiService.ibpHoldTrain(simulation, stand.getCode())); break; case ZZKC: - element.setOn(true); stands.forEach(stand -> ciApiService.ibpHoldTrainCancel(simulation, stand.getCode())); break; case JJTC: - element.setOn(true); stands.forEach(stand -> ciApiService.standEC(simulation, stand)); ibp.query(VirtualRealityIbp.Mean.ALARM, element.getUp()).forEach(alarm -> alarm.setOn(true)); break; case QXJJTC: - element.setOn(true); stands.forEach(stand -> ciApiService.cancelStandEC(simulation, stand)); break; case BJQC: - element.setOn(true); ibp.query(VirtualRealityIbp.Mean.ALARM, element.getUp()).forEach(ele -> ele.setOn(false)); break; case ALARM: break; case KM: { - element.setOn(true); - stands.forEach(stand -> ciApiService.openScreenDoor(simulation, stand.getCode())); + stands.forEach(stand -> ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.IBP)); break; } case GM: { - element.setOn(true); - stands.forEach(stand -> ciApiService.closeScreenDoor(simulation, stand.getCode())); + stands.forEach(stand -> ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.IBP)); break; } case XXYS: case SXYS: - element.setOn(!element.isOn()); +// element.setOn(!element.isOn()); break; - case AXLE_RESET: - element.setOn(true); + case AXLE_RESET: { + VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element; ciApiService.axleReset(simulation, button.getSectionCode()); break; - case AXLE_PRE_RESET: - if (change) { + } + case AXLE_PRE_RESET: { + VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element; + if (!button.isEffective()) { button.setEffective(true); button.setPressTime(LocalDateTime.now()); } break; + } case PRERESET_Z: - element.setOn(true); break; case SD: - element.setOn(true); ibp.queryByType(VirtualRealityIbp.Type.LIGHT).forEach(light -> light.setOn(true)); break; default: @@ -169,14 +162,30 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService { Station station = simulation.getRepository().getByCode(stationCode, Station.class); VirtualRealityIbp ibp = collect4Ibp(simulation, station); VirtualRealityIbp.IbpElement element = ibp.getByCode(buttonCode); + theButtonIsReleased(element); + } + + private void theButtonIsReleased(VirtualRealityIbp.IbpElement element) { BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(VirtualRealityIbp.Type.BUTTON.equals(element.getType()), "元素非按钮"); VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element; - button.setPressed(false); if (!VirtualRealityIbp.Mean.AXLE_PRE_RESET.equals(button.getMean())) { button.setOn(false); + } else { + button.setEffective(false); } - if (VirtualRealityIbp.Mean.SD.equals(button.getMean())) { - ibp.queryByType(VirtualRealityIbp.Type.LIGHT).forEach(light -> light.setOn(false)); + } + + /** + * 更新IBP元素状态 + * @param pressed true-按下;false-松开 + */ + @Override + public void updateElementStatus(Simulation simulation, VirtualRealityIbp ibp, + VirtualRealityIbp.IbpElement element, boolean pressed) { + if (pressed) { + theButtonIsPressed(simulation, ibp, element); + } else { + theButtonIsReleased(element); } } @@ -209,12 +218,12 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService { @Override public void addJobs(Simulation simulation) { - simulation.addJob(Simulation.JobName.ibpJob, () -> this.logic(simulation), 500); + simulation.addJob(Simulation.JobName.ibpJob, () -> this.preResetLogic(simulation), 500); simulation.addJob(SimulationModule.IBP_STATUS.name(), () -> this.collectAndDispatcher(simulation), SimulationConstants.IBP_STATUS_COLLECT_RATE); } - private void logic(Simulation simulation) { + private void preResetLogic(Simulation simulation) { SimulationDataRepository repository = simulation.getRepository(); for (Station station : repository.getStationList()) { VirtualRealityIbp ibp = station.getVrIbp(); @@ -256,8 +265,6 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService { boolean sd = false; if (!CollectionUtils.isEmpty(sdList)) { sd = sdList.stream().anyMatch(VirtualRealityIbp.IbpElement::isOn); -// VirtualRealityIbp.SquareButton sdButton = (VirtualRealityIbp.SquareButton) sdList.get(0); -// sd = sdButton.isOn(); } for (VirtualRealityIbp.IbpElement element : vrIbp.getElementList()) { List stands = chooseStands(station, element, config); diff --git a/src/main/java/club/joylink/rtss/services/psl/IVirtualRealityPslService.java b/src/main/java/club/joylink/rtss/services/psl/IVirtualRealityPslService.java index 5caee2cf3..b3a361e6a 100644 --- a/src/main/java/club/joylink/rtss/services/psl/IVirtualRealityPslService.java +++ b/src/main/java/club/joylink/rtss/services/psl/IVirtualRealityPslService.java @@ -10,5 +10,7 @@ public interface IVirtualRealityPslService { void pressTheButton(String group, String standCode, VirtualRealityPsl.Button button); + void updateStatus(Simulation simulation, VirtualRealityPsl vrPsl, VirtualRealityPsl.Button button, boolean on); + void addJobs(Simulation simulation); } diff --git a/src/main/java/club/joylink/rtss/services/psl/VirtualRealityPslService.java b/src/main/java/club/joylink/rtss/services/psl/VirtualRealityPslService.java index 33b0eec65..0aead1d0e 100644 --- a/src/main/java/club/joylink/rtss/services/psl/VirtualRealityPslService.java +++ b/src/main/java/club/joylink/rtss/services/psl/VirtualRealityPslService.java @@ -1,6 +1,7 @@ package club.joylink.rtss.services.psl; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService; import club.joylink.rtss.simulation.cbtc.GroupSimulationService; import club.joylink.rtss.simulation.cbtc.Simulation; @@ -9,8 +10,6 @@ import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.PSD; import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; -import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; import club.joylink.rtss.simulation.cbtc.event.SimulationPslStatusEvent; import club.joylink.rtss.vo.client.psl.PslStatus; import org.springframework.beans.factory.annotation.Autowired; @@ -22,7 +21,7 @@ import java.util.HashMap; import java.util.Map; @Service -public class VirtualRealityPslService implements IVirtualRealityPslService{ +public class VirtualRealityPslService implements IVirtualRealityPslService { @Autowired private GroupSimulationService groupSimulationService; @@ -31,9 +30,7 @@ public class VirtualRealityPslService implements IVirtualRealityPslService{ private ApplicationContext applicationContext; @Autowired - private CiStandService standService; - @Autowired - private VirtualRealityDeviceService virtualRealityDeviceService; + private CiApiService ciApiService; @Override public PslStatus getStatus(String group, String standCode) { @@ -58,6 +55,11 @@ public class VirtualRealityPslService implements IVirtualRealityPslService{ Simulation simulation = groupSimulationService.getSimulationByGroup(group); Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); VirtualRealityPsl vrPsl = collectStatus(stand); + theButtonIsPressed(simulation, vrPsl, button); + } + + private void theButtonIsPressed(Simulation simulation, VirtualRealityPsl vrPsl, VirtualRealityPsl.Button button) { + Stand stand = vrPsl.getStand(); synchronized (vrPsl) { switch (button) { case YXJZ: @@ -65,13 +67,13 @@ public class VirtualRealityPslService implements IVirtualRealityPslService{ break; case HSJC: vrPsl.setHsjcKey(!vrPsl.isHsjcKey()); - standService.setOrCancelInterlockRelease(simulation, stand, vrPsl.isHsjcKey()); + ciApiService.setOrCancelInterlockRelease(simulation, stand, vrPsl.isHsjcKey()); break; case KM: - standService.openScreenDoor(simulation, stand, CiStandService.PsdCommandSource.PSL); + ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL); break; case GM: - standService.closeScreenDoor(simulation, stand, CiStandService.PsdCommandSource.PSL); + ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL); break; case SD: vrPsl.setSdButton(!vrPsl.isSdButton()); @@ -80,6 +82,45 @@ public class VirtualRealityPslService implements IVirtualRealityPslService{ } } + @Override + public void updateStatus(Simulation simulation, VirtualRealityPsl vrPsl, VirtualRealityPsl.Button button, boolean on) { + switch (button) { + case YXJZ: + vrPsl.setYxjzKey(on); + break; + case HSJC: + vrPsl.setHsjcKey(on); + break; + case KM: + case GM: + break; + case SD: + vrPsl.setSdButton(on); + break; + } + effective(simulation, vrPsl.getStand(), button, on); + } + + private void effective(Simulation simulation, Stand stand, VirtualRealityPsl.Button button, boolean on) { + switch (button) { + case YXJZ: + break; + case HSJC: + ciApiService.setOrCancelInterlockRelease(simulation, stand, on); + break; + case KM: + if (on) + ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL); + break; + case GM: + if (on) + ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL); + break; + case SD: + break; + } + } + @Override public void addJobs(Simulation simulation) { simulation.addJobIfAbsent(Simulation.JobName.pslStatus, diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java index 838eb285f..a8092e2f4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.CI; +import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.ESP; import club.joylink.rtss.simulation.cbtc.data.map.Route; @@ -222,15 +223,17 @@ public interface CiApiService { * 开站台屏蔽门 * @param simulation * @param standCode + * @param source */ - void openScreenDoor(Simulation simulation, String standCode); + void openScreenDoor(Simulation simulation, String standCode, CiStandService.PsdCommandSource source); /** * 关站台屏蔽门 * @param simulation * @param standCode + * @param source */ - void closeScreenDoor(Simulation simulation, String standCode); + void closeScreenDoor(Simulation simulation, String standCode, CiStandService.PsdCommandSource source); /** * 站台扣车,联锁关系处理 @@ -349,4 +352,6 @@ public interface CiApiService { * @param overlapCode */ void setOverlap(Simulation simulation, String signalCode, String overlapCode); + + void setOrCancelInterlockRelease(Simulation simulation, Stand stand, boolean release); } 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 f70ff9ee7..e6d6a7140 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 @@ -318,15 +318,15 @@ public class CiApiServiceImpl2 implements CiApiService { } @Override - public void openScreenDoor(Simulation simulation, String standCode) { + public void openScreenDoor(Simulation simulation, String standCode, CiStandService.PsdCommandSource source) { Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); if (Objects.nonNull(stand.getPsd())) { - standService.openScreenDoor(simulation, stand, CiStandService.PsdCommandSource.SIG); + standService.openScreenDoor(simulation, stand, source); } } @Override - public void closeScreenDoor(Simulation simulation, String standCode) { + public void closeScreenDoor(Simulation simulation, String standCode, CiStandService.PsdCommandSource source) { Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); if (Objects.nonNull(stand.getPsd())) { standService.closeScreenDoor(simulation, stand, CiStandService.PsdCommandSource.SIG); @@ -593,6 +593,11 @@ public class CiApiServiceImpl2 implements CiApiService { this.routeService.setOverlap(simulation, overlap); } + @Override + public void setOrCancelInterlockRelease(Simulation simulation, Stand stand, boolean release) { + standService.setOrCancelInterlockRelease(stand, release); + } + /** * 获取计轴器并为预复位/复位操作检查设备状态 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiStandService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiStandService.java index 8c01c8a24..f89f9e2b2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiStandService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiStandService.java @@ -148,7 +148,7 @@ public class CiStandService { * 设置或取消互锁解除 * @param release 是否是设置 */ - public void setOrCancelInterlockRelease(Simulation simulation, Stand stand, boolean release) { + public void setOrCancelInterlockRelease(Stand stand, boolean release) { stand.getPsd().getVirtualScreenDoor().updateIL(release); stand.getPsd().setInterlockRelease(release); // if (release) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java index edb50b349..e0750f61d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java @@ -15,6 +15,7 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1Ib import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PscConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PslConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdIbpConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPslConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig; import club.joylink.rtss.simulation.cbtc.event.SimulationUserEnterEvent; import club.joylink.rtss.simulation.cbtc.member.MemberManager; @@ -24,6 +25,7 @@ import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.client.project.LwConfigVO; import club.joylink.rtss.vo.client.project.ProjectDeviceVO; +import club.joylink.rtss.vo.client.project.richor.ZjdPslConfigVO; import club.joylink.rtss.vo.map.MapVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -139,7 +141,9 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation case RICHOR_JOINT: { switch (config.getDeviceType()) { case IBP: - return ((ZjdIbpConfig) config).getConfigVO().getStationCode(); + return ((ZjdIbpConfig) config).getConfigVO().getIbpCode(); + case PSL: + return ((ZjdPslConfig) config).getConfigVO().getPslCode(); } } } 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 8fbf0850d..0c64e25f4 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 @@ -812,6 +812,7 @@ public class MapDeviceBuilder { //PSL VirtualRealityPsl vrPsl = new VirtualRealityPsl(stand.getCode() + "_PSL", stand.getName() + "_PSL"); stand.setVrPsl(vrPsl); + vrPsl.setStand(stand); elementMap.put(vrPsl.getCode(), vrPsl); deviceMap.put(vrPsl.getCode(), vrPsl); } @@ -1307,17 +1308,6 @@ public class MapDeviceBuilder { if (station.isHasControlMode()) { // 有控制模式,初始化为中控 station.setControlMode(Station.ControlMode.Center); } - //构建添加IBP - Ibp ibp = ibpMap.get(station.getCode()); - if (ibp == null) - ibp = ibpMap.get(null); - if (ibp != null) { - IbpData ibpData = JsonUtils.read(ibp.getData(), IbpData.class); - VirtualRealityIbp vrIbp = new VirtualRealityIbp(station.getCode() + "_IBP", station.getName() + "_IBP", ibpData); - station.setVrIbp(vrIbp); - elementMap.put(vrIbp.getCode(), vrIbp); - deviceMap.put(vrIbp.getCode(), vrIbp); - } }); // 设备集中站下的车站关联ZC,联锁站下的车站关联联锁站 stationList.forEach(stationVO -> { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java index f180a0bf6..1d9ab270a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java @@ -26,6 +26,7 @@ import javax.swing.text.Element; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; @Slf4j public class SimulationBuilder { @@ -81,13 +82,13 @@ public class SimulationBuilder { private static void buildIbpData(SimulationDeviceBuildResult mapDataBuildResult, List ibpList) { if (CollectionUtils.isEmpty(ibpList)) return; - Map elementMap = mapDataBuildResult.getDeviceMap(); + Map deviceMap = mapDataBuildResult.getDeviceMap(); + Map vrDeviceMap = mapDataBuildResult.getVrDeviceMap(); Map ibpMap = ibpList.stream().collect(Collectors.toMap(Ibp::getStationCode, Function.identity())); - elementMap.values().stream() + List collect = deviceMap.values().stream() .filter(element -> MapElement.DeviceType.STATION.equals(element.getDeviceType())) - .map(element -> (Station) element) - .forEach(station -> { - + .map(element -> (Station) element).collect(Collectors.toList()); + collect.forEach(station -> { //构建添加IBP Ibp ibp = ibpMap.get(station.getCode()); if (ibp == null) @@ -96,8 +97,8 @@ public class SimulationBuilder { IbpData ibpData = JsonUtils.read(ibp.getData(), IbpData.class); VirtualRealityIbp vrIbp = new VirtualRealityIbp(station.getCode() + "_IBP", station.getName() + "_IBP", ibpData, station); station.setVrIbp(vrIbp); - elementMap.put(vrIbp.getCode(), vrIbp); - elementMap.put(vrIbp.getCode(), vrIbp); + deviceMap.put(vrIbp.getCode(), vrIbp); + vrDeviceMap.put(vrIbp.getCode(), vrIbp); } }); } 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 2cd932e71..1042af922 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 @@ -1162,14 +1162,4 @@ public class SimulationDataRepository { .assertNotNull(vrPsl, String.format("%s无对应的vrPsl", vrPsd.debugStr())); return vrPsl; } - - public Station getStationByVrIbp(@NonNull VirtualRealityIbp vrIbp) { - for (Station station : this.getStationList()) { - if (vrIbp.equals(station.getVrIbp())) { - return station; - } - } - throw BusinessExceptionAssertEnum.DATA_NOT_EXIST - .exception(String.format("%s无对应的车站", vrIbp.debugStr())); - } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityIbp.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityIbp.java index 99ce40a99..f66129692 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityIbp.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityIbp.java @@ -1,6 +1,6 @@ package club.joylink.rtss.simulation.cbtc.data.vr; -import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement; +import club.joylink.rtss.simulation.cbtc.data.map.Station; import club.joylink.rtss.vo.client.ibp.IbpData; import lombok.Getter; import lombok.Setter; @@ -18,11 +18,13 @@ import java.util.stream.Collectors; * 虚拟真实IBP盘 */ public class VirtualRealityIbp extends VirtualRealityDevice { + @Getter + private final Station station; private final Map elementMap = new ConcurrentHashMap<>(); - public VirtualRealityIbp(String code, String name, IbpData ibpData) { - super(code, name, DeviceType.ESP); + public VirtualRealityIbp(String code, String name, IbpData ibpData, Station station) { + super(code, name, DeviceType.IBP); if (!CollectionUtils.isEmpty(ibpData.getDrawData().getSquareButtonList())) { for (IbpData.SquareButtonVO vo : ibpData.getDrawData().getSquareButtonList()) { SquareButton button = new SquareButton(vo.getCode(), vo.getMean(), false, vo.getSectionCode(), vo.getDirection()); @@ -48,6 +50,7 @@ public class VirtualRealityIbp extends VirtualRealityDevice { } } } + this.station = station; } public void reset() { @@ -100,7 +103,7 @@ public class VirtualRealityIbp extends VirtualRealityDevice { private Mean mean; - /** 是否生效(是否亮灯) */ + /** 是否开启/亮灯 */ private boolean on; /** 是否上行 */ @@ -122,9 +125,7 @@ public class VirtualRealityIbp extends VirtualRealityDevice { @Getter @Setter public class SquareButton extends IbpElement { - /** - * 是否被按下 - */ + /** 是否被按下 */ private boolean pressed; /** 按钮被按下的时刻 */ @@ -135,8 +136,8 @@ public class VirtualRealityIbp extends VirtualRealityDevice { /** 有效的(防止计轴预复位按钮多次生效) */ private boolean effective; - public SquareButton(String code, Mean mean, boolean status, String sectionCode, Boolean up) { - super(code, Type.BUTTON, mean, status, up); + public SquareButton(String code, Mean mean, boolean on, String sectionCode, Boolean up) { + super(code, Type.BUTTON, mean, on, up); this.sectionCode = sectionCode; } } @@ -157,7 +158,7 @@ public class VirtualRealityIbp extends VirtualRealityDevice { */ KC, /** - * 下行终止扣车 + * 终止扣车 */ ZZKC, /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityPsl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityPsl.java index 734d6ee65..bba8e67c0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityPsl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityPsl.java @@ -1,12 +1,14 @@ package club.joylink.rtss.simulation.cbtc.data.vr; import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement; +import club.joylink.rtss.simulation.cbtc.data.map.Stand; import lombok.Getter; import lombok.Setter; @Getter @Setter public class VirtualRealityPsl extends VirtualRealityDevice { + private Stand stand; /** 所有滑动门/应急门关闭且紧锁指示灯 */ private boolean qbgmLight; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/SimulationRealDeviceConnectManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/SimulationRealDeviceConnectManager.java index 22f46d3c1..30b34cc64 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/SimulationRealDeviceConnectManager.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/SimulationRealDeviceConnectManager.java @@ -85,6 +85,10 @@ public class SimulationRealDeviceConnectManager { typeEqual = true; realDevice.connect(vrDevice); } + if (MapElement.DeviceType.PSL.equals(vrDevice.getDeviceType())) { + typeEqual = true; + realDevice.connect(vrDevice); + } break; } case IBP:{ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java index be99b7304..751f51753 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; +import club.joylink.rtss.services.IVirtualRealityIbpService; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; @@ -18,12 +19,14 @@ import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; import club.joylink.rtss.vo.client.project.richor.ZjdIbpConfigVO; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; +import javafx.scene.effect.Light; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; import java.util.List; +import java.util.Objects; @Slf4j @Component @@ -36,7 +39,7 @@ public class ZjdIbpServiceImpl implements RealDeviceService { private CiApiService ciApiService; @Autowired - private ApplicationContext applicationContext; + private IVirtualRealityIbpService iVirtualRealityIbpService; @Override public boolean canHandle(RealDeviceConfig deviceConfig) { @@ -67,8 +70,8 @@ public class ZjdIbpServiceImpl implements RealDeviceService { if (plcGateway == null) return; ZjdIbpConfig config = (ZjdIbpConfig) deviceConfig; - Station station = (Station) config.getMapElement(); - if (station == null) + VirtualRealityIbp vrIbp = (VirtualRealityIbp) config.getMapElement(); + if (vrIbp == null) return; ZjdIbpConfigVO configVO = config.getConfigVO(); ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); @@ -93,58 +96,67 @@ public class ZjdIbpServiceImpl implements RealDeviceService { int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); Channel channel = plcGateway.getChannel(); //查找真实设备和vr设备 - SimulationDataRepository repository = simulation.getRepository(); - MapConfig mapConfig = repository.getConfig(); - List stands = station.getAllNormalStands(); - List upStands = station.getNormalStand(mapConfig.isRight(true)); - List downStands = station.getNormalStand(mapConfig.isRight(false)); - //输入 - if (r_xx_jjtc) - downStands.forEach(stand -> ciApiService.standEC(simulation, stand)); - if (r_xx_qxjt) - downStands.forEach(stand -> ciApiService.cancelStandEC(simulation, stand)); - if (r_xx_kc) { - for (Stand stand : downStands) { - if (!stand.isIbpHoldTrain()) { - ciApiService.ibpHoldTrain(simulation, stand.getCode()); - } - } - } - if (r_xx_qxkc) - downStands.forEach(stand -> ciApiService.ibpHoldTrainCancel(simulation, stand.getCode())); - if (r_sx_jjtc) - upStands.forEach(stand -> ciApiService.standEC(simulation, stand)); - if (r_sx_qxjt) - upStands.forEach(stand -> ciApiService.cancelStandEC(simulation, stand)); - if (r_sx_kc) { - for (Stand stand : upStands) { - if (!stand.isIbpHoldTrain()) { - ciApiService.ibpHoldTrain(simulation, stand.getCode()); - } - } - } - if (r_sx_qxkc) - upStands.forEach(stand -> ciApiService.ibpHoldTrainCancel(simulation, stand.getCode())); - VirtualRealityIbp vrIbp = station.getVrIbp(); - List ibpElements = vrIbp.queryByMean(VirtualRealityIbp.Mean.SXYS); + /*------------------------- 输入 -------------------------*/ + //下行紧急停车 + List jjtc = vrIbp.query(VirtualRealityIbp.Mean.JJTC, false); + jjtc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_xx_jjtc)); + //下行取消紧停 + List qxjt = vrIbp.query(VirtualRealityIbp.Mean.QXJJTC, false); + qxjt.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_xx_qxjt)); + //下行扣车 + List kc = vrIbp.query(VirtualRealityIbp.Mean.KC, false); + kc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_xx_kc)); + //下行取消扣车 + List qxkc = vrIbp.query(VirtualRealityIbp.Mean.ZZKC, false); + qxkc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_xx_qxkc)); + //上行紧急停车 + List sxjjtc = vrIbp.query(VirtualRealityIbp.Mean.JJTC, true); + sxjjtc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sx_jjtc)); + //上行取消紧停 + List sxqxjt = vrIbp.query(VirtualRealityIbp.Mean.QXJJTC, true); + sxqxjt.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sx_qxjt)); + //上行扣车 + List sxkc = vrIbp.query(VirtualRealityIbp.Mean.KC, true); + sxkc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sx_kc)); + //上行取消扣车 + List sxqxkc = vrIbp.query(VirtualRealityIbp.Mean.ZZKC, true); + sxqxkc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sx_qxkc)); + //试灯 + List sd = vrIbp.queryByMean(VirtualRealityIbp.Mean.SD); + sd.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sd)); + //下行允许禁止钥匙 + List ibpElements = vrIbp.queryByMean(VirtualRealityIbp.Mean.XXYS); ibpElements.forEach(ibpElement -> ibpElement.setOn(r_sx_czyx)); - //输出 - if (r_sd) { - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_kcd(), w_sx_kcd, true, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), w_sx_jjtcd, true, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_kcd(), w_xx_kcd, true, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), w_xx_jjtcd, true, channel); - } else { - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_fmq(), w_fmq, false, channel); - boolean upHoldTrain = upStands.stream().anyMatch(Stand::isIbpHoldTrain); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_kcd(), w_sx_kcd, upHoldTrain, channel); - boolean upEc = upStands.stream().anyMatch(Stand::isEmergencyClosed); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), w_sx_jjtcd, upEc, channel); - boolean downHoldTrain = downStands.stream().anyMatch(Stand::isIbpHoldTrain); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_kcd(), w_xx_kcd, downHoldTrain, channel); - boolean downEc = downStands.stream().anyMatch(Stand::isEmergencyClosed); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), w_xx_jjtcd, downEc, channel); - } + /*------------------------- 输出 -------------------------*/ + boolean xxkcd = vrIbp.query(VirtualRealityIbp.Mean.kcLight, false).stream() + .allMatch(VirtualRealityIbp.IbpElement::isOn); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_kcd(), w_xx_kcd, xxkcd, channel); + boolean sxkcd = vrIbp.query(VirtualRealityIbp.Mean.kcLight, true).stream() + .allMatch(VirtualRealityIbp.IbpElement::isOn); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_kcd(), w_sx_kcd, sxkcd, channel); + boolean xxjjtcd = vrIbp.query(VirtualRealityIbp.Mean.jjtcLight, false).stream() + .allMatch(VirtualRealityIbp.IbpElement::isOn); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), w_xx_jjtcd, xxjjtcd, channel); + boolean sxjjtcd = vrIbp.query(VirtualRealityIbp.Mean.jjtcLight, true).stream() + .allMatch(VirtualRealityIbp.IbpElement::isOn); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), w_sx_jjtcd, sxjjtcd, channel); +// //输出 +// if (r_sd) { +// plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_kcd(), w_sx_kcd, true, channel); +// plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), w_sx_jjtcd, true, channel); +// plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_kcd(), w_xx_kcd, true, channel); +// plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), w_xx_jjtcd, true, channel); +// } else { +// plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_fmq(), w_fmq, false, channel); +// boolean upHoldTrain = upStands.stream().anyMatch(Stand::isIbpHoldTrain); +// plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_kcd(), w_sx_kcd, upHoldTrain, channel); +// boolean upEc = upStands.stream().anyMatch(Stand::isEmergencyClosed); +// plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), w_sx_jjtcd, upEc, channel); +// boolean downHoldTrain = downStands.stream().anyMatch(Stand::isIbpHoldTrain); +// plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_kcd(), w_xx_kcd, downHoldTrain, channel); +// boolean downEc = downStands.stream().anyMatch(Stand::isEmergencyClosed); +// plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), w_xx_jjtcd, downEc, channel); +// } //ISCS状态 SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository(); String iscsCode = configVO.getIscsCode(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslServiceImpl.java index 2a6ae963e..8ccc73a3e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdPslServiceImpl.java @@ -1,9 +1,9 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; +import club.joylink.rtss.services.psl.IVirtualRealityPslService; import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; -import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsPslStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl; @@ -20,6 +20,9 @@ public class ZjdPslServiceImpl implements RealDeviceService { @Autowired private CiStandService standService; + @Autowired + private IVirtualRealityPslService iVirtualRealityPslService; + @Override public boolean canHandle(RealDeviceConfig deviceConfig) { return deviceConfig instanceof ZjdPslConfig; @@ -40,12 +43,13 @@ public class ZjdPslServiceImpl implements RealDeviceService { boolean r_sx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_gm()); boolean r_sx_hsjc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_hsjc()); //信号系统状态 - Stand stand = (Stand) config.getMapElement(); - if (stand != null) { - VirtualRealityPsl vrPsl = stand.getVrPsl(); - vrPsl.setYxjzKey(r_sx_czyx); - standService.setOrCancelInterlockRelease(simulation, stand, r_sx_hsjc); - } + VirtualRealityPsl vrPsl = (VirtualRealityPsl) config.getMapElement(); + if (vrPsl == null) + return; + iVirtualRealityPslService.updateStatus(simulation, vrPsl, VirtualRealityPsl.Button.YXJZ, r_sx_czyx); + iVirtualRealityPslService.updateStatus(simulation, vrPsl, VirtualRealityPsl.Button.KM, r_sx_km); + iVirtualRealityPslService.updateStatus(simulation, vrPsl, VirtualRealityPsl.Button.GM, r_sx_gm); + iVirtualRealityPslService.updateStatus(simulation, vrPsl, VirtualRealityPsl.Button.HSJC, r_sx_hsjc); //ISCS状态 SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository(); String iscsCode = configVO.getIscsCode(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java index d86f6eea5..4fd571828 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java @@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.onboard.ATO.service; import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; +import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.DriveMode; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; @@ -386,7 +387,7 @@ public class ATOService { } else { this.openTrainDoor(simulation, train, train.getDoor1()); } - this.ciApiService.openScreenDoor(simulation, stand.getCode()); + this.ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.SIG); } } @@ -407,7 +408,7 @@ public class ATOService { this.closeTrainDoor(simulation, train, train.getDoor2()); } for (Stand stand : standList) { - this.ciApiService.closeScreenDoor(simulation, stand.getCode()); + this.ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.SIG); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPService.java index be14dc358..51004df05 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPService.java @@ -1,6 +1,7 @@ package club.joylink.rtss.simulation.cbtc.onboard.ATP; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; +import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.DriveMode; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; @@ -310,7 +311,7 @@ public class ATPService { } if (train.isCommunicable()) { for (Stand stand : standList) { - this.ciApiService.openScreenDoor(simulation, stand.getCode()); + this.ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.SIG); } } } else { @@ -320,7 +321,7 @@ public class ATPService { } if (train.isCommunicable()) { for (Stand stand : standList) { - this.ciApiService.closeScreenDoor(simulation, stand.getCode()); + this.ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.SIG); } } } diff --git a/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdIbpConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdIbpConfigVO.java index 869734777..52c505d61 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdIbpConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdIbpConfigVO.java @@ -10,10 +10,7 @@ import lombok.Setter; @Getter @Setter public class ZjdIbpConfigVO extends RealConfigVO { - /** - * ibp盘绑定的车站 - */ - private String stationCode = "Station25166"; + private String ibpCode = "Station25166_IBP"; private String iscsCode = "ibp"; @@ -93,7 +90,6 @@ public class ZjdIbpConfigVO extends RealConfigVO { */ private Integer w_sx_kcd = 23; - /** 操作允许 */ private Integer r_sx_czyx = 77; diff --git a/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdPslConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdPslConfigVO.java index 234b55cde..6f764fdad 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdPslConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/richor/ZjdPslConfigVO.java @@ -10,7 +10,7 @@ import lombok.Setter; @Getter @Setter public class ZjdPslConfigVO extends RealConfigVO { - private String standCode = "PF59020"; + private String pslCode = "PF59020_PSL"; private String iscsCode = "psl"; From 4ab1703e1cb1cd7057ce9b805770f9e920a3660b Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 22 Sep 2021 17:06:10 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E6=95=88?= =?UTF-8?q?=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/real/modbustcp/richor/ZjdIbpServiceImpl.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java index 751f51753..474f3e9c9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/ZjdIbpServiceImpl.java @@ -3,11 +3,7 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; import club.joylink.rtss.services.IVirtualRealityIbpService; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; -import club.joylink.rtss.simulation.cbtc.data.map.MapConfig; -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.IscsIbpStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp; @@ -19,14 +15,11 @@ import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; import club.joylink.rtss.vo.client.project.richor.ZjdIbpConfigVO; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; -import javafx.scene.effect.Light; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; import java.util.List; -import java.util.Objects; @Slf4j @Component