From 5d15ba3240baae2c98b238cd96f981e4cc85fae9 Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Wed, 17 Apr 2024 10:42:05 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E6=94=B9]=E6=88=90=E9=83=BD=E5=B7=A5?= =?UTF-8?q?=E4=B8=9A=E8=81=8C=E4=B8=9A=E6=8A=80=E6=9C=AF=E5=AD=A6=E9=99=A2?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=BE=E5=A4=87=E8=81=94=E5=8A=A8=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/configuration/WebConfig.java | 2 + .../services/project/DeviceServiceImpl.java | 61 ++- .../psl/VirtualRealityPslService.java | 272 ++++++------ .../CI/device/CiSwitchControlService.java | 328 +++++++------- .../cbtc/GroupSimulationServiceImpl.java | 136 +++--- .../data/vr/VirtualRealityScreenDoor.java | 413 +++++++++--------- .../cbtc/data/vr/VirtualRealitySwitch.java | 234 +++++----- .../real/modbustcp/cgy/CgyPslConfig.java | 26 ++ .../real/modbustcp/cgy/CgyPslServiceImpl.java | 86 ++++ .../modbustcp/cgy/CgySignalServiceImpl.java | 143 +++--- .../modbustcp/cgy/CgySwitchServiceImpl.java | 16 +- .../onboard/TrainTargetUpdateService.java | 203 ++++----- .../vo/client/project/ProjectDeviceVO.java | 4 + .../vo/client/project/cgy/CgyPslConfigVO.java | 71 +++ .../project/cgy/CgySectionConfigVO.java | 10 +- .../client/project/cgy/CgySignalConfigVO.java | 56 ++- .../client/project/cgy/CgySwitchConfigVO.java | 21 +- 17 files changed, 1189 insertions(+), 893 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgyPslConfig.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgyPslServiceImpl.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/project/cgy/CgyPslConfigVO.java diff --git a/src/main/java/club/joylink/rtss/configuration/WebConfig.java b/src/main/java/club/joylink/rtss/configuration/WebConfig.java index b4bce0085..8d02fb100 100644 --- a/src/main/java/club/joylink/rtss/configuration/WebConfig.java +++ b/src/main/java/club/joylink/rtss/configuration/WebConfig.java @@ -70,6 +70,8 @@ public class WebConfig implements WebMvcConfigurer { whiteList.add("/api/v2/paper/composition/oldData/handle"); whiteList.add("/api/user/sync"); whiteList.add("/dataHandle"); + //modbus测试 + whiteList.add("/api/test/modbus/writeCoil"); registry.addInterceptor(authenticateInterceptor).excludePathPatterns(whiteList); } 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 35d270a39..da0b5eed1 100644 --- a/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java @@ -34,6 +34,8 @@ import club.joylink.rtss.vo.client.project.UDPClientConfigVO; import club.joylink.rtss.vo.client.project.UDPLowConfigVO; import club.joylink.rtss.vo.client.project.VrIbpConfigVO; import club.joylink.rtss.vo.client.project.VrpsdConfigVO; +import club.joylink.rtss.vo.client.project.cgy.CgyPslConfigVO; +import club.joylink.rtss.vo.client.project.cgy.CgySectionConfigVO; import club.joylink.rtss.vo.client.project.cgy.CgySignalConfigVO; import club.joylink.rtss.vo.client.project.cgy.CgySwitchConfigVO; import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO; @@ -579,7 +581,7 @@ public class DeviceServiceImpl implements DeviceService { plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name()); plcGateway.setCreator(accountVO.getId()); plcGateway.setCreateTime(now); - PlcGatewayConfigVO plcGatewayConfigVO = new PlcGatewayConfigVO(0, 16); + PlcGatewayConfigVO plcGatewayConfigVO = new PlcGatewayConfigVO(0, 64); plcGateway.setConfig(plcGatewayConfigVO.toJson()); list.add(plcGateway); //SIGNAL @@ -589,7 +591,7 @@ public class DeviceServiceImpl implements DeviceService { signal1.setType(ProjectDeviceType.SIGNAL.name()); signal1.setCreator(accountVO.getId()); signal1.setCreateTime(now); - signal1.setConfig(new CgySignalConfigVO(null, 2, 3, 4, 11, 12, 13).toJson()); + signal1.setConfig(new CgySignalConfigVO("S13289", 0, 1, 2, 3, 4, 5, 16, 17, 18, 19).toJson()); list.add(signal1); ProjectDevice signal2 = new ProjectDevice(); signal2.setProjectCode(projectCode); @@ -597,7 +599,7 @@ public class DeviceServiceImpl implements DeviceService { signal2.setType(ProjectDeviceType.SIGNAL.name()); signal2.setCreator(accountVO.getId()); signal2.setCreateTime(now); - signal2.setConfig(new CgySignalConfigVO(null, 5, 6, 7, 14, 15, 16).toJson()); + signal2.setConfig(new CgySignalConfigVO("X44854", 6, 7, 8, 9, 10, 11, 20, 21, 22, 23).toJson()); list.add(signal2); //SWITCH ProjectDevice aSwitch = new ProjectDevice(); @@ -606,17 +608,50 @@ public class DeviceServiceImpl implements DeviceService { aSwitch.setType(ProjectDeviceType.SWITCH.name()); aSwitch.setCreator(accountVO.getId()); aSwitch.setCreateTime(now); - aSwitch.setConfig(new CgySwitchConfigVO().toJson()); + aSwitch.setConfig(new CgySwitchConfigVO("W37779").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 CgySectionConfigVO().toJson()); -// list.add(section); + //PSL + ProjectDevice psl = new ProjectDevice(); + psl.setProjectCode(projectCode); + psl.setCode(prefix + "psl"); + psl.setType(ProjectDeviceType.PSL.name()); + psl.setCreator(accountVO.getId()); + psl.setCreateTime(now); + psl.setConfig(new CgyPslConfigVO("PF59020_PSL").toJson()); + list.add(psl); + //SECTION + ProjectDevice section106 = new ProjectDevice(); + section106.setProjectCode(projectCode); + section106.setCode(prefix + "section106"); + section106.setType(ProjectDeviceType.SECTION.name()); + section106.setCreator(accountVO.getId()); + section106.setCreateTime(now); + section106.setConfig(new CgySectionConfigVO(null, 35).toJson()); + list.add(section106); + ProjectDevice section104 = new ProjectDevice(); + section104.setProjectCode(projectCode); + section104.setCode(prefix + "section104"); + section104.setType(ProjectDeviceType.SECTION.name()); + section104.setCreator(accountVO.getId()); + section104.setCreateTime(now); + section104.setConfig(new CgySectionConfigVO(null, 36).toJson()); + list.add(section104); + ProjectDevice section101 = new ProjectDevice(); + section101.setProjectCode(projectCode); + section101.setCode(prefix + "section101"); + section101.setType(ProjectDeviceType.SECTION.name()); + section101.setCreator(accountVO.getId()); + section101.setCreateTime(now); + section101.setConfig(new CgySectionConfigVO(null, 37).toJson()); + list.add(section101); + ProjectDevice section102 = new ProjectDevice(); + section102.setProjectCode(projectCode); + section102.setCode(prefix + "section102"); + section102.setType(ProjectDeviceType.SECTION.name()); + section102.setCreator(accountVO.getId()); + section102.setCreateTime(now); + section102.setConfig(new CgySectionConfigVO(null, 38).toJson()); + list.add(section102); return list; } 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 d93436896..ae60ab7d5 100644 --- a/src/main/java/club/joylink/rtss/services/psl/VirtualRealityPslService.java +++ b/src/main/java/club/joylink/rtss/services/psl/VirtualRealityPslService.java @@ -12,152 +12,166 @@ import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl; import club.joylink.rtss.simulation.cbtc.event.SimulationPslStatusEvent; import club.joylink.rtss.vo.client.psl.PslStatus; +import java.util.HashMap; +import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import java.util.HashMap; -import java.util.Map; - @Service public class VirtualRealityPslService implements IVirtualRealityPslService { - @Autowired - private GroupSimulationService groupSimulationService; + @Autowired + private GroupSimulationService groupSimulationService; - @Autowired - private ApplicationContext applicationContext; + @Autowired + private ApplicationContext applicationContext; - @Autowired - private CiApiService ciApiService; + @Autowired + private CiApiService ciApiService; - @Override - public PslStatus getStatus(String group, String standCode) { - Simulation simulation = groupSimulationService.getSimulationByGroup(group); - SimulationDataRepository repository = simulation.getRepository(); - Map pslStatusMap = repository.getPslStatusMap(); - PslStatus status = pslStatusMap.get(standCode); - if (status != null) { - return status; + @Override + public PslStatus getStatus(String group, String standCode) { + Simulation simulation = groupSimulationService.getSimulationByGroup(group); + SimulationDataRepository repository = simulation.getRepository(); + Map pslStatusMap = repository.getPslStatusMap(); + PslStatus status = pslStatusMap.get(standCode); + if (status != null) { + return status; + } + Stand stand = repository.getByCode(standCode, Stand.class); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(stand.getPsd(), + String.format("%s没有屏蔽门", stand.debugStr())); + VirtualRealityPsl vrPsl = collectStatus(stand); + status = new PslStatus(vrPsl); + pslStatusMap.put(standCode, status); + return status; + } + + @Override + public void pressTheButton(Simulation simulation, String standCode, + VirtualRealityPsl.Button button) { + 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(); + switch (button) { + case YXJZ: + vrPsl.setYxjzKey(!vrPsl.isYxjzKey()); + break; + case HSJC: + vrPsl.setHsjcKey(!vrPsl.isHsjcKey()); + ciApiService.setOrCancelInterlockRelease(simulation, stand, vrPsl.isHsjcKey()); + break; + case KM: + ciApiService.openScreenDoor(simulation, stand.getCode(), + CiStandService.PsdCommandSource.PSL); + break; + case GM: + ciApiService.closeScreenDoor(simulation, stand.getCode(), + CiStandService.PsdCommandSource.PSL); + break; + case SD: + vrPsl.setSdButton(!vrPsl.isSdButton()); + break; + } + } + + @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: + vrPsl.setKmButton(on); + break; + case GM: + vrPsl.setGmButton(on); + 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); } - Stand stand = repository.getByCode(standCode, Stand.class); - BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(stand.getPsd(), - String.format("%s没有屏蔽门", stand.debugStr())); - VirtualRealityPsl vrPsl = collectStatus(stand); - status = new PslStatus(vrPsl); - pslStatusMap.put(standCode, status); - return status; - } - - @Override - public void pressTheButton(Simulation simulation, String standCode, VirtualRealityPsl.Button button) { - 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(); - switch (button) { - case YXJZ: - vrPsl.setYxjzKey(!vrPsl.isYxjzKey()); - break; - case HSJC: - vrPsl.setHsjcKey(!vrPsl.isHsjcKey()); - ciApiService.setOrCancelInterlockRelease(simulation, stand, vrPsl.isHsjcKey()); - break; - case KM: - ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL); - break; - case GM: - ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL); - break; - case SD: - vrPsl.setSdButton(!vrPsl.isSdButton()); - break; + break; + case GM: + if (on) { + ciApiService.closeScreenDoor(simulation, stand.getCode(), + CiStandService.PsdCommandSource.PSL); } + break; + case SD: + break; } + } - @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; + @Override + public void addJobs(Simulation simulation) { + simulation.addJobIfAbsent(Simulation.JobName.pslStatus, + () -> this.collectAndDispatcher(simulation), SimulationConstants.PSL_STATUS_COLLECT_RATE); + } + + public void collectAndDispatcher(Simulation simulation) { + SimulationDataRepository repository = simulation.getRepository(); + Map ibpStatusMap = repository.getPslStatusMap(); + Map collectionMap = new HashMap<>(); + for (Stand stand : repository.getStandList()) { + if (stand.getVrPsl() == null) { + continue; + } + VirtualRealityPsl vrPsl = this.collectStatus(stand); + PslStatus pslStatus = ibpStatusMap.get(stand.getCode()); + if (pslStatus == null) { + PslStatus newStatus = new PslStatus(vrPsl); + ibpStatusMap.put(stand.getCode(), newStatus); + collectionMap.put(stand.getCode(), newStatus); + } else { + PslStatus difference = pslStatus.collectDifference(vrPsl); + if (difference != null) { + collectionMap.put(stand.getCode(), difference); } - effective(simulation, vrPsl.getStand(), button, on); + } } + if (!CollectionUtils.isEmpty(collectionMap)) { + applicationContext.publishEvent( + new SimulationPslStatusEvent(this, simulation, collectionMap)); + } + } - 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, - () -> this.collectAndDispatcher(simulation), SimulationConstants.PSL_STATUS_COLLECT_RATE); - } - - public void collectAndDispatcher(Simulation simulation) { - SimulationDataRepository repository = simulation.getRepository(); - Map ibpStatusMap = repository.getPslStatusMap(); - Map collectionMap = new HashMap<>(); - for (Stand stand : repository.getStandList()) { - if (stand.getVrPsl() == null) - continue; - VirtualRealityPsl vrPsl = this.collectStatus(stand); - PslStatus pslStatus = ibpStatusMap.get(stand.getCode()); - if (pslStatus == null) { - PslStatus newStatus = new PslStatus(vrPsl); - ibpStatusMap.put(stand.getCode(), newStatus); - collectionMap.put(stand.getCode(), newStatus); - } else { - PslStatus difference = pslStatus.collectDifference(vrPsl); - if (difference != null) { - collectionMap.put(stand.getCode(), difference); - } - } - } - if (!CollectionUtils.isEmpty(collectionMap)) { - applicationContext.publishEvent(new SimulationPslStatusEvent(this, simulation, collectionMap)); - } - } - - private VirtualRealityPsl collectStatus(Stand stand) { - VirtualRealityPsl vrPsl = stand.getVrPsl(); - PSD psd = stand.getPsd(); - vrPsl.setQbgmLight(vrPsl.isSdButton() || psd.isCloseAndLock()); - vrPsl.setPslczLight(vrPsl.isSdButton() || vrPsl.isYxjzKey()); - vrPsl.setHsjcLight(vrPsl.isSdButton() || vrPsl.isHsjcKey()); - vrPsl.setKmLight(vrPsl.isSdButton() || !psd.isClose()); - vrPsl.setGmLight(vrPsl.isSdButton() || psd.isClose()); - return vrPsl; - } + private VirtualRealityPsl collectStatus(Stand stand) { + VirtualRealityPsl vrPsl = stand.getVrPsl(); + PSD psd = stand.getPsd(); + vrPsl.setQbgmLight(vrPsl.isSdButton() || psd.isCloseAndLock()); + vrPsl.setPslczLight(vrPsl.isSdButton() || vrPsl.isYxjzKey()); + vrPsl.setHsjcLight(vrPsl.isSdButton() || vrPsl.isHsjcKey()); + vrPsl.setKmLight(vrPsl.isSdButton() || !psd.isClose()); + vrPsl.setGmLight(vrPsl.isSdButton() || psd.isClose()); + return vrPsl; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSwitchControlService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSwitchControlService.java index 191ec7c59..7aedbfdd6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSwitchControlService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSwitchControlService.java @@ -6,192 +6,204 @@ import club.joylink.rtss.simulation.cbtc.data.map.Switch; import club.joylink.rtss.simulation.cbtc.data.map.SwitchElement; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; +import java.util.List; +import java.util.Objects; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.List; -import java.util.Objects; - @Component public class CiSwitchControlService { - @Autowired - private VirtualRealityDeviceService virtualRealityDeviceService; - /** - * 道岔单锁 - * - * @param aSwitch - */ - public void singleLock(Switch aSwitch) { - if (!aSwitch.isSingleLock()) { - aSwitch.setSingleLock(true); - } + @Autowired + private VirtualRealityDeviceService virtualRealityDeviceService; + + /** + * 道岔单锁 + * + * @param aSwitch + */ + public void singleLock(Switch aSwitch) { + if (!aSwitch.isSingleLock()) { + aSwitch.setSingleLock(true); } + } - /** - * 道岔单解 - * - * @param aSwitch - */ - public void singleUnlock(Switch aSwitch) { - if (aSwitch.isSingleLock()) { - aSwitch.setSingleLock(false); - } + /** + * 道岔单解 + * + * @param aSwitch + */ + public void singleUnlock(Switch aSwitch) { + if (aSwitch.isSingleLock()) { + aSwitch.setSingleLock(false); } + } - /** - * 封锁(封锁后,包含道岔的进路不能排列) - * - * @param aSwitch - */ - public void blockade(Switch aSwitch) { - if (!aSwitch.isBlockade()) { - aSwitch.setBlockade(true); - aSwitch.getA().setBlockade(true); - aSwitch.getB().setBlockade(true); - aSwitch.getC().setBlockade(true); - } - aSwitch.setInit(false); + /** + * 封锁(封锁后,包含道岔的进路不能排列) + * + * @param aSwitch + */ + public void blockade(Switch aSwitch) { + if (!aSwitch.isBlockade()) { + aSwitch.setBlockade(true); + aSwitch.getA().setBlockade(true); + aSwitch.getB().setBlockade(true); + aSwitch.getC().setBlockade(true); } + aSwitch.setInit(false); + } - /** - * 解封 - * - * @param aSwitch - */ - public void unblock(Switch aSwitch) { - if (aSwitch.isBlockade()) { - aSwitch.setBlockade(false); - aSwitch.getA().setBlockade(false); - aSwitch.getB().setBlockade(false); - aSwitch.getC().setBlockade(false); - } + /** + * 解封 + * + * @param aSwitch + */ + public void unblock(Switch aSwitch) { + if (aSwitch.isBlockade()) { + aSwitch.setBlockade(false); + aSwitch.getA().setBlockade(false); + aSwitch.getB().setBlockade(false); + aSwitch.getC().setBlockade(false); } + } - /** - * 强转道岔 - * - * @param simulation - * @param aSwitch - * @return - */ - public SwitchIndication forceTurn(Simulation simulation, Switch aSwitch) { - if (!aSwitch.isSectionOccupied()) { - return null; - } - if (aSwitch.isLocked()) { - return null; - } - // 设置强扳授权 - aSwitch.setForceTurnRemain(120 * 1000); - SwitchIndication pos = this.turn(simulation, aSwitch); - // 手动释放强扳 - aSwitch.setForceTurnRemain(0); - return pos; + /** + * 强转道岔 + * + * @param simulation + * @param aSwitch + * @return + */ + public SwitchIndication forceTurn(Simulation simulation, Switch aSwitch) { + if (!aSwitch.isSectionOccupied()) { + return null; } + if (aSwitch.isLocked()) { + return null; + } + // 设置强扳授权 + aSwitch.setForceTurnRemain(120 * 1000); + SwitchIndication pos = this.turn(simulation, aSwitch); + // 手动释放强扳 + aSwitch.setForceTurnRemain(0); + return pos; + } - /** - * 道岔转动 - * - * @param simulation - * @param aSwitch - * @return - */ - public SwitchIndication turn(Simulation simulation, Switch aSwitch) { - VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); - boolean lastTurnToN = vrSwitch.isLastTurnToN(); - if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) { - Switch linkedSwitch = aSwitch.queryLinkedSwitch(); - if (Objects.nonNull(linkedSwitch)) { - if (lastTurnToN) { - this.turn2ReversePosition(simulation, linkedSwitch); - } else { - this.turn2NormalPosition(simulation, linkedSwitch); - } - } - } + /** + * 道岔转动 + * + * @param simulation + * @param aSwitch + * @return + */ + public SwitchIndication turn(Simulation simulation, Switch aSwitch) { + VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); + boolean lastTurnToN; //最后转向的方向,主要是为了解决失表的情况下每次转动道岔要向不同方向转动 + if (vrSwitch.isPosN()) { + lastTurnToN = true; + } else if (vrSwitch.isPosR()) { + lastTurnToN = false; + } else { + lastTurnToN = vrSwitch.isLastTurnToN(); + } + if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) { + Switch linkedSwitch = aSwitch.queryLinkedSwitch(); + if (Objects.nonNull(linkedSwitch)) { if (lastTurnToN) { - if (this.turn2ReversePosition(simulation, aSwitch)) { - return SwitchIndication.R; - } + this.turn2ReversePosition(simulation, linkedSwitch); } else { - if (this.turn2NormalPosition(simulation, aSwitch)) { - return SwitchIndication.N; - } + this.turn2NormalPosition(simulation, linkedSwitch); } - return null; + } } + if (lastTurnToN) { + if (this.turn2ReversePosition(simulation, aSwitch)) { + return SwitchIndication.R; + } + } else { + if (this.turn2NormalPosition(simulation, aSwitch)) { + return SwitchIndication.N; + } + } + return null; + } - /** - * 道岔定操 - * - * @param simulation - * @param aSwitch - */ - public boolean turn2NormalPosition(Simulation simulation, Switch aSwitch) { - if (!this.checkTurnCondition(aSwitch)) { - return false; - } - VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); - this.virtualRealityDeviceService.control(simulation, vrSwitch, VirtualRealitySwitch.Operation.NP); - return true; + /** + * 道岔定操 + * + * @param simulation + * @param aSwitch + */ + public boolean turn2NormalPosition(Simulation simulation, Switch aSwitch) { + if (!this.checkTurnCondition(aSwitch)) { + return false; } + VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); + this.virtualRealityDeviceService.control(simulation, vrSwitch, + VirtualRealitySwitch.Operation.NP); + return true; + } - /** - * 道岔反操 - * - * @param simulation - * @param aSwitch - * @return - */ - public boolean turn2ReversePosition(Simulation simulation, Switch aSwitch) { - if (!this.checkTurnCondition(aSwitch)) { - return false; - } - VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); - this.virtualRealityDeviceService.control(simulation, vrSwitch, VirtualRealitySwitch.Operation.RP); - return true; + /** + * 道岔反操 + * + * @param simulation + * @param aSwitch + * @return + */ + public boolean turn2ReversePosition(Simulation simulation, Switch aSwitch) { + if (!this.checkTurnCondition(aSwitch)) { + return false; } + VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); + this.virtualRealityDeviceService.control(simulation, vrSwitch, + VirtualRealitySwitch.Operation.RP); + return true; + } - /** - * 检查道岔转动条件 - * - * @param aSwitch - * @return - */ - private boolean checkTurnCondition(Switch aSwitch) { - // 道岔锁闭 或者 道岔占用且无强扳授权,则不能转动 - return !(aSwitch.isLocked() || (aSwitch.isSectionOccupied() && aSwitch.getForceTurnRemain() <= 0)); - } + /** + * 检查道岔转动条件 + * + * @param aSwitch + * @return + */ + private boolean checkTurnCondition(Switch aSwitch) { + // 道岔锁闭 或者 道岔占用且无强扳授权,则不能转动 + return !(aSwitch.isLocked() || (aSwitch.isSectionOccupied() + && aSwitch.getForceTurnRemain() <= 0)); + } - /** - * 确保道岔位置正确 - */ - public boolean ensureSwitchPosCurrent(Simulation simulation, List switchElements, boolean guideSetting) { - boolean allOn = true; - if (switchElements == null) { - return true; - } - for (SwitchElement switchElement : switchElements) { - boolean onPos = this.turnRouteSwitch(simulation, switchElement); - if (!onPos && !(guideSetting && switchElement.getASwitch().isLoss() && switchElement.getASwitch().isGuideMasterLock())) { //不在正确位置并且不是办理引导进路中的引导总锁的失表道岔 - allOn = false; - } - } - return allOn; + /** + * 确保道岔位置正确 + */ + public boolean ensureSwitchPosCurrent(Simulation simulation, List switchElements, + boolean guideSetting) { + boolean allOn = true; + if (switchElements == null) { + return true; } + for (SwitchElement switchElement : switchElements) { + boolean onPos = this.turnRouteSwitch(simulation, switchElement); + if (!onPos && !(guideSetting && switchElement.getASwitch().isLoss() + && switchElement.getASwitch().isGuideMasterLock())) { //不在正确位置并且不是办理引导进路中的引导总锁的失表道岔 + allOn = false; + } + } + return allOn; + } - public boolean turnRouteSwitch(Simulation simulation, SwitchElement switchElement) { - boolean onPos = true; - if (!switchElement.isOnPosition()) { - onPos = false; - if (switchElement.isNormal()) { - this.turn2NormalPosition(simulation, switchElement.getASwitch()); - } else { - this.turn2ReversePosition(simulation, switchElement.getASwitch()); - } - } - return onPos; + public boolean turnRouteSwitch(Simulation simulation, SwitchElement switchElement) { + boolean onPos = true; + if (!switchElement.isOnPosition()) { + onPos = false; + if (switchElement.isNormal()) { + this.turn2NormalPosition(simulation, switchElement.getASwitch()); + } else { + this.turn2ReversePosition(simulation, switchElement.getASwitch()); + } } + return onPos; + } } 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 2fec80827..27ef6a0c8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java @@ -189,8 +189,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { Simulation.FunctionalType functionalType) { Objects.requireNonNull(mapId, "地图id不能为空"); Objects.requireNonNull(functionalType, "仿真功能类型不能为空"); - SimulationBuildParams params = this.prepareSimulationParams(loginUserInfoVO, mapId, - prdType, functionalType); + SimulationBuildParams params = this.prepareSimulationParams(loginUserInfoVO, mapId, prdType, + functionalType); String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), mapId); Simulation simulation = this.simulationLifeCycleService.create(params, group); @@ -212,17 +212,13 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { List parkTimeList = this.prepareParkTimeData(mapVO, loginUserInfoVO, mapId); // 获取操作定义数据 - List operationDefinitionList = this.iCommandService - .queryDefinitionsByLineCode(mapVO.getLineCode()); + List operationDefinitionList = this.iCommandService.queryDefinitionsByLineCode( + mapVO.getLineCode()); SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder(); // 都有的属性构造 - builder.loginUserInfo(loginUserInfoVO) - .createTime(LocalDateTime.now()) - .map(mapVO) - .userRunLevelList(runLevelList) - .userParkTimeList(parkTimeList) - .operationDefinitionList(operationDefinitionList) - .prodType(prdType) + builder.loginUserInfo(loginUserInfoVO).createTime(LocalDateTime.now()).map(mapVO) + .userRunLevelList(runLevelList).userParkTimeList(parkTimeList) + .operationDefinitionList(operationDefinitionList).prodType(prdType) .functionalType(functionalType); //运行图选择性构造 LocalDate runPlanDate = SimulationConstants.getRunPlanDate(); @@ -236,9 +232,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { schedulingPlanNewVO = this.schedulingService.queryCommonSchedulingPlanOfDay(mapId, runPlanDate); } else { - schedulingPlanNewVO = this.schedulingService - .querySchedulingPlanUserFirst(loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), - runPlanDate); + schedulingPlanNewVO = this.schedulingService.querySchedulingPlanUserFirst( + loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), runPlanDate); } builder.schedulingPlan(schedulingPlanNewVO); } @@ -294,15 +289,12 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { // 获取地图数据 MapVO mapVO = this.iMapService.getMapDetail(mapId); // 获取操作定义数据 - List operationDefinitionList = this.iCommandService - .queryDefinitionsByLineCode(mapVO.getLineCode()); + List operationDefinitionList = this.iCommandService.queryDefinitionsByLineCode( + mapVO.getLineCode()); SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder(); // 都有的属性构造 - builder.loginUserInfo(loginUserInfoVO) - .createTime(LocalDateTime.now()) - .map(mapVO) - .operationDefinitionList(operationDefinitionList) - .prodType(prdType) + builder.loginUserInfo(loginUserInfoVO).createTime(LocalDateTime.now()).map(mapVO) + .operationDefinitionList(operationDefinitionList).prodType(prdType) .functionalType(functionalType); //运行图选择性构造 LocalDate runPlanDate = SimulationConstants.getRunPlanDate(); @@ -314,9 +306,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { schedulingPlanNewVO = this.schedulingService.queryCommonSchedulingPlanOfDay(mapId, runPlanDate); } else { - schedulingPlanNewVO = this.schedulingService - .querySchedulingPlanUserFirst(loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), - runPlanDate); + schedulingPlanNewVO = this.schedulingService.querySchedulingPlanUserFirst( + loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), runPlanDate); } builder.schedulingPlan(schedulingPlanNewVO); } @@ -368,8 +359,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { confirmHasPermission(loginUserInfoVO.getAccountVO(), mapId, prodCode); MapPrdTypeEnum prdType = MapPrdTypeEnum.getMapPrdTypeEnumByCode(prodCode); - Simulation simulation = this.create(loginUserInfoVO, mapId, - prdType, + Simulation simulation = this.create(loginUserInfoVO, mapId, prdType, Simulation.FunctionalType.SIMULATION); if (Objects.equals(MapPrdTypeEnum.BIG_SCREEN, prdType)) { @@ -573,8 +563,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group); this.simulationLifeCycleService.checkErrorThrow(simulation); List tripPlanList = simulation.getRepository().getAllTripPlanList(); - List tripNumberList = tripPlanList.stream() - .map(TripPlan::getTripNumber) + List tripNumberList = tripPlanList.stream().map(TripPlan::getTripNumber) .collect(Collectors.toList()); return tripNumberList; } @@ -652,8 +641,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { RunPlanVO runPlan = this.iRunPlanTemplateService.getRunPlan(templateId); // 重新加载运行计划匹配的派班计划 Long userId = simulation.getBuildParams().getUser().getId(); - SchedulingPlanNewVO schedulingPlan = this.schedulingService - .querySchedulingPlanUserFirst(userId, templateId, SimulationConstants.getRunPlanDate()); + SchedulingPlanNewVO schedulingPlan = this.schedulingService.querySchedulingPlanUserFirst(userId, + templateId, SimulationConstants.getRunPlanDate()); this.simulationLifeCycleService.reloadRunPlan(simulation, runPlan, schedulingPlan); simulation.getRepository().clearChangeTrips(); //清除掉之前的车次计划变化信息 } @@ -673,8 +662,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { ScriptBO scriptBO = iScriptService.getScriptBOById(scriptId, simulation); iScriptSimulationService.scriptCoverSimulation(simulation, scriptBO); SocketMessageVO message = SocketMessageFactory.build( - WebSocketMessageType.Simulation_Script_Loaded, - simulation.getId(), true); + WebSocketMessageType.Simulation_Script_Loaded, simulation.getId(), true); Set userIds = simulation.getSimulationUserIds(); stompMessageService.sendToUser(userIds, message); } @@ -851,11 +839,9 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { @Override public List queryJointSimulationByUser(LoginUserInfoVO loginUserInfoVO) { List jointSimulationList = this.groupSimulationCache.queryAllJointSimulation(); - List userJointSimulationList = jointSimulationList.stream() - .filter(simulation -> - simulation.isSame(loginUserInfoVO.getProject()) && - simulation.containsUser(loginUserInfoVO.getAccountVO().getId())) - .collect(Collectors.toList()); + List userJointSimulationList = jointSimulationList.stream().filter( + simulation -> simulation.isSame(loginUserInfoVO.getProject()) && simulation.containsUser( + loginUserInfoVO.getAccountVO().getId())).collect(Collectors.toList()); List simulationVOList = SimulationVO.convert2VOList(userJointSimulationList); return simulationVOList; @@ -864,13 +850,11 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { @Override public void kickOut(String group, Long userId, AccountVO user) { Simulation simulation = this.getSimulationByGroup(group); - BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS - .assertTrue(simulation.isAdmin(user)); + BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertTrue(simulation.isAdmin(user)); SimulationUser simulationUser = simulation.querySimulationUserById(userId); if (Objects.nonNull(simulationUser)) { ProjectDeviceVO projectDevice = simulationUser.getProjectDevice(); - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED - .assertNull(projectDevice); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNull(projectDevice); this.kickOut(simulation, simulationUser); } } @@ -903,12 +887,12 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { Simulation simulation = this.getSimulationByGroup(group); 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, ProjectDeviceType.SECTION)); - realDeviceList = realDeviceList - .stream().filter(device -> displayDeviceTypes.contains(device.getDeviceType())) + Set displayDeviceTypes = new HashSet<>( + List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL, + ProjectDeviceType.PLC_GATEWAY, ProjectDeviceType.IBP, ProjectDeviceType.SECTION, + ProjectDeviceType.PSL)); + realDeviceList = realDeviceList.stream() + .filter(device -> displayDeviceTypes.contains(device.getDeviceType())) .collect(Collectors.toList()); } // List showList = null; @@ -953,8 +937,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { //校验目标成员类型 SimulationMember targetMember = simulation.getSimulationMemberById( initiateVO.getTargetMemberId()); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION - .assertEquals(targetMember.getType(), commandType.getMemberType(), "目标成员不正确"); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertEquals(targetMember.getType(), + commandType.getMemberType(), "目标成员不正确"); ScriptBO script = simulation.getScript(); if (script != null && script.isBgSet()) { //剧本背景已经保存 @@ -1008,15 +992,13 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { public void alarmConfirm(String group, List codes, AccountVO accountVO) { Simulation simulation = groupSimulationCache.getSimulationByGroup(group); simulation.getRepository().getAlarmList().stream() - .filter(atsAlarm -> codes.contains(atsAlarm.getCode())) - .filter(atsAlarm -> { + .filter(atsAlarm -> codes.contains(atsAlarm.getCode())).filter(atsAlarm -> { if (atsAlarm.isConfirmed()) { codes.remove(atsAlarm.getCode()); return false; } return true; - }) - .forEach(atsAlarm -> atsAlarm.confirm(accountVO, simulation.getCorrectSystemTime())); + }).forEach(atsAlarm -> atsAlarm.confirm(accountVO, simulation.getCorrectSystemTime())); this.applicationContext.publishEvent(new SimulationAlarmConfirmEvent(this, simulation, codes)); } @@ -1057,20 +1039,15 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { int end = pageNum * queryVO.getPageSize(); start = Math.min(start, logs.size() - 1); end = Math.min(end, logs.size()); - logs = logs.stream() - .filter(log -> { - if (queryVO.getStartTime() != null && log.getTime() - .isBefore(queryVO.getStartTime())) { - return false; - } - if (queryVO.getEndTime() != null && log.getTime().isAfter(queryVO.getEndTime())) { - return false; - } - return true; - }) - .skip(start) - .limit(end - start) - .collect(Collectors.toList()); + logs = logs.stream().filter(log -> { + if (queryVO.getStartTime() != null && log.getTime().isBefore(queryVO.getStartTime())) { + return false; + } + if (queryVO.getEndTime() != null && log.getTime().isAfter(queryVO.getEndTime())) { + return false; + } + return true; + }).skip(start).limit(end - start).collect(Collectors.toList()); pageVO.setList(logs); } else { pageVO.setPageNum(1); @@ -1173,23 +1150,21 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { Long mapId, String prdType) { if (accountVO.isThirdChildAccount()) { List loginInfos = this.loginSessionManager.getAllLoginUserInfos(); - Set thirdLoginList = loginInfos.stream() - .filter(loginUserInfoVO -> loginUserInfoVO.getAccountVO().isThirdChildAccount() + Set thirdLoginList = loginInfos.stream().filter( + loginUserInfoVO -> loginUserInfoVO.getAccountVO().isThirdChildAccount() && loginUserInfoVO.getAccountVO().getParentAccount() - .equals(accountVO.getParentAccount())) - .collect(Collectors.toSet()); + .equals(accountVO.getParentAccount())).collect(Collectors.toSet()); Set thirdLoginAccountIdList = thirdLoginList.stream() .map(loginUserInfoVO -> loginUserInfoVO.getAccountVO().getId().toString()) .collect(Collectors.toSet()); long count = this.simulationManager.getSimulationList().stream() .filter(simulation -> simulation instanceof Simulation) - .map(simulation -> ((Simulation) simulation)) - .filter(simulation -> { + .map(simulation -> ((Simulation) simulation)).filter(simulation -> { if (simulation.getBuildParams().getMap().getId().equals(mapId)) { - if (!((MapPrdTypeEnum.JOINT.getCode().equals(prdType) && - MapPrdTypeEnum.JOINT.equals(simulation.getBuildParams().getProdType())) || - (!MapPrdTypeEnum.JOINT.getCode().equals(prdType) && - !MapPrdTypeEnum.JOINT.equals(simulation.getBuildParams().getProdType())))) { + if (!((MapPrdTypeEnum.JOINT.getCode().equals(prdType) && MapPrdTypeEnum.JOINT.equals( + simulation.getBuildParams().getProdType())) || ( + !MapPrdTypeEnum.JOINT.getCode().equals(prdType) && !MapPrdTypeEnum.JOINT.equals( + simulation.getBuildParams().getProdType())))) { return false; } for (String accountId : simulation.getSimulationUserIds()) { @@ -1199,11 +1174,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { } } return false; - }) - .count(); - int sum = ups.stream() - .mapToInt(userPermissionVO -> userPermissionVO.getRemains()) - .sum(); + }).count(); + int sum = ups.stream().mapToInt(userPermissionVO -> userPermissionVO.getRemains()).sum(); if (sum <= count) { return false; } else { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java index 12c3c2253..7c8bfd449 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java @@ -9,79 +9,85 @@ import lombok.Setter; */ @Getter @Setter -public class VirtualRealityScreenDoor extends ControllableVrDevice { +public class VirtualRealityScreenDoor extends + ControllableVrDevice { - public boolean isCommandOpen() { - return Operation.K.equals(this.getCommand()); - } - - /** - * 道岔支持的操作 - */ - public enum Operation { - /** 开门 */ - K, - /** 关门 */ - G, - } - - /** - * 是否关闭 - */ - private boolean close; - - /** - * 是否开门到位 - */ - private boolean open2End; - - /** - * 是否锁闭 - */ - private boolean lock; - - /** - * psl盘互锁解除 - */ - private boolean pslInterlockRelease; - - /** - * ibp盘互锁解除 - */ - private boolean ibpInterlockRelease; - - private Fault fault; - - public VirtualRealityScreenDoor(String code, String name) { - super(code, name, MapElement.DeviceType.PSD, 3*1000); - this.close = true; - this.lock = true; - } - - @Override - public void reset() { - super.reset(); - this.close = true; - this.lock = true; - this.open2End = false; - this.pslInterlockRelease = false; - this.ibpInterlockRelease = false; - this.fault = null; - } - - @Override - protected boolean checkConditionBeforeControl(Operation command) { - if (command == null) - return false; - switch (command) { - case K: - return !open2End; - case G: - return !isLockAndClose(); - default: - throw new IllegalStateException("Unexpected value: " + command); - } + public boolean isCommandOpen() { + return Operation.K.equals(this.getCommand()); + } + + /** + * 道岔支持的操作 + */ + public enum Operation { + /** + * 开门 + */ + K, + /** + * 关门 + */ + G, + } + + /** + * 是否关闭 + */ + private boolean close; + + /** + * 是否开门到位 + */ + private boolean open2End; + + /** + * 是否锁闭 + */ + private boolean lock; + + /** + * psl盘互锁解除 + */ + private boolean pslInterlockRelease; + + /** + * ibp盘互锁解除 + */ + private boolean ibpInterlockRelease; + + private Fault fault; + + public VirtualRealityScreenDoor(String code, String name) { + super(code, name, MapElement.DeviceType.PSD, 3 * 1000); + this.close = true; + this.lock = true; + } + + @Override + public void reset() { + super.reset(); + this.close = true; + this.lock = true; + this.open2End = false; + this.pslInterlockRelease = false; + this.ibpInterlockRelease = false; + this.fault = null; + } + + @Override + protected boolean checkConditionBeforeControl(Operation command) { + if (command == null) { + return false; + } + switch (command) { + case K: + return !open2End; + case G: + return !isLockAndClose(); + default: + throw new IllegalStateException("Unexpected value: " + command); } + } // @Override // protected boolean checkConditionBeforeControl(Operation command) { @@ -101,148 +107,153 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice 0; - } - - public boolean isSettingClose() { - return Operation.G.equals(this.getCommand()) && this.getRemain() > 0; - } - - /** - * 开关门进行中 - */ - public void turning() { - if (this.lock) { - this.setLock(false); - } - if (this.close) { - this.close = false; - } - if (this.open2End) { - this.open2End = false; - } - } - - public enum Fault { - CANNOT_BE_CLOSED { - @Override - public void apply(VirtualRealityScreenDoor door) { - door.setFault(null); - door.control(Operation.K); - door.setFault(this); - } - }, - CANNOT_BE_OPENED { - @Override - public void apply(VirtualRealityScreenDoor door) { - door.setFault(null); - door.control(Operation.G); - door.setFault(this); - } - }, - NO_CLOSE_AND_LOCK { - @Override - public void apply(VirtualRealityScreenDoor door) { - door.setLock(false); - door.setFault(this); - } - }; - - public abstract void apply(VirtualRealityScreenDoor door); - - public void fix(VirtualRealityScreenDoor vrPSD) { - if (this.equals(vrPSD.getFault())) - vrPSD.setFault(null); + /** + * 全部关门 + */ + public void updateLockAndClose(boolean close, boolean lock) { + this.open2End = false; + this.close = close; + this.setLock(lock); + if (close && lock && this.isSettingClose()) { + this.finish(); + } + } + + public void updateOpen2End(boolean end) { + this.setLock(false); + this.close = false; + this.open2End = end; + if (end && this.isSettingOpen()) { + this.finish(); + } + } + + public boolean isSettingOpen() { + return Operation.K.equals(this.getCommand()) && this.getRemain() > 0; + } + + public boolean isSettingClose() { + return Operation.G.equals(this.getCommand()) && this.getRemain() > 0; + } + + /** + * 开关门进行中 + */ + public void turning() { + if (this.lock) { + this.setLock(false); + } + if (this.close) { + this.close = false; + } + if (this.open2End) { + this.open2End = false; + } + } + + public enum Fault { + CANNOT_BE_CLOSED { + @Override + public void apply(VirtualRealityScreenDoor door) { +// door.setFault(null); +// door.control(Operation.K); + door.setFault(this); + } + }, + CANNOT_BE_OPENED { + @Override + public void apply(VirtualRealityScreenDoor door) { +// door.setFault(null); +// door.control(Operation.G); + door.setFault(this); + } + }, + NO_CLOSE_AND_LOCK { + @Override + public void apply(VirtualRealityScreenDoor door) { + door.setLock(false); + door.setFault(this); + } + }; + + public abstract void apply(VirtualRealityScreenDoor door); + + public void fix(VirtualRealityScreenDoor vrPSD) { + if (this.equals(vrPSD.getFault())) { + vrPSD.setFault(null); } } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySwitch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySwitch.java index d67bc6dd3..3fce55e50 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySwitch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySwitch.java @@ -13,141 +13,147 @@ import lombok.Setter; @Setter public class VirtualRealitySwitch extends ControllableVrDevice { - private SwitchIndication p; + private SwitchIndication p; - // -------------运行逻辑控制参数------------- + // -------------运行逻辑控制参数------------- - private Fault fault; + private Fault fault; - private Operation lastOperation; + private Operation lastOperation; - @Override - public boolean control(Operation command) { - boolean control = super.control(command); - if (control && command != null) { - this.lastOperation = command; - } - return control; + @Override + public boolean control(Operation command) { + boolean control = super.control(command); + if (control && command != null) { + this.lastOperation = command; } + return control; + } - @Override - protected boolean checkConditionBeforeControl(Operation command) { - switch (command) { - case NP: - return !(SwitchIndication.N == this.p); - case RP: - return !(SwitchIndication.R == this.p); - } - return true; + @Override + protected boolean checkConditionBeforeControl(Operation command) { + switch (command) { + case NP: + return !(SwitchIndication.N == this.p); + case RP: + return !(SwitchIndication.R == this.p); } + return true; + } - @Override - protected void doTurn() { - this.p = SwitchIndication.NO; + @Override + protected void doTurn() { + this.p = SwitchIndication.NO; + } + + @Override + protected void doFinish(Operation command) { + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(command); + if (Fault.SQUEEZE.equals(this.getFault()) || Fault.SPLIT.equals(this.getFault())) { + return; } - - @Override - protected void doFinish(Operation command) { - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(command); - if (Fault.SQUEEZE.equals(this.getFault()) || Fault.SPLIT.equals(this.getFault())) { - return; - } - switch (command) { - case NP: - this.p = SwitchIndication.N; - break; - case RP: - this.p = SwitchIndication.R; - break; - } + switch (command) { + case NP: + this.p = SwitchIndication.N; + break; + case RP: + this.p = SwitchIndication.R; + break; } + } - public boolean isPosN() { - return SwitchIndication.N.equals(this.p); - } + public boolean isPosN() { + return SwitchIndication.N.equals(this.p); + } - public boolean isPosR() { - return SwitchIndication.R.equals(this.p); - } + public boolean isPosR() { + return SwitchIndication.R.equals(this.p); + } - public boolean isCommandNp() { - return Operation.NP.equals(this.getCommand()); - } + public boolean isCommandNp() { + return Operation.NP.equals(this.getCommand()); + } + /** + * 道岔支持的操作 + */ + public enum Operation { /** - * 道岔支持的操作 + * 定操 */ - public enum Operation { - /** 定操 */ - NP, - /** 反操 */ - RP, - } + NP, + /** + * 反操 + */ + RP, + } - public VirtualRealitySwitch(String code, String name, int turnTime) { - super(code, name, MapElement.DeviceType.SWITCH, turnTime * 1000); - this.p = SwitchIndication.N; - } + public VirtualRealitySwitch(String code, String name, int turnTime) { + super(code, name, MapElement.DeviceType.SWITCH, turnTime * 1000); + this.p = SwitchIndication.N; + } - @Override - public void reset() { - super.reset(); - this.p = SwitchIndication.N; - this.fault = null; - this.lastOperation = Operation.NP; - } + @Override + public void reset() { + super.reset(); + this.p = SwitchIndication.N; + this.fault = null; + this.lastOperation = Operation.NP; + } - public void apply(boolean normalPosition, boolean reversePosition) { - if (normalPosition) { - this.p = SwitchIndication.N; - } else if (reversePosition) { - this.p = SwitchIndication.R; - } else { - this.p = SwitchIndication.NO; + public void apply(boolean normalPosition, boolean reversePosition) { + if (normalPosition) { + this.p = SwitchIndication.N; + } else if (reversePosition) { + this.p = SwitchIndication.R; + } else { + this.p = SwitchIndication.NO; + } + if ((Operation.NP.equals(this.getCommand()) && SwitchIndication.N.equals(this.p)) || + (Operation.RP.equals(this.getCommand()) && SwitchIndication.R.equals(this.p))) { + this.finish(); + } + } + + //最后一次是否是转向定位 + public boolean isLastTurnToN() { + return this.lastOperation == Operation.NP; + } + + public enum Fault { + SPLIT { + @Override + public boolean apply(VirtualRealitySwitch vrSwitch) { + if (this.equals(vrSwitch.getFault())) { + return false; } - if ((Operation.NP.equals(this.getCommand()) && SwitchIndication.N.equals(this.p)) || - (Operation.RP.equals(this.getCommand()) && SwitchIndication.R.equals(this.p))) { - this.finish(); - } - } - - //最后一次是否是转向定位 - public boolean isLastTurnToN() { - return this.lastOperation == Operation.NP; - } - - public enum Fault { - SPLIT { - @Override - public boolean apply(VirtualRealitySwitch vrSwitch) { - if (this.equals(vrSwitch.getFault())) - return false; - vrSwitch.setFault(this); - vrSwitch.setP(SwitchIndication.NO); - return true; - } - }, - /** - * 挤岔 - */ - SQUEEZE { - @Override - public boolean apply(VirtualRealitySwitch vrSwitch) { - if (this.equals(vrSwitch.getFault())) - return false; - vrSwitch.setFault(this); - vrSwitch.setP(SwitchIndication.EX); - return true; - } - }; - - public abstract boolean apply(VirtualRealitySwitch vrSwitch); - - public void fix(VirtualRealitySwitch vrSwitch) { - if (this.equals(vrSwitch.getFault())) { - vrSwitch.setFault(null); - } + vrSwitch.setFault(this); + vrSwitch.setP(SwitchIndication.NO); + return true; + } + }, + /** + * 挤岔 + */ + SQUEEZE { + @Override + public boolean apply(VirtualRealitySwitch vrSwitch) { + if (this.equals(vrSwitch.getFault())) { + return false; } + vrSwitch.setFault(this); + vrSwitch.setP(SwitchIndication.EX); + return true; + } + }; + + public abstract boolean apply(VirtualRealitySwitch vrSwitch); + + public void fix(VirtualRealitySwitch vrSwitch) { + if (this.equals(vrSwitch.getFault())) { + vrSwitch.setFault(null); + } } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgyPslConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgyPslConfig.java new file mode 100644 index 000000000..92ac32c99 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgyPslConfig.java @@ -0,0 +1,26 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy; + +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.common.RealDeviceConfig; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.ProjectDeviceVO; +import club.joylink.rtss.vo.client.project.cgy.CgyPslConfigVO; +import club.joylink.rtss.vo.client.project.sdy.SdyPslConfigVO; +import lombok.Getter; + +@Getter +public class CgyPslConfig extends RealDeviceConfig { + + private CgyPslConfigVO configVO; + + public CgyPslConfig(ProjectDeviceVO projectDevice) { + super(projectDevice); + if (projectDevice != null) { + this.configVO = JsonUtils.read(projectDevice.getConfig(), CgyPslConfigVO.class); + } + } + + @Override + public String findDeviceCode() { + return configVO.findDeviceCode(); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgyPslServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgyPslServiceImpl.java new file mode 100644 index 000000000..6386ce8d9 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgyPslServiceImpl.java @@ -0,0 +1,86 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy; + +import club.joylink.rtss.services.psl.IVirtualRealityPslService; +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl.Button; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.common.PlcGateway; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.common.RealDeviceConfig; +import club.joylink.rtss.vo.client.project.cgy.CgyPslConfigVO; +import io.netty.buffer.ByteBuf; +import io.netty.channel.Channel; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +@Slf4j +@Component +public class CgyPslServiceImpl implements RealDeviceService { + + @Autowired + private PlcGatewayService plcGatewayService; + @Autowired + private IVirtualRealityPslService virtualRealityPslService; + + @Override + public boolean canHandle(RealDeviceConfig deviceConfig) { + return deviceConfig instanceof CgyPslConfig; + } + + @Override + public void init(Simulation simulation, RealDeviceConfig deviceConfig) { +// PlcGateway plcGateway = simulation.getPlcGateway(); +// CgyPslConfigVO configVO = ((CgyPslConfig) deviceConfig).getConfigVO(); +// Channel channel = plcGateway.getChannel(); +// int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); +// plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_gm_light(), false, channel); +// plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_km_light(), false, channel); +// plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_psl_light(), false, channel); +// plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_gbsj_light(), false, channel); + } + + @Override + public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { + PlcGateway plcGateway = simulation.queryPlcGatewayDevice(); + if (plcGateway == null) { + return; + } + CgyPslConfig config = (CgyPslConfig) deviceConfig; + CgyPslConfigVO configVO = config.getConfigVO(); + if (!StringUtils.hasText(configVO.getPslCode())) { + return; + } + VirtualRealityPsl vrPsl = simulation.getRepository() + .getByCode(configVO.getPslCode(), VirtualRealityPsl.class); + ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), + configVO.getQuantity()); + boolean r_km_btn = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_km_btn()); + boolean r_gm_btn = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_gm_btn()); + boolean r_yxjz_btn = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_yxjz_btn()); + boolean r_hsjc_key = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_hsjc_key()); + boolean r_xy_btn = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xy_btn()); + boolean w_km_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_km_light()); + boolean w_gm_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_gm_light()); + boolean w_yxcz_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_yxcz_light()); + boolean w_gbsj_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_gbsj_light()); + //向vrPSL同步操作 + virtualRealityPslService.updateStatus(simulation, vrPsl, Button.KM, r_km_btn); + virtualRealityPslService.updateStatus(simulation, vrPsl, Button.GM, r_gm_btn); + virtualRealityPslService.updateStatus(simulation, vrPsl, Button.YXJZ, r_yxjz_btn); + virtualRealityPslService.updateStatus(simulation, vrPsl, Button.HSJC, r_hsjc_key); + //向实体PSL同步状态 + int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); + Channel channel = plcGateway.getChannel(); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_km_light(), + w_km_light, vrPsl.isKmLight(), channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_gm_light(), + w_gm_light, vrPsl.isGmLight(), channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxcz_light(), + w_yxcz_light, vrPsl.isYxjzKey(), channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_gbsj_light(), + w_gbsj_light, vrPsl.isQbgmLight(), channel); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgySignalServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgySignalServiceImpl.java index 73086b7dd..bc5229e83 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgySignalServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgySignalServiceImpl.java @@ -46,29 +46,34 @@ public class CgySignalServiceImpl implements RealDeviceService { Channel channel = plcGateway.getChannel(); switch (aspect) { case No: - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), false, channel); break; case R: - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), true, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), false, channel); break; case G: - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), true, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), true, channel); break; case Y: - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), false, channel); break; case RY: - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), true, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), false, channel); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), false, channel); break; default: log.error("不支持的显示:{}", aspect); @@ -91,84 +96,82 @@ public class CgySignalServiceImpl implements RealDeviceService { ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); - boolean r_r = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_red()); - boolean r_g = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_green()); - boolean r_y = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_yellow()); - - SignalAspect aspect = null; - if (!r_r && !r_g && !r_y) { - aspect = SignalAspect.No; - } else if (r_r && !r_g && !r_y) { - aspect = SignalAspect.R; - } 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("未知的信号组合[红:%s][绿:%s][黄:%s]", r_r, r_g, r_y); - } else { - vrSignal.apply(aspect); - } - + //同步信号显示 + SignalAspect aspect = getAspect(deviceStatus, configVO); + vrSignal.apply(aspect); + //驱动信号显示 if (vrSignal.isTurning()) { - boolean w_r = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_red()); - boolean w_g = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_green()); - boolean w_y = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_yellow()); + boolean w_ddj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_ddj()); + boolean w_lxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_lxj()); + boolean w_yxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_yxj()); + boolean w_zxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_zxj()); int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); Channel channel = plcGateway.getChannel(); SignalAspect command = vrSignal.getCommand(); switch (command) { case No: - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, false, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj, true, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj, + false, + channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj, false, channel); break; case R: - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, true, - channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, + false, + channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj, + false, + channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj, false, channel); break; case G: - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, false, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj, + false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, true, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g, true, - channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj, true, + channel); break; case Y: - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, false, - channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, - true, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, true, + channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj, + false, + channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj, + false, channel); break; case RY: - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, true, - channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj, false, channel); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, - true, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, + false, + channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj, true, + channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj, + false, channel); break; default: @@ -177,4 +180,22 @@ public class CgySignalServiceImpl implements RealDeviceService { } } } + + private SignalAspect getAspect(ByteBuf deviceStatus, CgySignalConfigVO configVO) { + boolean r_ddj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_ddj()); + boolean r_lxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_lxj()); + boolean r_yxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_yxj()); + boolean r_zxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_zxj()); + if (r_yxj) { + return SignalAspect.RY; + } else if (r_lxj && r_zxj) { + return SignalAspect.G; + } else if (r_lxj) { + return SignalAspect.Y; + } else if (!r_ddj) { + return SignalAspect.R; + } else { + return SignalAspect.No; + } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgySwitchServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgySwitchServiceImpl.java index cc06e105a..6914600a6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgySwitchServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgySwitchServiceImpl.java @@ -35,7 +35,7 @@ public class CgySwitchServiceImpl implements RealDeviceService { CgySwitchConfigVO configVO = config.getConfigVO(); int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); Channel channel = plcGateway.getChannel(); - plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_sj(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_js(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dc(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_fc(), false, channel); } @@ -63,7 +63,7 @@ public class CgySwitchServiceImpl implements RealDeviceService { boolean r_fb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_fb()); vrSwitch.apply(r_db, r_fb); - //以下操作实体设备的逻辑中,防止继电器长期接通的逻辑将定反操视为技能,共用3秒冷却,技能持续时间也是3秒 + //以下操作实体设备的逻辑中,防止继电器长期接通的逻辑,将定反操视为技能,共用3秒冷却,技能持续时间也是3秒 if (config.isEnd()) { //此判断既可视为操作是否冷却,也可视为持续时间是否耗尽 config.sync(r_db, r_fb); release(deviceStatus, baseAddr, configVO, channel); //操作持续时间耗尽后断开所有继电器 @@ -87,10 +87,10 @@ public class CgySwitchServiceImpl implements RealDeviceService { private void turnToN(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO, Channel channel) { - boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sj()); + boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_js()); boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc()); boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc()); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sj(), w_sb, true, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_js(), w_sb, true, channel); plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, true, channel); @@ -100,10 +100,10 @@ public class CgySwitchServiceImpl implements RealDeviceService { private void turnToP(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO, Channel channel) { - boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sj()); + boolean w_js = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_js()); boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc()); boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc()); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sj(), w_sb, true, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_js(), w_js, true, channel); plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, false, channel); @@ -113,10 +113,10 @@ public class CgySwitchServiceImpl implements RealDeviceService { private void release(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO, Channel channel) { - boolean w_sj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sj()); + boolean w_sj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_js()); boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc()); boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc()); - plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sj(), w_sj, false, + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_js(), w_sj, false, channel); plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, false, channel); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/TrainTargetUpdateService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/TrainTargetUpdateService.java index bb772fa11..dafbb4b5f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/TrainTargetUpdateService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/TrainTargetUpdateService.java @@ -10,119 +10,124 @@ import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; -import org.springframework.stereotype.Component; - import java.util.List; import java.util.Objects; +import org.springframework.stereotype.Component; @Component public class TrainTargetUpdateService { - public static final String Model_Name = "TrainTargetUpdate"; - public static final int Rate = 5000; - public void addJobs(Simulation simulation) { - simulation.addJob(Model_Name, () -> this.run(simulation), Rate); + public static final String Model_Name = "TrainTargetUpdate"; + public static final int Rate = 5000; + + public void addJobs(Simulation simulation) { + simulation.addJob(Model_Name, () -> this.run(simulation), Rate); + } + + public void run(Simulation simulation) { + SimulationDataRepository repository = simulation.getRepository(); + List onlineTrain = repository.getOnlineTrainList(); + for (VirtualRealityTrain train : onlineTrain) { + TrainInfo trainInfo = repository.findSupervisedTrainByGroup(train.getGroupNumber()); + if (trainInfo == null) { + continue; + } + Section target = train.getTarget(); + Section newTarget = this.queryArriveTarget(train, trainInfo); + if (newTarget != null && !Objects.equals(target, newTarget)) { + train.setTarget(newTarget); + } } + } - public void run(Simulation simulation) { - SimulationDataRepository repository = simulation.getRepository(); - List onlineTrain = repository.getOnlineTrainList(); - for (VirtualRealityTrain train : onlineTrain) { - TrainInfo trainInfo = repository.getSupervisedTrainByGroup(train.getGroupNumber()); -// if (!trainInfo.isManualTrain()) { -// continue; -// } - Section target = train.getTarget(); - Section newTarget = this.queryArriveTarget(train, trainInfo); - if (newTarget != null && !Objects.equals(target, newTarget)) { - train.setTarget(newTarget); - } + private Section queryArriveTarget4Manual(VirtualRealityTrain train, TrainInfo trainInfo, + Section target) { + SectionPosition headPosition = train.getHeadPosition(); + boolean right = train.isRight(); + Section newTarget = target; + Section temp = headPosition.getSection(); + for (int i = 0; i < 50; i++) { + if (temp == null) { + break; } - } - - private Section queryArriveTarget4Manual(VirtualRealityTrain train, TrainInfo trainInfo, Section target) { - SectionPosition headPosition = train.getHeadPosition(); - boolean right = train.isRight(); - Section newTarget = target; - Section temp = headPosition.getSection(); - for (int i = 0; i < 50; i++) { - if (temp == null) - break; - if (!temp.isFunctionTrack()) { - temp = temp.findNextRunningSectionBaseRealSwitch(right); - continue; - } - Signal signal = temp.getSignalOf(right); - if (signal != null && !signal.isMainAspect()) { - newTarget = temp; - if (temp.isFunctionTrack()) - break; - } - if (temp.isNormalStandTrack() || temp.isTransferTrack()) { - if (temp.isNormalStandTrack()) { - if (temp.getStandList().stream().anyMatch(stand -> stand.isJumpStop(train.getGroupNumber()))) { //该列车应在站台跳停 - temp = temp.findNextRunningSectionBaseRealSwitch(right); - continue; - } - } - if (!temp.equals(headPosition.getSection())) { //列车还未到达该区段 - newTarget = temp; - break; - } else { - if (!temp.getCode().equals(trainInfo.getActualArriveStandTrack())) { //列车未在该区段停车 - SectionPosition maxStopPosition = CalculateService - .calculateNextPositionByStartAndLen(temp.buildStopPointPosition(right), - right, SimulationConstants.PARK_POINT_MAX_OFFSET, false); //最远停车点 - if (maxStopPosition.isAheadOf(headPosition, right)) { //该区段最远停车点在车头前方 - newTarget = temp; - break; - } - } - } - } + if (!temp.isFunctionTrack()) { + temp = temp.findNextRunningSectionBaseRealSwitch(right); + continue; + } + Signal signal = temp.getSignalOf(right); + if (signal != null && !signal.isMainAspect()) { + newTarget = temp; + if (temp.isFunctionTrack()) { + break; + } + } + if (temp.isNormalStandTrack() || temp.isTransferTrack()) { + if (temp.isNormalStandTrack()) { + if (temp.getStandList().stream() + .anyMatch(stand -> stand.isJumpStop(train.getGroupNumber()))) { //该列车应在站台跳停 temp = temp.findNextRunningSectionBaseRealSwitch(right); + continue; + } } - return newTarget; + if (!temp.equals(headPosition.getSection())) { //列车还未到达该区段 + newTarget = temp; + break; + } else { + if (!temp.getCode().equals(trainInfo.getActualArriveStandTrack())) { //列车未在该区段停车 + SectionPosition maxStopPosition = CalculateService + .calculateNextPositionByStartAndLen(temp.buildStopPointPosition(right), + right, SimulationConstants.PARK_POINT_MAX_OFFSET, false); //最远停车点 + if (maxStopPosition.isAheadOf(headPosition, right)) { //该区段最远停车点在车头前方 + newTarget = temp; + break; + } + } + } + } + temp = temp.findNextRunningSectionBaseRealSwitch(right); } + return newTarget; + } - private Section queryArriveTarget(VirtualRealityTrain train, TrainInfo trainInfo) { - Section newTarget = null; - MaService.Ma ma = train.getMa2(); - if (ma == null) - return null; - SectionPosition eoaPosition = ma.getEoaPosition(); - Section eoaSection = eoaPosition.getSection(); - SectionPosition headPosition = train.getHeadPosition(); - boolean right = train.isRight(); - Section headSection = headPosition.getSection(); - Section section = headSection; - for (int i = 0; i < 100; i++) { - if (section.equals(eoaSection) && newTarget == null) { //已经遍历到移动授权终点区段且中途未找到功能轨 - newTarget = section; - break; - } - if (section.isFunctionTrack()) { - if (section.isNormalStandTrack()) { - if (train.isHold()) { - newTarget = section; - break; - } - if (!section.getCode().equals(trainInfo.getActualArriveStandTrack())) { //列车没有抵达该站台轨的信息 - newTarget = section; - break; - } - } else { - newTarget = section; - } - } - section = section.findNextRunningSectionBaseRealSwitch(right); - if (section == null) { - break; - } else { - continue; - } + private Section queryArriveTarget(VirtualRealityTrain train, TrainInfo trainInfo) { + Section newTarget = null; + MaService.Ma ma = train.getMa2(); + if (ma == null) { + return null; + } + SectionPosition eoaPosition = ma.getEoaPosition(); + Section eoaSection = eoaPosition.getSection(); + SectionPosition headPosition = train.getHeadPosition(); + boolean right = train.isRight(); + Section headSection = headPosition.getSection(); + Section section = headSection; + for (int i = 0; i < 100; i++) { + if (section.equals(eoaSection) && newTarget == null) { //已经遍历到移动授权终点区段且中途未找到功能轨 + newTarget = section; + break; + } + if (section.isFunctionTrack()) { + if (section.isNormalStandTrack()) { + if (train.isHold()) { + newTarget = section; + break; + } + if (!section.getCode().equals(trainInfo.getActualArriveStandTrack())) { //列车没有抵达该站台轨的信息 + newTarget = section; + break; + } + } else { + newTarget = section; } - return newTarget; + } + section = section.findNextRunningSectionBaseRealSwitch(right); + if (section == null) { + break; + } else { + continue; + } } + return newTarget; + } } 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 167913155..4392fc1bc 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 @@ -4,6 +4,7 @@ import club.joylink.rtss.constants.ProjectCode; import club.joylink.rtss.constants.ProjectDeviceType; import club.joylink.rtss.entity.ProjectDevice; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgyPslConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySectionConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySignalConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySwitchConfig; @@ -175,6 +176,9 @@ public class ProjectDeviceVO { case SECTION: list.add(new CgySectionConfig(deviceVO)); break; + case PSL: + list.add(new CgyPslConfig(deviceVO)); + break; } } return list; diff --git a/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgyPslConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgyPslConfigVO.java new file mode 100644 index 000000000..55eea2a2a --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgyPslConfigVO.java @@ -0,0 +1,71 @@ +package club.joylink.rtss.vo.client.project.cgy; + +import club.joylink.rtss.vo.client.project.RealConfigVO; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class CgyPslConfigVO extends RealConfigVO { + + private String pslCode; + + /** + * 开门按钮 + */ + private Integer r_km_btn = 32; + + /** + * 关门按钮 + */ + private Integer r_gm_btn = 33; + + /** + * 就地(允许/禁止)按钮 + */ + private Integer r_yxjz_btn = 34; + + /** + * 互锁解除钥匙(true-互锁解除) + */ + private Integer r_hsjc_key = 46; + + /** + * 消音按钮(不知道消的啥音) + */ + private Integer r_xy_btn = 47; + + /** + * 控制-开门指示灯 + */ + private Integer w_km_light = 48; + + /** + * 控制-关门指示灯 + */ + private Integer w_gm_light = 49; + + /** + * 控制-psl允许操作指示灯 + */ + private Integer w_yxcz_light = 50; + + /** + * 控制-关闭锁紧指示灯 + */ + private Integer w_gbsj_light = 55; + + public CgyPslConfigVO(String pslCode) { + this(); + this.pslCode = pslCode; + } + + public CgyPslConfigVO() { + super(0, 64); + } + + @Override + public String findDeviceCode() { + return pslCode; + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgySectionConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgySectionConfigVO.java index 01f9e0e8c..740c74c4b 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgySectionConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgySectionConfigVO.java @@ -11,10 +11,16 @@ public class CgySectionConfigVO extends RealConfigVO { /** * 出清 */ - private Integer r_occupied = 6; + private Integer r_occupied; + + public CgySectionConfigVO(String sectionCode, Integer r_occupied) { + this(); + this.sectionCode = sectionCode; + this.r_occupied = r_occupied; + } public CgySectionConfigVO() { - super(0, 32); + super(0, 64); } @Override diff --git a/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgySignalConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgySignalConfigVO.java index 7623456b8..054c10c7a 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgySignalConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgySignalConfigVO.java @@ -1,46 +1,62 @@ package club.joylink.rtss.vo.client.project.cgy; import club.joylink.rtss.vo.client.project.RealConfigVO; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +/** + * 红灯常亮DDJ吸起红灯灭 Lxj吸起黄灯 YxJ红黄 LXJ、ZXJ吸起绿灯 + */ @Getter @Setter public class CgySignalConfigVO extends RealConfigVO { private String signalCode; - /** - * 红 - */ - private Integer r_red; + private Integer r_ddj; + + private Integer r_lxj; /** - * 绿 + * 主灯丝报警 */ - private Integer r_green; + private Integer r_dj; + + private Integer r_zxj; + + private Integer r_yxj; /** - * 黄 + * 副灯丝报警 */ - private Integer r_yellow; + private Integer r_dj2; - private Integer w_red; + private Integer w_ddj; - private Integer w_green; + private Integer w_lxj; - private Integer w_yellow; + private Integer w_zxj; - public CgySignalConfigVO(String signalCode, Integer r_red, - Integer r_green, Integer r_yellow, Integer w_red, Integer w_green, Integer w_yellow) { - super(0, 24); + private Integer w_yxj; + + public CgySignalConfigVO(String signalCode, Integer r_ddj, + Integer r_lxj, Integer r_dj, Integer r_zxj, Integer r_yxj, Integer r_dj2, Integer w_ddj, + Integer w_lxj, Integer w_zxj, Integer w_yxj) { + this(); this.signalCode = signalCode; - this.r_red = r_red; - this.r_green = r_green; - this.r_yellow = r_yellow; - this.w_red = w_red; - this.w_green = w_green; - this.w_yellow = w_yellow; + this.r_ddj = r_ddj; + this.r_lxj = r_lxj; + this.r_dj = r_dj; + this.r_zxj = r_zxj; + this.r_yxj = r_yxj; + this.r_dj2 = r_dj2; + this.w_ddj = w_ddj; + this.w_lxj = w_lxj; + this.w_zxj = w_zxj; + this.w_yxj = w_yxj; } public CgySignalConfigVO() { diff --git a/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgySwitchConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgySwitchConfigVO.java index a07de0558..97a30b01d 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgySwitchConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/cgy/CgySwitchConfigVO.java @@ -10,30 +10,39 @@ public class CgySwitchConfigVO extends RealConfigVO { private String switchCode; + /** + * 解锁表示 + */ + private Integer r_js = 12; /** * 定表 */ - private Integer r_db = 0; + private Integer r_db = 13; /** * 反表 */ - private Integer r_fb = 1; + private Integer r_fb = 14; /** - * 锁接 + * 解锁 */ - private Integer w_sj = 8; + private Integer w_js = 24; /** * 定操 */ - private Integer w_dc = 9; + private Integer w_dc = 25; /** * 反操 */ - private Integer w_fc = 10; + private Integer w_fc = 26; + + public CgySwitchConfigVO(String switchCode) { + this(); + this.switchCode = switchCode; + } public CgySwitchConfigVO() { super(0, 32);