working on route allocation

This commit is contained in:
Stephan Richter
2020-09-19 13:51:43 +02:00
parent 917ac5dd07
commit 1d1876e1d3
26 changed files with 72114 additions and 39 deletions

View File

@@ -1,14 +1,35 @@
package de.srsoftware.web4rail.tiles;
import java.io.IOException;
import java.util.Map;
import de.srsoftware.tools.Tag;
public abstract class Turnout extends Tile {
public static final String STATE = "state";
public enum State{
LEFT,STRAIGHT,RIGHT,UNDEF;
}
private boolean straight = true;
protected State state = State.STRAIGHT;
public boolean toggle() {
straight = !straight;
return straight;
public State state() {
return state;
}
public void state(State newState) throws IOException {
state = newState;
LOG.debug("Setting {} to {}",this,state);
plan.stream("place "+tag(null));
}
@Override
public Tag tag(Map<String, Object> replacements) throws IOException {
Tag tag = super.tag(replacements);
tag.clazz(tag.get("class")+(" "+state).toLowerCase());
return tag;
}
public void toggle() {
state = State.STRAIGHT;
}
}