improved error messages

This commit is contained in:
Stephan Richter
2021-03-12 16:04:08 +01:00
parent 2556ea7cd9
commit 6bf7882f3b
63 changed files with 205 additions and 184 deletions

View File

@@ -39,10 +39,12 @@ 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 -= step;
if (measuredDistance > calculatedDistance) brakeTime += brakeTime/2;
if (measuredDistance < calculatedDistance) {
step /= 2;
if (step < 1) step = 1;
brakeTime -= step;
}
LOG.debug("new brake time: {}, calculated distance: {}", brakeTime, calculatedDistance);
}
route.brakeTime(train.brakeId(), brakeTime);

View File

@@ -18,7 +18,7 @@ import de.srsoftware.web4rail.tiles.Block;
/**
* @author Stephan Richter, SRSoftware 2020-2021
*/
public abstract class PathFinder extends BaseClass implements Runnable, Train.Listener{
public abstract class PathFinder extends BaseClass implements Runnable{
public static final Logger LOG = LoggerFactory.getLogger(PathFinder.class);
// private Context context;
private boolean aborted = false;
@@ -150,14 +150,21 @@ public abstract class PathFinder extends BaseClass implements Runnable, Train.Li
public void run() {
while (true) {
if (aborted) return;
Route route = chooseRoute();
Route route = chooseRoute();
if (isSet(route)) {
found(route);
if (aborted) return;
found(route);
if (route.allocateFor(train)) {
if (aborted) {
route.reset();
return;
}
locked(route);
if (aborted) return;
if (route.prepareFor(train)) {
if (aborted) {
route.reset();
return;
}
prepared(route);
return;
}
@@ -172,19 +179,10 @@ public abstract class PathFinder extends BaseClass implements Runnable, Train.Li
public abstract void found(Route r);
public abstract void prepared(Route r);
@Override
public void on(Signal signal) {
switch (signal) {
case STOP:
abort();
break;
}
}
public void start() {
train.addListener(this);
public PathFinder start() {
Thread thread = new Thread(this);
thread.setName("Pathfinder("+train+")");
thread.start();
return this;
}
}