fixed tracing bug and brake-time bug
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.srsoftware</groupId>
|
||||
<artifactId>web4rail</artifactId>
|
||||
<version>1.3.43</version>
|
||||
<version>1.3.44</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -104,7 +104,7 @@ public class Route extends BaseClass {
|
||||
|
||||
timeStep = brakeTimes.get(brakeId);
|
||||
|
||||
if (isNull(timeStep)) timeStep = 256; // if no brake time is available for this train
|
||||
if (isNull(timeStep) || timeStep>1000000) timeStep = 256; // if no brake time is available for this train
|
||||
Application.threadPool.execute(this);
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ public class Route extends BaseClass {
|
||||
|
||||
private void increaseDistance(){
|
||||
long tick = timestamp();
|
||||
estimatedDistance += train.speed * (5+tick-latestTick);
|
||||
estimatedDistance += train.speed * (3+tick-latestTick);
|
||||
latestTick = tick;
|
||||
}
|
||||
|
||||
@@ -446,7 +446,6 @@ public class Route extends BaseClass {
|
||||
ActionList actions = triggeredActions.get(contact.trigger());
|
||||
LOG.debug("Contact has id {} / trigger {} and is assigned with {}",contact.id(),contact.trigger(),isNull(actions)?t("nothing"):actions);
|
||||
if (isNull(actions)) return;
|
||||
traceTrainFrom(contact);
|
||||
actions.fire(context);
|
||||
}
|
||||
|
||||
@@ -809,6 +808,7 @@ public class Route extends BaseClass {
|
||||
LOG.debug("{}.moveTrainToEndBlock()",this);
|
||||
|
||||
train.set(endBlock);
|
||||
traceTrainFrom(endBlock);
|
||||
train.heading(endDirection);
|
||||
|
||||
if (endBlock == train.destination()) {
|
||||
@@ -1059,7 +1059,7 @@ public class Route extends BaseClass {
|
||||
return getClass().getSimpleName()+"("+(isSet(train)?train+":":"")+name()+")";
|
||||
}
|
||||
|
||||
private void traceTrainFrom(Tile newHead) {
|
||||
public void traceTrainFrom(Tile newHead) {
|
||||
LOG.debug("{}.traceTrainFrom({})",this,newHead);
|
||||
if (isNull(train)) return;
|
||||
if (newHead instanceof BlockContact) newHead = (Tile) ((BlockContact)newHead).parent();
|
||||
@@ -1071,10 +1071,12 @@ public class Route extends BaseClass {
|
||||
Tile tile = path.elementAt(i-1);
|
||||
if (isNull(remainingLength)) {
|
||||
if (tile == newHead) traceHead = newHead; // wenn wir zuerst newHead finden: newHead als neuen traceHead übernehmen
|
||||
if (tile == traceHead) remainingLength = train.length(); // sobald wir auf den traceHead stoßen: suche beenden
|
||||
if (tile == traceHead) {
|
||||
remainingLength = train.length(); // sobald wir auf den traceHead stoßen: suche beenden
|
||||
}
|
||||
}
|
||||
if (isSet(remainingLength)) {
|
||||
if (remainingLength>0) {
|
||||
if (remainingLength>=0) {
|
||||
newTrace.add(tile);
|
||||
remainingLength -= tile.length();
|
||||
} else if (Route.freeBehindTrain) {
|
||||
|
||||
@@ -896,17 +896,13 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
public void setTrace(LinkedList<Tile> newTrace) {
|
||||
LOG.debug("{}.setTrace({})",this,newTrace);
|
||||
LOG.debug("old trace: {}",trace);
|
||||
if (isSet(trace)) {
|
||||
trace.removeAll(newTrace);
|
||||
|
||||
for (Tile tile : trace) {
|
||||
tile.setTrain(null);
|
||||
}
|
||||
};
|
||||
|
||||
trace.removeAll(newTrace);
|
||||
for (Tile tile : trace) tile.setTrain(null);
|
||||
trace = newTrace;
|
||||
for (Tile tile : trace) tile.setTrain(this);
|
||||
|
||||
LOG.debug("new trace of {}: {}",this,trace);
|
||||
LOG.debug("new trace of {}: {}",this,trace);
|
||||
}
|
||||
|
||||
public void setWaitTime(Range waitTime) {
|
||||
@@ -971,6 +967,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
route.set(context);
|
||||
if (isNull(error) && !route.prepare()) error = t("Was not able to fire all setup actions of route!");
|
||||
}
|
||||
if (isNull(route)) return this; // route may have been canceled in between
|
||||
if (isNull(error) && direction != route.startDirection) turn();
|
||||
|
||||
if (isNull(error) && !route.start(this)) error = t("Was not able to assign {} to {}!",this,route);
|
||||
|
||||
@@ -86,6 +86,7 @@ public class Contact extends Tile{
|
||||
Route route = route();
|
||||
Context context = isSet(route) ? route.context().contact(this) : new Context(this);
|
||||
|
||||
if (isSet(route)) route.traceTrainFrom(this);
|
||||
actions.fire(context);
|
||||
if (isSet(route)) route.contact(this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user