From 415e92b4dafd8b41dd507b7f3c35bb2923c6168b Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Tue, 9 Mar 2021 09:30:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E4=BB=BF=E7=9C=9F=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E4=B8=8B=E7=9A=84=E8=99=9A=E6=8B=9F=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=80=BB=E8=BE=91=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/club/joylink/rtss/simulation/Debug.java | 7 +++++++ .../joylink/rtss/simulation/rt/srd/SrdService.java | 12 +++++++----- .../joylink/rtss/simulation/rt/srd/bo/SrDevice.java | 8 +++++++- .../joylink/rtss/simulation/rt/srd/bo/SrTrack.java | 9 ++++++++- .../joylink/rtss/simulation/rt/srd/bo/SrTrain.java | 13 ++++++++----- 5 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/Debug.java diff --git a/src/main/java/club/joylink/rtss/simulation/Debug.java b/src/main/java/club/joylink/rtss/simulation/Debug.java new file mode 100644 index 000000000..0d0fe1d7c --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/Debug.java @@ -0,0 +1,7 @@ +package club.joylink.rtss.simulation; + +public interface Debug { + + String debugStr(); + +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/SrdService.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/SrdService.java index 0f72efb3b..ec7d1c5aa 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/SrdService.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/SrdService.java @@ -4,10 +4,12 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.rt.RtSimulation; import club.joylink.rtss.simulation.rt.srd.bo.*; import club.joylink.rtss.vo.client.map.MapVO; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.util.List; +@Slf4j @Component public class SrdService { public static final int TRAIN_RUN_RATE = 20; @@ -29,8 +31,7 @@ public class SrdService { if (!srTrain.isUsing()) { continue; } - TrackPosition position = srTrain.getPosition(); - long speed = srTrain.getSpeed(); + TrackPosition position = srTrain.getHeadPosition(); boolean right = srTrain.isRight(); int cv = this.calculateSpeed(srTrain); int s = this.calculateLen(cv, TRAIN_RUN_RATE); @@ -77,7 +78,8 @@ public class SrdService { SrTrack base = track; while (offset < 0 || offset > base.getLen()) { SrTrack nextTrack = base.queryNextTrack(right); - if (nextTrack == null) { + if (nextTrack == null) { // 下一区段为空,到达尽头或道岔失表处 + log.debug(String.format("区段[%s][%s]区段不存在",base.debugStr(), right?"右向":"左向")); if (offset < 0) { offset = 0; } else { @@ -86,10 +88,10 @@ public class SrdService { break; } else { if (right) { - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(offset < 0); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(offset > base.getLen()); offset -= base.getLen(); } else { - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(offset > base.getLen()); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(offset < 0); offset += nextTrack.getLen(); } base = nextTrack; diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrDevice.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrDevice.java index 0456092d0..eb7a251f2 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrDevice.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrDevice.java @@ -1,12 +1,13 @@ package club.joylink.rtss.simulation.rt.srd.bo; +import club.joylink.rtss.simulation.Debug; import lombok.Getter; /** * 虚拟真实设备抽象父类 */ @Getter -public abstract class SrDevice { +public abstract class SrDevice implements Debug { String id; DeviceType deviceType; @@ -16,4 +17,9 @@ public abstract class SrDevice { this.id = id; this.deviceType = deviceType; } + + @Override + public String debugStr() { + return String.format("%s:%s", this.deviceType, this.id); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrack.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrack.java index fc0319c54..d8e2c5250 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrack.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrack.java @@ -1,13 +1,15 @@ package club.joylink.rtss.simulation.rt.srd.bo; +import club.joylink.rtss.simulation.Debug; import lombok.Getter; /** * 虚拟真实轨道区段 */ @Getter -public class SrTrack extends SrDevice { +public class SrTrack extends SrDevice implements Debug { + String name; /** * 轨道长度,单位mm */ @@ -101,4 +103,9 @@ public class SrTrack extends SrDevice { } return null; } + + @Override + public String debugStr() { + return String.format("%s(%s)", this.name, this.id); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrain.java b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrain.java index 9e6e71309..7633794d7 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/srd/bo/SrTrain.java @@ -56,11 +56,14 @@ public class SrTrain extends SrDevice { public static final int FORWARD = 1; //前进挡 public static final int REVERSE = -1; //后退档 /** - * 列车位置 + * 列车头位置 */ - TrackPosition position; - - public SrTrain(String id, int len) { + TrackPosition headPosition; + /** + * 列车尾位置 + */ + TrackPosition tailPosition; + public SrTrain(String id, int len) { super(id, DeviceType.TRAIN); this.len = len; } @@ -70,7 +73,7 @@ public class SrTrain extends SrDevice { } public void updatePositionAndSpeed(TrackPosition position, int v) { - this.position = position; + this.headPosition = position; this.speed = v; } } From 7fdb0dd16b982f0a6a55e83651eeb4b44c985147 Mon Sep 17 00:00:00 2001 From: walker-sheng Date: Wed, 10 Mar 2021 16:58:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8C=89=E8=AE=A1=E5=88=92=E8=A1=8C?= =?UTF-8?q?=E8=BD=A6=EF=BC=8C=E8=BD=AC=E6=8D=A2=E8=BD=A8=E5=88=97=E8=BD=A6?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/service/AtsTrainLoadService.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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 d7c6c03d0..ab420b958 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 @@ -415,11 +415,19 @@ public class AtsTrainLoadService { for (int i = 1; i < stationPlanList.size(); i++) { StationPlan startStationPlan = stationPlanList.get(i - 1); StationPlan endStationPlan = stationPlanList.get(i); - if (this.isOnSectionStopPoint(headPosition, startStationPlan.getSection(), right)) { - // 在计划停车点 - trainInfo.updatePlanInfo(startStationPlan); - trainInfo.updateEstimatedArriveInfo(startStationPlan.getSection(), startStationPlan.getArriveTime()); - train.updateNextStationPlan(startStationPlan.getStation(), startStationPlan.getSection(), tripPlan.isPlanParking(startStationPlan)); + Section startSection = startStationPlan.getSection(); + if (this.isOnSectionStopPoint(headPosition, startSection, right)) { + if (startSection.isTransferTrack()) { + // 列车出库 + trainInfo.updatePlanInfo(endStationPlan); + trainInfo.updateEstimatedArriveInfo(endStationPlan.getSection(), endStationPlan.getArriveTime()); + train.updateNextStationPlan(endStationPlan.getStation(), endStationPlan.getSection(), tripPlan.isPlanParking(endStationPlan)); + } else { + // 在计划停车点 + trainInfo.updatePlanInfo(startStationPlan); + trainInfo.updateEstimatedArriveInfo(startSection, startStationPlan.getArriveTime()); + train.updateNextStationPlan(startStationPlan.getStation(), startSection, tripPlan.isPlanParking(startStationPlan)); + } break; } else if (this.isOnSectionStopPoint(headPosition, endStationPlan.getSection(), right)) { trainInfo.updatePlanInfo(endStationPlan); @@ -427,7 +435,7 @@ public class AtsTrainLoadService { train.updateNextStationPlan(endStationPlan.getStation(), endStationPlan.getSection(), tripPlan.isPlanParking(endStationPlan)); break; } else { - RoutePath routePath = this.selectDefaultRoutePath(repository, startStationPlan.getSection(), endStationPlan.getSection()); + RoutePath routePath = this.selectDefaultRoutePath(repository, startSection, endStationPlan.getSection()); if (routePath.containsPosition(headPosition)) { // 站间运行 train.setSpeed(0.1f);