From 7d30ceb7de5c59256c3162f3558bfbe03a778d05 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Mon, 25 Jan 2021 19:44:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=BD=A6=E6=B7=BB=E5=8A=A0=E5=80=92?= =?UTF-8?q?=E8=BD=A6=E6=9C=80=E5=A4=A7=E9=80=9F=E5=BA=A6=EF=BC=8C=E5=88=97?= =?UTF-8?q?=E8=BD=A6=E8=BF=90=E8=A1=8C=E9=80=BB=E8=BE=91=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/data/vr/VirtualRealityTrain.java | 9 +++++++-- .../device/virtual/VRTrainRunningService.java | 16 +++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) 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; }