From 2ddb1c38c5b1207b54b5b89f95266889a34fc2b3 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 6 Jul 2021 11:13:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E6=9C=89=E5=85=B3?= =?UTF-8?q?=E8=BF=9B=E8=B7=AF=E7=9A=84=E7=A7=BB=E5=8A=A8=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATP/ground/ZCLogicLoop.java | 37 +++++++++++++------ .../rtss/simulation/cbtc/data/map/Route.java | 4 ++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java index 4aded445e..b7822c358 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java @@ -23,7 +23,6 @@ import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.Set; import java.util.stream.Collectors; /** @@ -440,9 +439,10 @@ public class ZCLogicLoop { boolean lock = false; if (!CollectionUtils.isEmpty(settingRoutes)) { for (Route route : settingRoutes) { - if (route.isRouteSection(section)) { + if (route.isRouteSection(section) && route.isRight() == right) { lock = true; - if (!this.checkSwitchPosition(route) || !routeService.isFlsCheckPass(route.getFlsList())) { + List switches = screenSwitchesInFront(route, section); + if (!routeService.checkRouteSwitchPosition(switches) || !this.isFlsCheckPass(route.getFlsList(), switches)) { return new MovementAuthority.End(section, MovementAuthority.EndType.ROUTE_INTERLOCK_NOT_MET); } break; @@ -475,14 +475,29 @@ public class ZCLogicLoop { return null; } - private boolean checkSwitchPosition(Route route) { - Set sectionRelSwitches = route.getSectionList().stream() - .filter(Section::isRouteLock) - .map(Section::getRelSwitch) - .collect(Collectors.toSet()); - List switchList; - switchList = route.getSwitchList().stream().filter(element -> sectionRelSwitches.contains(element.getASwitch())).collect(Collectors.toList()); - return routeService.checkRouteSwitchPosition(switchList); + private boolean isFlsCheckPass(List flsList, List switches) { + if (!CollectionUtils.isEmpty(flsList) && !CollectionUtils.isEmpty(switches)) { + List collect = flsList.stream().filter(fls -> switches.contains(fls.getBase())).collect(Collectors.toList()); + return routeService.isFlsCheckPass(collect); + } + return true; + } + + /** + * 筛选前方的道岔 + */ + private List screenSwitchesInFront(Route route, Section section) { + boolean right = route.isRight(); + List
sectionList = route.getSectionList(); + List sectionRelSwitches = new ArrayList<>(); + while (sectionList.contains(section)) { + if (section.getRelSwitch() != null) + sectionRelSwitches.add(section.getRelSwitch()); + section = section.getNextRunningSectionOf(right); + } + return route.getSwitchList().stream() + .filter(element -> sectionRelSwitches.contains(element.getASwitch())) + .collect(Collectors.toList()); } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java index 12432b3d9..9dbfc0d9f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java @@ -578,6 +578,10 @@ public class Route extends MapNamedElement { return this.sectionList.stream().anyMatch(Section::isTransferTrack); } + public boolean isRight() { + return this.start.isRight(); + } + /** * 进路检查失败原因 */