列车添加倒车最大速度,列车运行逻辑对应修改
This commit is contained in:
parent
c159f9a8c1
commit
7d30ceb7de
@ -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防护速度
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user