苏电院屏蔽门调试
This commit is contained in:
parent
d1e339a307
commit
39482d6b1d
@ -181,4 +181,10 @@ public class DeviceController {
|
|||||||
UserVO userVO) {
|
UserVO userVO) {
|
||||||
this.deviceService.addOrUpdateGzbDeviceConfig(userVO);
|
this.deviceService.addOrUpdateGzbDeviceConfig(userVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/sdy/addOrUpdate")
|
||||||
|
public void addOrUpdateSdyDeviceConfig(@ApiIgnore @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
|
||||||
|
UserVO userVO) {
|
||||||
|
this.deviceService.addOrUpdateSdyDeviceConfig(userVO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,4 +177,6 @@ public interface DeviceService {
|
|||||||
void addOrUpdateXtyDeviceConfig(UserVO userVO);
|
void addOrUpdateXtyDeviceConfig(UserVO userVO);
|
||||||
|
|
||||||
void addOrUpdateGzbDeviceConfig(UserVO userVO);
|
void addOrUpdateGzbDeviceConfig(UserVO userVO);
|
||||||
|
|
||||||
|
void addOrUpdateSdyDeviceConfig(UserVO userVO);
|
||||||
}
|
}
|
||||||
|
@ -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.*;
|
||||||
import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO;
|
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.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 club.joylink.rtss.vo.client.project.xty.XtyPsdConfigVO;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
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<ProjectDevice> list = this.buildSdyProjectDevices(userVO);
|
||||||
|
for (ProjectDevice projectDevice : list) {
|
||||||
|
this.projectDeviceDAO.insert(projectDevice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ProjectDevice> buildSdyProjectDevices(UserVO userVO) {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
List<ProjectDevice> 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<ProjectDevice> buildGzbProjectDevices(UserVO userVO) {
|
private List<ProjectDevice> buildGzbProjectDevices(UserVO userVO) {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
List<ProjectDevice> list = new ArrayList<>();
|
List<ProjectDevice> list = new ArrayList<>();
|
||||||
|
@ -3,6 +3,7 @@ package club.joylink.rtss.simulation.cbtc;
|
|||||||
import club.joylink.rtss.configuration.configProp.OtherConfig;
|
import club.joylink.rtss.configuration.configProp.OtherConfig;
|
||||||
import club.joylink.rtss.configuration.configProp.WeChatConfig;
|
import club.joylink.rtss.configuration.configProp.WeChatConfig;
|
||||||
import club.joylink.rtss.constants.MapPrdTypeEnum;
|
import club.joylink.rtss.constants.MapPrdTypeEnum;
|
||||||
|
import club.joylink.rtss.constants.ProjectDeviceType;
|
||||||
import club.joylink.rtss.constants.SystemEnv;
|
import club.joylink.rtss.constants.SystemEnv;
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.services.*;
|
import club.joylink.rtss.services.*;
|
||||||
@ -782,7 +783,10 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
|
|||||||
@Override
|
@Override
|
||||||
public List<RealDeviceVO> getRealDeviceList(String group) {
|
public List<RealDeviceVO> getRealDeviceList(String group) {
|
||||||
Simulation simulation = this.getSimulationByGroup(group);
|
Simulation simulation = this.getSimulationByGroup(group);
|
||||||
List<RealDeviceConfig> realDeviceList = simulation.getRealDeviceList();
|
Set<ProjectDeviceType> displayDeviceTypes =
|
||||||
|
new HashSet<>(List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL, ProjectDeviceType.PLC_GATEWAY));
|
||||||
|
List<RealDeviceConfig> realDeviceList = simulation.getRealDeviceList()
|
||||||
|
.stream().filter(device -> displayDeviceTypes.contains(device.getDeviceType())).collect(Collectors.toList());
|
||||||
// List<RealDevice> showList = null;
|
// List<RealDevice> showList = null;
|
||||||
// if (!CollectionUtils.isEmpty(realDeviceList)) {
|
// if (!CollectionUtils.isEmpty(realDeviceList)) {
|
||||||
// showList = realDeviceList.stream()
|
// showList = realDeviceList.stream()
|
||||||
@ -880,9 +884,9 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changePassengerFlow(String group, Long passengerFlowId) {
|
public void changePassengerFlow(String group, Long passengerFlowId) {
|
||||||
if(passengerFlowSimulateService.changePassengerFlow(group,passengerFlowId)){
|
if (passengerFlowSimulateService.changePassengerFlow(group, passengerFlowId)) {
|
||||||
Simulation simulation = findSimulationByGroup(group);
|
Simulation simulation = findSimulationByGroup(group);
|
||||||
RunAsPlanParam param =new RunAsPlanParam(simulation.getCorrectSystemTime().toLocalTime(),null);
|
RunAsPlanParam param = new RunAsPlanParam(simulation.getCorrectSystemTime().toLocalTime(), null);
|
||||||
runAsPlan(group, param);
|
runAsPlan(group, param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -893,7 +897,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
|
|||||||
//根据时间筛选
|
//根据时间筛选
|
||||||
if (!CollectionUtils.isEmpty(logs)) {
|
if (!CollectionUtils.isEmpty(logs)) {
|
||||||
if (queryVO.getStartTime() != null || queryVO.getEndTime() != null) {
|
if (queryVO.getStartTime() != null || queryVO.getEndTime() != null) {
|
||||||
logs = logs.stream().filter(log->{
|
logs = logs.stream().filter(log -> {
|
||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
if (queryVO.getStartTime() != null) {
|
if (queryVO.getStartTime() != null) {
|
||||||
flag = flag && !log.getTime().isBefore(queryVO.getStartTime());
|
flag = flag && !log.getTime().isBefore(queryVO.getStartTime());
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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<RealDeviceConfig> 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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,19 @@
|
|||||||
package club.joylink.rtss.vo.client.project;
|
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.PlcGateway;
|
||||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
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.GzbSignalConfig;
|
||||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSwitchConfig;
|
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.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.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 club.joylink.rtss.util.JsonUtils;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -100,12 +102,33 @@ public class ProjectDeviceVO {
|
|||||||
case HEB: {
|
case HEB: {
|
||||||
return heb1DeviceConfigConvert(voList);
|
return heb1DeviceConfigConvert(voList);
|
||||||
}
|
}
|
||||||
|
case SDY: {
|
||||||
|
return sdyDeviceConfigConvert(voList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
private static List<RealDeviceConfig> heb1DeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
private static List<RealDeviceConfig> heb1DeviceConfigConvert(List<ProjectDeviceVO> voList) {
|
||||||
List<RealDeviceConfig> list = new ArrayList<>();
|
List<RealDeviceConfig> list = new ArrayList<>();
|
||||||
for (ProjectDeviceVO deviceVO : voList) {
|
for (ProjectDeviceVO deviceVO : voList) {
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user