bugfix: route preselct was broken
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.srsoftware</groupId>
|
<groupId>de.srsoftware</groupId>
|
||||||
<artifactId>web4rail</artifactId>
|
<artifactId>web4rail</artifactId>
|
||||||
<version>1.2.19</version>
|
<version>1.2.20</version>
|
||||||
<name>Web4Rail</name>
|
<name>Web4Rail</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>Java Model Railway Control</description>
|
<description>Java Model Railway Control</description>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import de.keawe.tools.translations.Translation;
|
import de.keawe.tools.translations.Translation;
|
||||||
import de.srsoftware.tools.Tag;
|
import de.srsoftware.tools.Tag;
|
||||||
|
import de.srsoftware.web4rail.Plan.Direction;
|
||||||
import de.srsoftware.web4rail.actions.Action;
|
import de.srsoftware.web4rail.actions.Action;
|
||||||
import de.srsoftware.web4rail.conditions.Condition;
|
import de.srsoftware.web4rail.conditions.Condition;
|
||||||
import de.srsoftware.web4rail.moving.Car;
|
import de.srsoftware.web4rail.moving.Car;
|
||||||
@@ -55,6 +56,7 @@ public abstract class BaseClass implements Constants{
|
|||||||
private Condition condition;
|
private Condition condition;
|
||||||
private Car car;
|
private Car car;
|
||||||
private Contact contact;
|
private Contact contact;
|
||||||
|
private Direction direction;
|
||||||
|
|
||||||
public Context(BaseClass object) {
|
public Context(BaseClass object) {
|
||||||
main = object;
|
main = object;
|
||||||
@@ -96,6 +98,15 @@ public abstract class BaseClass implements Constants{
|
|||||||
public Contact contact() {
|
public Contact contact() {
|
||||||
return contact;
|
return contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Direction direction() {
|
||||||
|
return direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Context direction(Direction newDirection) {
|
||||||
|
direction = newDirection;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Route route() {
|
public Route route() {
|
||||||
return route;
|
return route;
|
||||||
@@ -115,6 +126,7 @@ public abstract class BaseClass implements Constants{
|
|||||||
StringBuffer sb = new StringBuffer(getClass().getSimpleName());
|
StringBuffer sb = new StringBuffer(getClass().getSimpleName());
|
||||||
sb.append("(");
|
sb.append("(");
|
||||||
sb.append(t("Train: {}",train));
|
sb.append(t("Train: {}",train));
|
||||||
|
if (isSet(direction)) sb.append(", "+t("Direction: {}",direction));
|
||||||
if (isSet(route)) sb.append(", "+t("Route: {}",route));
|
if (isSet(route)) sb.append(", "+t("Route: {}",route));
|
||||||
if (isSet(contact)) sb.append(", "+t("Contact: {}",contact));
|
if (isSet(contact)) sb.append(", "+t("Contact: {}",contact));
|
||||||
sb.append(")");
|
sb.append(")");
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class PathFinder extends BaseClass{
|
|||||||
if (error) return availableRoutes;
|
if (error) return availableRoutes;
|
||||||
|
|
||||||
Block destination = train.destination();
|
Block destination = train.destination();
|
||||||
Direction direction = train.direction();
|
Direction direction = context.direction();
|
||||||
/* if (isSet(direction)) {
|
/* if (isSet(direction)) {
|
||||||
LOG.debug("{}Looking for {}-bound routes from {}",inset,direction,block);
|
LOG.debug("{}Looking for {}-bound routes from {}",inset,direction,block);
|
||||||
} else {
|
} else {
|
||||||
@@ -68,8 +68,7 @@ public class PathFinder extends BaseClass{
|
|||||||
priority = 1_000_000;
|
priority = 1_000_000;
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("{}- Candidate: {}",inset,routeCandidate.shortName());
|
LOG.debug("{}- Candidate: {}",inset,routeCandidate.shortName());
|
||||||
Context forwardContext = new Context(train);
|
Context forwardContext = new Context(train).block(routeCandidate.endBlock()).route(null).direction(routeCandidate.endDirection);
|
||||||
forwardContext.block(routeCandidate.endBlock()).route(null);
|
|
||||||
visitedRoutes.add(routeCandidate);
|
visitedRoutes.add(routeCandidate);
|
||||||
TreeMap<Integer, List<Route>> forwardRoutes = availableRoutes(forwardContext,visitedRoutes);
|
TreeMap<Integer, List<Route>> forwardRoutes = availableRoutes(forwardContext,visitedRoutes);
|
||||||
visitedRoutes.remove(routeCandidate);
|
visitedRoutes.remove(routeCandidate);
|
||||||
|
|||||||
@@ -574,7 +574,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reserveNext() {
|
public void reserveNext() {
|
||||||
Context context = new Context(this).route(route).block(route.endBlock());
|
Context context = new Context(this).route(route).block(route.endBlock()).direction(route.endDirection);
|
||||||
Route nextRoute = PathFinder.chooseRoute(context);
|
Route nextRoute = PathFinder.chooseRoute(context);
|
||||||
if (isNull(nextRoute)) return;
|
if (isNull(nextRoute)) return;
|
||||||
|
|
||||||
@@ -685,7 +685,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
if (maxSpeed() == 0) return t("Train has maximum speed of 0 {}, cannot go!",speedUnit);
|
if (maxSpeed() == 0) return t("Train has maximum speed of 0 {}, cannot go!",speedUnit);
|
||||||
if (isSet(route)) route.reset(); // reset route previously chosen
|
if (isSet(route)) route.reset(); // reset route previously chosen
|
||||||
|
|
||||||
Context context = new Context(this).block(this.currentBlock);
|
Context context = new Context(this).block(currentBlock).direction(direction);
|
||||||
String error = null;
|
String error = null;
|
||||||
if (isSet(nextRoute)) {
|
if (isSet(nextRoute)) {
|
||||||
route = nextRoute;
|
route = nextRoute;
|
||||||
|
|||||||
Reference in New Issue
Block a user