Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
Jade 2021-09-14 09:58:28 +08:00
commit 7bd5a25104
42 changed files with 1379 additions and 73 deletions

View File

@ -26,6 +26,8 @@ public enum ProjectDeviceType {
IBP, IBP,
/** PLC网关 */ /** PLC网关 */
PLC_GATEWAY, PLC_GATEWAY,
/** 单元控制器 */
DCU,
/* -----------plc device end---------- */ /* -----------plc device end---------- */
/* -----------client device start---------- */ /* -----------client device start---------- */
@ -65,6 +67,7 @@ public enum ProjectDeviceType {
PSL, PSL,
IBP, IBP,
SWITCH, SWITCH,
SIGNAL); SIGNAL,
DCU);
} }
} }

View File

@ -230,4 +230,10 @@ public class DeviceController {
AccountVO accountVO) { AccountVO accountVO) {
this.deviceService.addOrUpdateSdyDeviceConfig(accountVO); this.deviceService.addOrUpdateSdyDeviceConfig(accountVO);
} }
@PostMapping("/richor/addOrUpdate")
public void addOrUpdateRichorDeviceConfig(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateRichorDeviceConfig(accountVO);
}
} }

View File

@ -25,17 +25,11 @@ public class ModbusTestController {
/** /**
* 测试modbustcp写网关使用功能码05写单线圈 * 测试modbustcp写网关使用功能码05写单线圈
* @param code
* @param addr
* @param val
* @param accountVO
* @return
*/ */
@Role(SuperAdmin) @Role(SuperAdmin)
@PostMapping("/writeCoil") @PostMapping("/writeCoil")
public void modbusWriteSingleCoil(String code, public void modbusWriteSingleCoil(String code,
int addr, boolean val, int addr, boolean val) {
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) AccountVO accountVO) {
this.modbusTcpTestService.writeSingleCoil(this.plcGatewayConnectManager.getChannel(code), addr, val); this.modbusTcpTestService.writeSingleCoil(this.plcGatewayConnectManager.getChannel(code), addr, val);
} }

View File

@ -200,8 +200,10 @@ public class ReleaseService implements IReleaseService {
if (!CollectionUtils.isEmpty(releaseVO.getRunPlanTemplateList())) { if (!CollectionUtils.isEmpty(releaseVO.getRunPlanTemplateList())) {
//删除旧的运行图相关数据 //删除旧的运行图相关数据
List<RunPlanTemplate> runPlanTemplates = releaseVO.getRunPlanTemplateList(); RunPlanTemplateExample runPlanTemplateExample = new RunPlanTemplateExample();
for (RunPlanTemplate runPlanTemplate : runPlanTemplates) { runPlanTemplateExample.createCriteria().andMapIdEqualTo(mapId);
List<RunPlanTemplate> oldRunPlans = runPlanTemplateDAO.selectByExample(runPlanTemplateExample);
for (RunPlanTemplate runPlanTemplate : oldRunPlans) {
iRunPlanTemplateService.deletePlan(runPlanTemplate.getId(), user); iRunPlanTemplateService.deletePlan(runPlanTemplate.getId(), user);
} }
// //删除旧的运行图加载数据 // //删除旧的运行图加载数据
@ -218,6 +220,7 @@ public class ReleaseService implements IReleaseService {
// runPlanTemplateDAO.deleteByExample(runPlanTemplateExample); // runPlanTemplateDAO.deleteByExample(runPlanTemplateExample);
//插入新的模板运行图数据并记录id变化 //插入新的模板运行图数据并记录id变化
Map<Long, Long> runPlanTemplateIdMap = new HashMap<>(); Map<Long, Long> runPlanTemplateIdMap = new HashMap<>();
List<RunPlanTemplate> runPlanTemplates = releaseVO.getRunPlanTemplateList();
for (RunPlanTemplate template : runPlanTemplates) { for (RunPlanTemplate template : runPlanTemplates) {
long oldId = template.getId(); long oldId = template.getId();
template.setId(null); template.setId(null);

View File

@ -122,37 +122,20 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
break; break;
case KM: { case KM: {
element.setOn(true); element.setOn(true);
List<VirtualRealityIbp.IbpElement> key; stands.forEach(stand -> ciApiService.openScreenDoor(simulation, stand.getCode()));
if (element.getUp()) {
key = ibp.query(VirtualRealityIbp.Mean.SXYS, element.getUp());
} else {
key = ibp.query(VirtualRealityIbp.Mean.XXYS, element.getUp());
}
if (key.stream().allMatch(VirtualRealityIbp.IbpElement::isOn)) {
stands.forEach(stand -> ciApiService.openScreenDoor(simulation, stand.getCode()));
}
break; break;
} }
case GM: { case GM: {
element.setOn(true); element.setOn(true);
List<VirtualRealityIbp.IbpElement> key; stands.forEach(stand -> ciApiService.closeScreenDoor(simulation, stand.getCode()));
if (element.getUp() != null) {
if (element.getUp()) {
key = ibp.query(VirtualRealityIbp.Mean.SXYS, element.getUp());
} else {
key = ibp.query(VirtualRealityIbp.Mean.XXYS, element.getUp());
}
} else {
key = ibp.queryByType(VirtualRealityIbp.Type.KEY);
}
if (key.stream().allMatch(VirtualRealityIbp.IbpElement::isOn)) {
stands.forEach(stand -> ciApiService.closeScreenDoor(simulation, stand.getCode()));
}
break; break;
} }
case XXYS: case XXYS:
case SXYS: case SXYS:
element.setOn(!element.isOn()); element.setOn(!element.isOn());
stands.forEach(stand -> {
stand.getPsd().getVirtualScreenDoor().setIbpControl(true);
});
break; break;
case AXLE_RESET: case AXLE_RESET:
element.setOn(true); element.setOn(true);

View File

@ -179,4 +179,6 @@ public interface DeviceService {
void addOrUpdateGzbDeviceConfig(AccountVO accountVO); void addOrUpdateGzbDeviceConfig(AccountVO accountVO);
void addOrUpdateSdyDeviceConfig(AccountVO accountVO); void addOrUpdateSdyDeviceConfig(AccountVO accountVO);
void addOrUpdateRichorDeviceConfig(AccountVO accountVO);
} }

View File

@ -12,6 +12,10 @@ 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.richor.RichorDcuConfigVO;
import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO;
import club.joylink.rtss.vo.client.project.richor.RichorPsdConfigVO;
import club.joylink.rtss.vo.client.project.richor.RichorPslConfigVO;
import club.joylink.rtss.vo.client.project.sdy.SdyPsdConfigVO; 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.sdy.SdyPslConfigVO;
import club.joylink.rtss.vo.client.project.xty.XtyPsdConfigVO; import club.joylink.rtss.vo.client.project.xty.XtyPsdConfigVO;
@ -378,6 +382,78 @@ public class DeviceServiceImpl implements DeviceService {
} }
} }
@Override
public void addOrUpdateRichorDeviceConfig(AccountVO accountVO) {
// 删除旧配置
ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria()
.andProjectCodeEqualTo(Project.RICHOR_JOINT.name())
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream()
.map(Enum::name).collect(Collectors.toList()));
this.projectDeviceDAO.deleteByExample(example);
// 保存新配置
List<ProjectDevice> list = this.buildRichorProjectDevices(accountVO);
for (ProjectDevice projectDevice : list) {
this.projectDeviceDAO.insert(projectDevice);
}
}
private List<ProjectDevice> buildRichorProjectDevices(AccountVO accountVO) {
LocalDateTime now = LocalDateTime.now();
List<ProjectDevice> list = new ArrayList<>();
// PLC网关
ProjectDevice plcGateway = new ProjectDevice();
plcGateway.setProjectCode(Project.RICHOR_JOINT.name());
plcGateway.setCode("richorJoint-gateway");
plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name());
plcGateway.setCreator(accountVO.getId());
plcGateway.setCreateTime(now);
PlcGatewayConfigVO plcGatewayConfigVO = new PlcGatewayConfigVO(0, 144);
plcGateway.setConfig(plcGatewayConfigVO.toJson());
list.add(plcGateway);
// 屏蔽门
ProjectDevice psd = new ProjectDevice();
psd.setProjectCode(Project.RICHOR_JOINT.name());
psd.setCode("richorJoint-psd");
psd.setType(ProjectDeviceType.PSD.name());
psd.setCreator(accountVO.getId());
psd.setCreateTime(now);
RichorPsdConfigVO psdConfigVO = new RichorPsdConfigVO();
psd.setConfig(psdConfigVO.toJson());
list.add(psd);
// IBP盘
ProjectDevice ibp = new ProjectDevice();
ibp.setProjectCode(Project.RICHOR_JOINT.name());
ibp.setCode("richorJoint-ibp");
ibp.setType(ProjectDeviceType.IBP.name());
ibp.setCreator(accountVO.getId());
ibp.setCreateTime(now);
RichorIbpConfigVO ibpConfigVO = new RichorIbpConfigVO();
ibp.setConfig(ibpConfigVO.toJson());
list.add(ibp);
// PSL
ProjectDevice psl = new ProjectDevice();
psl.setProjectCode(Project.RICHOR_JOINT.name());
psl.setCode("richorJoint-psl");
psl.setType(ProjectDeviceType.PSL.name());
psl.setCreator(accountVO.getId());
psl.setCreateTime(now);
RichorPslConfigVO pslConfigVO = new RichorPslConfigVO();
psl.setConfig(pslConfigVO.toJson());
list.add(psl);
// // DCU
// ProjectDevice dcu = new ProjectDevice();
// dcu.setProjectCode(Project.RICHOR_JOINT.name());
// dcu.setCode("richorJoint-dcu");
// dcu.setType(ProjectDeviceType.DCU.name());
// dcu.setCreator(accountVO.getId());
// dcu.setCreateTime(now);
// RichorDcuConfigVO dcuConfigVO = new RichorDcuConfigVO();
// dcu.setConfig(dcuConfigVO.toJson());
// list.add(dcu);
return list;
}
private List<ProjectDevice> buildSdyProjectDevices(AccountVO accountVO) { private List<ProjectDevice> buildSdyProjectDevices(AccountVO accountVO) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
List<ProjectDevice> list = new ArrayList<>(); List<ProjectDevice> list = new ArrayList<>();

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.services.psl;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CI.service.StandService; import club.joylink.rtss.simulation.cbtc.CI.service.StandService;
import club.joylink.rtss.simulation.cbtc.CI.service.VrPsdService;
import club.joylink.rtss.simulation.cbtc.GroupSimulationService; import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
@ -32,6 +33,9 @@ public class VirtualRealityPslService implements IVirtualRealityPslService{
@Autowired @Autowired
private StandService standService; private StandService standService;
@Autowired
private VrPsdService vrPsdService;
@Override @Override
public PslStatus getStatus(String group, String standCode) { public PslStatus getStatus(String group, String standCode) {
Simulation simulation = groupSimulationService.getSimulationByGroup(group); Simulation simulation = groupSimulationService.getSimulationByGroup(group);
@ -68,13 +72,13 @@ public class VirtualRealityPslService implements IVirtualRealityPslService{
// vrPsl.setKmButton(!vrPsl.isKmButton()); // vrPsl.setKmButton(!vrPsl.isKmButton());
// if (vrPsl.isKmButton()) // if (vrPsl.isKmButton())
if (vrPsl.isYxjzKey() && vrPsd.isLockAndClose()) if (vrPsl.isYxjzKey() && vrPsd.isLockAndClose())
standService.controlVrPSD(simulation, vrPsd, true); vrPsdService.controlVrPSD(simulation, vrPsd, true, VrPsdService.CommandSource.IBP);
break; break;
case GM: case GM:
// vrPsl.setGmButton(!vrPsl.isGmButton()); // vrPsl.setGmButton(!vrPsl.isGmButton());
// if (vrPsl.isGmButton()) // if (vrPsl.isGmButton())
if (vrPsl.isYxjzKey() && vrPsd.isOpen2End()) if (vrPsl.isYxjzKey() && vrPsd.isOpen2End())
standService.controlVrPSD(simulation, vrPsd, false); vrPsdService.controlVrPSD(simulation, vrPsd, false, VrPsdService.CommandSource.IBP);
break; break;
case SD: case SD:
vrPsl.setSdButton(!vrPsl.isSdButton()); vrPsl.setSdButton(!vrPsl.isSdButton());

View File

@ -29,20 +29,23 @@ public class StandService {
@Autowired @Autowired
private RouteService routeService; private RouteService routeService;
/** @Autowired
* 控制室外屏蔽门开关 private VrPsdService vrPsdService;
*/
public void controlVrPSD(Simulation simulation, VirtualRealityScreenDoor vrPsd, boolean open) { // /**
if ((open && (vrPsd.isSettingOpen() || vrPsd.isOpen2End())) || // * 控制室外屏蔽门开关
(!open && (vrPsd.isSettingClose() || vrPsd.isLockAndClose()))) { // */
// log.debug(String.format("屏蔽门[%s(%s)]已经在对应状态,不需要再控制", vrPsd.getName(), vrPsd.getCode())); // public void controlVrPSD(Simulation simulation, VirtualRealityScreenDoor vrPsd, boolean open) {
return; // if ((open && (vrPsd.isSettingOpen() || vrPsd.isOpen2End())) ||
} // (!open && (vrPsd.isSettingClose() || vrPsd.isLockAndClose()))) {
vrPsd.startSetting(open); //// log.debug(String.format("屏蔽门[%s(%s)]已经在对应状态,不需要再控制", vrPsd.getName(), vrPsd.getCode()));
ControllableDevice ctrlMsg = new PsdSwitch(vrPsd, open); // return;
SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); // }
this.applicationContext.publishEvent(event); // vrPsd.startSetting(open);
} // ControllableDevice ctrlMsg = new PsdSwitch(vrPsd, open);
// SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg);
// this.applicationContext.publishEvent(event);
// }
/** /**
* 打开屏蔽门 * 打开屏蔽门
@ -55,7 +58,7 @@ public class StandService {
if (vrPsd.isPslControl()) { if (vrPsd.isPslControl()) {
return; return;
} }
this.controlVrPSD(simulation, vrPsd, true); vrPsdService.controlVrPSD(simulation, vrPsd, true, VrPsdService.CommandSource.SIG);
} }
/** /**
@ -69,7 +72,7 @@ public class StandService {
if (vrPsd.isPslControl()) { if (vrPsd.isPslControl()) {
return; return;
} }
this.controlVrPSD(simulation, vrPsd, false); vrPsdService.controlVrPSD(simulation, vrPsd, true, VrPsdService.CommandSource.SIG);
} }
/** /**

View File

@ -0,0 +1,52 @@
package club.joylink.rtss.simulation.cbtc.CI.service;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.communication.vo.ControllableDevice;
import club.joylink.rtss.simulation.cbtc.communication.vo.PsdSwitch;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class VrPsdService {
@Autowired
private ApplicationContext applicationContext;
/**
* 控制室外屏蔽门开关
*/
public void controlVrPSD(Simulation simulation, VirtualRealityScreenDoor vrPsd, boolean open, CommandSource source) {
if ((open && (vrPsd.isSettingOpen() || vrPsd.isOpen2End())) ||
(!open && (vrPsd.isSettingClose() || vrPsd.isLockAndClose()))) {
return;
}
switch (source) {
case SIG: {
if (vrPsd.isPslControl() || vrPsd.isIbpControl())
return;
break;
}
case PSL:
break;
case IBP: {
if (vrPsd.isPslControl())
return;
break;
}
}
vrPsd.startSetting(open);
ControllableDevice ctrlMsg = new PsdSwitch(vrPsd, open);
SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg);
this.applicationContext.publishEvent(event);
}
public enum CommandSource{
SIG,
PSL,
IBP
}
}

View File

@ -881,7 +881,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
List<RealDeviceConfig> realDeviceList = simulation.getRealDeviceList(); List<RealDeviceConfig> realDeviceList = simulation.getRealDeviceList();
if (!CollectionUtils.isEmpty(realDeviceList)) { if (!CollectionUtils.isEmpty(realDeviceList)) {
Set<ProjectDeviceType> displayDeviceTypes = Set<ProjectDeviceType> displayDeviceTypes =
new HashSet<>(List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL, ProjectDeviceType.PLC_GATEWAY)); new HashSet<>(List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL, ProjectDeviceType.PLC_GATEWAY, ProjectDeviceType.IBP));
realDeviceList = realDeviceList realDeviceList = realDeviceList
.stream().filter(device -> displayDeviceTypes.contains(device.getDeviceType())).collect(Collectors.toList()); .stream().filter(device -> displayDeviceTypes.contains(device.getDeviceType())).collect(Collectors.toList());
} }

View File

@ -14,6 +14,8 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDevice
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1IbpConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1IbpConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PscConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PscConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PslConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PslConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorIbpConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorPsdConfig;
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.simulation.cbtc.event.SimulationUserEnterEvent; import club.joylink.rtss.simulation.cbtc.event.SimulationUserEnterEvent;
import club.joylink.rtss.simulation.cbtc.member.MemberManager; import club.joylink.rtss.simulation.cbtc.member.MemberManager;
@ -135,6 +137,12 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
return ((XtyPsdConfig) config).getConfig().getPsdCode(); return ((XtyPsdConfig) config).getConfig().getPsdCode();
} }
} }
case RICHOR_JOINT: {
switch (config.getDeviceType()) {
case IBP:
return ((RichorIbpConfig) config).getConfigVO().getStationCode();
}
}
} }
return null; return null;
} }

View File

@ -11,6 +11,7 @@ import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.conversation.Conversation; import club.joylink.rtss.simulation.cbtc.conversation.Conversation;
import club.joylink.rtss.simulation.cbtc.conversation.ConversationMember; import club.joylink.rtss.simulation.cbtc.conversation.ConversationMember;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.vo.OldSimulationInfoVO; import club.joylink.rtss.simulation.cbtc.data.vo.OldSimulationInfoVO;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.DeviceQueryFuture; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.DeviceQueryFuture;
@ -24,6 +25,7 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.member.SimulationUser; import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
import club.joylink.rtss.simulation.cbtc.script.ScriptBO; import club.joylink.rtss.simulation.cbtc.script.ScriptBO;
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
import club.joylink.rtss.simulation.vo.SimulationInfoVO; import club.joylink.rtss.simulation.vo.SimulationInfoVO;
import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.fault.FaultRuleVO; import club.joylink.rtss.vo.client.fault.FaultRuleVO;
@ -68,6 +70,8 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
*/ */
private SimulationDataRepository repository; private SimulationDataRepository repository;
private SimulationIscsDataRepository iscsRepository;
private SimulationIdGenerator idGenerator; private SimulationIdGenerator idGenerator;
/** /**
@ -185,6 +189,7 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
this.dataErrMsgList = new ArrayList<>(); this.dataErrMsgList = new ArrayList<>();
this.faultRules = new HashSet<>(); this.faultRules = new HashSet<>();
this.repository = new SimulationDataRepository(); this.repository = new SimulationDataRepository();
this.iscsRepository = new SimulationIscsDataRepository();
this.idGenerator = new SimulationIdGenerator(); this.idGenerator = new SimulationIdGenerator();
} }
@ -538,6 +543,7 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
this.buildParams.getRunPlan().init(); this.buildParams.getRunPlan().init();
} }
this.repository.reset(); this.repository.reset();
this.iscsRepository.reset();
this.getSimulationMembers().forEach(member -> member.setCommand(null)); this.getSimulationMembers().forEach(member -> member.setCommand(null));
this.planRunning = false; this.planRunning = false;
if (!CollectionUtils.isEmpty(simulationConversationMap)) { if (!CollectionUtils.isEmpty(simulationConversationMap)) {

View File

@ -25,6 +25,7 @@ import club.joylink.rtss.simulation.cbtc.member.MemberManager;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPLogicLoop; import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPLogicLoop;
import club.joylink.rtss.simulation.cbtc.onboard.TrainTargetUpdateService; import club.joylink.rtss.simulation.cbtc.onboard.TrainTargetUpdateService;
import club.joylink.rtss.simulation.cbtc.robot.RobotLogicLoop; import club.joylink.rtss.simulation.cbtc.robot.RobotLogicLoop;
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
import club.joylink.rtss.vo.client.runplan.RunPlanVO; import club.joylink.rtss.vo.client.runplan.RunPlanVO;
import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO; import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -105,6 +106,8 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
Simulation simulation = SimulationBuilder.build(group, params); Simulation simulation = SimulationBuilder.build(group, params);
// 缓存 // 缓存
simulationManager.save(simulation); simulationManager.save(simulation);
// TODO: 2021/9/10 暂时放在这里
simulation.addMessagePublisher(new IscsStatusPublisher(simulation));
// 初始化设备状态 // 初始化设备状态
this.deviceStatusService.init(simulation); this.deviceStatusService.init(simulation);
// 初始化成员 // 初始化成员

View File

@ -623,7 +623,7 @@ public class SimulationMainThread {
simulation.getId(), conversation.getId())); simulation.getId(), conversation.getId()));
SocketMessageVO<ConversationSocketMessageVO> message = SocketMessageFactory SocketMessageVO<ConversationSocketMessageVO> message = SocketMessageFactory
.buildSimulationConversationChatMessage(simulation, conversation, conversationMessage); .buildSimulationConversationChatMessage(simulation, conversation, conversationMessage);
if(conversation.hasOtherMemberConnect()){ if (conversation.hasOtherMemberConnect()) {
Set<String> userIds = simulation.getSimulationUserIds(); Set<String> userIds = simulation.getSimulationUserIds();
this.stompMessageService.sendToUser(userIds, message); this.stompMessageService.sendToUser(userIds, message);
return; return;
@ -721,7 +721,7 @@ public class SimulationMainThread {
@EventListener @EventListener
public void simulationError(SimulationErrorEvent event) { public void simulationError(SimulationErrorEvent event) {
Simulation simulation = event.getSimulation(); Simulation simulation = event.getSimulation();
log.info(String.format("仿真[%s]运行异常, 时间 [%s]", simulation.getId(),simulation.getCorrectSystemTime().format(DateTimeFormatter.ofPattern("yyyy-mm-dd hh:mm:ss")))); log.info(String.format("仿真[%s]运行异常, 时间 [%s]", simulation.getId(), simulation.getCorrectSystemTime().format(DateTimeFormatter.ofPattern("yyyy-mm-dd hh:mm:ss"))));
Set<String> users = simulation.getSimulationUserIds(); Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<String> message = SocketMessageFactory.build(WebSocketMessageType.Simulation_Error, SocketMessageVO<String> message = SocketMessageFactory.build(WebSocketMessageType.Simulation_Error,
simulation.getId(), ""); simulation.getId(), "");

View File

@ -0,0 +1,27 @@
package club.joylink.rtss.simulation.cbtc.data;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO;
import lombok.NoArgsConstructor;
import java.util.*;
@NoArgsConstructor
public class SimulationIscsDataRepository {
private final Map<String, IscsStatusVO> statusVOMap = new HashMap<>();
public IscsStatusVO findStatus(String iscsCode) {
return statusVOMap.get(iscsCode);
}
public void addStatus(IscsStatusVO iscsStatusVO) {
statusVOMap.put(iscsStatusVO.getCode(), iscsStatusVO);
}
public Collection<IscsStatusVO> getAllStatus() {
return statusVOMap.values();
}
public void reset() {
this.statusVOMap.clear();
}
}

View File

@ -0,0 +1,65 @@
package club.joylink.rtss.simulation.cbtc.data.vo.iscs;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
public class IscsIbpStatusVO extends IscsStatusVO {
/** 上行状态 */
private DirectionalStatus upStatus;
/** 下行状态 */
private DirectionalStatus downStatus;
public IscsIbpStatusVO(String code, DeviceType deviceType,
DirectionalStatus upStatus, DirectionalStatus downStatus) {
super(code, deviceType);
this.upStatus = upStatus;
this.downStatus = downStatus;
}
@Getter
public static class DirectionalStatus {
/** 操作允许 */
private boolean operate;
/** 开门命令 */
private boolean openCommand;
/** 开边门命令 */
private boolean openSideCommand;
/** 关门命令 */
private boolean closeCommand;
public DirectionalStatus(boolean operate, boolean openCommand,
boolean openSideCommand, boolean closeCommand) {
this.operate = operate;
this.openCommand = openCommand;
this.openSideCommand = openSideCommand;
this.closeCommand = closeCommand;
}
public boolean compareAndChange(boolean operate, boolean openCommand, boolean openSideCommand, boolean closeCommand) {
boolean change = false;
if (this.operate != operate) {
this.operate = operate;
change = true;
}
if (this.openCommand != openCommand) {
this.openCommand = openCommand;
change = true;
}
if (this.openSideCommand != openSideCommand) {
this.openSideCommand = openSideCommand;
change = true;
}
if (this.closeCommand != closeCommand) {
this.closeCommand = closeCommand;
change = true;
}
return change;
}
}
}

View File

@ -0,0 +1,49 @@
package club.joylink.rtss.simulation.cbtc.data.vo.iscs;
import lombok.Getter;
@Getter
public class IscsPsdStatusVO extends IscsStatusVO{
private DirectionalStatus upStatus;
private DirectionalStatus downStatus;
public IscsPsdStatusVO(String code, DeviceType deviceType,
DirectionalStatus upStatus, DirectionalStatus downStatus) {
super(code, deviceType);
this.upStatus = upStatus;
this.downStatus = downStatus;
}
public enum Status {
OPEN,
CLOSE,
DCU_FAULT,
UNDEFINED,
}
@Getter
public static class DirectionalStatus {
private Status status;
private boolean isolationMode;
public DirectionalStatus(Status status, boolean isolationMode) {
this.status = status;
this.isolationMode = isolationMode;
}
public boolean compareAndChange(Status status, boolean isolationMode) {
boolean change = false;
if (this.status != status) {
this.status = status;
change = true;
}
if (this.isolationMode != isolationMode) {
this.isolationMode = isolationMode;
change = true;
}
return change;
}
}
}

View File

@ -0,0 +1,63 @@
package club.joylink.rtss.simulation.cbtc.data.vo.iscs;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
public class IscsPslStatusVO extends IscsStatusVO{
private DirectionalStatus upStatus;
private DirectionalStatus downStatus;
public IscsPslStatusVO(String code, DeviceType deviceType, DirectionalStatus upStatus,
DirectionalStatus downStatus) {
super(code, deviceType);
this.upStatus = upStatus;
this.downStatus = downStatus;
}
@Getter
public static class DirectionalStatus {
/** 操作允许 */
private boolean operate;
/** 开门命令 */
private boolean openCommand;
/** 关门命令 */
private boolean closeCommand;
/** 互锁解除 */
private boolean interlockRelease;
public DirectionalStatus(boolean operate, boolean openCommand,
boolean closeCommand, boolean interlockRelease) {
this.operate = operate;
this.openCommand = openCommand;
this.closeCommand = closeCommand;
this.interlockRelease = interlockRelease;
}
public boolean compareAndChange(boolean operate, boolean openCommand, boolean closeCommand, boolean interlockRelease) {
boolean change = false;
if (this.operate != operate) {
this.operate = operate;
change = true;
}
if (this.openCommand != openCommand) {
this.openCommand = openCommand;
change = true;
}
if (this.closeCommand != closeCommand) {
this.closeCommand = closeCommand;
change = true;
}
if (this.interlockRelease != interlockRelease) {
this.interlockRelease = interlockRelease;
change = true;
}
return change;
}
}
}

View File

@ -0,0 +1,54 @@
package club.joylink.rtss.simulation.cbtc.data.vo.iscs;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
public class IscsSafetyCircleStatusVO extends IscsStatusVO{
private DirectionalStatus upStatus;
private DirectionalStatus downStatus;
public IscsSafetyCircleStatusVO(String code, DeviceType deviceType,
DirectionalStatus upStatus, DirectionalStatus downStatus) {
super(code, deviceType);
this.upStatus = upStatus;
this.downStatus = downStatus;
}
@Getter
public static class DirectionalStatus {
/** PFDC故障 */
private boolean pfdcFault;
/** 总线故障 */
private boolean busFault;
/** 安全回路状态 */
private boolean safetyCircle;
public DirectionalStatus(boolean pfdcFault, boolean busFault, boolean safetyCircle) {
this.pfdcFault = pfdcFault;
this.busFault = busFault;
this.safetyCircle = safetyCircle;
}
public boolean compareAndChange(boolean pfdcFault, boolean busFault, boolean safetyCircle) {
boolean change = false;
if (this.pfdcFault != pfdcFault) {
this.pfdcFault = pfdcFault;
change = true;
}
if (this.busFault != busFault) {
this.busFault = busFault;
change = true;
}
if (this.safetyCircle != safetyCircle) {
this.safetyCircle = safetyCircle;
change = true;
}
return change;
}
}
}

View File

@ -0,0 +1,25 @@
package club.joylink.rtss.simulation.cbtc.data.vo.iscs;
import club.joylink.rtss.simulation.Watchable;
import lombok.Getter;
@Getter
public class IscsStatusVO extends Watchable {
private String code;
private DeviceType deviceType;
public IscsStatusVO(String code, DeviceType deviceType) {
this.code = code;
this.deviceType = deviceType;
}
public enum DeviceType {
/** 滑动门 */
SLIDING_DOOR,
IBP,
PSL,
/** 安全回路 */
SAFETY_CIRCLE
}
}

View File

@ -48,10 +48,15 @@ public class VirtualRealityScreenDoor extends VirtualRealityDevice {
private boolean commandOpen; private boolean commandOpen;
/** /**
* 正处于psl盘控制下 * psl操作允许
*/ */
private boolean pslControl; private boolean pslControl;
/**
* ibp盘操作允许
*/
private boolean ibpControl;
private Fault fault; private Fault fault;
public VirtualRealityScreenDoor(String code, String name) { public VirtualRealityScreenDoor(String code, String name) {

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.service;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CI.service.StandService; import club.joylink.rtss.simulation.cbtc.CI.service.StandService;
import club.joylink.rtss.simulation.cbtc.CI.service.VrPsdService;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.ESP; import club.joylink.rtss.simulation.cbtc.data.map.ESP;
import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.map.Stand;
@ -44,6 +45,9 @@ public class Heb1IbpServiceImpl implements RealDeviceService {
@Autowired @Autowired
private Heb1PscServiceImpl heb1PscService; private Heb1PscServiceImpl heb1PscService;
@Autowired
private VrPsdService vrPsdService;
@Override @Override
public boolean canHandle(RealDeviceConfig deviceConfig) { public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof Heb1IbpConfig; return deviceConfig instanceof Heb1IbpConfig;
@ -130,13 +134,13 @@ public class Heb1IbpServiceImpl implements RealDeviceService {
if (!vrPsd.isSettingOpen() && !vrPsd.isOpen2End()) { if (!vrPsd.isSettingOpen() && !vrPsd.isOpen2End()) {
log.info(String.format("仿真[%s]IBP设备[%s]执行控制上行PSD开门", log.info(String.format("仿真[%s]IBP设备[%s]执行控制上行PSD开门",
simulation.getId(), pslConfig.getProjectDevice())); simulation.getId(), pslConfig.getProjectDevice()));
this.standService.controlVrPSD(simulation, vrPsd, true); this.vrPsdService.controlVrPSD(simulation, vrPsd, true, VrPsdService.CommandSource.IBP);
} }
} else if (rbsxgm && !rbsxkm) { } else if (rbsxgm && !rbsxkm) {
if (!vrPsd.isSettingClose() && !vrPsd.isClose()) { if (!vrPsd.isSettingClose() && !vrPsd.isClose()) {
log.info(String.format("仿真[%s]IBP设备[%s]执行控制上行PSD关门", log.info(String.format("仿真[%s]IBP设备[%s]执行控制上行PSD关门",
simulation.getId(), pslConfig.getProjectDevice())); simulation.getId(), pslConfig.getProjectDevice()));
this.standService.controlVrPSD(simulation, vrPsd, false); this.vrPsdService.controlVrPSD(simulation, vrPsd, false, VrPsdService.CommandSource.IBP);
} }
} }
} }
@ -180,13 +184,13 @@ public class Heb1IbpServiceImpl implements RealDeviceService {
if (!vrPsd.isSettingOpen() && !vrPsd.isOpen2End()) { if (!vrPsd.isSettingOpen() && !vrPsd.isOpen2End()) {
log.info(String.format("仿真[%s]IBP设备[%s]执行控制下行PSD开门", log.info(String.format("仿真[%s]IBP设备[%s]执行控制下行PSD开门",
simulation.getId(), pslConfig.getProjectDevice())); simulation.getId(), pslConfig.getProjectDevice()));
this.standService.controlVrPSD(simulation, vrPsd, true); this.vrPsdService.controlVrPSD(simulation, vrPsd, true, VrPsdService.CommandSource.IBP);
} }
} else if (rbxxgm && !rbxxkm) { } else if (rbxxgm && !rbxxkm) {
if (!vrPsd.isSettingClose() && !vrPsd.isClose()) { if (!vrPsd.isSettingClose() && !vrPsd.isClose()) {
log.info(String.format("仿真[%s]IBP设备[%s]执行控制下行PSD关门", log.info(String.format("仿真[%s]IBP设备[%s]执行控制下行PSD关门",
simulation.getId(), pslConfig.getProjectDevice())); simulation.getId(), pslConfig.getProjectDevice()));
this.standService.controlVrPSD(simulation, vrPsd, false); this.vrPsdService.controlVrPSD(simulation, vrPsd, false, VrPsdService.CommandSource.IBP);
} }
} }
} }

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.service;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CI.service.StandService; import club.joylink.rtss.simulation.cbtc.CI.service.StandService;
import club.joylink.rtss.simulation.cbtc.CI.service.VrPsdService;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.ESP; import club.joylink.rtss.simulation.cbtc.data.map.ESP;
import club.joylink.rtss.simulation.cbtc.data.map.PSD; import club.joylink.rtss.simulation.cbtc.data.map.PSD;
@ -41,6 +42,9 @@ public class Heb1PslServiceImpl implements RealDeviceService {
@Autowired @Autowired
private Heb1PscServiceImpl heb1PscService; private Heb1PscServiceImpl heb1PscService;
@Autowired
private VrPsdService vrPsdService;
@Override @Override
public boolean canHandle(RealDeviceConfig deviceConfig) { public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof Heb1PslConfig; return deviceConfig instanceof Heb1PslConfig;
@ -107,7 +111,7 @@ public class Heb1PslServiceImpl implements RealDeviceService {
if (vrExist && !vrPsd.isSettingOpen() && !vrPsd.isOpen2End()) { if (vrExist && !vrPsd.isSettingOpen() && !vrPsd.isOpen2End()) {
log.info(String.format("仿真[%s]PSL设备[%s]执行控制PSD开门", log.info(String.format("仿真[%s]PSL设备[%s]执行控制PSD开门",
simulation.getId(), pslConfig.getProjectDevice())); simulation.getId(), pslConfig.getProjectDevice()));
this.standService.controlVrPSD(simulation, vrPsd, true); this.vrPsdService.controlVrPSD(simulation, vrPsd, true, VrPsdService.CommandSource.PSL);
} }
} }
// 关门按钮 // 关门按钮
@ -116,7 +120,7 @@ public class Heb1PslServiceImpl implements RealDeviceService {
if (vrExist && !vrPsd.isSettingClose() && !vrPsd.isClose()) { if (vrExist && !vrPsd.isSettingClose() && !vrPsd.isClose()) {
log.info(String.format("仿真[%s]PSL设备[%s]执行控制PSD关门", log.info(String.format("仿真[%s]PSL设备[%s]执行控制PSD关门",
simulation.getId(), pslConfig.getProjectDevice())); simulation.getId(), pslConfig.getProjectDevice()));
this.standService.controlVrPSD(simulation, vrPsd, false); this.vrPsdService.controlVrPSD(simulation, vrPsd, false, VrPsdService.CommandSource.PSL);
} }
} }
// 互锁解除按钮 // 互锁解除按钮

View File

@ -0,0 +1,21 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
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.richor.RichorDcuConfigVO;
import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO;
import lombok.Getter;
import java.util.Objects;
@Getter
public class RichorDcuConfig extends RealDeviceConfig {
private RichorDcuConfigVO configVO;
public RichorDcuConfig(ProjectDeviceVO deviceVO) {
super(deviceVO);
if (Objects.nonNull(deviceVO.getConfig())) {
this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorDcuConfigVO.class);
}
}
}

View File

@ -0,0 +1,57 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsSafetyCircleStatusVO;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
import club.joylink.rtss.vo.client.project.richor.RichorDcuConfigVO;
import io.netty.buffer.ByteBuf;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RichorDcuServiceImpl implements RealDeviceService {
@Autowired
private ApplicationContext applicationContext;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof RichorDcuConfig;
}
@Override
public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
}
@Override
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
RichorDcuConfig config = (RichorDcuConfig) deviceConfig;
RichorDcuConfigVO configVO = config.getConfigVO();
ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity());
boolean aqhl = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_aqhl());
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
String iscsCode = configVO.getIscsCode();
IscsSafetyCircleStatusVO iscsStatus = (IscsSafetyCircleStatusVO) iscsRepository.findStatus(iscsCode);
boolean change;
if (iscsStatus == null) {
IscsSafetyCircleStatusVO.DirectionalStatus upStatus = new IscsSafetyCircleStatusVO.DirectionalStatus(true, true, aqhl);
iscsStatus = new IscsSafetyCircleStatusVO(iscsCode, IscsStatusVO.DeviceType.SAFETY_CIRCLE, upStatus, null);
iscsRepository.addStatus(iscsStatus);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
simulation.watch(iscsStatus, watcher);
change = true;
} else {
IscsSafetyCircleStatusVO.DirectionalStatus upStatus = iscsStatus.getUpStatus();
change = upStatus.compareAndChange(true, true, aqhl);
}
if (change) {
iscsStatus.fireWatcher(null, null);
}
}
}

View File

@ -0,0 +1,23 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
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.richor.RichorIbpConfigVO;
import club.joylink.rtss.vo.client.project.richor.RichorPsdConfigVO;
import lombok.Getter;
import lombok.Setter;
import java.util.Objects;
@Getter
public class RichorIbpConfig extends RealDeviceConfig {
private RichorIbpConfigVO configVO;
public RichorIbpConfig(ProjectDeviceVO deviceVO) {
super(deviceVO);
if (Objects.nonNull(deviceVO.getConfig())) {
this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorIbpConfigVO.class);
}
}
}

View File

@ -0,0 +1,170 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CI.service.VrPsdService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.MapConfig;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsIbpStatusVO;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO;
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.rt.iscs.IscsStatusPublisher;
import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO;
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.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
public class RichorIbpServiceImpl implements RealDeviceService {
@Autowired
private PlcGatewayService plcGatewayService;
@Autowired
private CiApiService ciApiService;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private VrPsdService vrPsdService;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof RichorIbpConfig;
}
@Override
public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
PlcGateway plcGateway = simulation.getPlcGateway();
RichorIbpConfigVO configVO = ((RichorIbpConfig) deviceConfig).getConfigVO();
Channel channel = plcGateway.getChannel();
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_sx_kcd(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_xx_kcd(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), false, channel);
}
public static void main(String[] args) {
int addr = 2;
int bit = 9;
System.out.println((addr + 1) * 16 + (bit + 8) % 16);
}
@Override
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
PlcGateway plcGateway = simulation.queryPlcGatewayDevice();
if (plcGateway == null)
return;
RichorIbpConfig config = (RichorIbpConfig) deviceConfig;
Station station = (Station) config.getMapElement();
if (station == null)
return;
RichorIbpConfigVO configVO = config.getConfigVO();
ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity());
boolean r_xx_jjtc = !RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_jjtc());
boolean r_xx_qxjt = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_qxjt());
boolean r_xx_kc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_kc());
boolean r_xx_qxkc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_qxkc());
boolean r_sx_jjtc = !RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_jjtc());
boolean r_sx_qxjt = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_qxjt());
boolean r_sx_kc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_kc());
boolean r_sx_qxkc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_qxkc());
boolean r_sd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sd());
boolean r_qdbj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_qdbj());
boolean w_fmq = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fmq());
boolean w_sx_jjtcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_jjtcd());
boolean w_xx_jjtcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_jjtcd());
boolean w_sx_kcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_kcd());
boolean w_xx_kcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_kcd());
boolean r_sx_czyx = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_czyx());
boolean r_sx_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_km());
boolean r_sx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_gm());
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
Channel channel = plcGateway.getChannel();
//查找真实设备和vr设备
SimulationDataRepository repository = simulation.getRepository();
MapConfig mapConfig = repository.getConfig();
List<Stand> stands = station.getAllNormalStands();
List<Stand> upStands = station.getNormalStand(mapConfig.isRight(true));
List<Stand> downStands = station.getNormalStand(mapConfig.isRight(false));
//输入
if (r_xx_jjtc)
downStands.forEach(stand -> ciApiService.standEC(simulation, stand));
if (r_xx_qxjt)
downStands.forEach(stand -> ciApiService.cancelStandEC(simulation, stand));
if (r_xx_kc) {
for (Stand stand : downStands) {
if (!stand.isIbpHoldTrain()) {
ciApiService.ibpHoldTrain(simulation, stand.getCode());
}
}
}
if (r_xx_qxkc)
downStands.forEach(stand -> ciApiService.ibpHoldTrainCancel(simulation, stand.getCode()));
if (r_sx_jjtc)
upStands.forEach(stand -> ciApiService.standEC(simulation, stand));
if (r_sx_qxjt)
upStands.forEach(stand -> ciApiService.cancelStandEC(simulation, stand));
if (r_sx_kc) {
for (Stand stand : upStands) {
if (!stand.isIbpHoldTrain()) {
ciApiService.ibpHoldTrain(simulation, stand.getCode());
}
}
}
if (r_sx_qxkc)
upStands.forEach(stand -> ciApiService.ibpHoldTrainCancel(simulation, stand.getCode()));
upStands.forEach(stand -> stand.getPsd().getVirtualScreenDoor().setIbpControl(r_sx_czyx));
//输出
if (r_sd) {
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_kcd(), w_sx_kcd, true, channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), w_sx_jjtcd, true, channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_kcd(), w_xx_kcd, true, channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), w_xx_jjtcd, true, channel);
} else {
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_fmq(), w_fmq, false, channel);
boolean upHoldTrain = upStands.stream().anyMatch(Stand::isIbpHoldTrain);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_kcd(), w_sx_kcd, upHoldTrain, channel);
boolean upEc = upStands.stream().anyMatch(Stand::isEmergencyClosed);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), w_sx_jjtcd, upEc, channel);
boolean downHoldTrain = downStands.stream().anyMatch(Stand::isIbpHoldTrain);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_kcd(), w_xx_kcd, downHoldTrain, channel);
boolean downEc = downStands.stream().anyMatch(Stand::isEmergencyClosed);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), w_xx_jjtcd, downEc, channel);
}
//ISCS状态
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
String iscsCode = configVO.getIscsCode();
IscsIbpStatusVO iscsStatus = (IscsIbpStatusVO) iscsRepository.findStatus(iscsCode);
boolean change;
if (iscsStatus == null) {
IscsIbpStatusVO.DirectionalStatus downStatus =
new IscsIbpStatusVO.DirectionalStatus(r_sx_czyx, r_sx_km, false, r_sx_gm);
iscsStatus = new IscsIbpStatusVO(iscsCode, IscsStatusVO.DeviceType.IBP, null, downStatus);
iscsRepository.addStatus(iscsStatus);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
simulation.watch(iscsStatus, watcher);
change = true;
} else {
IscsIbpStatusVO.DirectionalStatus downStatus = iscsStatus.getDownStatus();
change = downStatus.compareAndChange(r_sx_czyx, r_sx_km, false, r_sx_gm);
}
if (change) {
iscsStatus.fireWatcher(null, null);
}
}
}

View File

@ -0,0 +1,21 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
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.richor.RichorPsdConfigVO;
import lombok.Getter;
import java.util.Objects;
@Getter
public class RichorPsdConfig extends RealDeviceConfig {
private RichorPsdConfigVO configVO;
public RichorPsdConfig(ProjectDeviceVO deviceVO) {
super(deviceVO);
if (Objects.nonNull(deviceVO.getConfig())) {
this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorPsdConfigVO.class);
}
}
}

View File

@ -0,0 +1,84 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsIbpStatusVO;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsPsdStatusVO;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
import club.joylink.rtss.vo.client.project.richor.RichorPsdConfigVO;
import io.netty.buffer.ByteBuf;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@Slf4j
@Component
public class RichorPsdServiceImpl implements RealDeviceService {
@Autowired
private ApplicationContext applicationContext;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof RichorPsdConfig;
}
@Override
public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
// PlcGateway plcGateway = simulation.getPlcGateway();
// RichorPsdConfig config = (RichorPsdConfig) deviceConfig;
// RichorPsdConfigVO configVO = config.getConfigVO();
// Channel channel = plcGateway.getChannel();
// int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
//
// VirtualRealityScreenDoor vrPsd = (VirtualRealityScreenDoor) config.getMapElement();
// if (vrPsd != null) {
// vrPsd.startSetting(false);
// }
}
@Override
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
RichorPsdConfig config = (RichorPsdConfig) deviceConfig;
RichorPsdConfigVO configVO = config.getConfigVO();
ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity());
boolean km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_wgm());
boolean sj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_sj());
boolean dcugz = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_dcugz());
boolean r_sx_glms = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_glms());
String iscsCode = configVO.getIscsCode();
if (StringUtils.hasText(iscsCode)) {
IscsPsdStatusVO.Status status;
if (km) {
status = IscsPsdStatusVO.Status.OPEN;
} else if (sj) {
status = IscsPsdStatusVO.Status.CLOSE;
} else if (dcugz) {
status = IscsPsdStatusVO.Status.DCU_FAULT;
} else {
status = IscsPsdStatusVO.Status.UNDEFINED;
}
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
IscsPsdStatusVO iscsStatus = (IscsPsdStatusVO) iscsRepository.findStatus(iscsCode);
boolean change = false;
if (iscsStatus == null) {
IscsPsdStatusVO.DirectionalStatus downStatus = new IscsPsdStatusVO.DirectionalStatus(status, r_sx_glms);
iscsStatus = new IscsPsdStatusVO(iscsCode, IscsStatusVO.DeviceType.SLIDING_DOOR, null, downStatus);
iscsRepository.addStatus(iscsStatus);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
simulation.watch(iscsStatus, watcher);
change = true;
} else {
IscsPsdStatusVO.DirectionalStatus downStatus = iscsStatus.getDownStatus();
change = downStatus.compareAndChange(status, r_sx_glms);
}
if (change) {
iscsStatus.fireWatcher(null, null);
}
}
}
}

View File

@ -0,0 +1,24 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
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.richor.RichorPsdConfigVO;
import club.joylink.rtss.vo.client.project.richor.RichorPslConfigVO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Objects;
@Getter
public class RichorPslConfig extends RealDeviceConfig {
private RichorPslConfigVO configVO;
public RichorPslConfig(ProjectDeviceVO deviceVO) {
super(deviceVO);
if (Objects.nonNull(deviceVO.getConfig())) {
this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorPslConfigVO.class);
}
}
}

View File

@ -0,0 +1,68 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
import club.joylink.rtss.simulation.cbtc.CI.service.StandService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsPslStatusVO;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
import club.joylink.rtss.vo.client.project.richor.RichorPslConfigVO;
import io.netty.buffer.ByteBuf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
@Component
public class RichorPslServiceImpl implements RealDeviceService {
@Autowired
private StandService standService;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof RichorPslConfig;
}
@Override
public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
}
@Override
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
RichorPslConfig config = (RichorPslConfig) deviceConfig;
RichorPslConfigVO configVO = config.getConfigVO();
ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity());
boolean r_sx_czyx = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_czyx());
boolean r_sx_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_km());
boolean r_sx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_gm());
boolean r_sx_hsjc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_hsjc());
//信号系统状态
Stand stand = (Stand) config.getMapElement();
if (stand != null) {
stand.getPsd().getVirtualScreenDoor().setPslControl(r_sx_czyx);
standService.setOrCancelInterlockRelease(simulation, stand, r_sx_hsjc);
}
//ISCS状态
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
String iscsCode = configVO.getIscsCode();
IscsPslStatusVO iscsStatus = (IscsPslStatusVO) iscsRepository.findStatus(iscsCode);
boolean change;
if (iscsStatus == null) {
IscsPslStatusVO.DirectionalStatus downStatus = new IscsPslStatusVO.DirectionalStatus(r_sx_czyx, r_sx_km, r_sx_gm, r_sx_hsjc);
iscsStatus = new IscsPslStatusVO(iscsCode, IscsStatusVO.DeviceType.PSL, null, downStatus);
iscsRepository.addStatus(iscsStatus);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
simulation.watch(iscsStatus, watcher);
change = true;
} else {
IscsPslStatusVO.DirectionalStatus downStatus = iscsStatus.getDownStatus();
change = downStatus.compareAndChange(r_sx_czyx, r_sx_km, r_sx_gm, r_sx_hsjc);
}
if (change) {
iscsStatus.fireWatcher(null, null);
}
}
}

View File

@ -5,11 +5,14 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher;
import club.joylink.rtss.simulation.cbtc.ATS.operation.handler.DriverOperateHandler; import club.joylink.rtss.simulation.cbtc.ATS.operation.handler.DriverOperateHandler;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStationService; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStationService;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CI.service.VrPsdService;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.map.Station; import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferReplyVO; import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferReplyVO;
@ -26,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.task.TaskExecutor; import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -66,6 +70,9 @@ public class RobotLogicLoop {
@Autowired @Autowired
private ATPService atpService; private ATPService atpService;
@Autowired
private VrPsdService vrPsdService;
/** /**
* 根据目标位置运行 * 根据目标位置运行
*/ */
@ -94,17 +101,14 @@ public class RobotLogicLoop {
break; break;
case CLOSE_DOOR: case CLOSE_DOOR:
atoService.syncCloseDoor(simulation, train); atoService.syncCloseDoor(simulation, train);
// atpService.openOrCloseDoor(simulation, train, false, false); SectionPosition headPosition = train.getHeadPosition();
// atpService.openOrCloseDoor(simulation, train, true, false); Section section = headPosition.getSection();
// if (!train.isCommunicable()) { List<Stand> standList = section.getStandList();
// Section headSection = train.getHeadPosition().getSection(); if (!CollectionUtils.isEmpty(standList)) {
// List<Stand> standList = headSection.getStandList(); //这里应该先转操作允许/禁止钥匙再关门暂时这样简单处理
// if (!CollectionUtils.isEmpty(standList)) { standList.forEach(stand -> vrPsdService.controlVrPSD(simulation,
// for (Stand stand : standList) { stand.getPsd().getVirtualScreenDoor(), false, VrPsdService.CommandSource.PSL));
// ciApiService.closeScreenDoor(simulation, stand.getCode()); }
// }
// }
// }
break; break;
case START: case START:
if (train.isAutoOpenATO()) { if (train.isAutoOpenATO()) {

View File

@ -0,0 +1,38 @@
package club.joylink.rtss.simulation.rt.iscs;
import club.joylink.rtss.simulation.Simulation;
import club.joylink.rtss.simulation.SimulationTriggerMessagePublisher;
import club.joylink.rtss.simulation.Watchable;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
import com.sun.source.tree.ReturnTree;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class IscsStatusPublisher extends SimulationTriggerMessagePublisher {
public static final String Name = "iscs";
public static final String Destination = String.format("%s/%s/%s", Simulation.MESSAGE_SUB_PREFIX, "iscs", "psd");
club.joylink.rtss.simulation.cbtc.Simulation simulation;
public IscsStatusPublisher(club.joylink.rtss.simulation.cbtc.Simulation simulation) {
super(Name, Collections.singletonList(Destination));
this.simulation = simulation;
}
@Override
public Object buildMessageOfSubscribe(String destination) {
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
return iscsRepository.getAllStatus();
}
@Override
public List<String> getNeedBuildDestination(Watchable watchable) {
return new ArrayList<>(this.getDestinationParamsMap().keySet());
}
@Override
public Object buildMessage(Watchable watchable) {
return Collections.singletonList(watchable);
}
}

View File

@ -188,5 +188,8 @@ public enum WebSocketMessageType {
/**广播消息 */ /**广播消息 */
BROADCAST, BROADCAST,
/** ------------ISCS消息------------- */
ISCS,
; ;
} }

View File

@ -9,10 +9,16 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDevice
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.richor.RichorDcuConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorIbpConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorPsdConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorPslConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPsdConfig; 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.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.util.JsonUtils; import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO;
import club.joylink.rtss.vo.client.project.richor.RichorPslConfigVO;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -104,12 +110,39 @@ public class ProjectDeviceVO {
case SDY: { case SDY: {
return sdyDeviceConfigConvert(voList); return sdyDeviceConfigConvert(voList);
} }
case RICHOR_JOINT: {
return richorJointDeviceConfigConvert(voList);
}
} }
} }
return list; return list;
} }
private static List<RealDeviceConfig> richorJointDeviceConfigConvert(List<ProjectDeviceVO> voList) {
List<RealDeviceConfig> list = new ArrayList<>();
for (ProjectDeviceVO deviceVO : voList) {
switch (deviceVO.getType()) {
case IBP:
list.add(new RichorIbpConfig(deviceVO));
break;
case PLC_GATEWAY:
list.add(new PlcGateway(deviceVO));
break;
case PSD:
list.add(new RichorPsdConfig(deviceVO));
break;
case PSL:
list.add(new RichorPslConfig(deviceVO));
break;
case DCU:
list.add(new RichorDcuConfig(deviceVO));
break;
}
}
return list;
}
private static List<RealDeviceConfig> sdyDeviceConfigConvert(List<ProjectDeviceVO> voList) { private static List<RealDeviceConfig> sdyDeviceConfigConvert(List<ProjectDeviceVO> voList) {
List<RealDeviceConfig> list = new ArrayList<>(); List<RealDeviceConfig> list = new ArrayList<>();
for (ProjectDeviceVO deviceVO : voList) { for (ProjectDeviceVO deviceVO : voList) {

View File

@ -0,0 +1,35 @@
package club.joylink.rtss.vo.client.project.richor;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* 安全回路
*/
@Getter
@Setter
@NoArgsConstructor
public class RichorDcuConfigVO {
private String iscsCode = "dcu";
/**
* 网关位开始地址
*/
private Integer addr = 0;
/**
* 位数量
*/
private Integer quantity = 80;
/* ----------------------状态位---------------------- */
/** 安全回路 */
private Integer r_sx_aqhl = 68;
@JsonIgnore
public String toJson() {
return JsonUtils.writeValueAsString(this);
}
}

View File

@ -0,0 +1,122 @@
package club.joylink.rtss.vo.client.project.richor;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class RichorIbpConfigVO {
/**
* ibp盘绑定的车站
*/
private String stationCode = "Station25166";
private String iscsCode = "ibp";
/**
* 网关位开始地址
*/
private Integer addr = 0;
/**
* 位数量
*/
private Integer quantity = 80;
/*---------------- 屏蔽门 ----------------*/
/**
* 下行紧急停车1是false因为只能接常闭点
*/
private Integer r_xx_jjtc = 4;
/**
* 下行取消紧停
*/
private Integer r_xx_qxjt = 5;
/**
* 下行扣车
*/
private Integer r_xx_kc = 6;
/**
* 下行取消扣车
*/
private Integer r_xx_qxkc = 7;
/**
* 上行紧急停车1是false因为只能接常闭点
*/
private Integer r_sx_jjtc = 0;
/**
* 上行取消紧停
*/
private Integer r_sx_qxjt = 1;
/**
* 上行扣车
*/
private Integer r_sx_kc = 2;
/**
* 上行取消扣车
*/
private Integer r_sx_qxkc = 3;
/**
* 试灯
*/
private Integer r_sd = 8;
/**
* 切断报警
*/
private Integer r_qdbj = 9;
/**
* 蜂鸣器
*/
private Integer w_fmq = 18;
/**
* 上行紧急停车灯
*/
private Integer w_sx_jjtcd = 21;
/**
* 下行紧急停车灯
*/
private Integer w_xx_jjtcd = 20;
/**
* 上行扣车灯
*/
private Integer w_sx_kcd = 23;
/**
* 下行扣车灯
*/
private Integer w_xx_kcd = 22;
/** 操作允许 */
private Integer r_sx_czyx = 77;
/** 开门命令 */
private Integer r_sx_km = 75;
/** 关门命令 */
private Integer r_sx_gm = 76;
public RichorIbpConfigVO(Integer addr, Integer quantity) {
this.addr = addr;
this.quantity = quantity;
}
@JsonIgnore
public String toJson() {
return JsonUtils.writeValueAsString(this);
}
}

View File

@ -0,0 +1,109 @@
package club.joylink.rtss.vo.client.project.richor;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
@Getter
@Setter
@NoArgsConstructor
public class RichorPsdConfigVO {
// /**
// * 关联的站台屏蔽门code
// */
// @NotBlank(message = "关联的站台屏蔽门code不能为空")
// private String psdCode;
/**
* 关联的ISCS元素的code
*/
private String iscsCode = "FuzhouPsd_33";
/**
* 网关位开始地址
*/
private Integer addr = 0;
/**
* 位数量
*/
private Integer quantity = 144;
/*---------------- 屏蔽门 ----------------*/
/**
* 自动模式
*/
private Integer r_sx_zdms = 136;
/**
* 处于手动开模式
*/
private Integer r_sx_sdkm = 137;
/**
* 处于手动关模式
*/
private Integer r_sx_sdgm = 138;
/**
* 处于隔离模式
*/
private Integer r_sx_glms = 139;
/**
* 门未关闭
*/
private Integer r_sx_wgm = 140;
/**
* 滑动门DCU故障
*/
private Integer r_sx_dcugz = 141;
/**
* 滑动门电机故障
*/
private Integer r_sx_djgz = 142;
/**
* 处于手动解锁模式
*/
private Integer r_sx_sdjs = 143;
/**
* 滑动门门锁开关故障
*/
private Integer r_sx_mskggz = 128;
/**
* 滑动门开关遇阻故障
*/
private Integer r_sx_yzgz = 129;
/**
* 滑动门通讯故障
*/
private Integer r_sx_txgz = 130;
/**
* 滑动门关闭且锁紧
*/
private Integer r_sx_sj = 131;
/**
* 对位隔离
*/
private Integer r_sx_dwgl = 132;
public RichorPsdConfigVO(Integer addr, Integer quantity) {
this.addr = addr;
this.quantity = quantity;
}
@JsonIgnore
public String toJson() {
return JsonUtils.writeValueAsString(this);
}
}

View File

@ -0,0 +1,43 @@
package club.joylink.rtss.vo.client.project.richor;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class RichorPslConfigVO {
private String standCode = "PF59020";
private String iscsCode = "psl";
/**
* 网关位开始地址
*/
private Integer addr = 0;
/**
* 位数量
*/
private Integer quantity = 64;
/** 状态位 */
/** 操作允许 */
private Integer r_sx_czyx = 52;
/** 开门命令 */
private Integer r_sx_km = 50;
/** 关门命令 */
private Integer r_sx_gm = 51;
/** 互锁解除 */
private Integer r_sx_hsjc = 49;
@JsonIgnore
public String toJson() {
return JsonUtils.writeValueAsString(this);
}
}

View File

@ -22,6 +22,18 @@ public class StompMessageService {
@Autowired @Autowired
private SimpMessagingTemplate SMT; private SimpMessagingTemplate SMT;
public void send(SocketMessageVO messageVO) {
if (Objects.nonNull(messageVO) && Objects.nonNull(messageVO.getBody())) {
if (!(messageVO.getBody() instanceof Collection) || !CollectionUtils.isEmpty((Collection<?>) messageVO.getBody())) {
Object send = getPayload(messageVO);
for (Object o : messageVO.getTopicList()) {
String topic = (String) o;
this.SMT.convertAndSend(topic, send);
}
}
}
}
public void sendToUser(String user, SocketMessageVO messageVO) { public void sendToUser(String user, SocketMessageVO messageVO) {
if (Objects.nonNull(messageVO) && Objects.nonNull(messageVO.getBody()) && StringUtils.hasText(user)) { if (Objects.nonNull(messageVO) && Objects.nonNull(messageVO.getBody()) && StringUtils.hasText(user)) {
if (!(messageVO.getBody() instanceof Collection) || !CollectionUtils.isEmpty((Collection<?>) messageVO.getBody())) { if (!(messageVO.getBody() instanceof Collection) || !CollectionUtils.isEmpty((Collection<?>) messageVO.getBody())) {

View File

@ -163,9 +163,9 @@ common:
spring: spring:
profiles: local profiles: local
datasource: datasource:
url: jdbc:mysql://160.20.60.16:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true url: jdbc:mysql://192.168.1.254:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root username: root
password: heblocal password: localdb
tencent-cloud: tencent-cloud:
allow-send: false allow-send: false