轨道交通仿真——添加信号机故障注入、移除逻辑,信号机基础属性添加是否调车信号机字段

This commit is contained in:
walker-sheng 2021-04-27 17:09:40 +08:00
parent b894b414df
commit 4e553f67bd
8 changed files with 88 additions and 27 deletions

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.simulation.rt.CIL; package club.joylink.rtss.simulation.rt.CIL;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.simulation.rt.CIL.bo.*; import club.joylink.rtss.simulation.rt.CIL.bo.*;
import club.joylink.rtss.simulation.rt.RtSimulation; import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.simulation.rt.SRD.bo.SrSignal; import club.joylink.rtss.simulation.rt.SRD.bo.SrSignal;
@ -124,7 +123,7 @@ public class CilRouteLogicService {
// 关灯 // 关灯
CommonSignal commonSignal = commonRoute.getStart(); CommonSignal commonSignal = commonRoute.getStart();
CilSignal cilSignal = cilRepository.getSignalById(commonSignal.getId()); CilSignal cilSignal = cilRepository.getSignalById(commonSignal.getId());
cilSignalLogicService.UpdateSignalDisplay(rtSimulation, cilSignal, SrSignal.RED, true); cilSignalLogicService.UpdateSignalDisplay(rtSimulation, cilSignal, SrSignal.H, true);
cilSignal.setLrId(null); cilSignal.setLrId(null);
/* 取消进路相关所有设备的锁闭状态 */ /* 取消进路相关所有设备的锁闭状态 */
// 延续保护解锁 // 延续保护解锁

View File

@ -1,9 +1,7 @@
package club.joylink.rtss.simulation.rt.CIL; package club.joylink.rtss.simulation.rt.CIL;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.rt.CIL.bo.CilRepository; import club.joylink.rtss.simulation.rt.CIL.bo.CilRepository;
import club.joylink.rtss.simulation.rt.CIL.bo.CilRoute;
import club.joylink.rtss.simulation.rt.CIL.bo.CilSignal; import club.joylink.rtss.simulation.rt.CIL.bo.CilSignal;
import club.joylink.rtss.simulation.rt.RtSimulation; import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.simulation.rt.SRD.SrdApiService; import club.joylink.rtss.simulation.rt.SRD.SrdApiService;
@ -14,7 +12,6 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.List; import java.util.List;
import java.util.Optional;
@Component @Component
public class CilSignalLogicService { public class CilSignalLogicService {
@ -71,6 +68,16 @@ public class CilSignalLogicService {
// srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect); // srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect);
// } // }
// } // }
if (signal.isDsFault()) {
// 控制显示禁止信号
CommonRepository commonRepository = rtSimulation.getRepository(CommonRepository.NAME, CommonRepository.class);
CommonSignal commonSignal = commonRepository.getSignalById(signal.getId());
if (commonSignal.isShunting()) {
aspect = SrSignal.A;
} else {
aspect = SrSignal.H;
}
}
if (signal.sufficientLevel(aspect, false)) { if (signal.sufficientLevel(aspect, false)) {
srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect); srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect);
} }
@ -78,6 +85,7 @@ public class CilSignalLogicService {
} }
public void UpdateSignalDisplay(RtSimulation rtSimulation, CilSignal signal, int aspect, boolean ctcMode) { public void UpdateSignalDisplay(RtSimulation rtSimulation, CilSignal signal, int aspect, boolean ctcMode) {
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(try2UpdateSignalDisplay(rtSimulation, signal, aspect, ctcMode)); BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(try2UpdateSignalDisplay(rtSimulation, signal, aspect, ctcMode));
} }

View File

@ -1,13 +1,10 @@
package club.joylink.rtss.simulation.rt.CIL.bo; package club.joylink.rtss.simulation.rt.CIL.bo;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.rt.CIL.CilLogicService; import club.joylink.rtss.simulation.rt.CIL.CilLogicService;
import club.joylink.rtss.simulation.rt.SRD.bo.SrSignal; import club.joylink.rtss.simulation.rt.SRD.bo.SrSignal;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
@Getter @Getter
public class CilSignal extends CilDevice { public class CilSignal extends CilDevice {
public static final int DEFAULT_DELAY_TIME = 30 * 1000; public static final int DEFAULT_DELAY_TIME = 30 * 1000;
@ -44,6 +41,8 @@ public class CilSignal extends CilDevice {
String lrId; //锁闭进路的id String lrId; //锁闭进路的id
int delayTime; //信号机延时解锁倒计时/ms int delayTime; //信号机延时解锁倒计时/ms
Fault fault;
public CilSignal(String id, String name) { public CilSignal(String id, String name) {
super(id, name); super(id, name);
} }
@ -114,4 +113,32 @@ public class CilSignal extends CilDevice {
public void updateDelayTime() { public void updateDelayTime() {
this.delayTime = Math.max(this.delayTime - CilLogicService.CilMainLogicRate, 0); this.delayTime = Math.max(this.delayTime - CilLogicService.CilMainLogicRate, 0);
} }
public void setFault(Fault fault) {
this.fault = fault;
}
public void removeFault(Fault fault) {
if (fault.equals(this.fault)) {
this.fault = null;
}
}
public boolean isDsFault() {
return Fault.DS.equals(this.fault);
}
public enum Fault {
DS,//灯丝熔断无法开放信号
;
public static Fault queryByName(String fault) {
for (Fault f : Fault.values()) {
if (f.name().equals(fault)) {
return f;
}
}
return null;
}
}
} }

View File

@ -77,20 +77,20 @@ public class SrdApiService {
srSignal.close(systemTime); srSignal.close(systemTime);
break; break;
} }
case SrSignal.RED:{ case SrSignal.H:{
srSignal.openRed(systemTime); srSignal.openRed(systemTime);
break; break;
} }
case SrSignal.GREEN:{ case SrSignal.L:{
srSignal.openGreen(systemTime); srSignal.openGreen(systemTime);
break; break;
} }
case SrSignal.YELLOW: { case SrSignal.U: {
srSignal.openYellow(systemTime); srSignal.openYellow(systemTime);
break; break;
} }
case SrSignal.GUIDE: { case SrSignal.UH: {
srSignal.openGuide(systemTime); srSignal.openYellowRed(systemTime);
break; break;
} }
default: default:

View File

@ -24,16 +24,16 @@ public class SrSignal extends SrDevice {
int state = OFF; int state = OFF;
public static final int OFF = 0; // 关闭 public static final int OFF = 0; // 关闭
public static final int RED = 1; // 红灯信号(禁止信号) public static final int H = 1; // 红灯信号(禁止信号)
public static final int GREEN = 2; // 绿灯信号(直向通行) public static final int L = 2; // 绿灯信号(直向通行)
public static final int YELLOW = 3; // 黄灯信号(侧向通行) public static final int U = 3; // 黄灯信号(侧向通行)
public static final int GUIDE = 4; // 引导信号(正线为黄红) public static final int UH = 4; // 引导信号(正线为黄红)
public static final int LL = 5; // 绿绿 public static final int LL = 5; // 绿绿
public static final int LH = 6; // 绿黄 public static final int LU = 6; // 绿黄
public static final int HH = 7; // 黄黄 public static final int UU = 7; // 黄黄
public static final int HSH = 8; // 黄闪黄 public static final int USU = 8; // 黄闪黄
public static final int BH = 9; // 白红 public static final int BH = 9; // 白红
public static final int L = 10; // public static final int A = 10; //
public static final int B = 11; // public static final int B = 11; //
public static final int HS = 12; // 红闪 public static final int HS = 12; // 红闪
@ -66,19 +66,19 @@ public class SrSignal extends SrDevice {
} }
public void openRed(LocalDateTime systemTime) { public void openRed(LocalDateTime systemTime) {
this.startTurn(systemTime, RED); this.startTurn(systemTime, H);
} }
public void openGreen(LocalDateTime systemTime) { public void openGreen(LocalDateTime systemTime) {
this.startTurn(systemTime, GREEN); this.startTurn(systemTime, L);
} }
public void openYellow(LocalDateTime systemTime) { public void openYellow(LocalDateTime systemTime) {
this.startTurn(systemTime, YELLOW); this.startTurn(systemTime, U);
} }
public void openGuide(LocalDateTime systemTime) { public void openYellowRed(LocalDateTime systemTime) {
this.startTurn(systemTime, GUIDE); this.startTurn(systemTime, UH);
} }
private void startTurn(LocalDateTime systemTime, int command) { private void startTurn(LocalDateTime systemTime, int command) {
@ -99,7 +99,7 @@ public class SrSignal extends SrDevice {
} }
@Override @Override
public void applyState(int state) { public void applyState(int state) {
if (OFF == state || RED == state || GREEN == state || YELLOW == state || GUIDE == state) { if (OFF == state || H == state || L == state || U == state || UH == state) {
this.state = state; this.state = state;
} else { } else {
throw new IllegalArgumentException(String.format("无效的道岔状态:[%s]", state)); throw new IllegalArgumentException(String.format("无效的道岔状态:[%s]", state));
@ -109,4 +109,5 @@ public class SrSignal extends SrDevice {
public void open(LocalDateTime systemTime, int aspect) { public void open(LocalDateTime systemTime, int aspect) {
this.startTurn(systemTime, aspect); this.startTurn(systemTime, aspect);
} }
} }

View File

@ -3,18 +3,34 @@ package club.joylink.rtss.simulation.rt.fault;
import club.joylink.rtss.simulation.Simulation; import club.joylink.rtss.simulation.Simulation;
import club.joylink.rtss.simulation.event.SimulationFaultInjectEvent; import club.joylink.rtss.simulation.event.SimulationFaultInjectEvent;
import club.joylink.rtss.simulation.event.SimulationFaultRemoveEvent; import club.joylink.rtss.simulation.event.SimulationFaultRemoveEvent;
import club.joylink.rtss.simulation.rt.CIL.CilSignalLogicService;
import club.joylink.rtss.simulation.rt.CIL.bo.CilRepository;
import club.joylink.rtss.simulation.rt.CIL.bo.CilSignal;
import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.simulation.rt.SRD.bo.SrSignal;
import club.joylink.rtss.simulation.vo.SimulationFaultVO; import club.joylink.rtss.simulation.vo.SimulationFaultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
public class SignalFaultListener { public class SignalFaultListener {
@Autowired
private CilSignalLogicService cilSignalLogicService;
@EventListener @EventListener
public void signalFaultInjectHandler(SimulationFaultInjectEvent event) { public void signalFaultInjectHandler(SimulationFaultInjectEvent event) {
SimulationFaultVO deviceFault = event.getDeviceFault(); SimulationFaultVO deviceFault = event.getDeviceFault();
Simulation simulation = event.getSimulation(); Simulation simulation = event.getSimulation();
if ("Signal".equals(deviceFault.getDeviceType())) { if ("Signal".equals(deviceFault.getDeviceType())) {
CilSignal.Fault fault = CilSignal.Fault.queryByName(deviceFault.getFault());
if (fault != null) {
CilRepository cilRepository = (CilRepository) simulation.getRepository(CilRepository.NAME, CilRepository.class);
CilSignal cilSignal = cilRepository.getSignalById(deviceFault.getDeviceId());
cilSignal.setFault(fault);
// 室外信号机显示控制
this.cilSignalLogicService.try2UpdateSignalDisplay((RtSimulation) simulation, cilSignal, SrSignal.H, false);
}
} }
} }
@ -23,6 +39,12 @@ public class SignalFaultListener {
SimulationFaultVO deviceFault = event.getDeviceFault(); SimulationFaultVO deviceFault = event.getDeviceFault();
Simulation simulation = event.getSimulation(); Simulation simulation = event.getSimulation();
if ("Signal".equals(deviceFault.getDeviceType())) { if ("Signal".equals(deviceFault.getDeviceType())) {
CilSignal.Fault fault = CilSignal.Fault.queryByName(deviceFault.getFault());
if (fault != null) {
CilRepository cilRepository = (CilRepository) simulation.getRepository(CilRepository.NAME, CilRepository.class);
CilSignal cilSignal = cilRepository.getSignalById(deviceFault.getDeviceId());
cilSignal.removeFault(fault);
}
} }
} }

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.simulation.rt.repo; package club.joylink.rtss.simulation.rt.repo;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.vo.client.map.MapSwitchVO; import club.joylink.rtss.vo.client.map.MapSwitchVO;
import club.joylink.rtss.vo.client.map.MapVO; import club.joylink.rtss.vo.client.map.MapVO;
import club.joylink.rtss.vo.client.map.newmap.*; import club.joylink.rtss.vo.client.map.newmap.*;
@ -416,6 +417,7 @@ public class CommonRepositoryBuilder {
CommonSignal commonSignal = new CommonSignal(signalVO.getCode(), signalVO.getUniqueName()); CommonSignal commonSignal = new CommonSignal(signalVO.getCode(), signalVO.getUniqueName());
signalMap.put(commonSignal.id, commonSignal); signalMap.put(commonSignal.id, commonSignal);
commonSignal.right = signalVO.isRight(); commonSignal.right = signalVO.isRight();
commonSignal.shunting = Signal.SignalType.SHUNTING.equals(signalVO.getType());
} }
} }

View File

@ -7,6 +7,8 @@ import java.util.List;
@Getter @Getter
public class CommonSignal extends CommonDevice { public class CommonSignal extends CommonDevice {
boolean shunting; // 是否调车信号机
CommonStation station; CommonStation station;
CommonStation ecStation;// 设备集中站 CommonStation ecStation;// 设备集中站
boolean right;//方向 boolean right;//方向