义乌项目真实设备联动

This commit is contained in:
thesai 2021-09-11 15:55:16 +08:00
parent 2cef80778a
commit 3701b2df84
33 changed files with 1219 additions and 13 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

@ -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

@ -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,66 @@
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
@Setter
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,23 @@
package club.joylink.rtss.simulation.cbtc.data.vo.iscs;
import lombok.Getter;
import lombok.Setter;
@Getter
public class IscsPsdStatusVO extends IscsStatusVO{
@Setter
private Status status;
public IscsPsdStatusVO(String code, DeviceType deviceType, Status status) {
super(code, deviceType);
this.status = status;
}
public enum Status {
OPEN,
CLOSE,
DCU_FAULT,
UNDEFINED,
}
}

View File

@ -0,0 +1,64 @@
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
@Setter
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,55 @@
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
@Setter
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

@ -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,165 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
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;
@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()));
//输出
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 upStatus =
new IscsIbpStatusVO.DirectionalStatus(r_sx_czyx, r_sx_km, false, r_sx_gm);
iscsStatus = new IscsIbpStatusVO(iscsCode, IscsStatusVO.DeviceType.IBP, upStatus, null);
iscsRepository.addStatus(iscsStatus);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
simulation.watch(iscsStatus, watcher);
change = true;
} else {
IscsIbpStatusVO.DirectionalStatus upStatus = iscsStatus.getUpStatus();
change = upStatus.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,83 @@
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.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());
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) {
iscsStatus = new IscsPsdStatusVO(iscsCode, IscsStatusVO.DeviceType.SLIDING_DOOR, status);
iscsRepository.addStatus(iscsStatus);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
simulation.watch(iscsStatus, watcher);
change = true;
} else {
if (!status.equals(iscsStatus.getStatus())) {
iscsStatus.setStatus(status);
change = true;
}
}
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,59 @@
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.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 ApplicationContext applicationContext;
@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());
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
String iscsCode = configVO.getIscsCode();
IscsPslStatusVO iscsStatus = (IscsPslStatusVO) iscsRepository.findStatus(iscsCode);
boolean change;
if (iscsStatus == null) {
IscsPslStatusVO.DirectionalStatus upStatus = new IscsPslStatusVO.DirectionalStatus(r_sx_czyx, r_sx_km, r_sx_gm, r_sx_hsjc);
iscsStatus = new IscsPslStatusVO(iscsCode, IscsStatusVO.DeviceType.PSL, upStatus, null);
iscsRepository.addStatus(iscsStatus);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
simulation.watch(iscsStatus, watcher);
change = true;
} else {
IscsPslStatusVO.DirectionalStatus upStatus = iscsStatus.getUpStatus();
change = upStatus.compareAndChange(r_sx_czyx, r_sx_km, r_sx_gm, r_sx_hsjc);
}
if (change) {
iscsStatus.fireWatcher(null, null);
}
}
}

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 = 0;
/**
* 下行取消紧停
*/
private Integer r_xx_qxjt = 1;
/**
* 下行扣车
*/
private Integer r_xx_kc = 2;
/**
* 下行取消扣车
*/
private Integer r_xx_qxkc = 3;
/**
* 上行紧急停车1是false因为只能接常闭点
*/
private Integer r_sx_jjtc = 4;
/**
* 上行取消紧停
*/
private Integer r_sx_qxjt = 5;
/**
* 上行扣车
*/
private Integer r_sx_kc = 6;
/**
* 上行取消扣车
*/
private Integer r_sx_qxkc = 7;
/**
* 试灯
*/
private Integer r_sd = 8;
/**
* 切断报警
*/
private Integer r_qdbj = 9;
/**
* 蜂鸣器
*/
private Integer w_fmq = 18;
/**
* 上行紧急停车灯
*/
private Integer w_sx_jjtcd = 20;
/**
* 下行紧急停车灯
*/
private Integer w_xx_jjtcd = 21;
/**
* 上行扣车灯
*/
private Integer w_sx_kcd = 22;
/**
* 下行扣车灯
*/
private Integer w_xx_kcd = 23;
/** 操作允许 */
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 psdCode;
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