diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java index 7205e7727..00e10337f 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java @@ -1,7 +1,6 @@ package club.joylink.rtss.simulation.rt.CIL; 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.RtSimulation; import club.joylink.rtss.simulation.rt.SRD.bo.SrSignal; @@ -124,7 +123,7 @@ public class CilRouteLogicService { // 关灯 CommonSignal commonSignal = commonRoute.getStart(); CilSignal cilSignal = cilRepository.getSignalById(commonSignal.getId()); - cilSignalLogicService.UpdateSignalDisplay(rtSimulation, cilSignal, SrSignal.RED, true); + cilSignalLogicService.UpdateSignalDisplay(rtSimulation, cilSignal, SrSignal.H, true); cilSignal.setLrId(null); /* 取消进路相关所有设备的锁闭状态 */ // 延续保护解锁 diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSignalLogicService.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSignalLogicService.java index 28e38203d..8dcc623b6 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSignalLogicService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilSignalLogicService.java @@ -1,9 +1,7 @@ package club.joylink.rtss.simulation.rt.CIL; 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.CilRoute; import club.joylink.rtss.simulation.rt.CIL.bo.CilSignal; import club.joylink.rtss.simulation.rt.RtSimulation; import club.joylink.rtss.simulation.rt.SRD.SrdApiService; @@ -14,7 +12,6 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.List; -import java.util.Optional; @Component public class CilSignalLogicService { @@ -71,6 +68,16 @@ public class CilSignalLogicService { // 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)) { srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect); } @@ -78,6 +85,7 @@ public class CilSignalLogicService { } public void UpdateSignalDisplay(RtSimulation rtSimulation, CilSignal signal, int aspect, boolean ctcMode) { + BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(try2UpdateSignalDisplay(rtSimulation, signal, aspect, ctcMode)); } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSignal.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSignal.java index 755d91da2..ff9cdda96 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSignal.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSignal.java @@ -1,13 +1,10 @@ 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.SRD.bo.SrSignal; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Getter public class CilSignal extends CilDevice { public static final int DEFAULT_DELAY_TIME = 30 * 1000; @@ -44,6 +41,8 @@ public class CilSignal extends CilDevice { String lrId; //锁闭进路的id int delayTime; //信号机延时解锁倒计时/ms + Fault fault; + public CilSignal(String id, String name) { super(id, name); } @@ -114,4 +113,32 @@ public class CilSignal extends CilDevice { public void updateDelayTime() { 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; + } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/SRD/SrdApiService.java b/src/main/java/club/joylink/rtss/simulation/rt/SRD/SrdApiService.java index cf716f523..2a7c0c4bf 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/SRD/SrdApiService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/SRD/SrdApiService.java @@ -77,20 +77,20 @@ public class SrdApiService { srSignal.close(systemTime); break; } - case SrSignal.RED:{ + case SrSignal.H:{ srSignal.openRed(systemTime); break; } - case SrSignal.GREEN:{ + case SrSignal.L:{ srSignal.openGreen(systemTime); break; } - case SrSignal.YELLOW: { + case SrSignal.U: { srSignal.openYellow(systemTime); break; } - case SrSignal.GUIDE: { - srSignal.openGuide(systemTime); + case SrSignal.UH: { + srSignal.openYellowRed(systemTime); break; } default: diff --git a/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrSignal.java b/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrSignal.java index 379f11dfe..5a25ee00b 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrSignal.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrSignal.java @@ -24,16 +24,16 @@ public class SrSignal extends SrDevice { int state = OFF; public static final int OFF = 0; // 关闭 - public static final int RED = 1; // 红灯信号(禁止信号) - public static final int GREEN = 2; // 绿灯信号(直向通行) - public static final int YELLOW = 3; // 黄灯信号(侧向通行) - public static final int GUIDE = 4; // 引导信号(正线为黄红) + public static final int H = 1; // 红灯信号(禁止信号) + public static final int L = 2; // 绿灯信号(直向通行) + public static final int U = 3; // 黄灯信号(侧向通行) + public static final int UH = 4; // 引导信号(正线为黄红) public static final int LL = 5; // 绿绿 - public static final int LH = 6; // 绿黄 - public static final int HH = 7; // 黄黄 - public static final int HSH = 8; // 黄闪黄 + public static final int LU = 6; // 绿黄 + public static final int UU = 7; // 黄黄 + public static final int USU = 8; // 黄闪黄 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 HS = 12; // 红闪 @@ -66,19 +66,19 @@ public class SrSignal extends SrDevice { } public void openRed(LocalDateTime systemTime) { - this.startTurn(systemTime, RED); + this.startTurn(systemTime, H); } public void openGreen(LocalDateTime systemTime) { - this.startTurn(systemTime, GREEN); + this.startTurn(systemTime, L); } public void openYellow(LocalDateTime systemTime) { - this.startTurn(systemTime, YELLOW); + this.startTurn(systemTime, U); } - public void openGuide(LocalDateTime systemTime) { - this.startTurn(systemTime, GUIDE); + public void openYellowRed(LocalDateTime systemTime) { + this.startTurn(systemTime, UH); } private void startTurn(LocalDateTime systemTime, int command) { @@ -99,7 +99,7 @@ public class SrSignal extends SrDevice { } @Override 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; } else { throw new IllegalArgumentException(String.format("无效的道岔状态:[%s]", state)); @@ -109,4 +109,5 @@ public class SrSignal extends SrDevice { public void open(LocalDateTime systemTime, int aspect) { this.startTurn(systemTime, aspect); } + } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/fault/SignalFaultListener.java b/src/main/java/club/joylink/rtss/simulation/rt/fault/SignalFaultListener.java index 81287a4a0..eba6a32df 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/fault/SignalFaultListener.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/fault/SignalFaultListener.java @@ -3,18 +3,34 @@ package club.joylink.rtss.simulation.rt.fault; import club.joylink.rtss.simulation.Simulation; import club.joylink.rtss.simulation.event.SimulationFaultInjectEvent; 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; @Component public class SignalFaultListener { + @Autowired + private CilSignalLogicService cilSignalLogicService; @EventListener public void signalFaultInjectHandler(SimulationFaultInjectEvent event) { SimulationFaultVO deviceFault = event.getDeviceFault(); Simulation simulation = event.getSimulation(); 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(); Simulation simulation = event.getSimulation(); 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); + } } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepositoryBuilder.java b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepositoryBuilder.java index 57b2003b3..d5b13a078 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepositoryBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepositoryBuilder.java @@ -1,6 +1,7 @@ package club.joylink.rtss.simulation.rt.repo; 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.MapVO; import club.joylink.rtss.vo.client.map.newmap.*; @@ -416,6 +417,7 @@ public class CommonRepositoryBuilder { CommonSignal commonSignal = new CommonSignal(signalVO.getCode(), signalVO.getUniqueName()); signalMap.put(commonSignal.id, commonSignal); commonSignal.right = signalVO.isRight(); + commonSignal.shunting = Signal.SignalType.SHUNTING.equals(signalVO.getType()); } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonSignal.java b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonSignal.java index 9c9b18cca..86a08bc5a 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonSignal.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonSignal.java @@ -7,6 +7,8 @@ import java.util.List; @Getter public class CommonSignal extends CommonDevice { + boolean shunting; // 是否调车信号机 + CommonStation station; CommonStation ecStation;// 设备集中站 boolean right;//方向