From 587a7bc7cf6fb418b1e80fc9f761cd955da7395f Mon Sep 17 00:00:00 2001 From: joylink_zhangsai Date: Sat, 11 Mar 2023 17:55:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8B=8F=E5=AE=89=E9=99=A2?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E8=AE=BE=E5=A4=87=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/project/DeviceServiceImpl.java | 16 +- .../cbtc/GroupSimulationServiceImpl.java | 6 +- .../ProjectJointSimulationServiceImpl.java | 150 ++++++++---------- .../cbtc/data/vr/VirtualRealitySignal.java | 2 + .../modbustcp/device/RealDeviceConfig.java | 4 + .../real/modbustcp/say/SaySectionConfig.java | 24 +++ .../modbustcp/say/SaySectionServiceImpl.java | 39 +++++ .../modbustcp/say/SaySignalServiceImpl.java | 112 ++++++------- .../modbustcp/say/SaySwitchServiceImpl.java | 8 +- .../vo/client/project/ProjectDeviceVO.java | 8 +- .../rtss/vo/client/project/RealConfigVO.java | 4 + .../project/say/SaySectionConfigVO.java | 23 +++ .../client/project/say/SaySignalConfigVO.java | 56 ++----- .../client/project/say/SaySwitchConfigVO.java | 10 +- 14 files changed, 249 insertions(+), 213 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySectionConfig.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySectionServiceImpl.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/project/say/SaySectionConfigVO.java 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 d0656f917..e1801e8f9 100644 --- a/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java @@ -19,10 +19,7 @@ import club.joylink.rtss.vo.client.project.hhcj.HhcjPsdConfigVO; 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.say.SayIbpConfigVO; -import club.joylink.rtss.vo.client.project.say.SayPsdConfigVO; -import club.joylink.rtss.vo.client.project.say.SaySignalConfigVO; -import club.joylink.rtss.vo.client.project.say.SaySwitchConfigVO; +import club.joylink.rtss.vo.client.project.say.*; 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.sr.SrSectionConfigVO; @@ -480,7 +477,7 @@ public class DeviceServiceImpl implements DeviceService { plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name()); plcGateway.setCreator(accountVO.getId()); plcGateway.setCreateTime(now); - PlcGatewayConfigVO plcGatewayConfigVO = new PlcGatewayConfigVO(0, 256); + PlcGatewayConfigVO plcGatewayConfigVO = new PlcGatewayConfigVO(0, 48); plcGateway.setConfig(plcGatewayConfigVO.toJson()); list.add(plcGateway); // IBP盘 @@ -521,6 +518,15 @@ public class DeviceServiceImpl implements DeviceService { aSwitch.setCreateTime(now); aSwitch.setConfig(new SaySwitchConfigVO().toJson()); list.add(aSwitch); + //SECTION + ProjectDevice section = new ProjectDevice(); + section.setProjectCode(projectCode); + section.setCode(prefix + "section"); + section.setType(ProjectDeviceType.SECTION.name()); + section.setCreator(accountVO.getId()); + section.setCreateTime(now); + section.setConfig(new SaySectionConfigVO().toJson()); + list.add(section); return list; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java index 998b9629b..fb36ae58a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java @@ -22,7 +22,6 @@ import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm; import club.joylink.rtss.simulation.cbtc.ATS.data.SimulationLog; import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainLoadService; - import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams; import club.joylink.rtss.simulation.cbtc.command.CommandBO; import club.joylink.rtss.simulation.cbtc.command.CommandExecuteService; @@ -38,11 +37,9 @@ import club.joylink.rtss.simulation.cbtc.data.map.MayOutOfOrderDevice; import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; import club.joylink.rtss.simulation.cbtc.data.storage.StorageSimulation; import club.joylink.rtss.simulation.cbtc.data.vo.RealDeviceVO; - import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.SimulationRealDeviceConnectManager; - import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; import club.joylink.rtss.simulation.cbtc.event.*; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; @@ -846,7 +843,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { List realDeviceList = simulation.getRealDeviceList(); if (!CollectionUtils.isEmpty(realDeviceList)) { Set displayDeviceTypes = - new HashSet<>(List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL, ProjectDeviceType.PLC_GATEWAY, ProjectDeviceType.IBP)); + new HashSet<>(List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL, + ProjectDeviceType.PLC_GATEWAY, ProjectDeviceType.IBP, ProjectDeviceType.SECTION)); realDeviceList = realDeviceList .stream().filter(device -> displayDeviceTypes.contains(device.getDeviceType())).collect(Collectors.toList()); } 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 602d5dada..a069f8185 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java @@ -9,23 +9,7 @@ import club.joylink.rtss.services.auth.UserLogoutEvent; import club.joylink.rtss.services.project.DeviceService; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.SimulationRealDeviceThread; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; -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.hhcj.HhcjIbpConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj.HhcjPsdConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say.SayIbpConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say.SayPsdConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say.SaySignalConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say.SaySwitchConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdIbpConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdPslConfig; import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceThread; -import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSectionConfig; -import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSignalConfig; -import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSwitchConfig; -import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrTrainConfig; import club.joylink.rtss.simulation.cbtc.event.SimulationUserEnterEvent; import club.joylink.rtss.simulation.cbtc.member.MemberManager; import club.joylink.rtss.simulation.cbtc.member.SimulationUser; @@ -135,71 +119,75 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation } private String queryDeviceCodeFromConfig(RealDeviceConfig config) { - switch (config.getProject()) { - case "HEB": { - switch (config.getDeviceType()) { - case IBP: - return ((Heb1IbpConfig) config).getConfig().getStationCode(); - case PSL: - return ((Heb1PslConfig) config).getConfig().getPsdCode(); - case PSC: - return ((Heb1PscConfig) config).getConfig().getPsdCode(); - } - break; - } - case "XTY": { - switch (config.getDeviceType()) { - case PSD: - return ((XtyPsdConfig) config).getConfig().getPsdCode(); - } - break; - } - case "RICHOR_JOINT": { - switch (config.getDeviceType()) { - case IBP: - return ((ZjdIbpConfig) config).getConfigVO().getIbpCode(); - case PSL: - return ((ZjdPslConfig) config).getConfigVO().getPslCode(); - } - break; - } - case "SR_SANDBOX": { - switch (config.getDeviceType()) { - case SIGNAL: - return ((SrSignalConfig) config).getConfigVO().getVrCode(); - case SECTION: - return ((SrSectionConfig) config).getConfigVO().getVrCode(); - case SWITCH: - return ((SrSwitchConfig) config).getConfigVO().getVrCode(); - case TRAIN: - return ((SrTrainConfig) config).getConfigVO().getVrCode(); - } - break; - } - case "RICHOR_HHCJ": { - switch (config.getDeviceType()) { - case IBP: - return ((HhcjIbpConfig) config).getConfigVO().getIbpCode(); - case PSD: - return ((HhcjPsdConfig) config).getConfigVO().getPsdCode(); - } - break; - } - case "SAY": { - switch (config.getDeviceType()) { - case IBP: - return ((SayIbpConfig) config).getConfigVO().getIbpCode(); - case PSD: - return ((SayPsdConfig) config).getConfigVO().getPsdCode(); - case SIGNAL: - return ((SaySignalConfig) config).getConfigVO().getSignalCode(); - case SWITCH: - return ((SaySwitchConfig) config).getConfigVO().getSwitchCode(); - } - break; - } - } - return null; + return config.findDeviceCode(); +// switch (config.getProject()) { +// case "HEB": { +// switch (config.getDeviceType()) { +// case IBP: +// return ((Heb1IbpConfig) config).getConfig().getStationCode(); +// case PSL: +// return ((Heb1PslConfig) config).getConfig().getPsdCode(); +// case PSC: +// return ((Heb1PscConfig) config).getConfig().getPsdCode(); +// } +// break; +// } +// case "XTY": { +// switch (config.getDeviceType()) { +// case PSD: +// return ((XtyPsdConfig) config).getConfig().getPsdCode(); +// } +// break; +// } +// case "RICHOR_JOINT": { +// switch (config.getDeviceType()) { +// case IBP: +// return ((ZjdIbpConfig) config).getConfigVO().getIbpCode(); +// case PSL: +// return ((ZjdPslConfig) config).getConfigVO().getPslCode(); +// } +// break; +// } +// case "SR_SANDBOX": { +// switch (config.getDeviceType()) { +// case SIGNAL: +// return ((SrSignalConfig) config).getConfigVO().getVrCode(); +// case SECTION: +// return ((SrSectionConfig) config).getConfigVO().getVrCode(); +// case SWITCH: +// return ((SrSwitchConfig) config).getConfigVO().getVrCode(); +// case TRAIN: +// return ((SrTrainConfig) config).getConfigVO().getVrCode(); +// } +// break; +// } +// case "RICHOR_HHCJ": { +// switch (config.getDeviceType()) { +// case IBP: +// return ((HhcjIbpConfig) config).getConfigVO().getIbpCode(); +// case PSD: +// return ((HhcjPsdConfig) config).getConfigVO().getPsdCode(); +// } +// break; +// } +// case "SAY": { +// return config.findDeviceCode(); +// switch (config.getDeviceType()) { +// case IBP: +// return ((SayIbpConfig) config).getConfigVO().getIbpCode(); +// case PSD: +// return ((SayPsdConfig) config).getConfigVO().getPsdCode(); +// case SIGNAL: +// return ((SaySignalConfig) config).getConfigVO().getSignalCode(); +// case SWITCH: +// return ((SaySwitchConfig) config).getConfigVO().getSwitchCode(); +// case SECTION: +// return config.findDeviceCode(); +// } +// break; +// } +// } +// return null; } private Simulation queryProjectSimulation(String project) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySignal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySignal.java index 8d6e11f8b..d5dfbcd6f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySignal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySignal.java @@ -39,6 +39,8 @@ public class VirtualRealitySignal extends ControllableVrDevice { public void apply(SignalAspect aspect) { if (aspect.equals(this.getCommand())) { this.finish(); + } else { + this.aspect = aspect; //徐州连接实体设备需要 } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/device/RealDeviceConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/device/RealDeviceConfig.java index cf02b72ee..3f5dd29ff 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/device/RealDeviceConfig.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/device/RealDeviceConfig.java @@ -85,5 +85,9 @@ public abstract class RealDeviceConfig { return this.projectDevice.getType(); } + /** + * 仿真设备的code。 + * 目前用于实体设备配置与仿真设备连接 + */ public abstract String findDeviceCode(); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySectionConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySectionConfig.java new file mode 100644 index 000000000..dcb5cdd31 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySectionConfig.java @@ -0,0 +1,24 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say; + +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.say.SaySectionConfigVO; +import lombok.Getter; + +@Getter +public class SaySectionConfig extends RealDeviceConfig { + private SaySectionConfigVO configVO; + + public SaySectionConfig(ProjectDeviceVO projectDevice) { + super(projectDevice); + if (projectDevice != null) { + configVO = JsonUtils.read(projectDevice.getConfig(), SaySectionConfigVO.class); + } + } + + @Override + public String findDeviceCode() { + return configVO == null ? null : configVO.findDeviceCode(); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySectionServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySectionServiceImpl.java new file mode 100644 index 000000000..d4a316e54 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySectionServiceImpl.java @@ -0,0 +1,39 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter; +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.vo.client.project.say.SaySectionConfigVO; +import io.netty.buffer.ByteBuf; +import org.springframework.stereotype.Service; + +@Service +public class SaySectionServiceImpl implements RealDeviceService { + @Override + public boolean canHandle(RealDeviceConfig deviceConfig) { + return deviceConfig instanceof SaySectionConfig; + } + + @Override + public void init(Simulation simulation, RealDeviceConfig deviceConfig) { + + } + + @Override + public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { + PlcGateway plcGateway = simulation.queryPlcGatewayDevice(); + if (plcGateway == null) + return; + SaySectionConfig config = (SaySectionConfig) deviceConfig; + VirtualRealitySectionAxleCounter vrAxleCounter = (VirtualRealitySectionAxleCounter) config.getMapElement(); + if (vrAxleCounter == null) + return; + SaySectionConfigVO configVO = config.getConfigVO(); + ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); + + boolean r_occupied = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_occupied()); + vrAxleCounter.setOccupy(r_occupied); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySignalServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySignalServiceImpl.java index 9976f8ee6..3bb693765 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySignalServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySignalServiceImpl.java @@ -42,35 +42,29 @@ public class SaySignalServiceImpl implements RealDeviceService { Channel channel = plcGateway.getChannel(); switch (aspect) { case No: - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddjdq(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_r(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_g(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_y(), false, channel); break; case R: - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddjdq(), true, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dj2(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dxj(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_r(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_g(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_y(), false, channel); break; case G: - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddjdq(), true, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dj2(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dxj(), true, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_r(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_g(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_y(), false, channel); break; case Y: - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddjdq(), true, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dj2(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), true, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dxj(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_r(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_g(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_y(), true, channel); break; case RY: - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddjdq(), true, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dj2(), true, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dxj(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_r(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_g(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_y(), true, channel); break; default: log.error("不支持的显示:{}", aspect); @@ -90,76 +84,64 @@ public class SaySignalServiceImpl implements RealDeviceService { SaySignalConfigVO configVO = config.getConfigVO(); ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); - boolean r_dj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_dj()); - boolean r_dj1 = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_dj1()); - boolean r_dj2 = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_dj2()); - boolean r_lxy = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_lxy()); - boolean r_dxy = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_dxy()); - boolean r_dsbj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_dsbj()); - boolean r_yxy = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_yxy()); + boolean r_r = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_r()); + boolean r_g = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_g()); + boolean r_y = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_y()); SignalAspect aspect = null; - if (r_dj) { + if (!r_r && !r_g && !r_y) { + aspect = SignalAspect.No; + } else if (r_r && !r_g && !r_y) { aspect = SignalAspect.R; - } else if (r_dj1) { - if (r_lxy) { - aspect = SignalAspect.Y; - } else if (r_dxy) { - aspect = SignalAspect.G; - } else if (r_yxy && r_dj2) { - aspect = SignalAspect.RY; - } + } else if (!r_r && r_g && !r_y) { + aspect = SignalAspect.G; + } else if (!r_r && !r_g && r_y) { + aspect = SignalAspect.Y; + } else if (r_r && !r_g && r_y) { + aspect = SignalAspect.RY; } if (aspect == null) { - log.error("未知的状态:[{}]-[{}]-[{}]-[{}]-[{}]-[{}]-[{}]", r_dj, r_dj1, r_dj2, r_lxy, r_dxy, r_dsbj, r_yxy); + log.error("未知的信号组合[红:%s][绿:%s][黄:%s]", r_r, r_g, r_y); } else { vrSignal.apply(aspect); } if (vrSignal.isTurning()) { - boolean w_dj2 = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dj2()); - boolean w_lxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_lxj()); - boolean w_dxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dxj()); - boolean w_yxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_yxj()); - boolean w_ddjdq = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_ddjdq()); + boolean w_r = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_r()); + boolean w_g = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_g()); + boolean w_y = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_y()); int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); Channel channel = plcGateway.getChannel(); SignalAspect command = vrSignal.getCommand(); switch (command) { case No: - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddjdq(), w_ddjdq, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_r(), w_r, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_g(), w_g, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_y(), w_y, false, channel); break; case R: - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddjdq(), w_ddjdq, true, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dj2(), w_dj2, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dxj(), w_dxj, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_r(), w_r, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_g(), w_g, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_y(), w_y, false, channel); break; case G: - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddjdq(), w_ddjdq, true, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dj2(), w_dj2, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dxj(), w_dxj, true, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_r(), w_r, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_g(), w_g, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_y(), w_y, false, channel); break; case Y: - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddjdq(), w_ddjdq, true, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dj2(), w_dj2, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, true, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dxj(), w_dxj, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_r(), w_r, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_g(), w_g, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_y(), w_y, true, channel); break; case RY: - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddjdq(), w_ddjdq, true, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dj2(), w_dj2, true, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dxj(), w_dxj, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_r(), w_r, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_g(), w_g, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_y(), w_y, true, channel); break; default: - log.error("不支持的显示:{}", command); + log.error("不支持的显示:{}", aspect); break; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySwitchServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySwitchServiceImpl.java index 7762aa9d3..a8980aeb0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySwitchServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/say/SaySwitchServiceImpl.java @@ -42,7 +42,7 @@ public class SaySwitchServiceImpl implements RealDeviceService { return; } - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_sb(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_sj(), true, channel); switch (p) { case N: plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dc(), true, channel); @@ -80,11 +80,11 @@ public class SaySwitchServiceImpl implements RealDeviceService { int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); Channel channel = plcGateway.getChannel(); - boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sb()); + boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sj()); if (vrSwitch.isTurning()) { boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc()); boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc()); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sb(), w_sb, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sj(), w_sb, true, channel); switch (vrSwitch.getCommand()) { case NP: plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, true, channel); @@ -98,7 +98,7 @@ public class SaySwitchServiceImpl implements RealDeviceService { throw new IllegalStateException("Unexpected value: " + vrSwitch.getCommand()); } } else { - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sb(), w_sb, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sj(), w_sb, false, channel); } } } diff --git a/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java b/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java index 5d910cb1a..956cf8c00 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 @@ -10,10 +10,7 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSwitchConf import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.*; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj.HhcjIbpConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj.HhcjPsdConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say.SayIbpConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say.SayPsdConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say.SaySignalConfig; -import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say.SaySwitchConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say.*; 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; @@ -155,6 +152,9 @@ public class ProjectDeviceVO { case SWITCH: list.add(new SaySwitchConfig(deviceVO)); break; + case SECTION: + list.add(new SaySectionConfig(deviceVO)); + break; } } return list; 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 index 1d69377e3..ba5f53ca6 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/RealConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/RealConfigVO.java @@ -26,5 +26,9 @@ public abstract class RealConfigVO { return JsonUtils.writeValueAsString(this); } + /** + * 仿真设备code。 + * 目前用于实体设备配置与仿真设备连接 + */ public abstract String findDeviceCode(); } diff --git a/src/main/java/club/joylink/rtss/vo/client/project/say/SaySectionConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/say/SaySectionConfigVO.java new file mode 100644 index 000000000..4ad3c74b0 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/project/say/SaySectionConfigVO.java @@ -0,0 +1,23 @@ +package club.joylink.rtss.vo.client.project.say; + +import club.joylink.rtss.vo.client.project.RealConfigVO; +import lombok.Getter; + +@Getter +public class SaySectionConfigVO extends RealConfigVO { + private String sectionCode; + + /** + * 占用 + */ + private Integer r_occupied = 6; + + public SaySectionConfigVO() { + super(0, 32); + } + + @Override + public String findDeviceCode() { + return sectionCode; + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/project/say/SaySignalConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/say/SaySignalConfigVO.java index e24cf542e..e9edf8537 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/say/SaySignalConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/say/SaySignalConfigVO.java @@ -9,68 +9,34 @@ import lombok.Setter; public class SaySignalConfigVO extends RealConfigVO { private String signalCode = "S13289"; - /** - * DJ - */ - private Integer r_dj = 2; - - /** - * DJ1 - */ - private Integer r_dj1 = 3; - - /** - * DJ2 - */ - private Integer r_dj2 = 4; - - /** - * LXY - */ - private Integer r_lxy = 5; - - /** - * DXY - */ - private Integer r_dxy = 6; - /** * 灯丝报警 */ - private Integer r_dsbj = 7; + private Integer r_bj = 2; /** - * YXY + * 红 */ - private Integer r_yxy = 8; + private Integer r_r = 3; /** - * 2DJ + * 绿 */ - private Integer w_dj2 = 19; + private Integer r_g = 4; /** - * LXJ + * 黄 */ - private Integer w_lxj = 20; + private Integer r_y = 5; - /** - * DXJ - */ - private Integer w_dxj = 21; + private Integer w_r = 35; - /** - * YXJ - */ - private Integer w_yxj = 22; + private Integer w_g = 36; - /** - * 点灯继电器(用于点/灭灯) - */ - private Integer w_ddjdq = 23; + private Integer w_y = 37; public SaySignalConfigVO() { - super(0, 24); + super(0, 40); } @Override diff --git a/src/main/java/club/joylink/rtss/vo/client/project/say/SaySwitchConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/say/SaySwitchConfigVO.java index fe7e049af..08b42cb75 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/say/SaySwitchConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/say/SaySwitchConfigVO.java @@ -22,20 +22,20 @@ public class SaySwitchConfigVO extends RealConfigVO { /** * 定操 */ - private Integer w_dc = 16; + private Integer w_dc = 32; /** * 反操 */ - private Integer w_fc = 17; + private Integer w_fc = 33; /** - * 锁闭 + * 锁接 */ - private Integer w_sb = 18; + private Integer w_sj = 34; public SaySwitchConfigVO() { - super(0, 24); + super(0, 40); } @Override