diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java index 60cc87b9f..581ba428e 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java @@ -1238,8 +1238,16 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { if (Objects.nonNull(oppositeSignal)) { // 找到反向信号机 Section firstSection = oppositeSignal.getSection().getSectionOf(oppositeSignal.isRight()); RouteFls.FlsElement flsElement; - if (firstSection.isSwitchTrack() && !Objects.equals(aSwitch, firstSection.getRelSwitch())) { - flsElement = new RouteFls.FlsElement(oppositeSignal, new SwitchElement(firstSection.getRelSwitch(), true)); + Switch relSwitch = firstSection.getRelSwitch(); + if (firstSection.isSwitchTrack() && + !Objects.equals(aSwitch, relSwitch) && + !Objects.equals(aSwitch.queryAxleRelatedOtherSwitch(), relSwitch)) { + Switch remoteSwitch = relSwitch.queryAxleRelatedOtherSwitch(); + if (Objects.nonNull(remoteSwitch)) { + flsElement = new RouteFls.FlsElement(oppositeSignal, new SwitchElement(remoteSwitch, true)); + } else { + flsElement = new RouteFls.FlsElement(oppositeSignal, new SwitchElement(relSwitch, true)); + } } else { flsElement = new RouteFls.FlsElement(oppositeSignal); } @@ -2042,7 +2050,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { SectionPath npPath = tempPath.cloneNew();// 定位路径 npPath.addSection(relSwitch.getB()); npPath.addSwitchElement(new SwitchElement(relSwitch, true)); - if (Objects.nonNull(linkedSwitch)) { + if (!config.isGenerateFls() && Objects.nonNull(linkedSwitch)) { npPath.addSwitchElement(new SwitchElement(linkedSwitch, true)); } getOverlapPathOf(relSwitch.getB().getSectionOf(right), right, @@ -2051,14 +2059,14 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { SectionPath rpPath = tempPath.cloneNew();// 反位路径 rpPath.addSection(relSwitch.getC()); rpPath.addSwitchElement(new SwitchElement(relSwitch, false)); - if (Objects.nonNull(linkedSwitch) && config.isOverlapOnlyOneSwitch()) { + if (!config.isGenerateFls() && Objects.nonNull(linkedSwitch) && config.isOverlapOnlyOneSwitch()) { // 如果有联动道岔,且配置只构建一个道岔,这里添加上联动道岔 rpPath.addSwitchElement(new SwitchElement(linkedSwitch, false)); } // if (config.isCoupleSwitch()) { // 如果是同一道岔计轴,添加另一道岔定位 Switch otherSwitch = relSwitch.queryAxleRelatedOtherSwitch(); - if (Objects.nonNull(otherSwitch) && relSwitch.isBConnectTo(otherSwitch)) { + if (!config.isGenerateFls() && Objects.nonNull(otherSwitch) && relSwitch.isBConnectTo(otherSwitch)) { rpPath.addSwitchElement(new SwitchElement(otherSwitch, true)); } // } @@ -2069,7 +2077,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { // 只有一条路径,从B->A,道岔定位 tempPath.addSection(relSwitch.getA()); tempPath.addSwitchElement(new SwitchElement(relSwitch, true)); - if (Objects.nonNull(linkedSwitch)) { + if (!config.isGenerateFls() && Objects.nonNull(linkedSwitch)) { tempPath.addSwitchElement(new SwitchElement(linkedSwitch, true)); } getOverlapPathOf(relSwitch.getA().getSectionOf(right), right, @@ -2081,7 +2089,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { // if (config.isCoupleSwitch()) { // 如果是同一道岔计轴,添加另一道岔定位 Switch otherSwitch = relSwitch.queryAxleRelatedOtherSwitch(); - if (Objects.nonNull(otherSwitch)) { + if (!config.isGenerateFls() && Objects.nonNull(otherSwitch)) { tempPath.addSwitchElement(new SwitchElement(otherSwitch, true)); } // } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java index 157933379..3f667aee8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java @@ -178,10 +178,10 @@ public class RouteService { if (aSwitch.isLocked() && !aSwitch.isOnPosition(element.isNormal())) { return new Route.CheckFailMessage(Route.CheckFailReason.SwitchLockPositionError, aSwitch); } - // 道岔是否故障 - if (aSwitch.isFaultOnPosition(element.isNormal()) && aSwitch.isLoss()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SwitchFault, aSwitch); - } +// // 道岔是否故障 +// if (aSwitch.isFaultOnPosition(element.isNormal()) && aSwitch.isLoss()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SwitchFault, aSwitch); +// } } // 敌对进路办理中或已锁闭,不能办理 List conflictingRouteList = route.getConflictingRouteList(); @@ -395,6 +395,16 @@ public class RouteService { List switchList = route.getSwitchList(); this.routeSwitchTurn(simulation, switchList); this.routeFlsControl(simulation, route.getFlsList()); + if (config.isLockFirst()) { + for (SwitchElement switchElement : switchList) { + switchElement.getASwitch().routeLock(); + } + if (!CollectionUtils.isEmpty(route.getFlsList())) { + for (RouteFls routeFls : route.getFlsList()) { + routeFls.lock(); + } + } + } route.updateRequisition(true); return; } @@ -503,19 +513,27 @@ public class RouteService { } } } + List switchList = sectionPath.getSwitchList(); if (!overlap.isRequisition()) { // 设备征用 // 延续保护位置转动 - // 道岔位置转换 - List pathSwitchList = sectionPath.getPathSwitchElementList(); - this.routeSwitchTurn(simulation, pathSwitchList); - List notPathSwitchList = sectionPath.getNotPathSwitchElementList(); - this.routeSwitchTurn(simulation, notPathSwitchList); - this.routeFlsControl(simulation, sectionPath.getFlsList()); + this.routeSwitchTurn(simulation, switchList); + List flsList = sectionPath.getFlsList(); + this.routeFlsControl(simulation, flsList); + if (config.isLockFirst()) { + for (SwitchElement switchElement : switchList) { + switchElement.getASwitch().overlapLock(); + } + if (!CollectionUtils.isEmpty(flsList)) { + for (RouteFls routeFls : flsList) { + routeFls.lock(); + } + } + } overlap.updateRequisition(true); return; } // 道岔是否转换到位置 - boolean onPosition = this.checkRouteSwitchPosition(sectionPath.getSwitchList()); + boolean onPosition = this.checkRouteSwitchPosition(switchList); if (!onPosition) return; // 未到位,返回 if (!overlap.getSection().isRouteLock()) { return; @@ -622,20 +640,7 @@ public class RouteService { private void routeFlsLock(List flsList) { if (!CollectionUtils.isEmpty(flsList)) { for (RouteFls routeFls : flsList) { - for (RouteFls.FlsElement flsElement : routeFls.getLevel1List()) { - SwitchElement pSwitch = flsElement.getPSwitch(); - if (pSwitch != null) { - Switch aSwitch = pSwitch.getASwitch(); - if (aSwitch.isOnPosition(pSwitch.isNormal())) { - aSwitch.fpLock(); - } - } else { - SwitchElement fpae = flsElement.getFpae(); - if (fpae != null && fpae.getASwitch().isOnPosition(fpae.isNormal())) { - fpae.getASwitch().fpLock(); - } - } - } + routeFls.lock(); } } } @@ -1099,10 +1104,9 @@ public class RouteService { section.getParent().routeUnlocking(right); } relSwitch.routeUnlock(); - relSwitch.overlapUnLock(); // 侧防解锁 RouteFls routeFls = route.getRouteFlsOfSwitch(relSwitch); - if (routeFls != null) { + if (routeFls != null && !routeFls.getBase().getASwitch().isRouteLock() && !routeFls.getBase().getASwitch().isOverlapLock()) { routeFls.unlock(); } //检查道岔的联动道岔和计轴关联道岔是否可以解锁 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteFls.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteFls.java index efa208ede..b171c460b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteFls.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteFls.java @@ -61,6 +61,20 @@ public class RouteFls { } } + public void lock() { + for (FlsElement flsElement : this.getLevel1List()) { + SwitchElement pSwitch = flsElement.getPSwitch(); + if (pSwitch != null) { + pSwitch.getASwitch().fpLock(); + } else { + SwitchElement fpae = flsElement.getFpae(); + if (fpae != null) { + fpae.getASwitch().fpLock(); + } + } + } + } + /** * 侧防元件 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/tool/DeviceStatusModifyTool.java b/src/main/java/club/joylink/rtss/simulation/cbtc/tool/DeviceStatusModifyTool.java index 07a19c642..80087693a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/tool/DeviceStatusModifyTool.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/tool/DeviceStatusModifyTool.java @@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -32,6 +33,8 @@ public class DeviceStatusModifyTool { public void openRouteDirect(Simulation simulation, Route route) { // 修改进路涉及的所有道岔元素到指定位置 this.batchSetRouteSwitchPositionAndLock(route, route.getSwitchList(), true); + // 修改进路侧防到指定位置 + this.batchSetRouteFlsSwitchPositionAndLock(route.getFlsList()); // 进路元素锁闭 route.getSectionList().forEach(section -> section.routeLocking(route.getStart().isRight())); if (this.routeService.checkCanOverlapSet(simulation, route)) { @@ -39,6 +42,7 @@ public class DeviceStatusModifyTool { if (Objects.nonNull(overlapPath)) { this.batchSetRouteSwitchPositionAndLock(route, overlapPath.getSwitchList(), false); overlapPath.getSectionList().forEach(section -> section.overlapLocking(route.getStart().isRight())); + this.batchSetRouteFlsSwitchPositionAndLock(overlapPath.getFlsList()); route.getOverlap().setLock(true); } } @@ -50,14 +54,37 @@ public class DeviceStatusModifyTool { route.getStart().setLockedRoute(route); } + private void batchSetRouteFlsSwitchPositionAndLock(List flsList) { + if (!CollectionUtils.isEmpty(flsList)) { + List switchElementList = new ArrayList<>(); + for (RouteFls routeFls : flsList) { + for (RouteFls.FlsElement flsElement : routeFls.getLevel1List()) { + SwitchElement pSwitch = flsElement.getPSwitch(); + if (pSwitch != null) { + switchElementList.add(pSwitch); + } else if (flsElement.getFpae() != null) { + switchElementList.add(flsElement.getFpae()); + } + } + } + for (SwitchElement switchElement : switchElementList) { + this.setSingleSwitchPositionDirectly(switchElement.getASwitch(), switchElement.isNormal()); + switchElement.getASwitch().fpLock(); + } + } + } + public void openGuideRouteDirect(Simulation simulation, Route route) { // 修改进路涉及的所有道岔元素到指定位置 this.batchSetRouteSwitchPositionAndLock(route, route.getSwitchList(), true); + // 修改进路侧防到指定位置 + this.batchSetRouteFlsSwitchPositionAndLock(route.getFlsList()); // 进路元素锁闭 route.getSectionList().forEach(section -> section.routeLocking(route.getStart().isRight())); SectionPath overlapPath = route.selectOverlapElement(); if (Objects.nonNull(overlapPath)) { this.batchSetRouteSwitchPositionAndLock(route, overlapPath.getSwitchList(), false); + this.batchSetRouteFlsSwitchPositionAndLock(overlapPath.getFlsList()); overlapPath.getSectionList().forEach(section -> section.overlapLocking(route.getStart().isRight())); } route.setLock(true);