From 2d6b93009b01bfb0fe7369efb3bfd8c17c8483e0 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Wed, 25 Nov 2020 10:57:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BF=A1=E5=8F=B7=E6=9C=BA?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=AE=9E=E8=AE=AD=E9=80=BB=E8=BE=91=E2=80=94?= =?UTF-8?q?=E2=80=94=E5=85=BC=E5=AE=B9=E5=93=88=E5=B0=94=E6=BB=A8=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=20=E6=8A=BD=E8=B1=A1=E4=BB=BF=E7=9C=9F=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E6=B7=BB=E5=8A=A0=E7=A7=BB=E9=99=A4=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generatornew/base/SignalGeneratorNew.java | 70 ++++++++++++++----- .../joylink/rtss/simulation/Simulation.java | 23 +++++- 2 files changed, 75 insertions(+), 18 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SignalGeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SignalGeneratorNew.java index a91089d5b..5582587e1 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SignalGeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SignalGeneratorNew.java @@ -62,12 +62,8 @@ public class SignalGeneratorNew implements GeneratorNew { case Signal_Block: case Signal_Find_Routes_Status: break; - case Signal_Set_Route: - case Signal_Set_CI_Auto_Trigger: - case Signal_Close_Auto_Setting:{ - if (CollectionUtils.isEmpty(routeList)) { - continue; - } else { + case Signal_Set_Route:{ + if (!CollectionUtils.isEmpty(routeList)) { for (Route route : routeList) { // 类似哈尔滨一号线,根据配置各类进路分别生成 if ((operateDefinitionVO.isAtp() && !route.isAtp()) @@ -84,6 +80,31 @@ public class SignalGeneratorNew implements GeneratorNew { } continue; } + case Signal_Set_CI_Auto_Trigger: + case Signal_Close_Auto_Setting:{ + if (!CollectionUtils.isEmpty(routeList)) { + if (routeLikeHa1) { + trainingVOList.add(this.build(config, simulation, signal, operateDefinitionVO)); + simulation.reset(); + continue; + } else { + for (Route route : routeList) { + // 类似哈尔滨一号线,根据配置各类进路分别生成 + if ((operateDefinitionVO.isAtp() && !route.isAtp()) + || (operateDefinitionVO.isGround() && !route.isGround())) { + continue; + } + if (route.isGuide()) { // 引导进路跳过 + continue; + } + trainingVOList.add(this.build(config, simulation, route, operateDefinitionVO)); + // 仿真重置 + simulation.reset(); + } + } + } + continue; + } case Signal_Total_Cancel: // 总取消暂时只生成取消未接近锁闭的进路这一种场景的实训 case Signal_Cancel_Route:{ // 查询以信号机为始端的进路列表,设置背景为进路已排列 @@ -159,15 +180,23 @@ public class SignalGeneratorNew implements GeneratorNew { case Signal_Open_Auto_Setting:{ // 查询进路列表,背景为进路人工控 if (!CollectionUtils.isEmpty(routeList)) { - for (Route route : routeList) { - if ((routeLikeHa1 && !route.isAtp()) - || route.isGuide()) { // 引导进路不生成 - continue; + if (routeLikeHa1) { + for (Route route : routeList) { + route.setAtsControl(false); } - route.setAtsControl(false); - trainingVOList.add(this.build(config, simulation, route, operateDefinitionVO)); + trainingVOList.add(this.build(config, simulation, signal, operateDefinitionVO)); // 仿真重置 simulation.reset(); + } else { + for (Route route : routeList) { + if (route.isGuide()) { // 引导进路不生成Signal_Cancel_CI_Auto_Trigger + continue; + } + route.setAtsControl(false); + trainingVOList.add(this.build(config, simulation, route, operateDefinitionVO)); + // 仿真重置 + simulation.reset(); + } } } continue; @@ -204,16 +233,25 @@ public class SignalGeneratorNew implements GeneratorNew { continue; } case Signal_Cancel_CI_Auto_Trigger:{ - // 查询自动触发进路列表,背景为自动触发进路的联锁自动触发模式已设置 if (!CollectionUtils.isEmpty(routeList)) { + // 查询自动触发进路列表,背景为自动触发进路的联锁自动触发模式已设置 List arcRouteList = routeList.stream() .filter(route -> route.isArs()) .collect(Collectors.toList()); - for (Route route : arcRouteList) { - route.setCiControl(true); - trainingVOList.add(this.build(config, simulation, route, operateDefinitionVO)); + if (routeLikeHa1) { + for (Route route : arcRouteList) { + route.setCiControl(true); + } + trainingVOList.add(this.build(config, simulation, signal, operateDefinitionVO)); // 仿真重置 simulation.reset(); + } else { + for (Route route : arcRouteList) { + route.setCiControl(true); + trainingVOList.add(this.build(config, simulation, route, operateDefinitionVO)); + // 仿真重置 + simulation.reset(); + } } } continue; diff --git a/src/main/java/club/joylink/rtss/simulation/Simulation.java b/src/main/java/club/joylink/rtss/simulation/Simulation.java index 938c97a60..719e914aa 100644 --- a/src/main/java/club/joylink/rtss/simulation/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/Simulation.java @@ -24,7 +24,7 @@ public abstract class Simulation { /** * 仿真状态 */ - private State state; + private volatile State state; /** * 仿真运行发生异常时,保存的异常信息 */ @@ -84,7 +84,7 @@ public abstract class Simulation { /** * 添加定时仿真逻辑循环 - * @param name + * @param name 任务名称,同时也是id * @param job 仿真逻辑 * @param rate 执行频率,单位ms */ @@ -100,6 +100,21 @@ public abstract class Simulation { scheduledJob.runAsSpeed(EXECUTOR, this.speed); } + /** + * 移除指定仿真任务逻辑循环 + * @param name + */ + public void removeJob(String name) { + if (null == name) { + throw new IllegalArgumentException("name can't be null"); + } + SimulationScheduledJob simulationScheduledJob = this.scheduledJobMap.get(name); + if (simulationScheduledJob != null) { + simulationScheduledJob.cancel(); + this.scheduledJobMap.remove(name); + } + } + /** * 控制-开始 */ @@ -182,6 +197,10 @@ public abstract class Simulation { } } + public Throwable getThrowable() { + return this.throwable; + } + public Map toDataMap() { Map map = new HashMap<>(); map.put("id", this.id);