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(); + } + /** * 进路检查失败原因 */