From e1ef8cf5491489802b8e7d13552591e88d035941 Mon Sep 17 00:00:00 2001 From: DU Date: Wed, 27 Jan 2021 18:17:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E5=9B=BE=E7=BC=96=E5=88=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=8A=A0=E8=BD=BD=E5=88=97=E8=BD=A6?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E4=BF=AE=E6=94=B9=EF=BC=8Cato=20bug=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/services/RunPlanDraftService.java | 9 +++ .../services/runplan/RunPlanGenerator.java | 2 +- .../runplan/RunPlanRunlevelService.java | 13 +++- .../cbtc/ATS/service/AtsTrainLoadService.java | 21 +++++- .../cbtc/CI/service/RouteService.java | 1 + .../cbtc/data/support/RoutePath.java | 69 +++++++++++++++---- .../cbtc/onboard/ATO/service/ATOService.java | 2 +- 7 files changed, 99 insertions(+), 18 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java index 91c5b6a37..e156ea664 100644 --- a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java @@ -452,6 +452,12 @@ public class RunPlanDraftService implements IRunPlanDraftService { List arriveConfigList = tripConfigVO.getArriveConfigList(); arriveConfigList.stream().map(RunPlanTripTimeVO::new).forEach(timeVO -> tripVO.getTimeList().add(timeVO)); + if (Objects.equals(tripVO.getEndSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getLast().getSectionCode())) { + tripVO.setEndTime(tripConfigVO.getEndTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME)); + } + if (Objects.equals(tripVO.getStartSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getFirst().getSectionCode())) { + tripVO.setStartTime(tripConfigVO.getStartTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME)); + } newTripList.add(tripVO); } } else { @@ -752,6 +758,9 @@ public class RunPlanDraftService implements IRunPlanDraftService { if (Objects.equals(tripVO.getEndSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getLast().getSectionCode())) { tripVO.setEndTime(tripConfig.getEndTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME)); } + if (Objects.equals(tripVO.getStartSectionCode(), (new LinkedList<> (tripVO.getTimeList())).getFirst().getSectionCode())) { + tripVO.setStartTime(tripConfig.getStartTime().minusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME)); + } if (CollectionUtils.isEmpty(runPlanVO.getTripList())) { runPlanVO.setTripList(new ArrayList<>()); diff --git a/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java b/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java index 30d93d99b..b2769e56c 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java +++ b/src/main/java/club/joylink/rtss/services/runplan/RunPlanGenerator.java @@ -429,7 +429,7 @@ public class RunPlanGenerator { } } - private void setTripTerminalTime(RunPlanTripVO runPlanTripVO, LinkedList tripTimeList, int reentryTime) { + public void setTripTerminalTime(RunPlanTripVO runPlanTripVO, LinkedList tripTimeList, int reentryTime) { setTripStartTime(runPlanTripVO, tripTimeList, reentryTime); setTripEndTime(runPlanTripVO, tripTimeList, reentryTime); } diff --git a/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java b/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java index 8e33ee40a..92828cd08 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java +++ b/src/main/java/club/joylink/rtss/services/runplan/RunPlanRunlevelService.java @@ -12,6 +12,7 @@ import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; +import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.map.MapVO; import club.joylink.rtss.vo.client.map.newmap.MapRunLevelQueryVO; @@ -82,7 +83,17 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService { list.forEach(l -> { Section startSection = (Section) deviceMap.get(l.getStartSectionCode()); Section endSection = (Section) deviceMap.get(l.getEndSectionCode()); - Float distance = CalculateService.calculateDistance(startSection, endSection, l.getRight()); + Float distance; + if((startSection.isStandTrack() && endSection.isTransferTrack()) || (endSection.isStandTrack() && startSection.isTransferTrack())){ + try{ + distance = CalculateService.calculateDistance(startSection, endSection, l.getRight()); + }catch (SimulationException e){ + distance = CalculateService.calculateDistance(startSection, endSection, !l.getRight()); + } + }else{ + + distance = CalculateService.calculateDistance(startSection, endSection, l.getRight()); + } RunPlanRunlevel entity = new RunPlanRunlevel(); entity.setId(l.getId()); entity.setMapId(l.getMapId()); 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 32a03e1c7..1153f056d 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 @@ -205,10 +205,15 @@ public class AtsTrainLoadService { RoutePath routePath = this.selectDefaultRoutePath(repository, stationPlan.getSection(), nextStationPlan.getSection()); right = routePath.isRight(); int t = current.toSecondOfDay() - stationPlan.getLeaveTime().toSecondOfDay(); - float s = routePath.getLength(); + float s = routePath.getLenFromSection(stationPlan.getSection()); + //右:-最后区段+后右停车点 + 前区段-前右停车点 左:-左停车点+前左停车点 + s= right? + s-nextStationPlan.getSection().getLen()+nextStationPlan.getSection().getStopPointByDirection(right)+stationPlan.getSection().getLen()-stationPlan.getSection().getStopPointByDirection(right) + : + s-nextStationPlan.getSection().getStopPointByDirection(right)+stationPlan.getSection().getStopPointByDirection(right); int totalTime = nextStationPlan.getArriveTime().toSecondOfDay() - stationPlan.getLeaveTime().toSecondOfDay(); float moveDistance = s / totalTime * t; // 移动的距离 - headPosition = routePath.getSectionPositionOfLen(moveDistance); + headPosition = routePath.getSectionPositionOfLen(moveDistance,stationPlan.getSection()); SectionPosition nextTargetPosition = new SectionPosition(nextStationPlan.getSection(), nextStationPlan.getSection().getStopPointByDirection(right)); if (headPosition.isAheadOf(nextTargetPosition, right)) { @@ -426,6 +431,8 @@ public class AtsTrainLoadService { trainInfo.updateEstimatedArriveInfo(endStationPlan.getSection(), endStationPlan.getArriveTime()); train.updateNextStationPlan(endStationPlan.getStation(), endStationPlan.getSection(), tripPlan.isPlanParking(endStationPlan)); break; + } else if (passedSectionStopPoint(headPosition, endStationPlan.getSection(), right)) { + continue; } else { RoutePath routePath = this.selectDefaultRoutePath(repository, startStationPlan.getSection(), endStationPlan.getSection()); if (routePath.containsSection(headPosition.getSection())) { @@ -454,6 +461,16 @@ public class AtsTrainLoadService { return false; } + + private boolean passedSectionStopPoint(SectionPosition headPosition, Section funSection, boolean right) { + float d = headPosition.getOffset() - funSection.getStopPointByDirection(right); + if (Objects.equals(headPosition.getSection(), funSection) + && d > SimulationConstants.PARK_POINT_MAX_OFFSET) { + return true; + } + return false; + } + /** * 处理碰撞逻辑 * @param simulation 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 d24dd8e44..8b5a45526 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 @@ -358,6 +358,7 @@ public class RouteService { if (simulation.getSystemTime().isAfter(route.getSettingStartTime().plusSeconds(10))) { route.settingFailed(); simulation.getRepository().removeSettingRoute(route); + route.setLock(false); log.info(String.format("进路[%s]办理失败,取消办理2", route.debugStr())); return; } 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 dadf8ba98..c78eb813a 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 @@ -110,36 +110,79 @@ public class RoutePath { this.end.getStation().getName(), this.end.getName()); } - public SectionPosition getSectionPositionOfLen(float runLen) { + public float getLenFromSection(Section fromSection){ + List
list = new ArrayList<>(); + if(sectionList.contains(fromSection)){ + int i = sectionList.indexOf(fromSection); + list.addAll(sectionList.subList(i,sectionList.size())); + }else{ + list.add(start); + list.addAll(this.sectionList); + } + float len = 0; + for (Section section : list) { + if(Objects.equals(section,fromSection)){ + continue; + } + len += section.getLen(); + } + return len; + } + public SectionPosition getSectionPositionOfLen(float runLen,Section fromSection) { float remain = runLen; Section target = null; Float offset = null; - if (remain < this.length) { +// if (remain < this.length) { List
list = new ArrayList<>(); + if(sectionList.contains(fromSection)){ + int i = sectionList.indexOf(fromSection); + list.addAll(sectionList.subList(i,sectionList.size())); + }else{ + list.add(start); list.addAll(this.sectionList); + } + float len = 0; + for (Section section : list) { + len += section.getLen(); + } + float addLen; for (Section section : list) { - float addLen = section.getLen(); + if (start == section) { + addLen = right ? section.getLen() - section.getStopPointByDirection(right) : section.getStopPointByDirection(right); + if (runLen < addLen) { + target = section; + offset = right ? section.getStopPointByDirection(right) + remain : section.getStopPointByDirection(right) - remain; + break; + } + } +// else if (this.end == section) { +// addLen = right?section.getStopPointByDirection(right):section.getLen() - section.getStopPointByDirection(right); +// } + else { + addLen = section.getLen(); + } + if (remain < addLen) { // 在此区段上 target = section; - if (Objects.equals(this.start, section)) { - if (this.right) { - offset = section.getLen() - (addLen - remain); - } else { - offset = (addLen - remain); - } - } else { +// if (Objects.equals(this.start, section)) { +// if (this.right) { +// offset = section.getLen() - (addLen - remain); +// } else { +// offset = (addLen - remain); +// } +// } else { if (this.right) { offset = remain; } else { - offset = section.getLen() - remain; + offset = addLen - remain; } - } +// } break; } else { remain -= addLen; } } - } +// } if (Objects.isNull(target) || Objects.isNull(offset)) { throw new SimulationException(SimulationExceptionType.System_Fault, String.format("路径[%s]的总距离[%s],未找到距离[%s]对应的区段位置", diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java index 2fedd158d..79ec60070 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java @@ -164,7 +164,7 @@ public class ATOService { SectionPosition targetStopPoint = new SectionPosition(target, target.getStopPointByDirection(right)); Float targetDistance = CalculateService.calculateDistance(headPosition, targetStopPoint, right); - if (Objects.nonNull(targetDistance) && targetDistance < distance) { + if (Objects.nonNull(targetDistance)&& targetDistance >= 0 && targetDistance < distance) { return targetDistance; } } else {