bugfixes
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.4.11</version>
|
<version>1.4.12</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>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<configuration scan="true" scanPeriod="60 seconds"
|
<configuration scan="true" scanPeriod="30 seconds"
|
||||||
debug="true">
|
debug="true">
|
||||||
<!-- scan="true" enables automatic updates if config file changes, see http://logback.qos.ch/manual/configuration.html -->
|
<!-- scan="true" enables automatic updates if config file changes, see http://logback.qos.ch/manual/configuration.html -->
|
||||||
<appender name="STDOUT"
|
<appender name="STDOUT"
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
</encoder>
|
</encoder>
|
||||||
<filter class="de.srsoftware.web4rail.ThreadFilter">
|
<filter class="de.srsoftware.web4rail.ThreadFilter">
|
||||||
<level>DEBUG</level>
|
<level>DEBUG</level>
|
||||||
<keywords>Brake, Contact, Feed, Route, Train</keywords>
|
<keywords>Brake, Contact, Feed, Route, e, u</keywords>
|
||||||
</filter>
|
</filter>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
|||||||
@@ -153,14 +153,14 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
if (isSet(train)) {
|
if (isSet(train)) {
|
||||||
Block currentBlock = train.currentBlock();
|
Block currentBlock = train.currentBlock();
|
||||||
if (isSet(currentBlock)) {
|
if (isSet(currentBlock)) {
|
||||||
if (!train.isStoppable()) {
|
if (isSet(train.direction()) && !train.isStoppable()) {
|
||||||
params.put(ACTION, ACTION_START);
|
params.put(ACTION, ACTION_START);
|
||||||
new Button(t("depart"),params).addTo(direction);
|
new Button(t("depart"),params).addTo(direction);
|
||||||
}
|
}
|
||||||
if (train.usesAutopilot()) {
|
if (train.usesAutopilot()) {
|
||||||
params.put(ACTION, ACTION_QUIT);
|
params.put(ACTION, ACTION_QUIT);
|
||||||
new Button(t("quit autopilot"),params).addTo(direction);
|
new Button(t("quit autopilot"),params).addTo(direction);
|
||||||
} else {
|
} else if (isSet(train.direction())){
|
||||||
params.put(ACTION, ACTION_AUTO);
|
params.put(ACTION, ACTION_AUTO);
|
||||||
new Button(t("auto"),params).addTo(direction);
|
new Button(t("auto"),params).addTo(direction);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public abstract class Bridge extends Tile {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean free(Train train) {
|
public boolean free(Train train) {
|
||||||
|
if (isFree()) return true;
|
||||||
if (!super.free(train)) return false;
|
if (!super.free(train)) return false;
|
||||||
return isSet(counterpart) ? counterpart.free(train) : true;
|
return isSet(counterpart) ? counterpart.free(train) : true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
|||||||
if (isNull(oldTrain)) return false;
|
if (isNull(oldTrain)) return false;
|
||||||
if (isSet(reservingTrain) && reservingTrain != oldTrain) return false;
|
if (isSet(reservingTrain) && reservingTrain != oldTrain) return false;
|
||||||
if (isSet(lockingTrain) && lockingTrain != oldTrain) return false;
|
if (isSet(lockingTrain) && lockingTrain != oldTrain) return false;
|
||||||
if (isSet(occupyingTrain) && occupyingTrain != oldTrain) return false;
|
if (isSet(occupyingTrain) && occupyingTrain != oldTrain) return false;
|
||||||
reservingTrain = lockingTrain = occupyingTrain = null;
|
reservingTrain = lockingTrain = occupyingTrain = null;
|
||||||
plan.place(this);
|
plan.place(this);
|
||||||
return true;
|
return true;
|
||||||
@@ -131,6 +131,13 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
|||||||
public boolean isDisabled() {
|
public boolean isDisabled() {
|
||||||
return disabled;
|
return disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isFree() {
|
||||||
|
if (isSet(lockingTrain)) return false;
|
||||||
|
if (isSet(reservingTrain)) return false;
|
||||||
|
if (isSet(occupyingTrain)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isFreeFor(Context newTrain) {
|
public boolean isFreeFor(Context newTrain) {
|
||||||
LOG.debug("{}.isFreeFor({})", this, newTrain);
|
LOG.debug("{}.isFreeFor({})", this, newTrain);
|
||||||
@@ -369,7 +376,27 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
|||||||
|
|
||||||
return super.properties(preForm, formInputs, postForm, errors);
|
return super.properties(preForm, formInputs, postForm, errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseClass remove() {
|
||||||
|
while (!routes.isEmpty()) routes.first().remove();
|
||||||
|
return super.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeChild(BaseClass child) {
|
||||||
|
String childAsString = child.toString();
|
||||||
|
if (childAsString.length() > 20) childAsString = childAsString.substring(0, 20) + "…";
|
||||||
|
LOG.debug("Removing {} from {}", childAsString, this);
|
||||||
|
if (child instanceof Route) routes.remove(child);
|
||||||
|
|
||||||
|
if (child == reservingTrain) reservingTrain = null;
|
||||||
|
if (child == lockingTrain) lockingTrain = null;
|
||||||
|
if (child == occupyingTrain) occupyingTrain = null;
|
||||||
|
super.removeChild(child);
|
||||||
|
plan.place(this);
|
||||||
|
}
|
||||||
|
|
||||||
private static String replace(String line, Entry<String, Object> replacement) {
|
private static String replace(String line, Entry<String, Object> replacement) {
|
||||||
String key = replacement.getKey();
|
String key = replacement.getKey();
|
||||||
Object val = replacement.getValue();
|
Object val = replacement.getValue();
|
||||||
@@ -387,6 +414,27 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean reserveFor(Context context) {
|
||||||
|
Train newTrain = context.train();
|
||||||
|
LOG.debug("{}.reserverFor({})",this,newTrain);
|
||||||
|
if (isNull(newTrain)) return false;
|
||||||
|
if (isSet(reservingTrain)) {
|
||||||
|
if (reservingTrain != newTrain) return debug("{} already reserved for {}",this,reservingTrain);
|
||||||
|
return true; // already reserved for newTrain
|
||||||
|
}
|
||||||
|
if (isSet(lockingTrain)) {
|
||||||
|
if (lockingTrain != newTrain) return debug("{} already locked by {}",this,lockingTrain);
|
||||||
|
return true; // do not downgrade!
|
||||||
|
}
|
||||||
|
if (isSet(occupyingTrain)) {
|
||||||
|
if (occupyingTrain != newTrain && !newTrain.isShunting()) return debug("{} already occupied by {}",this,occupyingTrain);
|
||||||
|
return true; // do not downgrade!
|
||||||
|
}
|
||||||
|
reservingTrain = newTrain;
|
||||||
|
plan.place(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public TreeSet<Route> routes() {
|
public TreeSet<Route> routes() {
|
||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
@@ -400,6 +448,13 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
|||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
boolean show = (disabled == enabled);
|
||||||
|
disabled = !enabled;
|
||||||
|
if (show) plan.place(this);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean setTrain(Train newTrain) {
|
public boolean setTrain(Train newTrain) {
|
||||||
if (disabled) return false;
|
if (disabled) return false;
|
||||||
if (isNull(newTrain)) return false;
|
if (isNull(newTrain)) return false;
|
||||||
@@ -478,55 +533,6 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
|||||||
return t("{}({},{})", getClass().getSimpleName(), x, y);
|
return t("{}({},{})", getClass().getSimpleName(), x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseClass remove() {
|
|
||||||
while (!routes.isEmpty()) routes.first().remove();
|
|
||||||
return super.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeChild(BaseClass child) {
|
|
||||||
String childAsString = child.toString();
|
|
||||||
if (childAsString.length() > 20) childAsString = childAsString.substring(0, 20) + "…";
|
|
||||||
LOG.debug("Removing {} from {}", childAsString, this);
|
|
||||||
if (child instanceof Route) routes.remove(child);
|
|
||||||
|
|
||||||
if (child == reservingTrain) reservingTrain = null;
|
|
||||||
if (child == lockingTrain) lockingTrain = null;
|
|
||||||
if (child == occupyingTrain) occupyingTrain = null;
|
|
||||||
super.removeChild(child);
|
|
||||||
plan.place(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean reserveFor(Context context) {
|
|
||||||
Train newTrain = context.train();
|
|
||||||
LOG.debug("{}.reserverFor({})",this,newTrain);
|
|
||||||
if (isNull(newTrain)) return false;
|
|
||||||
if (isSet(reservingTrain)) {
|
|
||||||
if (reservingTrain != newTrain) return debug("{} already reserved for {}",this,reservingTrain);
|
|
||||||
return true; // already reserved for newTrain
|
|
||||||
}
|
|
||||||
if (isSet(lockingTrain)) {
|
|
||||||
if (lockingTrain != newTrain) return debug("{} already locked by {}",this,lockingTrain);
|
|
||||||
return true; // do not downgrade!
|
|
||||||
}
|
|
||||||
if (isSet(occupyingTrain)) {
|
|
||||||
if (occupyingTrain != newTrain && !newTrain.isShunting()) return debug("{} already occupied by {}",this,occupyingTrain);
|
|
||||||
return true; // do not downgrade!
|
|
||||||
}
|
|
||||||
reservingTrain = newTrain;
|
|
||||||
plan.place(this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
|
||||||
boolean show = (disabled == enabled);
|
|
||||||
disabled = !enabled;
|
|
||||||
if (show) plan.place(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tile update(HashMap<String, String> params) {
|
public Tile update(HashMap<String, String> params) {
|
||||||
LOG.debug("{}.update({})", getClass().getSimpleName(), params);
|
LOG.debug("{}.update({})", getClass().getSimpleName(), params);
|
||||||
String oneWayDir = params.get("oneway");
|
String oneWayDir = params.get("oneway");
|
||||||
@@ -550,3 +556,4 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user