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

This commit is contained in:
walker-sheng 2021-09-23 14:37:37 +08:00
commit 760dfb8ca7
41 changed files with 490 additions and 594 deletions

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.services;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.status.IbpStatus;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp;
/**
* 虚拟真实IBP服务
@ -18,6 +19,9 @@ public interface IVirtualRealityIbpService {
*/
void pressTheButton(String group, String stationCode, String buttonCode);
void updateElementStatus(Simulation simulation, VirtualRealityIbp ibp,
VirtualRealityIbp.IbpElement element, boolean pressed);
/**
* 收集并发送IBP的状态数据
* @param simulation

View File

@ -2,10 +2,9 @@ package club.joylink.rtss.services;
import club.joylink.rtss.exception.BaseException;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.publishData.IbpService;
import club.joylink.rtss.services.publishData.IbpServiceImpl;
import club.joylink.rtss.simulation.cbtc.ATS.operation.handler.StandOperateHandler;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService;
import club.joylink.rtss.simulation.cbtc.GroupSimulationCache;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
@ -18,12 +17,6 @@ import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.status.IbpStatus;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp;
import club.joylink.rtss.simulation.cbtc.event.SimulationIbpStatusEvent;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.ibp.IbpData;
import club.joylink.rtss.vo.client.ibp.IbpQueryVO;
import club.joylink.rtss.vo.client.ibp.IbpVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
@ -50,10 +43,7 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
private ApplicationContext applicationContext;
@Autowired
private IbpService ibpService;
@Autowired
private IbpServiceImpl ibpServiceImpl;
private CiStandService ciStandService;
@Override
public IbpStatus getIbpStatus(String group, String stationCode) {
@ -76,79 +66,82 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
Station station = simulation.getRepository().getByCode(stationCode, Station.class);
VirtualRealityIbp ibp = collect4Ibp(simulation, station);
MapConfig config = simulation.getRepository().getConfig();
VirtualRealityIbp.IbpElement element = ibp.getByCode(buttonCode);
theButtonIsPressed(simulation, ibp, element);
}
private void theButtonIsPressed(Simulation simulation, VirtualRealityIbp ibp, VirtualRealityIbp.IbpElement element) {
boolean change = false;
if (VirtualRealityIbp.Type.KEY.equals(element.getType())) {
element.setOn(!element.isOn());
return;
}
List<Stand> stands = chooseStands(station, element, config);
boolean change = false;
VirtualRealityIbp.SquareButton button = null;
if (VirtualRealityIbp.Type.BUTTON.equals(element.getType())) {
button = (VirtualRealityIbp.SquareButton) element;
if (!button.isPressed())
} else if (VirtualRealityIbp.Type.BUTTON.equals(element.getType())) {
VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element;
if (!button.isOn())
change = true;
button.setPressed(true);
if (button.getMean() == null) {
button.setOn(true);
return;
}
element.setOn(true);
}
if (change)
effective(simulation, ibp, element);
}
/**
* IBP盘上元素对应的功能生效
*/
private void effective(Simulation simulation, VirtualRealityIbp ibp, VirtualRealityIbp.IbpElement element) {
if (!element.isOn())
return;
Station station = ibp.getStation();
MapConfig config = simulation.getRepository().getConfig();
List<Stand> stands = chooseStands(station, element, config);
switch (element.getMean()) {
case KC:
element.setOn(true);
stands.forEach(stand -> ciApiService.ibpHoldTrain(simulation, stand.getCode()));
break;
case ZZKC:
element.setOn(true);
stands.forEach(stand -> ciApiService.ibpHoldTrainCancel(simulation, stand.getCode()));
break;
case JJTC:
element.setOn(true);
stands.forEach(stand -> ciApiService.standEC(simulation, stand));
ibp.query(VirtualRealityIbp.Mean.ALARM, element.getUp()).forEach(alarm -> alarm.setOn(true));
break;
case QXJJTC:
element.setOn(true);
stands.forEach(stand -> ciApiService.cancelStandEC(simulation, stand));
break;
case BJQC:
element.setOn(true);
ibp.query(VirtualRealityIbp.Mean.ALARM, element.getUp()).forEach(ele -> ele.setOn(false));
break;
case ALARM:
break;
case KM: {
element.setOn(true);
stands.forEach(stand -> ciApiService.openScreenDoor(simulation, stand.getCode()));
stands.forEach(stand -> ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.IBP));
break;
}
case GM: {
element.setOn(true);
stands.forEach(stand -> ciApiService.closeScreenDoor(simulation, stand.getCode()));
stands.forEach(stand -> ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.IBP));
break;
}
case XXYS:
case SXYS:
element.setOn(!element.isOn());
// element.setOn(!element.isOn());
break;
case AXLE_RESET:
element.setOn(true);
case AXLE_RESET: {
VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element;
ciApiService.axleReset(simulation, button.getSectionCode());
break;
case AXLE_PRE_RESET:
if (change) {
}
case AXLE_PRE_RESET: {
VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element;
if (!button.isEffective()) {
button.setEffective(true);
button.setPressTime(LocalDateTime.now());
}
break;
}
case PRERESET_Z:
element.setOn(true);
break;
case SD:
element.setOn(true);
ibp.queryByType(VirtualRealityIbp.Type.LIGHT).forEach(light -> light.setOn(true));
break;
default:
@ -169,14 +162,30 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
Station station = simulation.getRepository().getByCode(stationCode, Station.class);
VirtualRealityIbp ibp = collect4Ibp(simulation, station);
VirtualRealityIbp.IbpElement element = ibp.getByCode(buttonCode);
theButtonIsReleased(element);
}
private void theButtonIsReleased(VirtualRealityIbp.IbpElement element) {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(VirtualRealityIbp.Type.BUTTON.equals(element.getType()), "元素非按钮");
VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element;
button.setPressed(false);
if (!VirtualRealityIbp.Mean.AXLE_PRE_RESET.equals(button.getMean())) {
button.setOn(false);
} else {
button.setEffective(false);
}
if (VirtualRealityIbp.Mean.SD.equals(button.getMean())) {
ibp.queryByType(VirtualRealityIbp.Type.LIGHT).forEach(light -> light.setOn(false));
}
/**
* 更新IBP元素状态
* @param pressed true-按下false-松开
*/
@Override
public void updateElementStatus(Simulation simulation, VirtualRealityIbp ibp,
VirtualRealityIbp.IbpElement element, boolean pressed) {
if (pressed) {
theButtonIsPressed(simulation, ibp, element);
} else {
theButtonIsReleased(element);
}
}
@ -209,12 +218,12 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
@Override
public void addJobs(Simulation simulation) {
simulation.addJob(Simulation.JobName.ibpJob, () -> this.logic(simulation), 500);
simulation.addJob(Simulation.JobName.ibpJob, () -> this.preResetLogic(simulation), 500);
simulation.addJob(SimulationModule.IBP_STATUS.name(), () -> this.collectAndDispatcher(simulation),
SimulationConstants.IBP_STATUS_COLLECT_RATE);
}
private void logic(Simulation simulation) {
private void preResetLogic(Simulation simulation) {
SimulationDataRepository repository = simulation.getRepository();
for (Station station : repository.getStationList()) {
VirtualRealityIbp ibp = station.getVrIbp();
@ -256,8 +265,6 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
boolean sd = false;
if (!CollectionUtils.isEmpty(sdList)) {
sd = sdList.stream().anyMatch(VirtualRealityIbp.IbpElement::isOn);
// VirtualRealityIbp.SquareButton sdButton = (VirtualRealityIbp.SquareButton) sdList.get(0);
// sd = sdButton.isOn();
}
for (VirtualRealityIbp.IbpElement element : vrIbp.getElementList()) {
List<Stand> stands = chooseStands(station, element, config);

View File

@ -12,10 +12,9 @@ import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.project.*;
import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO;
import club.joylink.rtss.vo.client.project.gzb.GzbSwitchConfigVO;
import club.joylink.rtss.vo.client.project.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.richor.ZjdIbpConfigVO;
import club.joylink.rtss.vo.client.project.richor.ZjdPsdConfigVO;
import club.joylink.rtss.vo.client.project.richor.ZjdPslConfigVO;
import club.joylink.rtss.vo.client.project.sdy.SdyPsdConfigVO;
import club.joylink.rtss.vo.client.project.sdy.SdyPslConfigVO;
import club.joylink.rtss.vo.client.project.xty.XtyPsdConfigVO;
@ -418,7 +417,7 @@ public class DeviceServiceImpl implements DeviceService {
psd.setType(ProjectDeviceType.PSD.name());
psd.setCreator(accountVO.getId());
psd.setCreateTime(now);
RichorPsdConfigVO psdConfigVO = new RichorPsdConfigVO();
ZjdPsdConfigVO psdConfigVO = new ZjdPsdConfigVO();
psd.setConfig(psdConfigVO.toJson());
list.add(psd);
// IBP盘
@ -428,7 +427,7 @@ public class DeviceServiceImpl implements DeviceService {
ibp.setType(ProjectDeviceType.IBP.name());
ibp.setCreator(accountVO.getId());
ibp.setCreateTime(now);
RichorIbpConfigVO ibpConfigVO = new RichorIbpConfigVO();
ZjdIbpConfigVO ibpConfigVO = new ZjdIbpConfigVO();
ibp.setConfig(ibpConfigVO.toJson());
list.add(ibp);
// PSL
@ -438,19 +437,9 @@ public class DeviceServiceImpl implements DeviceService {
psl.setType(ProjectDeviceType.PSL.name());
psl.setCreator(accountVO.getId());
psl.setCreateTime(now);
RichorPslConfigVO pslConfigVO = new RichorPslConfigVO();
ZjdPslConfigVO pslConfigVO = new ZjdPslConfigVO();
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;
}

View File

@ -10,5 +10,7 @@ public interface IVirtualRealityPslService {
void pressTheButton(String group, String standCode, VirtualRealityPsl.Button button);
void updateStatus(Simulation simulation, VirtualRealityPsl vrPsl, VirtualRealityPsl.Button button, boolean on);
void addJobs(Simulation simulation);
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.services.psl;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService;
import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
import club.joylink.rtss.simulation.cbtc.Simulation;
@ -9,8 +10,6 @@ import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.PSD;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService;
import club.joylink.rtss.simulation.cbtc.event.SimulationPslStatusEvent;
import club.joylink.rtss.vo.client.psl.PslStatus;
import org.springframework.beans.factory.annotation.Autowired;
@ -22,7 +21,7 @@ import java.util.HashMap;
import java.util.Map;
@Service
public class VirtualRealityPslService implements IVirtualRealityPslService{
public class VirtualRealityPslService implements IVirtualRealityPslService {
@Autowired
private GroupSimulationService groupSimulationService;
@ -31,9 +30,7 @@ public class VirtualRealityPslService implements IVirtualRealityPslService{
private ApplicationContext applicationContext;
@Autowired
private CiStandService standService;
@Autowired
private VirtualRealityDeviceService virtualRealityDeviceService;
private CiApiService ciApiService;
@Override
public PslStatus getStatus(String group, String standCode) {
@ -58,6 +55,11 @@ public class VirtualRealityPslService implements IVirtualRealityPslService{
Simulation simulation = groupSimulationService.getSimulationByGroup(group);
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
VirtualRealityPsl vrPsl = collectStatus(stand);
theButtonIsPressed(simulation, vrPsl, button);
}
private void theButtonIsPressed(Simulation simulation, VirtualRealityPsl vrPsl, VirtualRealityPsl.Button button) {
Stand stand = vrPsl.getStand();
synchronized (vrPsl) {
switch (button) {
case YXJZ:
@ -65,13 +67,13 @@ public class VirtualRealityPslService implements IVirtualRealityPslService{
break;
case HSJC:
vrPsl.setHsjcKey(!vrPsl.isHsjcKey());
standService.setOrCancelInterlockRelease(simulation, stand, vrPsl.isHsjcKey());
ciApiService.setOrCancelInterlockRelease(simulation, stand, vrPsl.isHsjcKey());
break;
case KM:
standService.openScreenDoor(simulation, stand, CiStandService.PsdCommandSource.PSL);
ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL);
break;
case GM:
standService.closeScreenDoor(simulation, stand, CiStandService.PsdCommandSource.PSL);
ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL);
break;
case SD:
vrPsl.setSdButton(!vrPsl.isSdButton());
@ -80,6 +82,45 @@ public class VirtualRealityPslService implements IVirtualRealityPslService{
}
}
@Override
public void updateStatus(Simulation simulation, VirtualRealityPsl vrPsl, VirtualRealityPsl.Button button, boolean on) {
switch (button) {
case YXJZ:
vrPsl.setYxjzKey(on);
break;
case HSJC:
vrPsl.setHsjcKey(on);
break;
case KM:
case GM:
break;
case SD:
vrPsl.setSdButton(on);
break;
}
effective(simulation, vrPsl.getStand(), button, on);
}
private void effective(Simulation simulation, Stand stand, VirtualRealityPsl.Button button, boolean on) {
switch (button) {
case YXJZ:
break;
case HSJC:
ciApiService.setOrCancelInterlockRelease(simulation, stand, on);
break;
case KM:
if (on)
ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL);
break;
case GM:
if (on)
ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL);
break;
case SD:
break;
}
}
@Override
public void addJobs(Simulation simulation) {
simulation.addJobIfAbsent(Simulation.JobName.pslStatus,

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.CI;
import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.ESP;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
@ -222,15 +223,17 @@ public interface CiApiService {
* 开站台屏蔽门
* @param simulation
* @param standCode
* @param source
*/
void openScreenDoor(Simulation simulation, String standCode);
void openScreenDoor(Simulation simulation, String standCode, CiStandService.PsdCommandSource source);
/**
* 关站台屏蔽门
* @param simulation
* @param standCode
* @param source
*/
void closeScreenDoor(Simulation simulation, String standCode);
void closeScreenDoor(Simulation simulation, String standCode, CiStandService.PsdCommandSource source);
/**
* 站台扣车联锁关系处理
@ -349,4 +352,6 @@ public interface CiApiService {
* @param overlapCode
*/
void setOverlap(Simulation simulation, String signalCode, String overlapCode);
void setOrCancelInterlockRelease(Simulation simulation, Stand stand, boolean release);
}

View File

@ -318,15 +318,15 @@ public class CiApiServiceImpl2 implements CiApiService {
}
@Override
public void openScreenDoor(Simulation simulation, String standCode) {
public void openScreenDoor(Simulation simulation, String standCode, CiStandService.PsdCommandSource source) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
if (Objects.nonNull(stand.getPsd())) {
standService.openScreenDoor(simulation, stand, CiStandService.PsdCommandSource.SIG);
standService.openScreenDoor(simulation, stand, source);
}
}
@Override
public void closeScreenDoor(Simulation simulation, String standCode) {
public void closeScreenDoor(Simulation simulation, String standCode, CiStandService.PsdCommandSource source) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
if (Objects.nonNull(stand.getPsd())) {
standService.closeScreenDoor(simulation, stand, CiStandService.PsdCommandSource.SIG);
@ -593,6 +593,11 @@ public class CiApiServiceImpl2 implements CiApiService {
this.routeService.setOverlap(simulation, overlap);
}
@Override
public void setOrCancelInterlockRelease(Simulation simulation, Stand stand, boolean release) {
standService.setOrCancelInterlockRelease(stand, release);
}
/**
* 获取计轴器并为预复位/复位操作检查设备状态
*/

View File

@ -148,7 +148,7 @@ public class CiStandService {
* 设置或取消互锁解除
* @param release 是否是设置
*/
public void setOrCancelInterlockRelease(Simulation simulation, Stand stand, boolean release) {
public void setOrCancelInterlockRelease(Stand stand, boolean release) {
stand.getPsd().getVirtualScreenDoor().updateIL(release);
stand.getPsd().setInterlockRelease(release);
// if (release) {

View File

@ -14,8 +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.Heb1PscConfig;
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.richor.ZjdIbpConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPslConfig;
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.member.MemberManager;
@ -25,6 +25,7 @@ import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.project.LwConfigVO;
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
import club.joylink.rtss.vo.client.project.richor.ZjdPslConfigVO;
import club.joylink.rtss.vo.map.MapVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -140,7 +141,9 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
case RICHOR_JOINT: {
switch (config.getDeviceType()) {
case IBP:
return ((RichorIbpConfig) config).getConfigVO().getStationCode();
return ((ZjdIbpConfig) config).getConfigVO().getIbpCode();
case PSL:
return ((ZjdPslConfig) config).getConfigVO().getPslCode();
}
}
}

View File

@ -114,7 +114,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
public Simulation create(SimulationBuildParams params, String group) {
// 构建仿真
List<Ibp> ibps = ibpService.queryEntities(params.getMap().getId());
params.getMap().getGraphDataNew().setIbpList(ibps);
params.getMap().setIbpList(ibps);
Simulation simulation = SimulationBuilder.build(group, params);
// 缓存
simulationManager.save(simulation);

View File

@ -812,6 +812,7 @@ public class MapDeviceBuilder {
//PSL
VirtualRealityPsl vrPsl = new VirtualRealityPsl(stand.getCode() + "_PSL", stand.getName() + "_PSL");
stand.setVrPsl(vrPsl);
vrPsl.setStand(stand);
elementMap.put(vrPsl.getCode(), vrPsl);
deviceMap.put(vrPsl.getCode(), vrPsl);
}
@ -1270,7 +1271,6 @@ public class MapDeviceBuilder {
*/
private static void buildStation(MapGraphDataNewVO graphData, Map<String, MapElement> elementMap, Map<String, VirtualRealityDevice> deviceMap, List<String> errMsgList) {
List<MapStationNewVO> stationList = graphData.getStationList();
Map<String, Ibp> ibpMap = graphData.getIbpList().stream().collect(Collectors.toMap(Ibp::getStationCode, Function.identity()));
stationList.forEach(stationVO -> {
Station station = new Station(stationVO.getCode(), stationVO.getName());
if (Objects.nonNull(elementMap.get(station.getCode()))) {
@ -1308,17 +1308,6 @@ public class MapDeviceBuilder {
if (station.isHasControlMode()) { // 有控制模式初始化为中控
station.setControlMode(Station.ControlMode.Center);
}
//构建添加IBP
Ibp ibp = ibpMap.get(station.getCode());
if (ibp == null)
ibp = ibpMap.get(null);
if (ibp != null) {
IbpData ibpData = JsonUtils.read(ibp.getData(), IbpData.class);
VirtualRealityIbp vrIbp = new VirtualRealityIbp(station.getCode() + "_IBP", station.getName() + "_IBP", ibpData);
station.setVrIbp(vrIbp);
elementMap.put(vrIbp.getCode(), vrIbp);
deviceMap.put(vrIbp.getCode(), vrIbp);
}
});
// 设备集中站下的车站关联ZC联锁站下的车站关联联锁站
stationList.forEach(stationVO -> {

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.build;
import club.joylink.rtss.entity.Ibp;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
@ -8,6 +9,9 @@ import club.joylink.rtss.simulation.cbtc.data.plan.TerminalDeparturePlan;
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.ibp.IbpData;
import club.joylink.rtss.vo.client.runplan.RunPlanVO;
import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO;
import club.joylink.rtss.vo.map.logic.MapStationParkingTimeVO;
@ -18,7 +22,11 @@ import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import javax.swing.text.Element;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Slf4j
public class SimulationBuilder {
@ -42,6 +50,8 @@ public class SimulationBuilder {
.setSharingECStations(buildParams.getMap().getGraphDataNew().getGenerateConfig().getSharingECStations());
// 地图数据构建
SimulationDeviceBuildResult mapDataBuildResult = checkAndBuildMapData(buildParams.getMap());
// ibp数据构建
buildIbpData(mapDataBuildResult, buildParams.getMap().getIbpList());
simulation.getRepository().setDeviceMap(mapDataBuildResult.getDeviceMap());
simulation.getRepository().setSectionArriveNearMap(mapDataBuildResult.sectionArriveNearMap);
simulation.getRepository().setVrDeviceMap(mapDataBuildResult.getVrDeviceMap());
@ -69,6 +79,30 @@ public class SimulationBuilder {
return simulation;
}
private static void buildIbpData(SimulationDeviceBuildResult mapDataBuildResult, List<Ibp> ibpList) {
if (CollectionUtils.isEmpty(ibpList))
return;
Map<String, MapElement> deviceMap = mapDataBuildResult.getDeviceMap();
Map<String, VirtualRealityDevice> vrDeviceMap = mapDataBuildResult.getVrDeviceMap();
Map<String, Ibp> ibpMap = ibpList.stream().collect(Collectors.toMap(Ibp::getStationCode, Function.identity()));
List<Station> collect = deviceMap.values().stream()
.filter(element -> MapElement.DeviceType.STATION.equals(element.getDeviceType()))
.map(element -> (Station) element).collect(Collectors.toList());
collect.forEach(station -> {
//构建添加IBP
Ibp ibp = ibpMap.get(station.getCode());
if (ibp == null)
ibp = ibpMap.get(null);
if (ibp != null) {
IbpData ibpData = JsonUtils.read(ibp.getData(), IbpData.class);
VirtualRealityIbp vrIbp = new VirtualRealityIbp(station.getCode() + "_IBP", station.getName() + "_IBP", ibpData, station);
station.setVrIbp(vrIbp);
deviceMap.put(vrIbp.getCode(), vrIbp);
vrDeviceMap.put(vrIbp.getCode(), vrIbp);
}
});
}
private static boolean isOverlapSettingByTrigger(Map<String, MapElement> deviceMap) {
for (MapElement mapElement : deviceMap.values()) {
if (mapElement.getDeviceType().equals(MapElement.DeviceType.OVERLAP)) {

View File

@ -1162,14 +1162,4 @@ public class SimulationDataRepository {
.assertNotNull(vrPsl, String.format("%s无对应的vrPsl", vrPsd.debugStr()));
return vrPsl;
}
public Station getStationByVrIbp(@NonNull VirtualRealityIbp vrIbp) {
for (Station station : this.getStationList()) {
if (vrIbp.equals(station.getVrIbp())) {
return station;
}
}
throw BusinessExceptionAssertEnum.DATA_NOT_EXIST
.exception(String.format("%s无对应的车站", vrIbp.debugStr()));
}
}

View File

@ -1,6 +1,6 @@
package club.joylink.rtss.simulation.cbtc.data.vr;
import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.vo.client.ibp.IbpData;
import lombok.Getter;
import lombok.Setter;
@ -18,11 +18,13 @@ import java.util.stream.Collectors;
* 虚拟真实IBP盘
*/
public class VirtualRealityIbp extends VirtualRealityDevice {
@Getter
private final Station station;
private final Map<String, IbpElement> elementMap = new ConcurrentHashMap<>();
public VirtualRealityIbp(String code, String name, IbpData ibpData) {
super(code, name, DeviceType.ESP);
public VirtualRealityIbp(String code, String name, IbpData ibpData, Station station) {
super(code, name, DeviceType.IBP);
if (!CollectionUtils.isEmpty(ibpData.getDrawData().getSquareButtonList())) {
for (IbpData.SquareButtonVO vo : ibpData.getDrawData().getSquareButtonList()) {
SquareButton button = new SquareButton(vo.getCode(), vo.getMean(), false, vo.getSectionCode(), vo.getDirection());
@ -48,6 +50,7 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
}
}
}
this.station = station;
}
public void reset() {
@ -100,7 +103,7 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
private Mean mean;
/** 是否生效(是否亮灯) */
/** 是否开启/亮灯 */
private boolean on;
/** 是否上行 */
@ -122,9 +125,7 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
@Getter
@Setter
public class SquareButton extends IbpElement {
/**
* 是否被按下
*/
/** 是否被按下 */
private boolean pressed;
/** 按钮被按下的时刻 */
@ -135,8 +136,8 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
/** 有效的(防止计轴预复位按钮多次生效) */
private boolean effective;
public SquareButton(String code, Mean mean, boolean status, String sectionCode, Boolean up) {
super(code, Type.BUTTON, mean, status, up);
public SquareButton(String code, Mean mean, boolean on, String sectionCode, Boolean up) {
super(code, Type.BUTTON, mean, on, up);
this.sectionCode = sectionCode;
}
}
@ -157,7 +158,7 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
*/
KC,
/**
* 下行终止扣车
* 终止扣车
*/
ZZKC,
/**

View File

@ -1,12 +1,14 @@
package club.joylink.rtss.simulation.cbtc.data.vr;
import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class VirtualRealityPsl extends VirtualRealityDevice {
private Stand stand;
/** 所有滑动门/应急门关闭且紧锁指示灯 */
private boolean qbgmLight;

View File

@ -85,6 +85,10 @@ public class SimulationRealDeviceConnectManager {
typeEqual = true;
realDevice.connect(vrDevice);
}
if (MapElement.DeviceType.PSL.equals(vrDevice.getDeviceType())) {
typeEqual = true;
realDevice.connect(vrDevice);
}
break;
}
case IBP:{

View File

@ -1,57 +0,0 @@
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

@ -1,169 +0,0 @@
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.data.vr.VirtualRealityIbp;
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()));
VirtualRealityIbp vrIbp = station.getVrIbp();
List<VirtualRealityIbp.IbpElement> ibpElements = vrIbp.queryByMean(VirtualRealityIbp.Mean.SXYS);
ibpElements.forEach(ibpElement -> ibpElement.setOn(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

@ -1,24 +0,0 @@
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

@ -3,19 +3,19 @@ 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.ZjdIbpConfigVO;
import lombok.Getter;
import java.util.Objects;
@Getter
public class RichorPsdConfig extends RealDeviceConfig {
private RichorPsdConfigVO configVO;
public class ZjdIbpConfig extends RealDeviceConfig {
private ZjdIbpConfigVO configVO;
public RichorPsdConfig(ProjectDeviceVO deviceVO) {
public ZjdIbpConfig(ProjectDeviceVO deviceVO) {
super(deviceVO);
if (Objects.nonNull(deviceVO.getConfig())) {
this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorPsdConfigVO.class);
this.configVO = JsonUtils.read(deviceVO.getConfig(), ZjdIbpConfigVO.class);
}
}
}

View File

@ -0,0 +1,174 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
import club.joylink.rtss.services.IVirtualRealityIbpService;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
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.IscsStatusVO;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp;
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.ZjdIbpConfigVO;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
public class ZjdIbpServiceImpl implements RealDeviceService {
@Autowired
private PlcGatewayService plcGatewayService;
@Autowired
private CiApiService ciApiService;
@Autowired
private IVirtualRealityIbpService iVirtualRealityIbpService;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof ZjdIbpConfig;
}
@Override
public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
PlcGateway plcGateway = simulation.getPlcGateway();
ZjdIbpConfigVO configVO = ((ZjdIbpConfig) 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;
ZjdIbpConfig config = (ZjdIbpConfig) deviceConfig;
VirtualRealityIbp vrIbp = (VirtualRealityIbp) config.getMapElement();
if (vrIbp == null)
return;
ZjdIbpConfigVO 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设备
/*------------------------- 输入 -------------------------*/
//下行紧急停车
List<VirtualRealityIbp.IbpElement> jjtc = vrIbp.query(VirtualRealityIbp.Mean.JJTC, false);
jjtc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_xx_jjtc));
//下行取消紧停
List<VirtualRealityIbp.IbpElement> qxjt = vrIbp.query(VirtualRealityIbp.Mean.QXJJTC, false);
qxjt.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_xx_qxjt));
//下行扣车
List<VirtualRealityIbp.IbpElement> kc = vrIbp.query(VirtualRealityIbp.Mean.KC, false);
kc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_xx_kc));
//下行取消扣车
List<VirtualRealityIbp.IbpElement> qxkc = vrIbp.query(VirtualRealityIbp.Mean.ZZKC, false);
qxkc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_xx_qxkc));
//上行紧急停车
List<VirtualRealityIbp.IbpElement> sxjjtc = vrIbp.query(VirtualRealityIbp.Mean.JJTC, true);
sxjjtc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sx_jjtc));
//上行取消紧停
List<VirtualRealityIbp.IbpElement> sxqxjt = vrIbp.query(VirtualRealityIbp.Mean.QXJJTC, true);
sxqxjt.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sx_qxjt));
//上行扣车
List<VirtualRealityIbp.IbpElement> sxkc = vrIbp.query(VirtualRealityIbp.Mean.KC, true);
sxkc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sx_kc));
//上行取消扣车
List<VirtualRealityIbp.IbpElement> sxqxkc = vrIbp.query(VirtualRealityIbp.Mean.ZZKC, true);
sxqxkc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sx_qxkc));
//试灯
List<VirtualRealityIbp.IbpElement> sd = vrIbp.queryByMean(VirtualRealityIbp.Mean.SD);
sd.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sd));
//下行允许禁止钥匙
List<VirtualRealityIbp.IbpElement> ibpElements = vrIbp.queryByMean(VirtualRealityIbp.Mean.XXYS);
ibpElements.forEach(ibpElement -> ibpElement.setOn(r_sx_czyx));
/*------------------------- 输出 -------------------------*/
boolean xxkcd = vrIbp.query(VirtualRealityIbp.Mean.kcLight, false).stream()
.allMatch(VirtualRealityIbp.IbpElement::isOn);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_kcd(), w_xx_kcd, xxkcd, channel);
boolean sxkcd = vrIbp.query(VirtualRealityIbp.Mean.kcLight, true).stream()
.allMatch(VirtualRealityIbp.IbpElement::isOn);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_kcd(), w_sx_kcd, sxkcd, channel);
boolean xxjjtcd = vrIbp.query(VirtualRealityIbp.Mean.jjtcLight, false).stream()
.allMatch(VirtualRealityIbp.IbpElement::isOn);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), w_xx_jjtcd, xxjjtcd, channel);
boolean sxjjtcd = vrIbp.query(VirtualRealityIbp.Mean.jjtcLight, true).stream()
.allMatch(VirtualRealityIbp.IbpElement::isOn);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), w_sx_jjtcd, sxjjtcd, channel);
// //输出
// 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

@ -3,19 +3,19 @@ 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 club.joylink.rtss.vo.client.project.richor.ZjdPsdConfigVO;
import lombok.Getter;
import java.util.Objects;
@Getter
public class RichorDcuConfig extends RealDeviceConfig {
private RichorDcuConfigVO configVO;
public RichorDcuConfig(ProjectDeviceVO deviceVO) {
public class ZjdPsdConfig extends RealDeviceConfig {
private ZjdPsdConfigVO configVO;
public ZjdPsdConfig(ProjectDeviceVO deviceVO) {
super(deviceVO);
if (Objects.nonNull(deviceVO.getConfig())) {
this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorDcuConfigVO.class);
this.configVO = JsonUtils.read(deviceVO.getConfig(), ZjdPsdConfigVO.class);
}
}
}

View File

@ -2,13 +2,12 @@ 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 club.joylink.rtss.vo.client.project.richor.ZjdPsdConfigVO;
import io.netty.buffer.ByteBuf;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,20 +17,20 @@ import org.springframework.util.StringUtils;
@Slf4j
@Component
public class RichorPsdServiceImpl implements RealDeviceService {
public class ZjdPsdServiceImpl implements RealDeviceService {
@Autowired
private ApplicationContext applicationContext;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof RichorPsdConfig;
return deviceConfig instanceof ZjdPsdConfig;
}
@Override
public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
// PlcGateway plcGateway = simulation.getPlcGateway();
// RichorPsdConfig config = (RichorPsdConfig) deviceConfig;
// RichorPsdConfigVO configVO = config.getConfigVO();
// ZjdPsdConfig config = (ZjdPsdConfig) deviceConfig;
// ZjdPsdConfigVO configVO = config.getConfigVO();
// Channel channel = plcGateway.getChannel();
// int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
//
@ -43,8 +42,8 @@ public class RichorPsdServiceImpl implements RealDeviceService {
@Override
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
RichorPsdConfig config = (RichorPsdConfig) deviceConfig;
RichorPsdConfigVO configVO = config.getConfigVO();
ZjdPsdConfig config = (ZjdPsdConfig) deviceConfig;
ZjdPsdConfigVO 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());

View File

@ -3,21 +3,19 @@ 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 club.joylink.rtss.vo.client.project.richor.ZjdPslConfigVO;
import lombok.Getter;
import lombok.Setter;
import java.util.Objects;
@Getter
public class RichorIbpConfig extends RealDeviceConfig {
private RichorIbpConfigVO configVO;
public class ZjdPslConfig extends RealDeviceConfig {
private ZjdPslConfigVO configVO;
public RichorIbpConfig(ProjectDeviceVO deviceVO) {
public ZjdPslConfig(ProjectDeviceVO deviceVO) {
super(deviceVO);
if (Objects.nonNull(deviceVO.getConfig())) {
this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorIbpConfigVO.class);
this.configVO = JsonUtils.read(deviceVO.getConfig(), ZjdPslConfigVO.class);
}
}
}

View File

@ -1,28 +1,31 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
import club.joylink.rtss.services.psl.IVirtualRealityPslService;
import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService;
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.data.vr.VirtualRealityPsl;
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 club.joylink.rtss.vo.client.project.richor.ZjdPslConfigVO;
import io.netty.buffer.ByteBuf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class RichorPslServiceImpl implements RealDeviceService {
public class ZjdPslServiceImpl implements RealDeviceService {
@Autowired
private CiStandService standService;
@Autowired
private IVirtualRealityPslService iVirtualRealityPslService;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof RichorPslConfig;
return deviceConfig instanceof ZjdPslConfig;
}
@Override
@ -32,20 +35,21 @@ public class RichorPslServiceImpl implements RealDeviceService {
@Override
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
RichorPslConfig config = (RichorPslConfig) deviceConfig;
RichorPslConfigVO configVO = config.getConfigVO();
ZjdPslConfig config = (ZjdPslConfig) deviceConfig;
ZjdPslConfigVO 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) {
VirtualRealityPsl vrPsl = stand.getVrPsl();
vrPsl.setYxjzKey(r_sx_czyx);
standService.setOrCancelInterlockRelease(simulation, stand, r_sx_hsjc);
}
VirtualRealityPsl vrPsl = (VirtualRealityPsl) config.getMapElement();
if (vrPsl == null)
return;
iVirtualRealityPslService.updateStatus(simulation, vrPsl, VirtualRealityPsl.Button.YXJZ, r_sx_czyx);
iVirtualRealityPslService.updateStatus(simulation, vrPsl, VirtualRealityPsl.Button.KM, r_sx_km);
iVirtualRealityPslService.updateStatus(simulation, vrPsl, VirtualRealityPsl.Button.GM, r_sx_gm);
iVirtualRealityPslService.updateStatus(simulation, vrPsl, VirtualRealityPsl.Button.HSJC, r_sx_hsjc);
//ISCS状态
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
String iscsCode = configVO.getIscsCode();

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.onboard.ATO.service;
import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
@ -386,7 +387,7 @@ public class ATOService {
} else {
this.openTrainDoor(simulation, train, train.getDoor1());
}
this.ciApiService.openScreenDoor(simulation, stand.getCode());
this.ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.SIG);
}
}
@ -407,7 +408,7 @@ public class ATOService {
this.closeTrainDoor(simulation, train, train.getDoor2());
}
for (Stand stand : standList) {
this.ciApiService.closeScreenDoor(simulation, stand.getCode());
this.ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.SIG);
}
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.simulation.cbtc.onboard.ATP;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
@ -310,7 +311,7 @@ public class ATPService {
}
if (train.isCommunicable()) {
for (Stand stand : standList) {
this.ciApiService.openScreenDoor(simulation, stand.getCode());
this.ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.SIG);
}
}
} else {
@ -320,7 +321,7 @@ public class ATPService {
}
if (train.isCommunicable()) {
for (Stand stand : standList) {
this.ciApiService.closeScreenDoor(simulation, stand.getCode());
this.ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.SIG);
}
}
}

View File

@ -11,6 +11,7 @@ import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.PSD;
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;
@ -107,7 +108,8 @@ public class RobotLogicLoop {
List<Stand> standList = section.getStandList();
if (!CollectionUtils.isEmpty(standList)) {
for (Stand stand : standList) {
if (!stand.getPsd().isCloseAndLock()) {
PSD psd = stand.getPsd();
if (psd != null && !psd.isCloseAndLock()) {
VirtualRealityPsl vrPsl = stand.getVrPsl();
if (!vrPsl.isAllowOperation()) { //确保此时允许操作
iVirtualRealityPslService.pressTheButton(simulation.getId(),

View File

@ -9,16 +9,13 @@ 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.GzbSwitchConfig;
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.richor.ZjdIbpConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPsdConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.ZjdPslConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPsdConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPslConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig;
import club.joylink.rtss.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 lombok.Getter;
import lombok.NoArgsConstructor;
@ -124,19 +121,16 @@ public class ProjectDeviceVO {
for (ProjectDeviceVO deviceVO : voList) {
switch (deviceVO.getType()) {
case IBP:
list.add(new RichorIbpConfig(deviceVO));
list.add(new ZjdIbpConfig(deviceVO));
break;
case PLC_GATEWAY:
list.add(new PlcGateway(deviceVO));
break;
case PSD:
list.add(new RichorPsdConfig(deviceVO));
list.add(new ZjdPsdConfig(deviceVO));
break;
case PSL:
list.add(new RichorPslConfig(deviceVO));
break;
case DCU:
list.add(new RichorDcuConfig(deviceVO));
list.add(new ZjdPslConfig(deviceVO));
break;
}
}

View File

@ -0,0 +1,30 @@
package club.joylink.rtss.vo.client.project;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
public class RealConfigVO {
/**
* 网关位开始位置
*/
private Integer addr;
/**
* 位数量
*/
private Integer quantity;
public RealConfigVO(Integer addr, Integer quantity) {
this.addr = addr;
this.quantity = quantity;
}
public String toJson() {
return JsonUtils.writeValueAsString(this);
}
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.vo.client.project.gzb;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
@ -10,18 +11,7 @@ import lombok.Setter;
/**
*贵州装备学院项目信号机配置
*/
public class GzbSignalConfigVO {
/**
*网关位开始地址
*/
private Integer addr = 0;
/**
*位数量
*/
private Integer quantity = 16;
public class GzbSignalConfigVO extends RealConfigVO {
// 0001: 黄灯, 0011: 绿灯 0100: 黄红灯, 1000: 故障
// 4 -红灯
// 0+4
@ -76,8 +66,7 @@ public class GzbSignalConfigVO {
*/
private Integer w11 = 11;
@JsonIgnore
public String toJson() {
return JsonUtils.writeValueAsString(this);
public GzbSignalConfigVO() {
super(0, 16);
}
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.vo.client.project.gzb;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
@ -10,18 +11,7 @@ import lombok.Setter;
*/
@Getter
@Setter
public class GzbSwitchConfigVO {
/**
*网关位开始地址
*/
private Integer addr = 0;
/**
*位数量
*/
private Integer quantity = 16;
public class GzbSwitchConfigVO extends RealConfigVO {
// 定位为1且反位为1,即为故障状态
// 6
//5
@ -53,8 +43,7 @@ public class GzbSwitchConfigVO {
*/
private Integer wsn = 15;
@JsonIgnore
public String toJson() {
return JsonUtils.writeValueAsString(this);
public GzbSwitchConfigVO() {
super(0, 16);
}
}

View File

@ -1,35 +0,0 @@
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

@ -1,6 +1,7 @@
package club.joylink.rtss.vo.client.project.richor;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -8,22 +9,10 @@ import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class RichorIbpConfigVO {
/**
* ibp盘绑定的车站
*/
private String stationCode = "Station25166";
public class ZjdIbpConfigVO extends RealConfigVO {
private String ibpCode = "Station25166_IBP";
private String iscsCode = "ibp";
/**
* 网关位开始地址
*/
private Integer addr = 0;
/**
* 位数量
*/
private Integer quantity = 80;
/*---------------- 屏蔽门 ----------------*/
/**
@ -101,7 +90,6 @@ public class RichorIbpConfigVO {
*/
private Integer w_sx_kcd = 23;
/** 操作允许 */
private Integer r_sx_czyx = 77;
@ -111,13 +99,7 @@ public class RichorIbpConfigVO {
/** 关门命令 */
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);
public ZjdIbpConfigVO() {
super(0, 80);
}
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.vo.client.project.richor;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -10,8 +11,7 @@ import javax.validation.constraints.NotBlank;
@Getter
@Setter
@NoArgsConstructor
public class RichorPsdConfigVO {
public class ZjdPsdConfigVO extends RealConfigVO {
// /**
// * 关联的站台屏蔽门code
// */
@ -22,14 +22,6 @@ public class RichorPsdConfigVO {
* 关联的ISCS元素的code
*/
private String iscsCode = "FuzhouPsd_33";
/**
* 网关位开始地址
*/
private Integer addr = 0;
/**
* 位数量
*/
private Integer quantity = 144;
/*---------------- 屏蔽门 ----------------*/
/**
@ -97,13 +89,7 @@ public class RichorPsdConfigVO {
*/
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);
public ZjdPsdConfigVO() {
super(0, 144);
}
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.vo.client.project.richor;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -8,21 +9,11 @@ import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class RichorPslConfigVO {
private String standCode = "PF59020";
public class ZjdPslConfigVO extends RealConfigVO {
private String pslCode = "PF59020_PSL";
private String iscsCode = "psl";
/**
* 网关位开始地址
*/
private Integer addr = 0;
/**
* 位数量
*/
private Integer quantity = 64;
/** 状态位 */
/** 操作允许 */
private Integer r_sx_czyx = 52;
@ -36,8 +27,7 @@ public class RichorPslConfigVO {
/** 互锁解除 */
private Integer r_sx_hsjc = 49;
@JsonIgnore
public String toJson() {
return JsonUtils.writeValueAsString(this);
public ZjdPslConfigVO() {
super(0, 64);
}
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.vo.client.project.sdy;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -13,21 +14,12 @@ import javax.validation.constraints.NotBlank;
*/
@Getter
@Setter
@NoArgsConstructor
public class SdyPsdConfigVO {
public class SdyPsdConfigVO extends RealConfigVO {
/**
* 关联的站台屏蔽门code
*/
@NotBlank(message = "关联的站台屏蔽门code不能为空")
private String psdCode;
/**
* 网关位开始地址
*/
private Integer addr = 0;
/**
* 位数量
*/
private Integer quantity = 16;
/*---------------- 屏蔽门 ----------------*/
/**
@ -50,13 +42,7 @@ public class SdyPsdConfigVO {
*/
private Integer w_jb = 9;
public SdyPsdConfigVO(Integer addr, Integer quantity) {
this.addr = addr;
this.quantity = quantity;
}
@JsonIgnore
public String toJson() {
return JsonUtils.writeValueAsString(this);
public SdyPsdConfigVO() {
super(0, 16);
}
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.vo.client.project.sdy;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -8,17 +9,8 @@ import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class SdyPslConfigVO {
public class SdyPslConfigVO extends RealConfigVO {
private String psdCode;
/**
* 网关位开始地址
*/
private Integer addr = 0;
/**
* 位数量
*/
private Integer quantity = 16;
/**
* 试灯按钮
@ -65,8 +57,7 @@ public class SdyPslConfigVO {
*/
private Integer w_hsjc_light = 13;
@JsonIgnore
public String toJson() {
return JsonUtils.writeValueAsString(this);
public SdyPslConfigVO() {
super(0, 16);
}
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.vo.client.project.xty;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -13,25 +14,13 @@ import javax.validation.constraints.NotBlank;
*/
@Getter
@Setter
@NoArgsConstructor
public class XtyPsdConfigVO {
public class XtyPsdConfigVO extends RealConfigVO {
/**
*关联的站台屏蔽门code
*/
@NotBlank(message = "关联的站台屏蔽门code不能为空")
private String psdCode = "Psd69543";
/**
*网关位开始地址
*/
private Integer addr = 0;
/**
*位数量
*/
private Integer quantity = 32;
// 门模式abc组合意义111自动模式100PSL模式011IBP模式010LCB操作模式001LCB隔离模式
/**
*门模式位a
@ -99,8 +88,7 @@ public class XtyPsdConfigVO {
*/
private Integer wvgm = 0x55;
@JsonIgnore
public String toJson() {
return JsonUtils.writeValueAsString(this);
public XtyPsdConfigVO() {
super(0, 32);
}
}

View File

@ -218,11 +218,6 @@ public class MapGraphDataNewVO {
private List<MapSignalButtonVO> signalButtonList = new ArrayList<>();
/**
* ibp列表
*/
private List<Ibp> ibpList = new ArrayList<>();
public MapGraphDataNewVO() {
this.bigScreenConfig = new BigScreenConfig();
this.generateConfig = new MapCiGenerateConfig();

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.vo.map;
import club.joylink.rtss.entity.DraftMap;
import club.joylink.rtss.entity.DraftMapWithBLOBs;
import club.joylink.rtss.entity.Ibp;
import club.joylink.rtss.entity.MapInfo;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.map.MapDataVO;
@ -108,6 +109,11 @@ public class MapVO {
private Map3dDataVO map3dData;
/**
* ibp数据列表
*/
private List<Ibp> ibpList = new ArrayList<>();
public MapVO(DraftMap draftMap) {
this.name = draftMap.getName();
this.lineCode = draftMap.getLineCode();