minor improvement: turnouts will now get re-initialized, when ports are altered
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.0.15</version>
|
<version>1.0.16</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>
|
||||||
|
|||||||
@@ -143,13 +143,13 @@ public abstract class Turnout extends Tile implements Device{
|
|||||||
|
|
||||||
public Reply state(State newState) throws IOException {
|
public Reply state(State newState) throws IOException {
|
||||||
if (train != null && newState != state) return new Reply(415, t("{} locked by {}!",this,train));
|
if (train != null && newState != state) return new Reply(415, t("{} locked by {}!",this,train));
|
||||||
Reply reply = init();
|
|
||||||
if (reply != null && !reply.succeeded()) return reply;
|
|
||||||
if (address == 0) {
|
if (address == 0) {
|
||||||
state = newState;
|
state = newState;
|
||||||
plan.place(this);
|
plan.place(this);
|
||||||
return new Reply(200,"OK");
|
return new Reply(200,"OK");
|
||||||
}
|
}
|
||||||
|
Reply reply = init();
|
||||||
|
if (reply != null && !reply.succeeded()) return reply;
|
||||||
try {
|
try {
|
||||||
return plan.queue(new Command(commandFor(newState)) {
|
return plan.queue(new Command(commandFor(newState)) {
|
||||||
|
|
||||||
@@ -206,8 +206,22 @@ public abstract class Turnout extends Tile implements Device{
|
|||||||
address = newAddress;
|
address = newAddress;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (params.containsKey(PORT_A)) portA = Integer.parseInt(params.get(PORT_A));
|
String newPort = params.get(PORT_A);
|
||||||
if (params.containsKey(PORT_B)) portB = Integer.parseInt(params.get(PORT_B));
|
if (isSet(newPort)) {
|
||||||
|
int npa = Integer.parseInt(newPort);
|
||||||
|
if (npa != portA) {
|
||||||
|
portA = npa;
|
||||||
|
initialized = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newPort = params.get(PORT_B);
|
||||||
|
if (isSet(newPort)) {
|
||||||
|
int npb = Integer.parseInt(newPort);
|
||||||
|
if (npb != portB) {
|
||||||
|
portB = npb;
|
||||||
|
initialized = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return super.update(params);
|
return super.update(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user