diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java index e42b16412..d11792ca9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java @@ -82,6 +82,7 @@ public class AtpSectionService { SimulationDataRepository repository = simulation.getRepository(); MapConfig config = repository.getConfig(); boolean switchSingleHandle = config.isSwitchSingleHandle(); + boolean isHasCTC = config.isHasCTC(); // 大铁逻辑 if (train.isCommunicable()) { // 通信车占用 // 车尾位置追加不确定性距离:(速度*2)m SectionPosition trainTailPosition = CalculateService @@ -110,7 +111,7 @@ public class AtpSectionService { for (Section section : sectionList) { if (section.isSwitchAxleCounterSection()) { Section switchSection = section.getLogicList().get(0); - if (switchSingleHandle) { + if (switchSingleHandle && isHasCTC) { atpSectionList.addAll(handleSingleSwitchPosition(section, right)); } else { atpSectionList.addAll(switchSection.getSwitchAxleSectionsBySwitchPosition()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/GroundAtpApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/GroundAtpApiServiceImpl.java index 32033b9d5..1fe02e8ea 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/GroundAtpApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/GroundAtpApiServiceImpl.java @@ -74,32 +74,37 @@ public class GroundAtpApiServiceImpl implements GroundAtpApiService { section.communicateTrainOccupy(train.isRight()); } })); - // 非通信车占用 - nctSectionMap.forEach(((train, sections) -> { - //简单写法,效率比较低 -// sections.stream().filter(section -> train.getHeadPosition() -// .isAheadOf(section, section.getStopPointByDirection(train.isRight()),train.isRight()) -// ).forEach(section -> section.nonCommunicateTrainOccupy(train.isRight())); - // 判断车头所在位置 - int index = sections.indexOf(train.getHeadPosition().getSection()); - if (index > 0) { - /** - * 这样写是为了解决反位道岔区段不按顺序加入的问题 - * 错误:T111,T114,T112,T137,T138,T136,T135 - * 正常:T111,T114,T112,T137,T138,T135,T136 - * - * 处理步骤是将T135前部全部标识状态后,再处理T135 - * - * 因为是追加添加,判断下区段位置跟车头位置 - */ - int nextIndex = sections.indexOf(train.getHeadPosition().getSection().getNextRunningSectionOf(train.isRight())); - int limitIndex = (nextIndex == -1) ? sections.size() : ((nextIndex > index) ? index + 1 : nextIndex); - sections.stream().limit(limitIndex).forEach(section -> section.nonCommunicateTrainOccupy(train.isRight())); - } - if (index > -1) { - sections.get(index).nonCommunicateTrainOccupy(train.isRight()); - } - })); + // 大铁逻辑 + if (simulation.getRepository().getConfig().isHasCTC()) { + // 非通信车占用 + nctSectionMap.forEach(((train, sections) -> { + // 判断车头所在位置 + int index = sections.indexOf(train.getHeadPosition().getSection()); + if (index > 0) { + /** + * 这样写是为了解决反位道岔区段不按顺序加入的问题 + * 错误:T111,T114,T112,T137,T138,T136,T135 + * 正常:T111,T114,T112,T137,T138,T135,T136 + * + * 处理步骤是将T135前部全部标识状态后,再处理T135 + * + * 因为是追加添加,判断下区段位置跟车头位置 + */ + int nextIndex = sections.indexOf(train.getHeadPosition().getSection().getNextRunningSectionOf(train.isRight())); + int limitIndex = (nextIndex == -1) ? sections.size() : ((nextIndex > index) ? index + 1 : nextIndex); + sections.stream().limit(limitIndex).forEach(section -> section.nonCommunicateTrainOccupy(train.isRight())); + } + if (index > -1) { + sections.get(index).nonCommunicateTrainOccupy(train.isRight()); + } + })); + } else { + nctSectionMap.forEach(((train, sections) -> { + for (Section section : sections) { + section.nonCommunicateTrainOccupy(train.isRight()); + } + })); + } // 信号机接近信息 this.atpSectionService.changeSignalModeByTrainApproach(simulation, onlineTrainList, trainAtpSectionMap);