diff --git a/pom.xml b/pom.xml index 15f2906..0f71868 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 de.srsoftware web4rail - 1.0.15 + 1.0.16 Web4Rail jar Java Model Railway Control diff --git a/src/main/java/de/srsoftware/web4rail/tiles/Turnout.java b/src/main/java/de/srsoftware/web4rail/tiles/Turnout.java index bd7f8c4..f17e490 100644 --- a/src/main/java/de/srsoftware/web4rail/tiles/Turnout.java +++ b/src/main/java/de/srsoftware/web4rail/tiles/Turnout.java @@ -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{ 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); } } \ No newline at end of file