tunin BrakeProcessor

This commit is contained in:
Stephan Richter
2021-03-12 17:19:42 +01:00
parent 629b30c078
commit 8a9aada83e
4 changed files with 10 additions and 6 deletions

View File

@@ -903,12 +903,12 @@ public class Train extends BaseClass implements Comparable<Train> {
@Override
public void locked(Route newRoute) {
LOG.debug("Locked route {} for {}",newRoute,Train.this);
route = newRoute;
}
@Override
public void prepared(Route newRoute) {
LOG.debug("Prepared route {} for {}",newRoute,Train.this);
route = newRoute;
set((PathFinder)null);
route.start(Train.this);
}

View File

@@ -43,10 +43,13 @@ public class BrakeProcessor extends BaseClass implements Runnable {
int step = brakeTime;
for (int i = 0; i < 15; i++) {
long calculatedDistance = calculate(brakeTime, startSpeed);
step /= 2;
if (step < 1) step = 1;
if (measuredDistance > calculatedDistance) brakeTime += step;
if (measuredDistance > calculatedDistance) {
brakeTime += brakeTime;
step = brakeTime/3;
}
if (measuredDistance < calculatedDistance) {
step /= 2;
if (step < 1) step = 1;
brakeTime -= step;
}
LOG.debug("new brake time: {}, calculated distance: {}", brakeTime, calculatedDistance);