bugfixes
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.4.11</version>
|
||||
<version>1.4.12</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<configuration scan="true" scanPeriod="60 seconds"
|
||||
<configuration scan="true" scanPeriod="30 seconds"
|
||||
debug="true">
|
||||
<!-- scan="true" enables automatic updates if config file changes, see http://logback.qos.ch/manual/configuration.html -->
|
||||
<appender name="STDOUT"
|
||||
@@ -9,7 +9,7 @@
|
||||
</encoder>
|
||||
<filter class="de.srsoftware.web4rail.ThreadFilter">
|
||||
<level>DEBUG</level>
|
||||
<keywords>Brake, Contact, Feed, Route, Train</keywords>
|
||||
<keywords>Brake, Contact, Feed, Route, e, u</keywords>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
|
||||
@@ -153,14 +153,14 @@ public class Locomotive extends Car implements Constants,Device{
|
||||
if (isSet(train)) {
|
||||
Block currentBlock = train.currentBlock();
|
||||
if (isSet(currentBlock)) {
|
||||
if (!train.isStoppable()) {
|
||||
if (isSet(train.direction()) && !train.isStoppable()) {
|
||||
params.put(ACTION, ACTION_START);
|
||||
new Button(t("depart"),params).addTo(direction);
|
||||
}
|
||||
if (train.usesAutopilot()) {
|
||||
params.put(ACTION, ACTION_QUIT);
|
||||
new Button(t("quit autopilot"),params).addTo(direction);
|
||||
} else {
|
||||
} else if (isSet(train.direction())){
|
||||
params.put(ACTION, ACTION_AUTO);
|
||||
new Button(t("auto"),params).addTo(direction);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public abstract class Bridge extends Tile {
|
||||
|
||||
@Override
|
||||
public boolean free(Train train) {
|
||||
if (isFree()) return true;
|
||||
if (!super.free(train)) return false;
|
||||
return isSet(counterpart) ? counterpart.free(train) : true;
|
||||
}
|
||||
|
||||
@@ -132,6 +132,13 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
||||
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) {
|
||||
LOG.debug("{}.isFreeFor({})", this, newTrain);
|
||||
if (isDisabled()) {
|
||||
@@ -370,6 +377,26 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
||||
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) {
|
||||
String key = replacement.getKey();
|
||||
Object val = replacement.getValue();
|
||||
@@ -387,6 +414,27 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
||||
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() {
|
||||
return routes;
|
||||
}
|
||||
@@ -400,6 +448,13 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
||||
file.close();
|
||||
}
|
||||
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
boolean show = (disabled == enabled);
|
||||
disabled = !enabled;
|
||||
if (show) plan.place(this);
|
||||
}
|
||||
|
||||
public boolean setTrain(Train newTrain) {
|
||||
if (disabled) 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);
|
||||
}
|
||||
|
||||
@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) {
|
||||
LOG.debug("{}.update({})", getClass().getSimpleName(), params);
|
||||
String oneWayDir = params.get("oneway");
|
||||
@@ -550,3 +556,4 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user