From bffa8837039f9d7338b5cea682d8633240babd6b Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Thu, 28 Jan 2021 18:09:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=88=97=E8=BD=A6=E2=80=94?= =?UTF-8?q?=E2=80=94=E6=9E=84=E5=BB=BA=E5=88=97=E8=BD=A6=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8C=E7=AB=99=E9=97=B4=E6=83=85=E5=86=B5?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E8=B0=83=E6=95=B4=E4=B8=BA=E5=88=97=E8=BD=A6?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E6=98=AF=E5=90=A6=E5=9C=A8=E8=BF=9B=E8=B7=AF?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/service/AtsTrainLoadService.java | 2 +- .../cbtc/data/support/RoutePath.java | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java index 29e7dffd2..d7c6c03d0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java @@ -428,7 +428,7 @@ public class AtsTrainLoadService { break; } else { RoutePath routePath = this.selectDefaultRoutePath(repository, startStationPlan.getSection(), endStationPlan.getSection()); - if (routePath.containsSection(headPosition.getSection())) { + if (routePath.containsPosition(headPosition)) { // 站间运行 train.setSpeed(0.1f); trainInfo.updatePlanInfo(endStationPlan); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/RoutePath.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/RoutePath.java index 6e0d3783a..d4afff002 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/RoutePath.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/RoutePath.java @@ -308,6 +308,35 @@ public class RoutePath { return null; } + public boolean containsPosition(SectionPosition position) { + if (this.sectionList.contains(position.getSection())) { + return true; + } + if (Objects.equals(position.getSection(), this.start)) { + if (this.isRight()) { + if (this.start.getStopPointRight() < position.getOffset()) { + return true; + } + } else { + if (position.getOffset() < this.start.getStopPointLeft()) { + return true; + } + } + } + if (Objects.equals(position.getSection(), this.end)) { + if (this.isRight()) { + if (this.end.getStopPointRight() >= position.getOffset()) { + return true; + } + } else { + if (position.getOffset() >= this.end.getStopPointLeft()) { + return true; + } + } + } + return false; + } + public boolean isStartSection(Section section) { return Objects.equals(this.start, section); }