Browse Source

minor improvement: turnouts will now get re-initialized, when ports are altered

lookup-tables
Stephan Richter 4 years ago
parent
commit
4fb474097a
  1. 2
      pom.xml
  2. 22
      src/main/java/de/srsoftware/web4rail/tiles/Turnout.java

2
pom.xml

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.srsoftware</groupId>
<artifactId>web4rail</artifactId>
<version>1.0.15</version>
<version>1.0.16</version>
<name>Web4Rail</name>
<packaging>jar</packaging>
<description>Java Model Railway Control</description>

22
src/main/java/de/srsoftware/web4rail/tiles/Turnout.java

@ -143,13 +143,13 @@ public abstract class Turnout extends Tile implements Device{ @@ -143,13 +143,13 @@ public abstract class Turnout extends Tile implements Device{
public Reply state(State newState) throws IOException {
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) {
state = newState;
plan.place(this);
return new Reply(200,"OK");
}
Reply reply = init();
if (reply != null && !reply.succeeded()) return reply;
try {
return plan.queue(new Command(commandFor(newState)) {
@ -206,8 +206,22 @@ public abstract class Turnout extends Tile implements Device{ @@ -206,8 +206,22 @@ public abstract class Turnout extends Tile implements Device{
address = newAddress;
}
}
if (params.containsKey(PORT_A)) portA = Integer.parseInt(params.get(PORT_A));
if (params.containsKey(PORT_B)) portB = Integer.parseInt(params.get(PORT_B));
String newPort = params.get(PORT_A);
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);
}
}
Loading…
Cancel
Save