真实IBP/PSL盘改为连接vrIBP/PSL(仅义乌项目)

This commit is contained in:
joylink_zhangsai 2021-09-22 16:58:27 +08:00
parent 3cb47d9577
commit 2463a96204
20 changed files with 243 additions and 173 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

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

@ -15,6 +15,7 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1Ib
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.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;
@ -24,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;
@ -139,7 +141,9 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation
case RICHOR_JOINT: {
switch (config.getDeviceType()) {
case IBP:
return ((ZjdIbpConfig) config).getConfigVO().getStationCode();
return ((ZjdIbpConfig) config).getConfigVO().getIbpCode();
case PSL:
return ((ZjdPslConfig) config).getConfigVO().getPslCode();
}
}
}

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);
}
@ -1307,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

@ -26,6 +26,7 @@ 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 {
@ -81,13 +82,13 @@ public class SimulationBuilder {
private static void buildIbpData(SimulationDeviceBuildResult mapDataBuildResult, List<Ibp> ibpList) {
if (CollectionUtils.isEmpty(ibpList))
return;
Map<String, MapElement> elementMap = mapDataBuildResult.getDeviceMap();
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()));
elementMap.values().stream()
List<Station> collect = deviceMap.values().stream()
.filter(element -> MapElement.DeviceType.STATION.equals(element.getDeviceType()))
.map(element -> (Station) element)
.forEach(station -> {
.map(element -> (Station) element).collect(Collectors.toList());
collect.forEach(station -> {
//构建添加IBP
Ibp ibp = ibpMap.get(station.getCode());
if (ibp == null)
@ -96,8 +97,8 @@ public class SimulationBuilder {
IbpData ibpData = JsonUtils.read(ibp.getData(), IbpData.class);
VirtualRealityIbp vrIbp = new VirtualRealityIbp(station.getCode() + "_IBP", station.getName() + "_IBP", ibpData, station);
station.setVrIbp(vrIbp);
elementMap.put(vrIbp.getCode(), vrIbp);
elementMap.put(vrIbp.getCode(), vrIbp);
deviceMap.put(vrIbp.getCode(), vrIbp);
vrDeviceMap.put(vrIbp.getCode(), vrIbp);
}
});
}

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,5 +1,6 @@
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.SimulationDataRepository;
@ -18,12 +19,14 @@ 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 javafx.scene.effect.Light;
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;
import java.util.Objects;
@Slf4j
@Component
@ -36,7 +39,7 @@ public class ZjdIbpServiceImpl implements RealDeviceService {
private CiApiService ciApiService;
@Autowired
private ApplicationContext applicationContext;
private IVirtualRealityIbpService iVirtualRealityIbpService;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
@ -67,8 +70,8 @@ public class ZjdIbpServiceImpl implements RealDeviceService {
if (plcGateway == null)
return;
ZjdIbpConfig config = (ZjdIbpConfig) deviceConfig;
Station station = (Station) config.getMapElement();
if (station == null)
VirtualRealityIbp vrIbp = (VirtualRealityIbp) config.getMapElement();
if (vrIbp == null)
return;
ZjdIbpConfigVO configVO = config.getConfigVO();
ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity());
@ -93,58 +96,67 @@ public class ZjdIbpServiceImpl implements RealDeviceService {
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);
/*------------------------- 输入 -------------------------*/
//下行紧急停车
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));
//输出
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);
}
/*------------------------- 输出 -------------------------*/
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();

View File

@ -1,9 +1,9 @@
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;
@ -20,6 +20,9 @@ public class ZjdPslServiceImpl implements RealDeviceService {
@Autowired
private CiStandService standService;
@Autowired
private IVirtualRealityPslService iVirtualRealityPslService;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof ZjdPslConfig;
@ -40,12 +43,13 @@ public class ZjdPslServiceImpl implements RealDeviceService {
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

@ -10,10 +10,7 @@ import lombok.Setter;
@Getter
@Setter
public class ZjdIbpConfigVO extends RealConfigVO {
/**
* ibp盘绑定的车站
*/
private String stationCode = "Station25166";
private String ibpCode = "Station25166_IBP";
private String iscsCode = "ibp";
@ -93,7 +90,6 @@ public class ZjdIbpConfigVO extends RealConfigVO {
*/
private Integer w_sx_kcd = 23;
/** 操作允许 */
private Integer r_sx_czyx = 77;

View File

@ -10,7 +10,7 @@ import lombok.Setter;
@Getter
@Setter
public class ZjdPslConfigVO extends RealConfigVO {
private String standCode = "PF59020";
private String pslCode = "PF59020_PSL";
private String iscsCode = "psl";