From 430fe344cfc5df047dcb6b741302befdf651246b Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Mon, 15 May 2023 13:02:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?ncc=E5=9B=BE=E4=BE=8B=E9=93=81=E8=BD=A6?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/data/StationDiagram.java | 11 ++---- .../ATS/service/diagram/RuningService.java | 39 ++++++++++--------- .../cbtc/data/CalculateService.java | 6 ++- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/data/StationDiagram.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/data/StationDiagram.java index c3685b998..34d630bf1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/data/StationDiagram.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/data/StationDiagram.java @@ -21,18 +21,15 @@ public class StationDiagram { this.finalStation = false; } - public StationDiagram(VirtualRealityTrain train,Float stationComplateRatio, Boolean finalStation){ + public StationDiagram(VirtualRealityTrain train,Float stationCompleteRatio, Boolean finalStation){ this.groupNum = train.getGroupNumber(); this.right = train.isRight(); - this.stationCompleteRatio = stationComplateRatio; + this.stationCompleteRatio = stationCompleteRatio; this.finalStation = finalStation; } - public StationDiagram(VirtualRealityTrain train,boolean showTrainDiagram,Float stationComplateRatio, Boolean finalStation){ - this.groupNum = train.getGroupNumber(); - this.right = train.isRight(); - this.stationCompleteRatio = stationComplateRatio; - this.finalStation = finalStation; + public StationDiagram(VirtualRealityTrain train,boolean showTrainDiagram,Float stationCompleteRatio, Boolean finalStation){ + this(train,stationCompleteRatio,finalStation); this.showTrainDiagram = showTrainDiagram; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/diagram/RuningService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/diagram/RuningService.java index e254546d1..98a4be422 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/diagram/RuningService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/diagram/RuningService.java @@ -61,31 +61,34 @@ public class RuningService implements CalculateDiagram{ private Float calculateStationRatio(Simulation simulation,Section begin,Section end,VirtualRealityTrain train){ Long mapId = simulation.getBuildParams().getMap().getId(); LocalDateTime simulationDateTime = simulation.getCorrectSystemTime(); - Float totalDis =null; - Float runOffset =null; - try{ - totalDis = CalculateService.calculateDistance(begin,end,train.isRight()); - if(totalDis == 0F){ - //车辆已经到达站点 - return 1F; - } - float off = begin.getStopPointByDirection(train.isRight()); - runOffset = CalculateService.calculateDistanceIgnoreSwitchFromStationToTrainHead(new SectionPosition(begin,off),train.getHeadPosition(),train.isRight()); - double t = runOffset / totalDis; - float d = new BigDecimal(t).setScale(3, RoundingMode.HALF_UP).floatValue(); - if(d >= 1F){ - d = 1F; +// Float totalDis =null; +// Float runOffset =null; +// try{ + Float totalDis = CalculateService.calculateDistance(begin,end,train.isRight()); + Float runOffset = 0F; + float stationCompleteRatio = 1F; + if(totalDis != 0F){ + float off = begin.getStopPointByDirection(train.isRight()); + runOffset = CalculateService.calculateDistanceIgnoreSwitchFromStationToTrainHead(new SectionPosition(begin,off),train.getHeadPosition(),train.isRight()); + if(runOffset != 1F){ + stationCompleteRatio = new BigDecimal(runOffset / totalDis).setScale(3, RoundingMode.HALF_UP).floatValue(); + if(stationCompleteRatio >= 1F){ + stationCompleteRatio = 1F; + } + } } log.debug("线路id:{} 仿真时间:{} 车次[{}] 方向[{}] 车头区段[{}] 车头位置[{}] 车尾区段[{}] 查找开始区段[{}] 结束区段[{}] 距离总长[{}] 剩余距离[{}] 已行驶[{}] 行驶完成度[{}]" ,mapId,simulationDateTime ,train.getGroupNumber(),train.isRight(),train.getHeadPosition().getSection().getCode(),train.getHeadPosition().getOffset() - ,train.getTailPosition().getSection().getCode(), begin.getCode(),end.getCode() , totalDis ,(totalDis - runOffset),runOffset ,d); - return Math.abs(d); - }catch (Exception e){ + ,train.getTailPosition().getSection().getCode(), begin.getCode(),end.getCode() , totalDis ,(totalDis - runOffset),runOffset ,stationCompleteRatio); + return Math.abs(stationCompleteRatio); +/* }catch (Exception e){ log.error("计算失败 线路id:{} 仿真时间:{} groupNum:{},isRight:{},begin:{},end:{},totalDis:{},targetDis:{} 错误信息:{}",mapId,simulationDateTime ,train.getGroupNumber() ,train.isRight(),begin.getCode() ,end.getCode() ,totalDis , runOffset,e.getMessage(),e); + float off = begin.getStopPointByDirection(train.isRight()); + CalculateService.calculateDistanceIgnoreSwitchFromStationToTrainHead(new SectionPosition(begin,off),train.getHeadPosition(),train.isRight()); return null; - } + }*/ } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java index 5cca95d12..0f01db9e9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/CalculateService.java @@ -1257,10 +1257,12 @@ public class CalculateService { } else { offset = startPosition.getOffset() - endPosition.getOffset(); } - if (offset > 0) { + if (offset >= 0) { return offset; } else { - return null; + return 1F; +// return Math.abs(offset); +// return null; } } else { Float distance = recursiveCalculate(startPosition.getSection(), endPosition.getSection(), right, (byte) 51); From 9e130d9f31a0e33e862fe50b2a090d4329596b76 Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Mon, 15 May 2023 13:04:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?ncc=E5=9B=BE=E4=BE=8B=E9=93=81=E8=BD=A6?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/service/diagram/RuningService.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/diagram/RuningService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/diagram/RuningService.java index 98a4be422..e0ead2142 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/diagram/RuningService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/diagram/RuningService.java @@ -61,9 +61,7 @@ public class RuningService implements CalculateDiagram{ private Float calculateStationRatio(Simulation simulation,Section begin,Section end,VirtualRealityTrain train){ Long mapId = simulation.getBuildParams().getMap().getId(); LocalDateTime simulationDateTime = simulation.getCorrectSystemTime(); -// Float totalDis =null; -// Float runOffset =null; -// try{ + try{ Float totalDis = CalculateService.calculateDistance(begin,end,train.isRight()); Float runOffset = 0F; float stationCompleteRatio = 1F; @@ -82,13 +80,11 @@ public class RuningService implements CalculateDiagram{ ,train.getGroupNumber(),train.isRight(),train.getHeadPosition().getSection().getCode(),train.getHeadPosition().getOffset() ,train.getTailPosition().getSection().getCode(), begin.getCode(),end.getCode() , totalDis ,(totalDis - runOffset),runOffset ,stationCompleteRatio); return Math.abs(stationCompleteRatio); -/* }catch (Exception e){ - log.error("计算失败 线路id:{} 仿真时间:{} groupNum:{},isRight:{},begin:{},end:{},totalDis:{},targetDis:{} 错误信息:{}",mapId,simulationDateTime - ,train.getGroupNumber() ,train.isRight(),begin.getCode() ,end.getCode() ,totalDis , runOffset,e.getMessage(),e); - float off = begin.getStopPointByDirection(train.isRight()); - CalculateService.calculateDistanceIgnoreSwitchFromStationToTrainHead(new SectionPosition(begin,off),train.getHeadPosition(),train.isRight()); + }catch (Exception e){ + log.error("计算失败 线路id:{} 仿真时间:{} groupNum:{},isRight:{},begin:{},end:{}, 错误信息:{}",mapId,simulationDateTime + ,train.getGroupNumber() ,train.isRight(),begin.getCode() ,end.getCode() ,e.getMessage(),e); return null; - }*/ + } } }