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

# Conflicts:
#	src/main/java/club/joylink/rtss/services/psl/VirtualRealityPslService.java
#	src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/StandService.java
#	src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java
#	src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1IbpServiceImpl.java
#	src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1PslServiceImpl.java
This commit is contained in:
walker-sheng 2021-09-14 10:01:10 +08:00
commit aea19447d8
16 changed files with 167 additions and 83 deletions

View File

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

View File

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

View File

@ -441,16 +441,16 @@ public class DeviceServiceImpl implements DeviceService {
RichorPslConfigVO pslConfigVO = new RichorPslConfigVO();
psl.setConfig(pslConfigVO.toJson());
list.add(psl);
// DCU
ProjectDevice dcu = new ProjectDevice();
dcu.setProjectCode(Project.RICHOR_JOINT.name());
dcu.setCode("richorJoint-dcu");
dcu.setType(ProjectDeviceType.DCU.name());
dcu.setCreator(accountVO.getId());
dcu.setCreateTime(now);
RichorDcuConfigVO dcuConfigVO = new RichorDcuConfigVO();
dcu.setConfig(dcuConfigVO.toJson());
list.add(dcu);
// // 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

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

View File

@ -20,7 +20,6 @@ public class IscsIbpStatusVO extends IscsStatusVO {
}
@Getter
@Setter
public static class DirectionalStatus {
/** 操作允许 */
private boolean operate;

View File

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

View File

@ -18,7 +18,6 @@ public class IscsPslStatusVO extends IscsStatusVO{
}
@Getter
@Setter
public static class DirectionalStatus {
/** 操作允许 */
private boolean operate;

View File

@ -18,7 +18,6 @@ public class IscsSafetyCircleStatusVO extends IscsStatusVO{
}
@Getter
@Setter
public static class DirectionalStatus {
/** PFDC故障 */
private boolean pfdcFault;

View File

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

View File

@ -31,9 +31,8 @@ public class Heb1PslServiceImpl implements RealDeviceService {
@Autowired
private PlcGatewayService plcGatewayService;
@Autowired
private VirtualRealityDeviceService virtualRealityDeviceService;
private VirtualRealityDeviceService virtualRealityDeviceService;
@Autowired
private CiApiService ciApiService;

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.CI.service.VrPsdService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
@ -37,6 +38,9 @@ public class RichorIbpServiceImpl implements RealDeviceService {
@Autowired
private ApplicationContext applicationContext;
@Autowired
private VrPsdService vrPsdService;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof RichorIbpConfig;
@ -124,6 +128,7 @@ public class RichorIbpServiceImpl implements RealDeviceService {
}
if (r_sx_qxkc)
upStands.forEach(stand -> ciApiService.ibpHoldTrainCancel(simulation, stand.getCode()));
upStands.forEach(stand -> stand.getPsd().getVirtualScreenDoor().setIbpControl(r_sx_czyx));
//输出
if (r_sd) {
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_kcd(), w_sx_kcd, true, channel);
@ -147,16 +152,16 @@ public class RichorIbpServiceImpl implements RealDeviceService {
IscsIbpStatusVO iscsStatus = (IscsIbpStatusVO) iscsRepository.findStatus(iscsCode);
boolean change;
if (iscsStatus == null) {
IscsIbpStatusVO.DirectionalStatus upStatus =
IscsIbpStatusVO.DirectionalStatus downStatus =
new IscsIbpStatusVO.DirectionalStatus(r_sx_czyx, r_sx_km, false, r_sx_gm);
iscsStatus = new IscsIbpStatusVO(iscsCode, IscsStatusVO.DeviceType.IBP, upStatus, null);
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 upStatus = iscsStatus.getUpStatus();
change = upStatus.compareAndChange(r_sx_czyx, r_sx_km, false, r_sx_gm);
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

@ -2,6 +2,7 @@ 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;
@ -48,6 +49,7 @@ public class RichorPsdServiceImpl implements RealDeviceService {
boolean km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_wgm());
boolean sj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_sj());
boolean dcugz = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_dcugz());
boolean r_sx_glms = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_glms());
String iscsCode = configVO.getIscsCode();
if (StringUtils.hasText(iscsCode)) {
IscsPsdStatusVO.Status status;
@ -64,16 +66,15 @@ public class RichorPsdServiceImpl implements RealDeviceService {
IscsPsdStatusVO iscsStatus = (IscsPsdStatusVO) iscsRepository.findStatus(iscsCode);
boolean change = false;
if (iscsStatus == null) {
iscsStatus = new IscsPsdStatusVO(iscsCode, IscsStatusVO.DeviceType.SLIDING_DOOR, status);
IscsPsdStatusVO.DirectionalStatus downStatus = new IscsPsdStatusVO.DirectionalStatus(status, r_sx_glms);
iscsStatus = new IscsPsdStatusVO(iscsCode, IscsStatusVO.DeviceType.SLIDING_DOOR, null, downStatus);
iscsRepository.addStatus(iscsStatus);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
simulation.watch(iscsStatus, watcher);
change = true;
} else {
if (!status.equals(iscsStatus.getStatus())) {
iscsStatus.setStatus(status);
change = true;
}
IscsPsdStatusVO.DirectionalStatus downStatus = iscsStatus.getDownStatus();
change = downStatus.compareAndChange(status, r_sx_glms);
}
if (change) {
iscsStatus.fireWatcher(null, null);

View File

@ -1,7 +1,9 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor;
import club.joylink.rtss.simulation.cbtc.CI.service.StandService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsPslStatusVO;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService;
@ -16,7 +18,7 @@ import org.springframework.stereotype.Component;
@Component
public class RichorPslServiceImpl implements RealDeviceService {
@Autowired
private ApplicationContext applicationContext;
private StandService standService;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
@ -37,20 +39,27 @@ public class RichorPslServiceImpl implements RealDeviceService {
boolean r_sx_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_km());
boolean r_sx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_gm());
boolean r_sx_hsjc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_hsjc());
//信号系统状态
Stand stand = (Stand) config.getMapElement();
if (stand != null) {
stand.getPsd().getVirtualScreenDoor().setPslControl(r_sx_czyx);
standService.setOrCancelInterlockRelease(simulation, stand, r_sx_hsjc);
}
//ISCS状态
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
String iscsCode = configVO.getIscsCode();
IscsPslStatusVO iscsStatus = (IscsPslStatusVO) iscsRepository.findStatus(iscsCode);
boolean change;
if (iscsStatus == null) {
IscsPslStatusVO.DirectionalStatus upStatus = new IscsPslStatusVO.DirectionalStatus(r_sx_czyx, r_sx_km, r_sx_gm, r_sx_hsjc);
iscsStatus = new IscsPslStatusVO(iscsCode, IscsStatusVO.DeviceType.PSL, upStatus, null);
IscsPslStatusVO.DirectionalStatus downStatus = new IscsPslStatusVO.DirectionalStatus(r_sx_czyx, r_sx_km, r_sx_gm, r_sx_hsjc);
iscsStatus = new IscsPslStatusVO(iscsCode, IscsStatusVO.DeviceType.PSL, null, downStatus);
iscsRepository.addStatus(iscsStatus);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
simulation.watch(iscsStatus, watcher);
change = true;
} else {
IscsPslStatusVO.DirectionalStatus upStatus = iscsStatus.getUpStatus();
change = upStatus.compareAndChange(r_sx_czyx, r_sx_km, r_sx_gm, r_sx_hsjc);
IscsPslStatusVO.DirectionalStatus downStatus = iscsStatus.getDownStatus();
change = downStatus.compareAndChange(r_sx_czyx, r_sx_km, r_sx_gm, r_sx_hsjc);
}
if (change) {
iscsStatus.fireWatcher(null, null);

View File

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

View File

@ -29,42 +29,42 @@ public class RichorIbpConfigVO {
/**
* 下行紧急停车1是false因为只能接常闭点
*/
private Integer r_xx_jjtc = 0;
private Integer r_xx_jjtc = 4;
/**
* 下行取消紧停
*/
private Integer r_xx_qxjt = 1;
private Integer r_xx_qxjt = 5;
/**
* 下行扣车
*/
private Integer r_xx_kc = 2;
private Integer r_xx_kc = 6;
/**
* 下行取消扣车
*/
private Integer r_xx_qxkc = 3;
private Integer r_xx_qxkc = 7;
/**
* 上行紧急停车1是false因为只能接常闭点
*/
private Integer r_sx_jjtc = 4;
private Integer r_sx_jjtc = 0;
/**
* 上行取消紧停
*/
private Integer r_sx_qxjt = 5;
private Integer r_sx_qxjt = 1;
/**
* 上行扣车
*/
private Integer r_sx_kc = 6;
private Integer r_sx_kc = 2;
/**
* 上行取消扣车
*/
private Integer r_sx_qxkc = 7;
private Integer r_sx_qxkc = 3;
/**
* 试灯
@ -84,22 +84,22 @@ public class RichorIbpConfigVO {
/**
* 上行紧急停车灯
*/
private Integer w_sx_jjtcd = 20;
private Integer w_sx_jjtcd = 21;
/**
* 下行紧急停车灯
*/
private Integer w_xx_jjtcd = 21;
private Integer w_xx_jjtcd = 20;
/**
* 上行扣车灯
*/
private Integer w_sx_kcd = 22;
private Integer w_sx_kcd = 23;
/**
* 下行扣车灯
*/
private Integer w_xx_kcd = 23;
private Integer w_xx_kcd = 22;
/** 操作允许 */
private Integer r_sx_czyx = 77;

View File

@ -10,7 +10,7 @@ import lombok.Setter;
@Setter
@NoArgsConstructor
public class RichorPslConfigVO {
// private String psdCode;
private String standCode = "PF59020";
private String iscsCode = "psl";