bugfixes
This commit is contained in:
@@ -9,5 +9,6 @@
|
|||||||
|
|
||||||
<root level="debug">
|
<root level="debug">
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
|
<logger name="de.srsoftware.web4rail.ControlUnit" level="WARN"/>
|
||||||
</root>
|
</root>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -39,6 +39,7 @@ public class ControlUnit extends Thread implements Constants{
|
|||||||
private static final String MODE_INFO = "INFO";
|
private static final String MODE_INFO = "INFO";
|
||||||
private static final String MODE_COMMAND = "COMMAND";
|
private static final String MODE_COMMAND = "COMMAND";
|
||||||
protected static final String FEEDBACK = "FB";
|
protected static final String FEEDBACK = "FB";
|
||||||
|
protected static final String ACESSORY = "GA";
|
||||||
|
|
||||||
private String host = DEFAULT_HOST;
|
private String host = DEFAULT_HOST;
|
||||||
private int port = DEFAULT_PORT;
|
private int port = DEFAULT_PORT;
|
||||||
@@ -315,6 +316,7 @@ public class ControlUnit extends Thread implements Constants{
|
|||||||
int addr = Integer.parseInt(parts[5]);
|
int addr = Integer.parseInt(parts[5]);
|
||||||
boolean active = !parts[6].equals("0");
|
boolean active = !parts[6].equals("0");
|
||||||
ControlUnit.this.plan.sensor(addr,active);
|
ControlUnit.this.plan.sensor(addr,active);
|
||||||
|
case ACESSORY:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG.debug("Info thread received: {}",line);
|
LOG.debug("Info thread received: {}",line);
|
||||||
|
|||||||
@@ -575,7 +575,12 @@ public class Plan extends BaseClass{
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Route registerRoute(Route newRoute) {
|
Route registerRoute(Route newRoute) {
|
||||||
for (Tile tile: newRoute.path()) tile.add(newRoute);
|
for (Tile tile: newRoute.path()) {
|
||||||
|
if (isNull(tile)) {
|
||||||
|
System.err.println("--");
|
||||||
|
}
|
||||||
|
tile.add(newRoute);
|
||||||
|
}
|
||||||
int routeId = newRoute.id();
|
int routeId = newRoute.id();
|
||||||
Route existingRoute = routes.get(routeId);
|
Route existingRoute = routes.get(routeId);
|
||||||
if (isSet(existingRoute)) newRoute.addPropertiesFrom(existingRoute);
|
if (isSet(existingRoute)) newRoute.addPropertiesFrom(existingRoute);
|
||||||
|
|||||||
@@ -461,11 +461,15 @@ public class Route extends BaseClass{
|
|||||||
|
|
||||||
private Route load(JSONObject json,Plan plan) {
|
private Route load(JSONObject json,Plan plan) {
|
||||||
if (json.has(ID)) id = json.getInt(ID);
|
if (json.has(ID)) id = json.getInt(ID);
|
||||||
|
if (json.has(NAME)) name(json.getString(NAME));
|
||||||
JSONArray pathIds = json.getJSONArray(PATH);
|
JSONArray pathIds = json.getJSONArray(PATH);
|
||||||
startDirection = Direction.valueOf(json.getString(START_DIRECTION));
|
startDirection = Direction.valueOf(json.getString(START_DIRECTION));
|
||||||
endDirection = Direction.valueOf(json.getString(END_DIRECTION));
|
endDirection = Direction.valueOf(json.getString(END_DIRECTION));
|
||||||
for (Object tileId : pathIds) {
|
for (Object tileId : pathIds) {
|
||||||
Tile tile = plan.get((String) tileId,false);
|
Tile tile = plan.get((String) tileId,false);
|
||||||
|
if (isNull(tile)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (isNull(startBlock)) {
|
if (isNull(startBlock)) {
|
||||||
begin((Block) tile, startDirection);
|
begin((Block) tile, startDirection);
|
||||||
} else if (tile instanceof Block) { // make sure, endDirection is set on last block
|
} else if (tile instanceof Block) { // make sure, endDirection is set on last block
|
||||||
@@ -474,7 +478,10 @@ public class Route extends BaseClass{
|
|||||||
add(tile, null);
|
add(tile, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (json.has(NAME)) name(json.getString(NAME));
|
if (isNull(path) || path.isEmpty()) {
|
||||||
|
LOG.warn("{} has no tiles. It will be ignored.",this);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (json.has(TURNOUTS)) {
|
if (json.has(TURNOUTS)) {
|
||||||
JSONArray turnouts = json.getJSONArray(TURNOUTS);
|
JSONArray turnouts = json.getJSONArray(TURNOUTS);
|
||||||
for (int i=0; i<turnouts.length();i++) {
|
for (int i=0; i<turnouts.length();i++) {
|
||||||
|
|||||||
@@ -534,7 +534,12 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void reverseTrace() {
|
private void reverseTrace() {
|
||||||
// TODO Auto-generated method stub
|
LinkedList<Tile> reversed = new LinkedList<Tile>();
|
||||||
|
LOG.debug("Trace: {}",trace);
|
||||||
|
while (!trace.isEmpty()) reversed.addFirst(trace.removeFirst());
|
||||||
|
trace = reversed;
|
||||||
|
LOG.debug("reversed: {}",trace);
|
||||||
|
reversed = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveAll(String filename) throws IOException {
|
public static void saveAll(String filename) throws IOException {
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ public class Checkbox extends Tag {
|
|||||||
Tag checkbox = new Tag("input").attr("type", "checkbox").attr("name", name);
|
Tag checkbox = new Tag("input").attr("type", "checkbox").attr("name", name);
|
||||||
if (preCheck) checkbox.attr("checked", "checked");
|
if (preCheck) checkbox.attr("checked", "checked");
|
||||||
checkbox.addTo(this);
|
checkbox.addTo(this);
|
||||||
content(label);
|
content(label);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user