南宁设备逻辑
This commit is contained in:
parent
4e5e83202c
commit
3189b6b51a
@ -0,0 +1,41 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
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.simulation.cbtc.device.real.modbustcp.gzb.GzbSignalConfig;
|
||||
import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@Slf4j
|
||||
public abstract class GxsdService implements RealDeviceService {
|
||||
|
||||
@Autowired
|
||||
@Getter
|
||||
protected PlcGatewayService plcGatewayService;
|
||||
|
||||
@Override
|
||||
public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
|
||||
//设置plc 继电器的工作模式,此配置不在configVo中体现
|
||||
PlcGateway plcGateway = simulation.getPlcGateway();
|
||||
Channel channel = plcGateway.getChannel();
|
||||
log.info("设置plc继电器...");
|
||||
this.plcGatewayService.writeSingleCoil(0, 14, true, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测继电器
|
||||
*/
|
||||
public boolean checkElectricRelay(ByteBuf signalStatus) {
|
||||
boolean rReplay = RealDeviceConfig.getBitOf(signalStatus, 6);
|
||||
// boolean outReplay = RealDeviceConfig.getBitOf(signalStatus, 14);
|
||||
log.info("读取继电器... val:" + rReplay);
|
||||
return rReplay;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd;
|
||||
|
||||
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.gxsd.GxsdSignalConfigVO;
|
||||
import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class GxsdSignalConfig extends RealDeviceConfig {
|
||||
|
||||
private GxsdSignalConfigVO config;
|
||||
|
||||
public GxsdSignalConfig(ProjectDeviceVO deviceVO) {
|
||||
super(deviceVO);
|
||||
if (Objects.nonNull(deviceVO.getConfig())) {
|
||||
this.config = JsonUtils.read(deviceVO.getConfig(), GxsdSignalConfigVO.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findDeviceCode() {
|
||||
return config.findDeviceCode();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
GxsdSignalConfigVO vo = new GxsdSignalConfigVO();
|
||||
System.out.println(JsonUtils.writeValueAsString(vo));
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal.Fault;
|
||||
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.simulation.cbtc.device.real.modbustcp.gzb.GzbSignalConfig;
|
||||
import club.joylink.rtss.vo.client.project.gxsd.GxsdSignalConfigVO;
|
||||
import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class GxsdSignalServiceImpl extends GxsdService {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canHandle(RealDeviceConfig deviceConfig) {
|
||||
return deviceConfig instanceof GxsdSignalConfig;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
|
||||
super.init(simulation, deviceConfig);
|
||||
GxsdSignalConfig switchConfig = (GxsdSignalConfig) deviceConfig;
|
||||
GxsdSignalConfigVO config = switchConfig.getConfig();
|
||||
PlcGateway plcGateway = simulation.getPlcGateway();
|
||||
Channel channel = plcGateway.getChannel();
|
||||
int baseAddr = plcGateway.getConfig().getAddr() + config.getAddr();
|
||||
this.plcGatewayService.writeSingleCoil(baseAddr, config.getW5(), true, channel);
|
||||
this.plcGatewayService.writeSingleCoil(baseAddr, config.getW3(), false, channel);
|
||||
this.plcGatewayService.writeSingleCoil(baseAddr, config.getW4(), false, channel);
|
||||
this.plcGatewayService.writeSingleCoil(baseAddr, config.getW7(), false, channel);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
|
||||
PlcGateway plcGateway = simulation.queryPlcGatewayDevice();
|
||||
GxsdSignalConfig switchConfig = (GxsdSignalConfig) deviceConfig;
|
||||
VirtualRealitySignal vrSignal = ((VirtualRealitySignal) switchConfig.getMapElement());
|
||||
|
||||
if (Objects.isNull(vrSignal)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GxsdSignalConfigVO config = switchConfig.getConfig();
|
||||
Channel channel = plcGateway.getChannel();
|
||||
int baseAddr = plcGateway.getConfig().getAddr() + config.getAddr();
|
||||
ByteBuf signalStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, config.getAddr(), config.getQuantity());
|
||||
|
||||
boolean br0 = RealDeviceConfig.getBitOf(signalStatus, config.getR1());//红灯
|
||||
boolean br3 = RealDeviceConfig.getBitOf(signalStatus, config.getR3());//绿灯或黄灯
|
||||
boolean w3 = RealDeviceConfig.getBitOf(signalStatus, config.getW3()); //输出 绿灯
|
||||
boolean w4 = RealDeviceConfig.getBitOf(signalStatus, config.getW4()); //输出 黄灯
|
||||
boolean w5 = RealDeviceConfig.getBitOf(signalStatus, config.getW5()); //输出 灭灯 开启 默认就是红灯
|
||||
boolean w7 = RealDeviceConfig.getBitOf(signalStatus, config.getW7()); //输出 红黄灯
|
||||
|
||||
SignalAspect aspect = null;
|
||||
if (br0 && w5) {
|
||||
aspect = SignalAspect.No;
|
||||
} else if (br0) {
|
||||
aspect = SignalAspect.R;
|
||||
} else if (br3 && w3) {
|
||||
aspect = SignalAspect.G;
|
||||
} else if (br3 && w4) {
|
||||
aspect = SignalAspect.Y;
|
||||
} else if (w7) {
|
||||
aspect = SignalAspect.RY;
|
||||
}
|
||||
log.info("当前信号灯状态 读红[{}],读绿黄[{}],写红[{}],写黄[{}],写灭灯[{}],写红黄[{}]", br0, br3, w3, w4, w5, w7);
|
||||
if (Objects.nonNull(aspect)) {
|
||||
vrSignal.apply(aspect);
|
||||
}
|
||||
if (!this.checkElectricRelay(signalStatus)) {
|
||||
return;
|
||||
}
|
||||
if (!vrSignal.isTurning()) {
|
||||
return;
|
||||
}
|
||||
switch (vrSignal.getCommand()) {
|
||||
case RY: {
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW3(), w3, false, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW4(), w4, false, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW5(), w5, false, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW7(), w7, true, channel);
|
||||
break;
|
||||
}
|
||||
|
||||
case G: {
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW3(), w3, true, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW4(), w4, false, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW5(), w5, false, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW7(), w7, false, channel);
|
||||
break;
|
||||
}
|
||||
case Y: {
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW3(), w3, false, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW4(), w4, true, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW5(), w5, false, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW7(), w7, false, channel);
|
||||
break;
|
||||
}
|
||||
case R:
|
||||
case No: {
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW3(), w3, false, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW4(), w4, false, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW5(), w5, true, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW7(), w7, false, channel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd;
|
||||
|
||||
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.gxsd.GxsdSignalConfigVO;
|
||||
import club.joylink.rtss.vo.client.project.gxsd.GxsdSwitchConfigVO;
|
||||
import club.joylink.rtss.vo.client.project.gzb.GzbSwitchConfigVO;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class GxsdSwitchConfig extends RealDeviceConfig {
|
||||
|
||||
private GxsdSwitchConfigVO config;
|
||||
/**
|
||||
* 下令定操
|
||||
*/
|
||||
private boolean turnToN;
|
||||
|
||||
/**
|
||||
* 下令反操
|
||||
*/
|
||||
private boolean turnToP;
|
||||
|
||||
/**
|
||||
* 定反操继电器接通时刻。 3s后断开继电器,防止继电器长期接通。
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
public GxsdSwitchConfig(ProjectDeviceVO deviceVO) {
|
||||
super(deviceVO);
|
||||
if (Objects.nonNull(deviceVO.getConfig())) {
|
||||
this.config = JsonUtils.read(deviceVO.getConfig(), GxsdSwitchConfigVO.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findDeviceCode() {
|
||||
return config.findDeviceCode();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求转向定位
|
||||
*
|
||||
* @return 是否可以操作继电器以转向定位
|
||||
*/
|
||||
public boolean turnToN() {
|
||||
if (turnToN) {
|
||||
return false;
|
||||
} else {
|
||||
turnToN = true;
|
||||
turnToP = false;
|
||||
startTime = LocalDateTime.now();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求转向反位
|
||||
*
|
||||
* @return 是否可以操作继电器以转向反位
|
||||
*/
|
||||
public boolean turnToP() {
|
||||
if (turnToP) {
|
||||
return false;
|
||||
} else {
|
||||
turnToN = false;
|
||||
turnToP = true;
|
||||
startTime = LocalDateTime.now();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定反操的继电器操作是否可以结束。
|
||||
*/
|
||||
public boolean isEnd() {
|
||||
return startTime == null || LocalDateTime.now().isAfter(startTime.plusSeconds(3));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 同步道岔状态表示以限定此时道岔可以进行的操作。 此方法是为了防止类似以下情况:通过仿真将道岔操到定位,再手摇道岔到反位,则此时仿真中道岔表示为反位, 只能执行定操,又因此处记录上一次操作也是定操,不予执行,导致死循环:仿真中无法再操作道岔了。
|
||||
*/
|
||||
public void sync(boolean r_db, boolean r_fb) {
|
||||
if (r_db) {
|
||||
turnToN = true;
|
||||
turnToP = false;
|
||||
} else if (r_fb) {
|
||||
turnToN = false;
|
||||
turnToP = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService;
|
||||
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.say.SaySwitchConfig;
|
||||
import club.joylink.rtss.vo.client.project.gxsd.GxsdSwitchConfigVO;
|
||||
import club.joylink.rtss.vo.client.project.say.SaySwitchConfigVO;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class GxsdSwitchServiceImpl extends GxsdService {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(RealDeviceConfig deviceConfig) {
|
||||
return deviceConfig instanceof GxsdSwitchConfig;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
|
||||
super.init(simulation, deviceConfig);
|
||||
PlcGateway plcGateway = simulation.queryPlcGatewayDevice();
|
||||
if (plcGateway == null) {
|
||||
return;
|
||||
}
|
||||
GxsdSwitchConfig switchConfig = (GxsdSwitchConfig) deviceConfig;
|
||||
GxsdSwitchConfigVO configVO = switchConfig.getConfig();
|
||||
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
|
||||
Channel channel = plcGateway.getChannel();
|
||||
plcGatewayService.writeSingleCoil(baseAddr, configVO.getWdc(), false, channel);
|
||||
plcGatewayService.writeSingleCoil(baseAddr, configVO.getWfc(), false, channel);
|
||||
plcGatewayService.writeSingleCoil(baseAddr, configVO.getWsj(), false, channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
|
||||
PlcGateway plcGateway = simulation.queryPlcGatewayDevice();
|
||||
if (plcGateway == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GxsdSwitchConfig config = (GxsdSwitchConfig) deviceConfig;
|
||||
GxsdSwitchConfigVO configVO = config.getConfig();
|
||||
ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity());
|
||||
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
|
||||
Channel channel = plcGateway.getChannel();
|
||||
VirtualRealitySwitch vrSwitch = (VirtualRealitySwitch) config.getMapElement();
|
||||
if (vrSwitch == null) {
|
||||
release(deviceStatus, baseAddr, configVO, channel); //防止定反操继电器长时间接通
|
||||
return;
|
||||
}
|
||||
|
||||
boolean r_db = RealDeviceConfig.getBitOf(deviceStatus, configVO.getRdc());
|
||||
boolean r_fb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getRfc());
|
||||
vrSwitch.apply(r_db, r_fb);
|
||||
if (!this.checkElectricRelay(deviceStatus)) {
|
||||
return;
|
||||
}
|
||||
//以下操作实体设备的逻辑中,防止继电器长期接通的逻辑将定反操视为技能,共用3秒冷却,技能持续时间也是3秒
|
||||
if (config.isEnd()) { //此判断既可视为操作是否冷却,也可视为持续时间是否耗尽
|
||||
config.sync(r_db, r_fb);
|
||||
release(deviceStatus, baseAddr, configVO, channel); //操作持续时间耗尽后断开所有继电器
|
||||
if (vrSwitch.isTurning()) {
|
||||
switch (vrSwitch.getCommand()) {
|
||||
case NP:
|
||||
if (config.turnToN()) {
|
||||
turnToN(deviceStatus, baseAddr, configVO, channel);
|
||||
}
|
||||
break;
|
||||
case RP:
|
||||
if (config.turnToP()) {
|
||||
turnToP(deviceStatus, baseAddr, configVO, channel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void turnToN(ByteBuf deviceStatus, int baseAddr, GxsdSwitchConfigVO configVO, Channel channel) {
|
||||
boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWsj());
|
||||
boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWdc());
|
||||
boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWfc());
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWsj(), w_sb, true, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWdc(), w_dc, true, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWfc(), w_fc, false, channel);
|
||||
}
|
||||
|
||||
private void turnToP(ByteBuf deviceStatus, int baseAddr, GxsdSwitchConfigVO configVO, Channel channel) {
|
||||
boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWsj());
|
||||
boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWdc());
|
||||
boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWfc());
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWsj(), w_sb, true, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWdc(), w_dc, false, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWfc(), w_fc, true, channel);
|
||||
}
|
||||
|
||||
private void release(ByteBuf deviceStatus, int baseAddr, GxsdSwitchConfigVO configVO, Channel channel) {
|
||||
boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWsj());
|
||||
boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWdc());
|
||||
boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getWfc());
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWsj(), w_sb, false, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWdc(), w_dc, false, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getWfc(), w_fc, false, channel);
|
||||
}
|
||||
}
|
@ -5,6 +5,8 @@ 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.gxsd.GxsdSignalConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gxsd.GxsdSwitchConfig;
|
||||
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.*;
|
||||
@ -47,349 +49,377 @@ import java.util.Objects;
|
||||
@NoArgsConstructor
|
||||
public class ProjectDeviceVO {
|
||||
|
||||
private Long id;
|
||||
/**
|
||||
* 所属项目
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 所属项目
|
||||
*/
|
||||
// @NotBlank(message = "所属项目编码不能为空")
|
||||
private String project;
|
||||
private String project;
|
||||
|
||||
/**
|
||||
* 设备编号(或名称),一个项目下唯一
|
||||
*/
|
||||
@NotBlank(message = "设备编号(或名称)不能为空")
|
||||
private String code;
|
||||
/**
|
||||
* 设备编号(或名称),一个项目下唯一
|
||||
*/
|
||||
@NotBlank(message = "设备编号(或名称)不能为空")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private ProjectDeviceType type;
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private ProjectDeviceType type;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long creator;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long creator;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 设备网关映射配置
|
||||
*/
|
||||
private String config;
|
||||
/**
|
||||
* 设备网关映射配置
|
||||
*/
|
||||
private String config;
|
||||
|
||||
public ProjectDeviceVO(ProjectDevice device) {
|
||||
this.id = device.getId();
|
||||
this.project = device.getProjectCode();
|
||||
this.code = device.getCode();
|
||||
this.type = ProjectDeviceType.valueOf(device.getType());
|
||||
this.creator = device.getCreator();
|
||||
this.createTime = device.getCreateTime();
|
||||
this.config = device.getConfig();
|
||||
public ProjectDeviceVO(ProjectDevice device) {
|
||||
this.id = device.getId();
|
||||
this.project = device.getProjectCode();
|
||||
this.code = device.getCode();
|
||||
this.type = ProjectDeviceType.valueOf(device.getType());
|
||||
this.creator = device.getCreator();
|
||||
this.createTime = device.getCreateTime();
|
||||
this.config = device.getConfig();
|
||||
}
|
||||
|
||||
public static List<ProjectDeviceVO> convert2VOList(List<ProjectDevice> list) {
|
||||
List<ProjectDeviceVO> voList = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
list.forEach(projectDevice -> voList.add(new ProjectDeviceVO(projectDevice)));
|
||||
}
|
||||
return voList;
|
||||
}
|
||||
|
||||
public static List<ProjectDeviceVO> convert2VOList(List<ProjectDevice> list) {
|
||||
List<ProjectDeviceVO> voList = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
list.forEach(projectDevice -> voList.add(new ProjectDeviceVO(projectDevice)));
|
||||
public static List<RealDeviceConfig> convert2RealDeviceList(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(voList)) {
|
||||
String project = voList.get(0).getProject();
|
||||
String projectCode = StringUtils.hasText(project) ? project.toUpperCase() : "";
|
||||
switch (projectCode) {
|
||||
case "XTY": {
|
||||
return xtyDeviceConfigConvert(voList);
|
||||
}
|
||||
return voList;
|
||||
}
|
||||
|
||||
public static List<RealDeviceConfig> convert2RealDeviceList(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(voList)) {
|
||||
String project = voList.get(0).getProject();
|
||||
switch (project) {
|
||||
case "XTY": {
|
||||
return xtyDeviceConfigConvert(voList);
|
||||
}
|
||||
case "GZB": {
|
||||
return gzbDeviceConfigConvert(voList);
|
||||
}
|
||||
case "HEB": {
|
||||
return heb1DeviceConfigConvert(voList);
|
||||
}
|
||||
case "SDY": {
|
||||
return sdyDeviceConfigConvert(voList);
|
||||
}
|
||||
case "RICHOR_JOINT": {
|
||||
return zjdDeviceConfigConvert(voList);
|
||||
}
|
||||
case "SR_SANDBOX": {
|
||||
return srSandboxDeviceConfigConvert(voList);
|
||||
}
|
||||
case "RICHOR_HHCJ": {
|
||||
return hhcjDeviceConfigConvert(voList);
|
||||
}
|
||||
case "SAY": {
|
||||
return sayDeviceConfigConvert(voList);
|
||||
}
|
||||
}
|
||||
case "GZB": {
|
||||
return gzbDeviceConfigConvert(voList);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<RealDeviceConfig> sayDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case IBP:
|
||||
list.add(new SayIbpConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
case PSD:
|
||||
list.add(new SayPsdConfig(deviceVO));
|
||||
break;
|
||||
case SIGNAL:
|
||||
list.add(new SaySignalConfig(deviceVO));
|
||||
break;
|
||||
case SWITCH:
|
||||
list.add(new SaySwitchConfig(deviceVO));
|
||||
break;
|
||||
case SECTION:
|
||||
list.add(new SaySectionConfig(deviceVO));
|
||||
break;
|
||||
}
|
||||
case "HEB": {
|
||||
return heb1DeviceConfigConvert(voList);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<RealDeviceConfig> hhcjDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case IBP:
|
||||
list.add(new HhcjIbpConfig(deviceVO));
|
||||
break;
|
||||
case PSD:
|
||||
list.add(new HhcjPsdConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
}
|
||||
case "SDY": {
|
||||
return sdyDeviceConfigConvert(voList);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<RealDeviceConfig> srSandboxDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case UDP_LOW:
|
||||
list.add(new UDPLowConfig(deviceVO));
|
||||
break;
|
||||
case UDP_CLIENT:
|
||||
list.add(new UDPClientConfig(deviceVO));
|
||||
break;
|
||||
case SIGNAL:
|
||||
list.add(new SrSignalConfig(deviceVO));
|
||||
break;
|
||||
case SECTION:
|
||||
list.add(new SrSectionConfig(deviceVO));
|
||||
break;
|
||||
case SWITCH:
|
||||
list.add(new SrSwitchConfig(deviceVO));
|
||||
break;
|
||||
case TRAIN:
|
||||
list.add(new SrTrainConfig(deviceVO));
|
||||
break;
|
||||
}
|
||||
case "RICHOR_JOINT": {
|
||||
return zjdDeviceConfigConvert(voList);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<RealDeviceConfig> zjdDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case IBP:
|
||||
list.add(new ZjdIbpConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
case PSD:
|
||||
list.add(new ZjdPsdConfig(deviceVO));
|
||||
break;
|
||||
case PSL:
|
||||
list.add(new ZjdPslConfig(deviceVO));
|
||||
break;
|
||||
}
|
||||
case "SR_SANDBOX": {
|
||||
return srSandboxDeviceConfigConvert(voList);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<RealDeviceConfig> sdyDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> 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;
|
||||
}
|
||||
case "RICHOR_HHCJ": {
|
||||
return hhcjDeviceConfigConvert(voList);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<RealDeviceConfig> heb1DeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case SWITCH:
|
||||
list.add(new Heb1SwitchConfig(deviceVO));
|
||||
break;
|
||||
case SIGNAL:
|
||||
list.add(new Heb1SignalConfig(deviceVO));
|
||||
break;
|
||||
case PSC:
|
||||
list.add(new Heb1PscConfig(deviceVO));
|
||||
break;
|
||||
case PSL:
|
||||
list.add(new Heb1PslConfig(deviceVO));
|
||||
break;
|
||||
case IBP:
|
||||
list.add(new Heb1IbpConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
default: {
|
||||
log.warn(String.format("设备[%s]不是PLC可连接控制设备", deviceVO));
|
||||
break;
|
||||
}
|
||||
}
|
||||
case "SAY": {
|
||||
return sayDeviceConfigConvert(voList);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<RealDeviceConfig> gzbDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case SWITCH:
|
||||
list.add(new GzbSwitchConfig(deviceVO));
|
||||
break;
|
||||
case SIGNAL:
|
||||
list.add(new GzbSignalConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
default: {
|
||||
log.warn(String.format("设备[%s]不是PLC可连接控制设备", deviceVO));
|
||||
break;
|
||||
}
|
||||
}
|
||||
case "GXSD": {
|
||||
return gxsdDeviceConfigConvert(voList);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<RealDeviceConfig> xtyDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case PSD:
|
||||
list.add(new XtyPsdConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<RealDeviceConfig> gxsdDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case SWITCH:
|
||||
list.add(new GxsdSwitchConfig(deviceVO));
|
||||
break;
|
||||
case SIGNAL:
|
||||
list.add(new GxsdSignalConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
default: {
|
||||
log.warn(String.format("设备[%s]不是PLC可连接控制设备", deviceVO));
|
||||
break;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public ProjectDevice buildDB() {
|
||||
ProjectDevice device = new ProjectDevice();
|
||||
device.setProjectCode(this.getProject());
|
||||
device.setCode(this.getCode());
|
||||
device.setType(this.getType().name());
|
||||
return device;
|
||||
private static List<RealDeviceConfig> sayDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case IBP:
|
||||
list.add(new SayIbpConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
case PSD:
|
||||
list.add(new SayPsdConfig(deviceVO));
|
||||
break;
|
||||
case SIGNAL:
|
||||
list.add(new SaySignalConfig(deviceVO));
|
||||
break;
|
||||
case SWITCH:
|
||||
list.add(new SaySwitchConfig(deviceVO));
|
||||
break;
|
||||
case SECTION:
|
||||
list.add(new SaySectionConfig(deviceVO));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectDeviceVO{" +
|
||||
"project=" + project +
|
||||
", code='" + code + '\'' +
|
||||
", type=" + type +
|
||||
'}';
|
||||
private static List<RealDeviceConfig> hhcjDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case IBP:
|
||||
list.add(new HhcjIbpConfig(deviceVO));
|
||||
break;
|
||||
case PSD:
|
||||
list.add(new HhcjPsdConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public LwConfigVO buildLwConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.LW), "设备不是[现地工作站]");
|
||||
return JsonUtils.read(this.config, LwConfigVO.class);
|
||||
private static List<RealDeviceConfig> srSandboxDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case UDP_LOW:
|
||||
list.add(new UDPLowConfig(deviceVO));
|
||||
break;
|
||||
case UDP_CLIENT:
|
||||
list.add(new UDPClientConfig(deviceVO));
|
||||
break;
|
||||
case SIGNAL:
|
||||
list.add(new SrSignalConfig(deviceVO));
|
||||
break;
|
||||
case SECTION:
|
||||
list.add(new SrSectionConfig(deviceVO));
|
||||
break;
|
||||
case SWITCH:
|
||||
list.add(new SrSwitchConfig(deviceVO));
|
||||
break;
|
||||
case TRAIN:
|
||||
list.add(new SrTrainConfig(deviceVO));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public VrIbpConfigVO buildVrIbpConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.IBP), "设备不是[IBP盘]");
|
||||
return JsonUtils.read(this.config, VrIbpConfigVO.class);
|
||||
private static List<RealDeviceConfig> zjdDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case IBP:
|
||||
list.add(new ZjdIbpConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
case PSD:
|
||||
list.add(new ZjdPsdConfig(deviceVO));
|
||||
break;
|
||||
case PSL:
|
||||
list.add(new ZjdPslConfig(deviceVO));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public LswConfigVO buildLswConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.LSW), "设备不是[大屏工作站]");
|
||||
return JsonUtils.read(this.config, LswConfigVO.class);
|
||||
private static List<RealDeviceConfig> sdyDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> 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;
|
||||
}
|
||||
|
||||
public RelationLoginConfigVO buildRelationLoginConfig() {
|
||||
if (StringUtils.isEmpty(this.config)) {
|
||||
return null;
|
||||
private static List<RealDeviceConfig> heb1DeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case SWITCH:
|
||||
list.add(new Heb1SwitchConfig(deviceVO));
|
||||
break;
|
||||
case SIGNAL:
|
||||
list.add(new Heb1SignalConfig(deviceVO));
|
||||
break;
|
||||
case PSC:
|
||||
list.add(new Heb1PscConfig(deviceVO));
|
||||
break;
|
||||
case PSL:
|
||||
list.add(new Heb1PslConfig(deviceVO));
|
||||
break;
|
||||
case IBP:
|
||||
list.add(new Heb1IbpConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
default: {
|
||||
log.warn(String.format("设备[%s]不是PLC可连接控制设备", deviceVO));
|
||||
break;
|
||||
}
|
||||
return JsonUtils.read(this.config, RelationLoginConfigVO.class);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public SwitchConfigVO buildSwitchConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.SWITCH), "设备不是[道岔]");
|
||||
return JsonUtils.read(this.config, SwitchConfigVO.class);
|
||||
private static List<RealDeviceConfig> gzbDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case SWITCH:
|
||||
list.add(new GzbSwitchConfig(deviceVO));
|
||||
break;
|
||||
case SIGNAL:
|
||||
list.add(new GzbSignalConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
default: {
|
||||
log.warn(String.format("设备[%s]不是PLC可连接控制设备", deviceVO));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public PslConfigVO buildPslConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.PSL), "设备不是[端头屏蔽门控制盒]");
|
||||
return JsonUtils.read(this.config, PslConfigVO.class);
|
||||
private static List<RealDeviceConfig> xtyDeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case PSD:
|
||||
list.add(new XtyPsdConfig(deviceVO));
|
||||
break;
|
||||
case PLC_GATEWAY:
|
||||
list.add(new PlcGateway(deviceVO));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public IbpConfigVO buildIbpConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.IBP), "设备不是[IBP]");
|
||||
return JsonUtils.read(this.config, IbpConfigVO.class);
|
||||
}
|
||||
@JsonIgnore
|
||||
public ProjectDevice buildDB() {
|
||||
ProjectDevice device = new ProjectDevice();
|
||||
device.setProjectCode(this.getProject());
|
||||
device.setCode(this.getCode());
|
||||
device.setType(this.getType().name());
|
||||
return device;
|
||||
}
|
||||
|
||||
public PscConfigVO buildPscConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.PSC), "设备不是[PSC]");
|
||||
return JsonUtils.read(this.config, PscConfigVO.class);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectDeviceVO{" +
|
||||
"project=" + project +
|
||||
", code='" + code + '\'' +
|
||||
", type=" + type +
|
||||
'}';
|
||||
}
|
||||
|
||||
public PlcGatewayConfigVO buildPlcGatewayConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.PLC_GATEWAY), "设备不是[PLC网关]");
|
||||
return JsonUtils.read(this.config, PlcGatewayConfigVO.class);
|
||||
public LwConfigVO buildLwConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.LW), "设备不是[现地工作站]");
|
||||
return JsonUtils.read(this.config, LwConfigVO.class);
|
||||
}
|
||||
|
||||
public VrIbpConfigVO buildVrIbpConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.IBP), "设备不是[IBP盘]");
|
||||
return JsonUtils.read(this.config, VrIbpConfigVO.class);
|
||||
}
|
||||
|
||||
public LswConfigVO buildLswConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.LSW), "设备不是[大屏工作站]");
|
||||
return JsonUtils.read(this.config, LswConfigVO.class);
|
||||
}
|
||||
|
||||
public RelationLoginConfigVO buildRelationLoginConfig() {
|
||||
if (StringUtils.isEmpty(this.config)) {
|
||||
return null;
|
||||
}
|
||||
return JsonUtils.read(this.config, RelationLoginConfigVO.class);
|
||||
}
|
||||
|
||||
public SwitchConfigVO buildSwitchConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.SWITCH), "设备不是[道岔]");
|
||||
return JsonUtils.read(this.config, SwitchConfigVO.class);
|
||||
}
|
||||
|
||||
public PslConfigVO buildPslConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.PSL),
|
||||
"设备不是[端头屏蔽门控制盒]");
|
||||
return JsonUtils.read(this.config, PslConfigVO.class);
|
||||
}
|
||||
|
||||
public IbpConfigVO buildIbpConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.IBP), "设备不是[IBP]");
|
||||
return JsonUtils.read(this.config, IbpConfigVO.class);
|
||||
}
|
||||
|
||||
public PscConfigVO buildPscConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.PSC), "设备不是[PSC]");
|
||||
return JsonUtils.read(this.config, PscConfigVO.class);
|
||||
}
|
||||
|
||||
public PlcGatewayConfigVO buildPlcGatewayConfig() {
|
||||
BusinessExceptionAssertEnum
|
||||
.SYSTEM_EXCEPTION
|
||||
.assertTrue(Objects.equals(this.getType(), ProjectDeviceType.PLC_GATEWAY),
|
||||
"设备不是[PLC网关]");
|
||||
return JsonUtils.read(this.config, PlcGatewayConfigVO.class);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
package club.joylink.rtss.vo.client.project.gxsd;
|
||||
|
||||
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
/**
|
||||
*广西水利电力职业技术学院项目信号机配置
|
||||
*/
|
||||
public class GxsdSignalConfigVO extends RealConfigVO {
|
||||
|
||||
/**
|
||||
* 信号输入位 红灯
|
||||
*/
|
||||
private Integer r1 = 1;
|
||||
|
||||
/**
|
||||
* 信号输入位 绿灯或黄灯
|
||||
*/
|
||||
private Integer r3 = 3;
|
||||
|
||||
|
||||
/**
|
||||
* 信号输出控制位 绿灯
|
||||
*/
|
||||
private Integer w3 = 11;
|
||||
|
||||
/**
|
||||
* 信号输出控制位 黄灯
|
||||
*/
|
||||
private Integer w4 = 12;
|
||||
|
||||
/**
|
||||
* 信号输出控制位 灭灯 开启 默认就是红灯
|
||||
*/
|
||||
private Integer w5 = 13;
|
||||
|
||||
/**
|
||||
* 信号输出控制位 红黄灯
|
||||
*/
|
||||
private Integer w7 = 15;
|
||||
|
||||
public GxsdSignalConfigVO() {
|
||||
super(0, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findDeviceCode() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package club.joylink.rtss.vo.client.project.gxsd;
|
||||
|
||||
import club.joylink.rtss.vo.client.project.RealConfigVO;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 广西水利电力职业技术学院项目道岔配置
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class GxsdSwitchConfigVO extends RealConfigVO {
|
||||
|
||||
/**
|
||||
* 设置定反位锁机
|
||||
* 道岔定位/反位
|
||||
* 设置锁接
|
||||
* 设置道岔定位/反位3秒后取消定反操
|
||||
* 道岔到位 取消锁接
|
||||
*/
|
||||
|
||||
/**
|
||||
* 读反位
|
||||
*/
|
||||
private Integer rfc = 0;
|
||||
|
||||
/**
|
||||
* 读定位
|
||||
*/
|
||||
private Integer rdc = 2;
|
||||
|
||||
|
||||
/**
|
||||
* 写反操
|
||||
*/
|
||||
private Integer wfc = 10;
|
||||
|
||||
/**
|
||||
* 写定操
|
||||
*/
|
||||
private Integer wdc = 9;
|
||||
|
||||
/**
|
||||
* 锁接
|
||||
*/
|
||||
private Integer wsj = 8;
|
||||
|
||||
public GxsdSwitchConfigVO() {
|
||||
super(0, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findDeviceCode() {
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user