diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index 975371e1e..55cab902c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -70,9 +70,14 @@ public class VirtualRealityTrain extends VirtualRealityDevice { private float mass = 230; /** - * 列车物理最大速度 + * 列车前进最大速度 */ - private float speedMax = (float) (120 / 3.6); + private float speedMax = (float) (100 / 3.6); + + /** + * 列车倒车最大速度 + */ + private float reverseSpeedMax = (float) (36 / 3.6); /** * 列车ATP防护速度 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRTrainRunningService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRTrainRunningService.java index e6cab0495..d5fff7df3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRTrainRunningService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRTrainRunningService.java @@ -50,21 +50,27 @@ public class VRTrainRunningService { float currentSpeed = originSpeed + increment; if (currentSpeed < 0) { currentSpeed = 0; - } else if (currentSpeed > train.getSpeedMax()) { - currentSpeed = train.getSpeedMax(); } +// else if (currentSpeed > train.getSpeedMax()) { +// currentSpeed = train.getSpeedMax(); +// } // 更新列车速度 - train.setSpeed(currentSpeed); // System.out.println(String.format("当前车速:[%s]", currentSpeed)); // 根据速度计算并更新列车所在区段位置 // float s = (float) (currentSpeed * time - acceleration * Math.pow(time, 2) / 2); - float s = (currentSpeed+originSpeed) * time / 2; + float s; if (ControlGear.Reverse.equals(train.getGear())) { // 倒车挡 - s = -s; + currentSpeed = Math.min(train.getReverseSpeedMax(), currentSpeed); + s = -((currentSpeed+originSpeed) * time / 2); } else if (ControlGear.Neutral.equals(train.getGear())) { // 空挡 + currentSpeed = 0; s = 0; + } else { + currentSpeed = Math.min(train.getSpeedMax(), currentSpeed); + s = (currentSpeed + originSpeed) * time / 2; } + train.setSpeed(currentSpeed); //更新列车速度 if (s == 0) { return; }