修改车站故障枚举及逻辑

修改信号机故障枚举及逻辑
添加草稿地图信号机型号数据处理
This commit is contained in:
walker-sheng 2021-09-26 15:44:28 +08:00
parent 1a23bd4a82
commit 7916b63df8
19 changed files with 135 additions and 78 deletions

View File

@ -53,4 +53,9 @@ public class DraftMapDataHandleController {
public void handleSignalApproach(@PathVariable Long mapId) {
this.draftMapDataHandleService.handleSignalApproach(mapId);
}
@PutMapping("/{mapId}/signalModel")
public void handleSignalModel(@PathVariable Long mapId) {
this.draftMapDataHandleService.handleSignalModel(mapId);
}
}

View File

@ -280,6 +280,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
List<Signal> signalList = deviceMap.values().stream()
.filter(mapElement -> mapElement.getDeviceType().equals(MapElement.DeviceType.SIGNAL))
.map(mapElement -> ((Signal) mapElement))
.filter(signal -> !signal.getInterlockStation().isDepot())
.collect(Collectors.toList());
// 获取所有道岔
List<Switch> switchList = deviceMap.values().stream()

View File

@ -16,4 +16,6 @@ public interface DraftMapDataHandleService {
void handleSignalApproach(Long mapId);
void handleRouteSignalAspect();
void handleSignalModel(Long mapId);
}

View File

@ -9,6 +9,7 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IDraftMapService;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
import club.joylink.rtss.simulation.cbtc.constant.SignalModel;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.rt.repo.CommonRepository;
import club.joylink.rtss.simulation.rt.repo.CommonRepositoryBuilder;
@ -257,6 +258,29 @@ public class DraftMapDataHandleServiceImpl implements DraftMapDataHandleService
}
}
@Override
public void handleSignalModel(Long mapId) {
DraftMapWithBLOBs draftMap = this.draftMapDAO.selectByPrimaryKey(mapId);
MapGraphDataNewVO graphDataNew = JsonUtils.read(draftMap.getGraphData(), MapGraphDataNewVO.class);
List<MapSignalNewVO> signalList = graphDataNew.getSignalList();
for (MapSignalNewVO signalVo : signalList) {
switch (signalVo.getType()) {
case PROTECTION:
case PASSING:
signalVo.setSignalModel(SignalModel.RGY.name());
break;
case BLOCKING:
signalVo.setSignalModel(SignalModel.R.name());
break;
case SHUNTING2:
signalVo.setSignalModel(SignalModel.YRW.name());
break;
}
}
draftMap.setGraphData(graphDataNew.toJson());
this.draftMapDAO.updateByPrimaryKeyWithBLOBs(draftMap);
}
private void calculateSectionLengthThroughStationKmPostVal(MapVO mapVO) {
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildBasicMapData(mapVO);
for (String errMsg : buildResult.getErrMsgList()) {

View File

@ -190,6 +190,7 @@ public class MaService {
break;
}
case Closed_Section:
case No_Status_Section:
case UnLock_Section:
case Reverse_Lock_Section:
case Fault_Route:{
@ -319,6 +320,8 @@ public class MaService {
Reverse_Lock_Section,
/** 未锁闭的区段 */
UnLock_Section,
/** 联锁故障无状态区段 */
No_Status_Section,
/** 进路联锁条件不再完备 */
Fault_Route,
/** 站台问题(屏蔽门或紧急停车) */
@ -439,6 +442,10 @@ public class MaService {
}
}
}
if (section.isNoStatus()) {
// 联锁故障
ma = this.checkAndUpdateMa(ma, new Ma(train, section, MaType.No_Status_Section));
}
if (section.isClosed()) {
// 关闭的区段
ma = this.checkAndUpdateMa(ma, new Ma(train, section, MaType.Closed_Section));

View File

@ -37,7 +37,7 @@ public class StationFaultService implements DeviceFaultService {
Station.Fault fault = checkAndGetFault(param);
MayOutOfOrderDevice.DeviceFault deviceFault = device.getFault();
fault.fix(device);
if (fault.equals(deviceFault) && fault.equals(Station.Fault.INTERLOCK_MACHINE_FAULT)) {
if (fault.equals(deviceFault) && fault.equals(Station.Fault.INTERLOCK_FAULT)) {
Station station = (Station) device;
if (station.getDeviceStation() != null) {
station = station.getDeviceStation();

View File

@ -493,7 +493,7 @@ public class AtsStationService {
}
station.setInterlockMachineStarting(true);
station.setRestartTime(LocalTime.now());
Station.Fault.INTERLOCK_MACHINE_FAULT.fix(station);
Station.Fault.INTERLOCK_FAULT.fix(station);
}
public void openAutoSetting(Simulation simulation, String stationCode) {

View File

@ -41,6 +41,10 @@ public class AtsTriggerRouteService {
AtsRouteSelectService routeSelectService = this.getRouteSelectService(trainInfo);
Route route = routeSelectService.select(simulation, trainInfo);
if (route != null && route.isAtsControl()) {
if (route.getInterlockStation() != null && route.getInterlockStation().isAtsRouteTriggerFault()) {
// ATS触发进路故障
return;
}
atsTriggerRouteMap.put(route.getCode(), route);
this.trySetRoute(simulation, trainInfo, route);
}

View File

@ -209,6 +209,17 @@ public class CiService {
}
}
}
// 站台扣车
if (!CollectionUtils.isEmpty(route.getStandHoldList())) {
for (Stand stand : route.getStandHoldList()) {
if (stand.isHoldTrain()) {
// log.debug("进路[{}]连锁条件检查:站台[{}({})]扣车",
// route.debugStr(),
// stand.getName(), stand.getCode());
return level;
}
}
}
if (route.getStart().isCbtcMode()) {
level = Signal.LEVEL_Atp; // ATP级
}
@ -250,17 +261,6 @@ public class CiService {
// }
}
}
// 站台扣车
if (!CollectionUtils.isEmpty(route.getStandHoldList())) {
for (Stand stand : route.getStandHoldList()) {
if (stand.isHoldTrain()) {
// log.debug("进路[{}]连锁条件检查:站台[{}({})]扣车",
// route.debugStr(),
// stand.getName(), stand.getCode());
return level;
}
}
}
// 延续保护
if (!this.interlockCheck(simulation, route.getOverlap())) {
// log.debug("进路[{}]连锁条件检查: 延续保护未锁闭", route.debugStr());

View File

@ -94,6 +94,7 @@ public class MapDeviceBuilder {
errMsgList.add(String.format("道岔[%s(%s)]未设置所属设备集中站或所属设备集中站不存在", aSwitch.getName(), aSwitch.getCode()));
} else {
aSwitch.setDeviceStation(deviceStation);
deviceStation.addDevice(aSwitch);
}
// 创建虚拟真实道岔
VirtualRealitySwitch virtualRealitySwitch = new VirtualRealitySwitch(aSwitch.getCode(), aSwitch.getName(), switchVO.getTurnTime());
@ -713,6 +714,7 @@ public class MapDeviceBuilder {
errMsgList.add(String.format("站台[%s(%s)]未设置所属设备集中站或所属设备集中站不存在", stand.getName(), stand.getCode()));
} else {
stand.setDeviceStation(deviceStation);
deviceStation.addDevice(stand);
}
// 关联站台轨
Section section = (Section) elementMap.get(standVO.getStandTrackCode());
@ -809,6 +811,9 @@ public class MapDeviceBuilder {
}
psd.setStand(stand);
stand.setPsd(psd);
if (stand.getDeviceStation() != null) {
stand.getDeviceStation().addDevice(psd);
}
//PSL
VirtualRealityPsl vrPsl = new VirtualRealityPsl(stand.getCode() + "_PSL", stand.getName() + "_PSL");
stand.setVrPsl(vrPsl);
@ -995,6 +1000,7 @@ public class MapDeviceBuilder {
errMsgList.add(String.format("区段[%s(%s)]未关联设备集中站或设备集中站不存在", section.getName(), section.getCode()));
} else {
section.setDeviceStation(deviceStation);
deviceStation.addDevice(section);
}
section.setStandTrack(sectionVO.isStandTrack());
section.setTurnBackTrack(sectionVO.isReentryTrack());
@ -1078,6 +1084,7 @@ public class MapDeviceBuilder {
errMsgList.add(String.format("信号机[%s(%s)]未设置所属设备集中站或所属设备集中站不存在", signal.getName(), signal.getCode()));
} else {
signal.setDeviceStation(deviceStation);
deviceStation.addDevice(signal);
}
signal.setStation((Station) elementMap.get(signalVO.getBelongStationCode()));

View File

@ -10,7 +10,7 @@ import lombok.Setter;
*/
@Getter
@Setter
public abstract class MayOutOfOrderDevice extends MapNamedElement {
public abstract class MayOutOfOrderDevice extends StatusDevice {
private DeviceFault fault;
@ -23,6 +23,7 @@ public abstract class MayOutOfOrderDevice extends MapNamedElement {
}
public void reset() {
super.reset();
this.fault = null;
}

View File

@ -9,7 +9,7 @@ import lombok.Setter;
*/
@Getter
@Setter
public class PSD extends MapNamedElement {
public class PSD extends StatusDevice {
public PSD(String code, String name) {
super(code, name, DeviceType.PSD);
@ -36,15 +36,12 @@ public class PSD extends MapNamedElement {
/** 是否互锁解除 */
private boolean interlockRelease;
/** 无状态 */
private boolean noStatus;
@Override
public void reset() {
super.reset();
this.close = true;
this.lock = true;
this.interlockRelease = false;
this.noStatus = false;
}
public boolean isCloseAndLock() {

View File

@ -222,11 +222,6 @@ public class Section extends DelayUnlockDevice {
*/
private int speedUpLimit = -1;
/**
* 无状态哈尔滨灰显
*/
private boolean noStatus;
/**
* 延时解锁
*/
@ -261,7 +256,6 @@ public class Section extends DelayUnlockDevice {
this.invalid = false;
this.faultLock = false;
this.speedUpLimit = -1;
this.noStatus = false;
this.delayUnlock = false;
this.closeInit = false;
this.openInit = false;

View File

@ -204,11 +204,6 @@ public class Signal extends DelayUnlockDevice {
*/
private boolean forcePhysical;
/**
* 无状态
*/
private boolean noStatus;
/**
* 初始化
*/
@ -240,7 +235,6 @@ public class Signal extends DelayUnlockDevice {
this.aspect = this.signalModel.getDefaultAspect();
this.guideRemain = 0;
this.forcePhysical = false;
this.noStatus = false;
this.init = false;
this.approachLock = false;
this.overlapLock = false;
@ -292,9 +286,6 @@ public class Signal extends DelayUnlockDevice {
}
public void changeLightType(boolean logic) {
if (SignalFault.MAIN_FILAMENT_BROKEN.equals(getFault()) && logic) {
return;
}
if (logic && forcePhysical) {
return;
}
@ -675,29 +666,20 @@ public class Signal extends DelayUnlockDevice {
public enum SignalFault implements DeviceFault {
/**
* 主灯丝熔断故障
* 无法开放故障
*/
MAIN_FILAMENT_BROKEN {
NO_OPEN {
@Override
public boolean apply(MayOutOfOrderDevice device) {
// todo 信号机故障逻辑
// if (Objects.equals(device.getFault(), this)) {
// return false;
// }
// Signal signal = (Signal) device;
// if (signal.isVirtual())
// return false;
// device.setFault(this);
// signal.changeLightType(false); //改为物理点灯
// signal.apply(false, false, true);
// VirtualRealitySignal realSignal = signal.getVirtualSignal();
// if (realSignal != null) {
// VirtualRealitySignal.Fault.MAIN_FILAMENT_BROKEN.apply(realSignal);
// }
// if (!signal.isLogicLight()) { //如果是物理点灯
// VirtualRealitySignal realSignal = signal.getVirtualSignal();
// realSignal.apply(false, false, true);
// }
Signal signal = (Signal) device;
VirtualRealitySignal realSignal = signal.getVirtualSignal();
if (realSignal == null) {
return false;
}
device.setFault(this);
if (realSignal != null) {
VirtualRealitySignal.Fault.NO_OPEN.apply(realSignal);
}
return true;
}
};

View File

@ -155,11 +155,6 @@ public class Stand extends MayOutOfOrderDevice {
*/
private TurnBackType typeStrategy;
/**
* 无状态
*/
private boolean noStatus;
private boolean closed;
/**
@ -192,7 +187,6 @@ public class Stand extends MayOutOfOrderDevice {
this.clearTrainParkingTime();
this.parkingAlwaysValid = false;
this.typeStrategy = this.defaultTypeStrategy;
this.noStatus = false;
this.closed = false;
}

View File

@ -15,10 +15,7 @@ import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -48,6 +45,10 @@ public class Station extends MayOutOfOrderDevice {
* 所属设备集中站
*/
private Station deviceStation;
/**
* 设备集中站管理的设备
*/
private Map<String, StatusDevice> deviceMap = new HashMap<>();
/**
* 公里标距离毫米
@ -431,6 +432,14 @@ public class Station extends MayOutOfOrderDevice {
}
}
public void addDevice(StatusDevice device) {
this.deviceMap.put(device.getCode(), device);
}
public boolean isAtsRouteTriggerFault() {
return Fault.ATS_ROUTE_TRIGGER_FAULT.equals(this.getFault());
}
public enum ControlMode {
/**
* 交出未被接收
@ -532,17 +541,21 @@ public class Station extends MayOutOfOrderDevice {
public enum Fault implements DeviceFault {
/**
* 联锁故障
* 联锁故障
*/
INTERLOCK_MACHINE_FAULT {
INTERLOCK_FAULT {
@Override
public boolean apply(MayOutOfOrderDevice device) {
Station station = (Station) device;
if (station.getDeviceStation() != null) {
station = station.getDeviceStation();
}
if (Objects.equals(this, station.getFault()))
for (StatusDevice statusDevice : station.deviceMap.values()) {
statusDevice.setNoStatus(true);
}
if (Objects.equals(this, station.getFault())) {
return false;
}
station.setFault(this);
return true;
}
@ -555,11 +568,16 @@ public class Station extends MayOutOfOrderDevice {
}
if (!Objects.equals(this, device.getFault()))
return;
for (StatusDevice statusDevice : station.deviceMap.values()) {
statusDevice.setNoStatus(false);
}
station.setFault(null);
}
},
ATS_FAULT {
/**
* ATS进路触发故障
*/
ATS_ROUTE_TRIGGER_FAULT {
@Override
public boolean apply(MayOutOfOrderDevice device) {
Station station = (Station) device;

View File

@ -0,0 +1,19 @@
package club.joylink.rtss.simulation.cbtc.data.map;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public abstract class StatusDevice extends MapNamedElement {
/** 无状态(灰显) */
private boolean noStatus;
protected StatusDevice(String code, String name, DeviceType deviceType) {
super(code, name, deviceType);
}
public void reset() {
this.noStatus = false;
}
}

View File

@ -95,11 +95,6 @@ public class Switch extends DelayUnlockDevice {
*/
private SwitchIndication pos;
/**
* 无状态
*/
private boolean noStatus;
/**
* 预复位
*/
@ -151,7 +146,6 @@ public class Switch extends DelayUnlockDevice {
this.overlapLock = false;
this.masterGuideLock = false;
this.pos = SwitchIndication.N;
this.noStatus = false;
this.preReset = false;
this.auto = true;
this.dispatcherReserve = false;

View File

@ -37,8 +37,6 @@ public class VirtualRealitySignal extends ControllableVrDevice<SignalAspect> {
}
public void apply(SignalAspect aspect) {
if (Fault.MAIN_FILAMENT_BROKEN.equals(fault))
return;
if (aspect.equals(this.getCommand())) {
this.finish();
}
@ -60,13 +58,23 @@ public class VirtualRealitySignal extends ControllableVrDevice<SignalAspect> {
@Override
protected void doFinish(SignalAspect command) {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(command);
if (Fault.NO_OPEN.equals(fault)) {
if (!this.model.getDefaultAspect().equals(command) && !command.equals(this.model.getGuideAspect())) {
return;
}
}
this.aspect = command;
}
public enum Fault {
MAIN_FILAMENT_BROKEN {
/** 无法开放主信号 */
NO_OPEN {
@Override
public void apply(VirtualRealitySignal vrSignal) {
vrSignal.setFault(this);
if (SignalAspect.No.equals(vrSignal.getAspect())) {
return;
}
vrSignal.apply(vrSignal.getModel().getDefaultAspect());
}
};