bugfixes:
- now initializing signals before setting aspects - fixed css for HL2
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.3.1</version>
|
<version>1.3.2</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>
|
||||||
|
|||||||
@@ -194,10 +194,11 @@ h2{
|
|||||||
.signal.red .sig_a{
|
.signal.red .sig_a{
|
||||||
fill: red;
|
fill: red;
|
||||||
}
|
}
|
||||||
|
.signal.HL2 .sig_a,
|
||||||
.signal.green .sig_a{
|
.signal.green .sig_a{
|
||||||
fill: lime;
|
fill: lime;
|
||||||
}
|
}
|
||||||
.signal.HL2 .sig_a{
|
.signal.HL2 .sig_b{
|
||||||
fill: yellow;
|
fill: yellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<svg width="%width%" height="100" viewbox="0 0 100 100">
|
<svg width="%width%" height="100" viewbox="0 0 100 100">
|
||||||
<rect x="0" y="35" width="100" height="30" />
|
<rect x="0" y="35" width="100" height="30" />
|
||||||
<rect class="sig_a" x="75" y="75" height="20" width="20" />
|
<rect class="sig_a" x="75" y="75" height="20" width="20" />
|
||||||
<rect class="sig_B" x="55" y="75" height="20" width="20" />
|
<rect class="sig_b" x="55" y="75" height="20" width="20" />
|
||||||
<line x1="30" y1="85" x2="55" y2="85" />
|
<line x1="30" y1="85" x2="55" y2="85" />
|
||||||
<line x1="30" y1="80" x2="30" y2="90" />
|
<line x1="30" y1="80" x2="30" y2="90" />
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 316 B |
@@ -1,7 +1,7 @@
|
|||||||
<svg width="100" height="" viewbox="0 0 100 100">
|
<svg width="100" height="" viewbox="0 0 100 100">
|
||||||
<rect x="35" y="0" width="30" height="100" />
|
<rect x="35" y="0" width="30" height="100" />
|
||||||
<rect class="sig_a" x="75" y="5" height="20" width="20" />
|
<rect class="sig_a" x="75" y="5" height="20" width="20" />
|
||||||
<rect class="sig_B" x="75" y="25" height="20" width="20" />
|
<rect class="sig_b" x="75" y="25" height="20" width="20" />
|
||||||
<line x1="85" y1="45" x2="85" y2="70" />
|
<line x1="85" y1="45" x2="85" y2="70" />
|
||||||
<line x1="80" y1="70" x2="90" y2="70" />
|
<line x1="80" y1="70" x2="90" y2="70" />
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 308 B After Width: | Height: | Size: 308 B |
@@ -1,7 +1,7 @@
|
|||||||
<svg width="100" height="" viewbox="0 0 100 100">
|
<svg width="100" height="" viewbox="0 0 100 100">
|
||||||
<rect x="35" y="0" width="30" height="100" />
|
<rect x="35" y="0" width="30" height="100" />
|
||||||
<rect class="sig_a" x="5" y="75" height="20" width="20" />
|
<rect class="sig_a" x="5" y="75" height="20" width="20" />
|
||||||
<rect class="sig_B" x="5" y="55" height="20" width="20" />
|
<rect class="sig_b" x="5" y="55" height="20" width="20" />
|
||||||
<line x1="15" y1="30" x2="15" y2="55" />
|
<line x1="15" y1="30" x2="15" y2="55" />
|
||||||
<line x1="10" y1="30" x2="20" y2="30" />
|
<line x1="10" y1="30" x2="20" y2="30" />
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 307 B After Width: | Height: | Size: 307 B |
@@ -1,7 +1,7 @@
|
|||||||
<svg width="%width%" height="100" viewbox="0 0 100 100">
|
<svg width="%width%" height="100" viewbox="0 0 100 100">
|
||||||
<rect x="0" y="35" width="100" height="30" />
|
<rect x="0" y="35" width="100" height="30" />
|
||||||
<rect class="sig_a" x="5" y="5" height="20" width="20" />
|
<rect class="sig_a" x="5" y="5" height="20" width="20" />
|
||||||
<rect class="sig_B" x="25" y="5" height="20" width="20" />
|
<rect class="sig_b" x="25" y="5" height="20" width="20" />
|
||||||
<line x1="45" y1="15" x2="70" y2="15" />
|
<line x1="45" y1="15" x2="70" y2="15" />
|
||||||
<line x1="70" y1="10" x2="70" y2="20" />
|
<line x1="70" y1="10" x2="70" y2="20" />
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 313 B After Width: | Height: | Size: 313 B |
@@ -6,16 +6,17 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import java.util.Vector;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import de.srsoftware.tools.Tag;
|
import de.srsoftware.tools.Tag;
|
||||||
import de.srsoftware.web4rail.Command;
|
import de.srsoftware.web4rail.Command;
|
||||||
import de.srsoftware.web4rail.Plan.Direction;
|
import de.srsoftware.web4rail.Plan.Direction;
|
||||||
|
import de.srsoftware.web4rail.Protocol;
|
||||||
import de.srsoftware.web4rail.Window;
|
import de.srsoftware.web4rail.Window;
|
||||||
import de.srsoftware.web4rail.tags.Button;
|
import de.srsoftware.web4rail.tags.Button;
|
||||||
import de.srsoftware.web4rail.tags.Checkbox;
|
import de.srsoftware.web4rail.tags.Checkbox;
|
||||||
@@ -30,10 +31,12 @@ public abstract class Signal extends Tile {
|
|||||||
public static final String GREEN = "green";
|
public static final String GREEN = "green";
|
||||||
public static final TreeSet<String> knownStates = new TreeSet<String>(List.of(RED, GREEN));
|
public static final TreeSet<String> knownStates = new TreeSet<String>(List.of(RED, GREEN));
|
||||||
private final HashMap<String,HashSet<int[]>> aspects = new HashMap<String, HashSet<int[]>>();
|
private final HashMap<String,HashSet<int[]>> aspects = new HashMap<String, HashSet<int[]>>();
|
||||||
|
private final HashSet<Integer> initialized = new HashSet<Integer>();
|
||||||
private static final String ADDRESS = "addr";
|
private static final String ADDRESS = "addr";
|
||||||
private static final String HOLD = "hold";
|
private static final String HOLD = "hold";
|
||||||
private static final String NEW_ASPECT = "new_aspect";
|
private static final String NEW_ASPECT = "new_aspect";
|
||||||
private static final String ASPECTS = "aspects";
|
private static final String ASPECTS = "aspects";
|
||||||
|
private Protocol protocol = Protocol.DCC128;
|
||||||
|
|
||||||
private String state = RED;
|
private String state = RED;
|
||||||
|
|
||||||
@@ -100,6 +103,22 @@ public abstract class Signal extends Tile {
|
|||||||
return super.load(json);
|
return super.load(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private char proto() {
|
||||||
|
switch (protocol) {
|
||||||
|
case DCC14:
|
||||||
|
case DCC27:
|
||||||
|
case DCC28:
|
||||||
|
case DCC128:
|
||||||
|
return 'N';
|
||||||
|
case MOTO:
|
||||||
|
return 'M';
|
||||||
|
case SELECTRIX:
|
||||||
|
return 'S';
|
||||||
|
default:
|
||||||
|
return 'P';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
||||||
Fieldset aspectEditor = new Fieldset(t("Aspects"));
|
Fieldset aspectEditor = new Fieldset(t("Aspects"));
|
||||||
@@ -142,6 +161,8 @@ public abstract class Signal extends Tile {
|
|||||||
HashSet<int[]> commands = aspects.get(aspect);
|
HashSet<int[]> commands = aspects.get(aspect);
|
||||||
if (isSet(commands)) {
|
if (isSet(commands)) {
|
||||||
for (int[] data : commands) {
|
for (int[] data : commands) {
|
||||||
|
int addr = data[0];
|
||||||
|
init(addr);
|
||||||
Command cmd = new Command("SET {} GA "+data[0]+" "+data[1]+" "+data[2]+" "+(data[3]==1?-1:200));
|
Command cmd = new Command("SET {} GA "+data[0]+" "+data[1]+" "+data[2]+" "+(data[3]==1?-1:200));
|
||||||
LOG.debug("new Command: {}",cmd);
|
LOG.debug("new Command: {}",cmd);
|
||||||
plan.controlUnit().queue(cmd);
|
plan.controlUnit().queue(cmd);
|
||||||
@@ -151,6 +172,31 @@ public abstract class Signal extends Tile {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init(int addr) {
|
||||||
|
if (!initialized.contains(addr)) {
|
||||||
|
Command command = new Command("INIT {} GA "+addr+" "+proto()) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
super.onSuccess();
|
||||||
|
initialized.add(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Reply r) {
|
||||||
|
super.onFailure(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
plan.queue(command).reply();
|
||||||
|
} catch (TimeoutException e) {
|
||||||
|
LOG.warn(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tag tag(Map<String, Object> replacements) throws IOException {
|
public Tag tag(Map<String, Object> replacements) throws IOException {
|
||||||
Tag tag = super.tag(replacements);
|
Tag tag = super.tag(replacements);
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public abstract class Turnout extends Tile implements Device{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Reply r) {
|
public void onFailure(Reply r) {
|
||||||
super.onSuccess();
|
super.onFailure(r);
|
||||||
initialized = false;
|
initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||