diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilLogicService.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilLogicService.java index 3664ecac2..e487e16d5 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilLogicService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilLogicService.java @@ -4,6 +4,7 @@ import club.joylink.rtss.simulation.rt.CIL.bo.*; import club.joylink.rtss.simulation.rt.RtSimulation; import club.joylink.rtss.simulation.rt.srd.SrdApiService; import club.joylink.rtss.simulation.rt.srd.bo.SrAXC; +import club.joylink.rtss.simulation.rt.srd.bo.SrPSD; import club.joylink.rtss.simulation.rt.srd.bo.SrSignal; import club.joylink.rtss.simulation.rt.srd.bo.SrSwitch; import club.joylink.rtss.vo.client.map.MapVO; @@ -23,6 +24,9 @@ public class CilLogicService { @Autowired private SrdApiService srdApiService; + @Autowired + private CilRouteLogicService cilRouteLogicService; + public void buildRepository(RtSimulation rtSimulation, MapVO mapVO) { CilRepository cilRepository = CilRepositoryBuilder.buildFrom(mapVO); rtSimulation.addRepository(cilRepository); @@ -57,9 +61,15 @@ public class CilLogicService { CilSignal cilSignal = repository.getSignalById(srSignal.getId()); cilSignal.updateByDeviceState(srSignal.getState()); } + // 屏蔽门 + List psdList = this.srdApiService.queryAllPsd(rtSimulation); + for (SrPSD srPSD : psdList) { + CilPsd cilPsd = repository.getPsdById(srPSD.getId()); + cilPsd.updateState(srPSD.getState()); + } } private void mainLogic(CilRepository cilRepository) { - + this.cilRouteLogicService.routeLogic(cilRepository); } } 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 new file mode 100644 index 000000000..8220ea2b0 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/CilRouteLogicService.java @@ -0,0 +1,38 @@ +package club.joylink.rtss.simulation.rt.CIL; + +import club.joylink.rtss.simulation.rt.CIL.bo.CilRepository; +import club.joylink.rtss.simulation.rt.CIL.bo.CilRoute; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class CilRouteLogicService { + public void routeLogic(CilRepository cilRepository) { + List supervisedRouteList = cilRepository.getSupervisedRouteList(); + for (CilRoute cilRoute : supervisedRouteList) { + switch (cilRoute.getStage()) { + case CilRoute.STAGE_SETTING: + this.settingProgress(cilRoute); + break; + case CilRoute.STAGE_WATCH: + this.watchRoute(cilRoute); + break; + } + } + } + + private void settingProgress(CilRoute cilRoute) { + + } + + /** + * 进路监控 + * @param cilRoute + */ + private void watchRoute(CilRoute cilRoute) { + if (cilRoute.isOpen()) { + + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilPsd.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilPsd.java index 85d93f56b..66d1f3163 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilPsd.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilPsd.java @@ -1,8 +1,14 @@ package club.joylink.rtss.simulation.rt.CIL.bo; public class CilPsd extends CilDevice { + int state; + boolean cut; public CilPsd(String id, String name) { super(id, name); } + + public void updateState(int state) { + this.state = state; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java index 05a3ae1e0..cc5ce1bb6 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepository.java @@ -3,7 +3,9 @@ package club.joylink.rtss.simulation.rt.CIL.bo; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.SimulationRepository; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; public class CilRepository extends SimulationRepository { @@ -16,6 +18,7 @@ public class CilRepository extends SimulationRepository { Map psdMap; Map espMap; Map routeMap; + Map supervisedRouteMap; // 监控中的进路 Map autoSignalMap; /** * key-id @@ -61,4 +64,18 @@ public class CilRepository extends SimulationRepository { BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(cilSignal); return cilSignal; } + + public CilPsd getPsdById(String id) { + CilPsd cilPsd = this.psdMap.get(id); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(cilPsd); + return cilPsd; + } + + public List getRouteList() { + return new ArrayList<>(this.routeMap.values()); + } + + public List getSupervisedRouteList() { + return new ArrayList<>(this.supervisedRouteMap.values()); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRoute.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRoute.java index 380bdfeb0..5e874d23c 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRoute.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRoute.java @@ -1,7 +1,10 @@ package club.joylink.rtss.simulation.rt.CIL.bo; +import lombok.Getter; + import java.util.List; +@Getter public class CilRoute extends CilDevice { int type; // 进路类型 @@ -24,8 +27,15 @@ public class CilRoute extends CilDevice { public static final int SA_RED = 1; public static final int SA_GREEN = 2; public static final int SA_YELLOW = 3; - public static final int SA_GUIDE = 4;//引导信号,黄红灯显示 + public static final int SA_GUIDE = 4; //引导信号,黄红灯显示 + int stage; // 进路当前所处逻辑阶段 + public static final int STAGE_NONE = 0; // 无 + public static final int STAGE_SETTING = 1; // 建立阶段 + public static final int STAGE_WATCH = 2; // 信号正常开发后监视 + public static final int STAGE_UL = 3; // 正常解锁 + public static final int STAGE_DUL = 4; // 延时解锁 + public static final int STAGE_FUL = 5; // 故障解锁 int signalState;// 进路信号状态(当前实际状态) @@ -33,4 +43,14 @@ public class CilRoute extends CilDevice { public CilRoute(String id, String name) { super(id, name); } + + public boolean isOpen() { + return this.start.getSignalAspect() == CilSignal.GREEN + || + this.start.getSignalAspect() == CilSignal.YELLOW; + } + + public boolean isGuide() { + return this.start.getSignalAspect() == CilSignal.GUIDE; + } } 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 019baceee..a14e34de8 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,22 +1,26 @@ package club.joylink.rtss.simulation.rt.CIL.bo; import club.joylink.rtss.simulation.rt.srd.bo.SrSignal; +import lombok.Getter; import java.util.List; +@Getter public class CilSignal extends CilDevice { boolean right; List approachList; List ctcApproachList; - int signalAspect; //信号显示 + int signalAspect; //当前显示的信号 public static final int RED = 1; // 红灯信号(禁止信号) public static final int GREEN = 2; // 绿灯信号(直向通行) public static final int YELLOW = 3; // 黄灯信号(侧向通行) public static final int GUIDE = 4; // 引导信号(正线为黄红) boolean logic; - int blockade; + boolean bl; // 封锁 + boolean rbl; // 重复封锁 + int forceLight; int level; public static final int LEVEL_1 = 1; //关闭/非监控级 diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitch.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitch.java index 876b8fa13..a1e1bc29b 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitch.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilSwitch.java @@ -8,11 +8,11 @@ public class CilSwitch extends CilDevice { public static final int REVERSE = 2; // 反位 public static final int SQUEEZING = 4; // 挤叉 - int singleLock; - int blockade; - int routeLock; - int overlapLock; - int fpLock; + boolean bl; // 封锁 + boolean sl; // 单锁 + boolean rl; // 进路锁闭 + boolean ol; // 延续保护锁闭 + boolean fl; // 侧防锁闭 public CilSwitch(String id, String name) { super(id, name); 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 11f329321..0059616aa 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 @@ -1,10 +1,7 @@ package club.joylink.rtss.simulation.rt.srd; import club.joylink.rtss.simulation.rt.RtSimulation; -import club.joylink.rtss.simulation.rt.srd.bo.SrAXC; -import club.joylink.rtss.simulation.rt.srd.bo.SrSignal; -import club.joylink.rtss.simulation.rt.srd.bo.SrSwitch; -import club.joylink.rtss.simulation.rt.srd.bo.SrdRepository; +import club.joylink.rtss.simulation.rt.srd.bo.*; import org.springframework.stereotype.Component; import java.util.List; @@ -25,4 +22,9 @@ public class SrdApiService { SrdRepository repository = rtSimulation.getRepository(SrdRepository.NAME, SrdRepository.class); return repository.getSignalList(); } + + public List queryAllPsd(RtSimulation rtSimulation) { + SrdRepository repository = rtSimulation.getRepository(SrdRepository.NAME, SrdRepository.class); + return repository.getPsdList(); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrPSD.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrPSD.java index 8d84b2571..651a21ab8 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrPSD.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrPSD.java @@ -27,6 +27,10 @@ public class SrPSD extends SrDevice { super(id, DeviceType.PSD); } + public int getState() { + return state; + } + public boolean isTurning() { return NONE != this.command.get(); }