From 39482d6b1dfd0c5d6e8993b7dc78aa0f6c63c82f Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 5 Jan 2021 17:47:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=8F=E7=94=B5=E9=99=A2=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E9=97=A8=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/project/DeviceController.java | 6 + .../rtss/services/project/DeviceService.java | 2 + .../services/project/DeviceServiceImpl.java | 66 +++++++++ .../cbtc/GroupSimulationServiceImpl.java | 12 +- .../real/modbustcp/sdy/SdyPsdConfig.java | 20 +++ .../real/modbustcp/sdy/SdyPsdServiceImpl.java | 75 ++++++++++ .../real/modbustcp/sdy/SdyPslConfig.java | 20 +++ .../real/modbustcp/sdy/SdyPslServiceImpl.java | 130 ++++++++++++++++++ .../vo/client/project/ProjectDeviceVO.java | 33 ++++- .../vo/client/project/sdy/SdyPsdConfigVO.java | 59 ++++++++ .../vo/client/project/sdy/SdyPslConfigVO.java | 71 ++++++++++ 11 files changed, 485 insertions(+), 9 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPsdConfig.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPsdServiceImpl.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPslConfig.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPslServiceImpl.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPsdConfigVO.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPslConfigVO.java diff --git a/src/main/java/club/joylink/rtss/controller/project/DeviceController.java b/src/main/java/club/joylink/rtss/controller/project/DeviceController.java index fe997f83b..61a906bfa 100644 --- a/src/main/java/club/joylink/rtss/controller/project/DeviceController.java +++ b/src/main/java/club/joylink/rtss/controller/project/DeviceController.java @@ -181,4 +181,10 @@ public class DeviceController { UserVO userVO) { this.deviceService.addOrUpdateGzbDeviceConfig(userVO); } + + @PostMapping("/sdy/addOrUpdate") + public void addOrUpdateSdyDeviceConfig(@ApiIgnore @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) + UserVO userVO) { + this.deviceService.addOrUpdateSdyDeviceConfig(userVO); + } } diff --git a/src/main/java/club/joylink/rtss/services/project/DeviceService.java b/src/main/java/club/joylink/rtss/services/project/DeviceService.java index 07ae5b4b4..f67d261bf 100644 --- a/src/main/java/club/joylink/rtss/services/project/DeviceService.java +++ b/src/main/java/club/joylink/rtss/services/project/DeviceService.java @@ -177,4 +177,6 @@ public interface DeviceService { void addOrUpdateXtyDeviceConfig(UserVO userVO); void addOrUpdateGzbDeviceConfig(UserVO userVO); + + void addOrUpdateSdyDeviceConfig(UserVO userVO); } 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 ee19cbf1d..c73551aea 100644 --- a/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java @@ -12,6 +12,8 @@ import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.project.*; import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO; import club.joylink.rtss.vo.client.project.gzb.GzbSwitchConfigVO; +import club.joylink.rtss.vo.client.project.sdy.SdyPsdConfigVO; +import club.joylink.rtss.vo.client.project.sdy.SdyPslConfigVO; import club.joylink.rtss.vo.client.project.xty.XtyPsdConfigVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; @@ -360,6 +362,70 @@ public class DeviceServiceImpl implements DeviceService { } } + @Override + public void addOrUpdateSdyDeviceConfig(UserVO userVO) { + // 删除旧配置 + ProjectDeviceExample example = new ProjectDeviceExample(); + example.createCriteria() + .andProjectCodeEqualTo(Project.SDY.name()) + .andTypeIn(ProjectDeviceType.PlcDeviceList().stream() + .map(Enum::name).collect(Collectors.toList())); + this.projectDeviceDAO.deleteByExample(example); + // 保存新配置 + List list = this.buildSdyProjectDevices(userVO); + for (ProjectDevice projectDevice : list) { + this.projectDeviceDAO.insert(projectDevice); + } + } + + private List buildSdyProjectDevices(UserVO userVO) { + LocalDateTime now = LocalDateTime.now(); + List list = new ArrayList<>(); +// // 教员机 +// list.add(buildIm(Project.SDY, userVO.getId())); + // PLC网关 + ProjectDevice plcGateway = new ProjectDevice(); + plcGateway.setProjectCode(Project.SDY.name()); + plcGateway.setCode("sdy-gateway"); + plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name()); + plcGateway.setCreator(userVO.getId()); + plcGateway.setCreateTime(now); + PlcGatewayConfigVO plcGatewayConfigVO = new PlcGatewayConfigVO(0, 16); + plcGateway.setConfig(plcGatewayConfigVO.toJson()); + list.add(plcGateway); + // 屏蔽门 + ProjectDevice psd = new ProjectDevice(); + psd.setProjectCode(Project.SDY.name()); + psd.setCode("sdy-psd"); + psd.setType(ProjectDeviceType.PSD.name()); + psd.setCreator(userVO.getId()); + psd.setCreateTime(now); + SdyPsdConfigVO psdConfigVO = new SdyPsdConfigVO(); + psd.setConfig(psdConfigVO.toJson()); + list.add(psd); + // PSL盘 + ProjectDevice psl = new ProjectDevice(); + psl.setProjectCode(Project.SDY.name()); + psl.setCode("sdy-psl"); + psl.setType(ProjectDeviceType.PSL.name()); + psl.setCreator(userVO.getId()); + psl.setCreateTime(now); + SdyPslConfigVO pslConfigVO = new SdyPslConfigVO(); + psl.setConfig(pslConfigVO.toJson()); + list.add(psl); + return list; + } + + private ProjectDevice buildIm(Project project, Long creatorId) { + ProjectDevice im = new ProjectDevice(); + im.setProjectCode(project.name()); + im.setCode(project.name().toLowerCase() + "-" +"im"); + im.setType(ProjectDeviceType.IM.name()); + im.setCreator(creatorId); + im.setCreateTime(LocalDateTime.now()); + return im; + } + private List buildGzbProjectDevices(UserVO userVO) { LocalDateTime now = LocalDateTime.now(); List list = new ArrayList<>(); 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 89b652c75..2545beb8b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java @@ -3,6 +3,7 @@ package club.joylink.rtss.simulation.cbtc; import club.joylink.rtss.configuration.configProp.OtherConfig; import club.joylink.rtss.configuration.configProp.WeChatConfig; import club.joylink.rtss.constants.MapPrdTypeEnum; +import club.joylink.rtss.constants.ProjectDeviceType; import club.joylink.rtss.constants.SystemEnv; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.*; @@ -782,7 +783,10 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { @Override public List getRealDeviceList(String group) { Simulation simulation = this.getSimulationByGroup(group); - List realDeviceList = simulation.getRealDeviceList(); + Set displayDeviceTypes = + new HashSet<>(List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL, ProjectDeviceType.PLC_GATEWAY)); + List realDeviceList = simulation.getRealDeviceList() + .stream().filter(device -> displayDeviceTypes.contains(device.getDeviceType())).collect(Collectors.toList()); // List showList = null; // if (!CollectionUtils.isEmpty(realDeviceList)) { // showList = realDeviceList.stream() @@ -880,9 +884,9 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { @Override public void changePassengerFlow(String group, Long passengerFlowId) { - if(passengerFlowSimulateService.changePassengerFlow(group,passengerFlowId)){ + if (passengerFlowSimulateService.changePassengerFlow(group, passengerFlowId)) { Simulation simulation = findSimulationByGroup(group); - RunAsPlanParam param =new RunAsPlanParam(simulation.getCorrectSystemTime().toLocalTime(),null); + RunAsPlanParam param = new RunAsPlanParam(simulation.getCorrectSystemTime().toLocalTime(), null); runAsPlan(group, param); } } @@ -893,7 +897,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { //根据时间筛选 if (!CollectionUtils.isEmpty(logs)) { if (queryVO.getStartTime() != null || queryVO.getEndTime() != null) { - logs = logs.stream().filter(log->{ + logs = logs.stream().filter(log -> { boolean flag = true; if (queryVO.getStartTime() != null) { flag = flag && !log.getTime().isBefore(queryVO.getStartTime()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPsdConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPsdConfig.java new file mode 100644 index 000000000..7d19447f1 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPsdConfig.java @@ -0,0 +1,20 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy; + +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.sdy.SdyPsdConfigVO; +import lombok.Getter; + +@Getter +public class SdyPsdConfig extends RealDeviceConfig { + + private SdyPsdConfigVO configVO; + + public SdyPsdConfig(ProjectDeviceVO projectDevice) { + super(projectDevice); + if (projectDevice != null) { + this.configVO = JsonUtils.read(projectDevice.getConfig(), SdyPsdConfigVO.class); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPsdServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPsdServiceImpl.java new file mode 100644 index 000000000..b5babd6e8 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPsdServiceImpl.java @@ -0,0 +1,75 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; +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.device.PlcGateway; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.vo.client.project.sdy.SdyPsdConfigVO; +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; + +@Slf4j +@Component +public class SdyPsdServiceImpl implements RealDeviceService { + + @Autowired + private PlcGatewayService plcGatewayService; + + @Override + public boolean canHandle(RealDeviceConfig deviceConfig) { + return deviceConfig instanceof SdyPsdConfig; + } + + @Override + public void init(Simulation simulation, RealDeviceConfig deviceConfig) { + PlcGateway plcGateway = simulation.getPlcGateway(); + SdyPsdConfigVO configVO = ((SdyPsdConfig) deviceConfig).getConfigVO(); + Channel channel = plcGateway.getChannel(); + int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_kgm(), false, channel); //关门 + } + + @Override + public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { + VirtualRealityScreenDoor vrPsd = (VirtualRealityScreenDoor) deviceConfig.getMapElement(); + if (vrPsd == null) + return; + PlcGateway plcGateway = simulation.queryPlcGatewayDevice(); + if (plcGateway == null) { + log.error(String.format("仿真[%s]没有plc", simulation.getGroup())); + return; + } + + SdyPsdConfig config = (SdyPsdConfig) deviceConfig; + SdyPsdConfigVO configVO = config.getConfigVO(); + ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); + boolean km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_km()); + boolean gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_gm()); + boolean w_kgm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_kgm()); + + int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); + Channel channel = plcGateway.getChannel(); + if (vrPsd.isSettingClose()) { + if (!gm && km) { + this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_kgm(), w_kgm, false, channel); + } + } + if (vrPsd.isSettingOpen()) { + if (!km && gm) { + this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_kgm(), w_kgm, true, channel); + } + } + + if (!km && !gm) + vrPsd.turning(); + if (km && !gm) + vrPsd.updateOpen2End(true); + if (gm && !km) + vrPsd.updateLockAndClose(true, true); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPslConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPslConfig.java new file mode 100644 index 000000000..8dfbd527d --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPslConfig.java @@ -0,0 +1,20 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy; + +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.sdy.SdyPslConfigVO; +import lombok.Getter; + +@Getter +public class SdyPslConfig extends RealDeviceConfig { + + private SdyPslConfigVO configVO; + + public SdyPslConfig(ProjectDeviceVO projectDevice) { + super(projectDevice); + if (projectDevice != null) { + this.configVO = JsonUtils.read(projectDevice.getConfig(), SdyPslConfigVO.class); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPslServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPslServiceImpl.java new file mode 100644 index 000000000..e25d18d01 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPslServiceImpl.java @@ -0,0 +1,130 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy; + +import club.joylink.rtss.constants.ProjectDeviceType; +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; +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.device.PlcGateway; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.vo.client.project.sdy.SdyPsdConfigVO; +import club.joylink.rtss.vo.client.project.sdy.SdyPslConfigVO; +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 java.util.Objects; +import java.util.Optional; + +@Slf4j +@Component +public class SdyPslServiceImpl implements RealDeviceService { + + @Autowired + private PlcGatewayService plcGatewayService; + + @Override + public boolean canHandle(RealDeviceConfig deviceConfig) { + return deviceConfig instanceof SdyPslConfig; + } + + @Override + public void init(Simulation simulation, RealDeviceConfig deviceConfig) { + + PlcGateway plcGateway = simulation.getPlcGateway(); + SdyPslConfigVO configVO = ((SdyPslConfig) deviceConfig).getConfigVO(); + Channel channel = plcGateway.getChannel(); + int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_gm_light(), true, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_km_light(), false, channel); + } + + @Override + public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { + PlcGateway plcGateway = simulation.queryPlcGatewayDevice(); + if (plcGateway == null) + return; + SdyPslConfig config = (SdyPslConfig) deviceConfig; + SdyPslConfigVO configVO = config.getConfigVO(); + ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); + boolean r_gm_button = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_gm_button()); + boolean r_km_button = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_km_button()); + boolean r_sd_button = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sd_button()); + boolean r_yxjz_key = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xyjz_key()); + boolean r_hsjc_key = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_hsjc_key()); + boolean w_gm_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_gm_light()); + boolean w_km_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_km_light()); + boolean w_psl_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_psl_light()); + boolean w_hsjc_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_hsjc_light()); + int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); + Channel channel = plcGateway.getChannel(); + //查找真实设备和vr设备 + SdyPsdConfig realPsd = null; + VirtualRealityScreenDoor vrPsd = null; + Optional optional = simulation.getRealDeviceList().stream() + .filter(device -> device.getDeviceType().equals(ProjectDeviceType.PSD)).findAny(); + if (optional.isPresent()) + realPsd = (SdyPsdConfig) optional.get(); + if (realPsd != null) + vrPsd = (VirtualRealityScreenDoor) realPsd.getMapElement(); + //真实屏蔽门的状态等 + SdyPsdConfigVO psdConfigVO = null; + Integer psdBaseAddr = null; + Boolean psd_r_gm = null; + Boolean psd_w_kgm = null; + if (realPsd != null) { + psdConfigVO = realPsd.getConfigVO(); + psdBaseAddr = plcGateway.getConfig().getAddr() + psdConfigVO.getAddr(); + ByteBuf psdStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, psdConfigVO.getAddr(), psdConfigVO.getQuantity()); + psd_r_gm = RealDeviceConfig.getBitOf(psdStatus, psdConfigVO.getR_gm()); + psd_w_kgm = RealDeviceConfig.getBitOf(psdStatus, psdConfigVO.getW_kgm()); + } + //所有灯的状态控制 + if (r_sd_button) { //试灯按钮按下 + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_gm_light(), w_gm_light, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_km_light(), w_km_light, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_psl_light(), w_psl_light, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_hsjc_light(), w_hsjc_light, true, channel); + } else { + //开关门灯(读取状态从真实设备) + if (Objects.equals(true, psd_r_gm)) { + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_gm_light(), w_gm_light, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_km_light(), w_km_light, false, channel); + } else { + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_gm_light(), w_gm_light, false, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_km_light(), w_km_light, true, channel); + } + //psl操作灯 + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_psl_light(), w_psl_light, r_yxjz_key, channel); + //互锁解除灯 + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_hsjc_light(), w_hsjc_light, r_hsjc_key, channel); + } + //psl操作灯和开关门按钮 + if (r_yxjz_key) { + if (vrPsd != null) { + if (r_gm_button && !r_km_button) { + if (!vrPsd.isSettingClose() && !vrPsd.isClose()) { + vrPsd.startSetting(false); + } + } + if (r_km_button && !r_gm_button) { + if (!vrPsd.isOpen2End()) { + vrPsd.startSetting(true); + } + } + } else if (realPsd != null) { + if (r_gm_button && !r_km_button) { + plcGatewayService.checkEqualAndWriteSingleCoil(psdBaseAddr, psdConfigVO.getW_kgm(), psd_w_kgm, false, channel); + } + if (r_km_button && !r_gm_button) { + plcGatewayService.checkEqualAndWriteSingleCoil(psdBaseAddr, psdConfigVO.getW_kgm(), psd_w_kgm, true, channel); + } + } + } + //互锁解除钥匙 + if (vrPsd != null) + vrPsd.setInterlockRelease(r_hsjc_key); + } +} 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 84820790c..128fb7446 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 @@ -1,17 +1,19 @@ package club.joylink.rtss.vo.client.project; -import com.fasterxml.jackson.annotation.JsonIgnore; +import club.joylink.rtss.constants.Project; +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.device.PlcGateway; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSignalConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSwitchConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.*; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPsdConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPslConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig; -import club.joylink.rtss.constants.Project; -import club.joylink.rtss.constants.ProjectDeviceType; -import club.joylink.rtss.entity.ProjectDevice; -import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; @@ -100,12 +102,33 @@ public class ProjectDeviceVO { case HEB: { return heb1DeviceConfigConvert(voList); } + case SDY: { + return sdyDeviceConfigConvert(voList); + } } } return list; } + private static List sdyDeviceConfigConvert(List voList) { + List list = new ArrayList<>(); + for (ProjectDeviceVO deviceVO : voList) { + switch (deviceVO.getType()) { + case PSD: + list.add(new SdyPsdConfig(deviceVO)); + break; + case PLC_GATEWAY: + list.add(new PlcGateway(deviceVO)); + break; + case PSL: + list.add(new SdyPslConfig(deviceVO)); + break; + } + } + return list; + } + private static List heb1DeviceConfigConvert(List voList) { List list = new ArrayList<>(); for (ProjectDeviceVO deviceVO : voList) { diff --git a/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPsdConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPsdConfigVO.java new file mode 100644 index 000000000..0da4db38c --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPsdConfigVO.java @@ -0,0 +1,59 @@ +package club.joylink.rtss.vo.client.project.sdy; + +import club.joylink.rtss.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +@Getter +@Setter +@ApiModel("苏电院屏蔽门配置对象") +@NoArgsConstructor +public class SdyPsdConfigVO { + + @ApiModelProperty("关联的站台屏蔽门code") + @NotBlank(message = "关联的站台屏蔽门code不能为空") + private String psdCode; + + @ApiModelProperty(value = "网关位开始地址") + private Integer addr = 0; + + @ApiModelProperty(value = "位数量") + private Integer quantity = 16; + + /*---------------- 屏蔽门 ----------------*/ + /** + * 是否开门 + */ + private Integer r_km = 0; + + /** + * 是否关门 + */ + private Integer r_gm = 1; + + /** + * 控制开/关门,0关1开 + */ + private Integer w_kgm = 8; + + /** + * 控制警报 + */ + private Integer w_jb = 9; + + public SdyPsdConfigVO(Integer addr, Integer quantity) { + this.addr = addr; + this.quantity = quantity; + } + + @JsonIgnore + public String toJson() { + return JsonUtils.writeValueAsString(this); + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPslConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPslConfigVO.java new file mode 100644 index 000000000..4b5335909 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/project/sdy/SdyPslConfigVO.java @@ -0,0 +1,71 @@ +package club.joylink.rtss.vo.client.project.sdy; + +import club.joylink.rtss.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +public class SdyPslConfigVO { + private String psdCode; + + @ApiModelProperty(value = "网关位开始地址") + private Integer addr = 0; + + @ApiModelProperty(value = "位数量") + private Integer quantity = 16; + + /** + * 试灯按钮 + */ + private Integer r_sd_button = 2; + + /** + * 开门按钮 + */ + private Integer r_km_button = 3; + + /** + * 关门按钮 + */ + private Integer r_gm_button = 4; + + /** + * 允许/禁止钥匙 + */ + private Integer r_xyjz_key = 5; + + /** + * 互锁解除钥匙(true-互锁解除) + */ + private Integer r_hsjc_key = 6; + + /** + * 控制-开门指示灯 + */ + private Integer w_km_light = 10; + + /** + * 控制-关门指示灯 + */ + private Integer w_gm_light = 11; + + /** + * 控制-psl操作指示灯 + */ + private Integer w_psl_light = 12; + + /** + * 控制-互锁解除指示灯 + */ + private Integer w_hsjc_light = 13; + + @JsonIgnore + public String toJson() { + return JsonUtils.writeValueAsString(this); + } +}