GUI improvements, bugfixes
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.srsoftware</groupId>
|
||||
<artifactId>web4rail</artifactId>
|
||||
<version>1.2.64</version>
|
||||
<version>1.2.65</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender" append="false">
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||
<append>false</append>
|
||||
<file>Web4Rail.log</file>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>DEBUG</level>
|
||||
|
||||
@@ -40,7 +40,7 @@ Block properties : Block-Eigenschaften
|
||||
{}bound : nach {}
|
||||
BrakeCancel : Bremsvorgang abbrechen
|
||||
BrakeStart : Bremsvorgang starten
|
||||
BrakeStop : Zug anhalten
|
||||
BrakeStop : Bremsvorgang abschließen
|
||||
Brake time¹, forward : Bremszeit¹, vorwärts
|
||||
Brake time¹, reverse : Bremszeit¹, rückwärts
|
||||
Brake time table : Bremszeit-Tabelle
|
||||
@@ -106,10 +106,11 @@ Faster (10 {}) : 10 {} schneller
|
||||
Final speed after breaking, before halting : Endgeschwindigkeit nach Bremsvorgang, vor dem Anhalten
|
||||
FinishRoute : Route abschließen
|
||||
Firing {} : starte {}
|
||||
For each {} do: Für jede(n) {}:
|
||||
For each {} do\: : Mit jedem {}:
|
||||
forward : vorwärts
|
||||
Found {} routes. : {} Routen gefunden.
|
||||
FreeStartBlock : Start-Block freigeben
|
||||
Free tiles behind train : Kacheln hinter dem Zug freigeben
|
||||
Fullscreen : Vollbild
|
||||
Function : Funktion
|
||||
Hardware settings : Hardware-Einstellungen
|
||||
@@ -117,6 +118,8 @@ Height : Höhe
|
||||
Help : Hilfe
|
||||
(id\: {}, length\: {}) : (Id: {}, Länge: {})
|
||||
if ({})\: : falls ({}):
|
||||
If checked, tiles behind the train are freed according to the length of the train and the tiles. If it is unchecked, tiles will not get free before route is finished.
|
||||
Falls aktiviert, wird die Strecke anhand von Zug- und Kachel-Länge hinter dem Zug freigegeben, Falls deaktiviert wird die Strecke hinter dem Zug erst bei Abschluss der Route freigegeben.
|
||||
internal contacts : interne Kontakte
|
||||
inverted : invertiert
|
||||
Inverts the direction {} is heading to. : Kehrt die Richtung, in welche {} fährt, um.
|
||||
@@ -136,6 +139,7 @@ Locked by {} : Durch {} besetzt
|
||||
Locomotive manager : Lok-Verwaltung
|
||||
Locomotives\: : Lokomotiven:
|
||||
Locomotives and cars : Lokomotiven und Waggons
|
||||
Loop : Wiederholung
|
||||
Lower speed limit : Minimale Geschwindigkeit
|
||||
Manage cars : Waggons verwalten
|
||||
Manage locos : Lokomotiven verwalten
|
||||
@@ -200,6 +204,7 @@ Select car : Fahrzeug auswählen
|
||||
Select contact\: : Kotakt auswählen:
|
||||
Select display : Anzeige auswählen
|
||||
Select from plan : Auf Plan auswählen
|
||||
Select object : Objekt auswählen
|
||||
Select relay\: : Relais auswählen:
|
||||
Select state : Status auswählen
|
||||
Select train : Zug auswählen
|
||||
@@ -241,6 +246,8 @@ StartStopAuto : Automatikmodus an/abschalten
|
||||
Stop autopilot : Autopilot abschalten
|
||||
{} stopping at next block. : {} hält im nächsten Block.
|
||||
Stopsettings : Halte-Einstellungen
|
||||
StopTrain : Zug stoppen
|
||||
Stop train immediately : Zug sofort anhalten
|
||||
Straight port\: : Port für gerade
|
||||
STRAIGHT : gerade
|
||||
SwitchFunction : Funktion schalten
|
||||
@@ -284,8 +291,12 @@ Turn allowed : Wenden erlaubt
|
||||
{} turned. : {} gewendet.
|
||||
Turnout : Weiche
|
||||
TurnoutLE : WeicheLE
|
||||
TurnoutLN : WeicheLN
|
||||
TurnoutLS : WeicheLS
|
||||
TurnoutLW : WeicheLW
|
||||
TurnoutRE : WeicheRE
|
||||
TurnoutRN : WeicheRN
|
||||
TurnoutRS : WeicheRS
|
||||
TurnoutRW : WeicheRW
|
||||
Turnouts : Weichen
|
||||
TurnTrain : Fahrtrichtung umkehren
|
||||
|
||||
@@ -27,7 +27,9 @@ import de.srsoftware.tools.Tag;
|
||||
import de.srsoftware.web4rail.moving.Car;
|
||||
import de.srsoftware.web4rail.moving.Train;
|
||||
import de.srsoftware.web4rail.tags.Button;
|
||||
import de.srsoftware.web4rail.tags.Checkbox;
|
||||
import de.srsoftware.web4rail.tags.Div;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
import de.srsoftware.web4rail.tags.Form;
|
||||
import de.srsoftware.web4rail.tags.Input;
|
||||
import de.srsoftware.web4rail.tags.Label;
|
||||
@@ -138,6 +140,7 @@ public class Plan extends BaseClass{
|
||||
private static final String LENGTH_UNIT = "length_unit";
|
||||
private static final String CONFIRM = "confirm";
|
||||
private static final String FINAL_SPEED = "final_speed";
|
||||
private static final String FREE_BEHIND_TRAIN = "free_behind_train";
|
||||
|
||||
private ControlUnit controlUnit = new ControlUnit(this); // the control unit, to which the plan is connected
|
||||
private Contact learningContact;
|
||||
@@ -442,10 +445,11 @@ public class Plan extends BaseClass{
|
||||
.forEach(jTiles::put);
|
||||
|
||||
return new JSONObject()
|
||||
.put(TILE, jTiles)
|
||||
.put(SPEED_UNIT, speedUnit)
|
||||
.put(FINAL_SPEED, Route.endSpeed)
|
||||
.put(FREE_BEHIND_TRAIN, Route.freeBehindTrain)
|
||||
.put(LENGTH_UNIT, lengthUnit)
|
||||
.put(FINAL_SPEED, Route.endSpeed);
|
||||
.put(SPEED_UNIT, speedUnit)
|
||||
.put(TILE, jTiles);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,6 +479,7 @@ public class Plan extends BaseClass{
|
||||
if (json.has(LENGTH_UNIT)) lengthUnit = json.getString(LENGTH_UNIT);
|
||||
if (json.has(SPEED_UNIT)) speedUnit = json.getString(SPEED_UNIT);
|
||||
if (json.has(FINAL_SPEED)) Route.endSpeed = json.getInt(FINAL_SPEED);
|
||||
if (json.has(FREE_BEHIND_TRAIN)) Route.freeBehindTrain = json.getBoolean(FREE_BEHIND_TRAIN);
|
||||
|
||||
try {
|
||||
Train.loadAll(filename+".trains",plan);
|
||||
@@ -627,19 +632,21 @@ public class Plan extends BaseClass{
|
||||
if (isSet(tile)) return tile.properties();
|
||||
}
|
||||
|
||||
Window win = new Window("plan-properties", t("Properties of plan"));
|
||||
Window win = new Window("plan-properties", t("Properties of {}",t("Plan")));
|
||||
|
||||
new Tag("h4").content(t("Editable properties")).addTo(win);
|
||||
Fieldset fieldset = new Fieldset(t("Editable properties"));
|
||||
//new Tag("h4").content(t("Editable properties")).addTo(win);
|
||||
Form form = new Form("plan-properties-form");
|
||||
new Input(REALM,REALM_PLAN).hideIn(form);
|
||||
new Input(ACTION,ACTION_UPDATE).hideIn(form);
|
||||
new Input(LENGTH_UNIT, lengthUnit).addTo(new Label(t("Length unit")+":"+NBSP)).addTo(form);
|
||||
new Input(SPEED_UNIT, speedUnit).addTo(new Label(t("Speed unit")+":"+NBSP)).addTo(form);
|
||||
new Input(FINAL_SPEED, Route.endSpeed).addTo(new Label(t("Lower speed limit")+":"+NBSP)).attr("title", t("Final speed after breaking, before halting")).addTo(form);
|
||||
new Checkbox(FREE_BEHIND_TRAIN, t("Free tiles behind train"), Route.freeBehindTrain).attr("title", t("If checked, tiles behind the train are freed according to the length of the train and the tiles. If it is unchecked, tiles will not get free before route is finished.")).addTo(form);
|
||||
new Button(t("Save"), form).addTo(form);
|
||||
form.addTo(win);
|
||||
form.addTo(fieldset).addTo(win);
|
||||
|
||||
new Tag("h4").content(t("Relays and Turnouts")).addTo(win);
|
||||
fieldset = new Fieldset(t("Relays and Turnouts"));
|
||||
Table table = new Table();
|
||||
table.addHead(t("Address"),t("Relay/Turnout"));
|
||||
List<Device> devices = BaseClass.listElements(Tile.class)
|
||||
@@ -654,16 +661,16 @@ public class Plan extends BaseClass{
|
||||
if (device.address() % 4 == 1) table.children().lastElement().clazz("group");
|
||||
|
||||
}
|
||||
table.clazz("turnouts").addTo(win);
|
||||
table.clazz("turnouts").addTo(fieldset).addTo(win);
|
||||
|
||||
new Tag("h4").content(t("Routes")).addTo(win);
|
||||
fieldset = new Fieldset(t("Routes"));
|
||||
table = new Table();
|
||||
table.addHead(t("Name"),t("Start"),t("End"),t("Actions"));
|
||||
List<Route> routes = BaseClass.listElements(Route.class);
|
||||
for (Route route : routes) {
|
||||
table.addRow(route.link("span",route.name()),route.link("span", route.startBlock()),route.link("span", route.endBlock()),plan.button(t("simplify name"), Map.of(ACTION,ACTION_AUTO,ROUTE,route.id().toString())));
|
||||
}
|
||||
table.clazz("turnouts").addTo(win);
|
||||
table.clazz("turnouts").addTo(fieldset).addTo(win);
|
||||
|
||||
return win;
|
||||
}
|
||||
@@ -862,6 +869,7 @@ public class Plan extends BaseClass{
|
||||
if (params.containsKey(LENGTH_UNIT)) lengthUnit = params.get(LENGTH_UNIT);
|
||||
if (params.containsKey(SPEED_UNIT)) speedUnit = params.get(SPEED_UNIT);
|
||||
if (params.containsKey(FINAL_SPEED)) Route.endSpeed = Integer.parseInt(params.get(FINAL_SPEED));
|
||||
Route.freeBehindTrain = "on".equalsIgnoreCase(params.get(FREE_BEHIND_TRAIN));
|
||||
|
||||
return t("Plan updated.");
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import de.srsoftware.web4rail.tags.Fieldset;
|
||||
import de.srsoftware.web4rail.tags.Input;
|
||||
import de.srsoftware.web4rail.tags.Table;
|
||||
import de.srsoftware.web4rail.tiles.Block;
|
||||
import de.srsoftware.web4rail.tiles.BlockContact;
|
||||
import de.srsoftware.web4rail.tiles.Contact;
|
||||
import de.srsoftware.web4rail.tiles.Shadow;
|
||||
import de.srsoftware.web4rail.tiles.Signal;
|
||||
@@ -70,7 +71,7 @@ public class Route extends BaseClass {
|
||||
static final String TURNOUTS = "turnouts";
|
||||
private State state = State.FREE;
|
||||
public static int endSpeed = 10;
|
||||
public static boolean freeBehindTrace = true;
|
||||
public static boolean freeBehindTrain = true;
|
||||
|
||||
private static final String ROUTE_START = "route_start";
|
||||
|
||||
@@ -131,7 +132,8 @@ public class Route extends BaseClass {
|
||||
if (train.speed == 0) aborted = true;
|
||||
while (train.speed > endSpeed) {
|
||||
if (aborted || train.nextRoutePrepared()) break;
|
||||
train.setSpeed(train.speed - 5);
|
||||
LOG.debug("BrakeProcessor({}) setting Speed of {}.",route,train);
|
||||
train.setSpeed(Math.max(train.speed - 5,endSpeed));
|
||||
try {
|
||||
sleep(timeStep);
|
||||
} catch (InterruptedException e) {
|
||||
@@ -904,12 +906,14 @@ public class Route extends BaseClass {
|
||||
|
||||
private void traceTrainFrom(Tile tile) {
|
||||
LOG.debug("{}.traceTrainFrom({})",this,tile);
|
||||
if (isNull(train)) return;
|
||||
Vector<Tile> trace = new Vector<Tile>();
|
||||
if (tile instanceof BlockContact) tile = (Tile) ((BlockContact)tile).parent();
|
||||
for (Tile t:path) {
|
||||
trace.add(t);
|
||||
if (t == tile) break;
|
||||
}
|
||||
if (isSet(train)) train.addToTrace(trace);
|
||||
train.addToTrace(trace);
|
||||
}
|
||||
|
||||
public Train train() {
|
||||
|
||||
@@ -61,8 +61,8 @@ public abstract class Action extends BaseClass {
|
||||
SetSpeed.class,
|
||||
SetTurnout.class,
|
||||
ShowText.class,
|
||||
StopAllTrains.class,
|
||||
StartStopAuto.class,
|
||||
StopTrain.class,
|
||||
SwitchFunction.class,
|
||||
TriggerContact.class,
|
||||
TurnTrain.class
|
||||
|
||||
@@ -20,8 +20,9 @@ import de.srsoftware.web4rail.tiles.Turnout;
|
||||
|
||||
public class Loop extends ActionList {
|
||||
|
||||
private String subject = Train.class.getSimpleName();
|
||||
private static final String SUBJECT = "subject";
|
||||
private String object = Train.class.getSimpleName();
|
||||
private static final String SUBJECT = "subject";
|
||||
private static final String OBJECT = "object";
|
||||
|
||||
public Loop(BaseClass parent) {
|
||||
super(parent);
|
||||
@@ -29,9 +30,9 @@ public class Loop extends ActionList {
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(subject)) return false;
|
||||
if (isNull(object)) return false;
|
||||
List<? extends BaseClass> elements = null;
|
||||
switch (subject) {
|
||||
switch (object) {
|
||||
case "Block":
|
||||
elements = BaseClass.listElements(Block.class);
|
||||
break;
|
||||
@@ -59,29 +60,30 @@ public class Loop extends ActionList {
|
||||
@Override
|
||||
public JSONObject json() {
|
||||
JSONObject json = super.json();
|
||||
if (isSet(subject)) json.put(SUBJECT, subject);
|
||||
if (isSet(object)) json.put(OBJECT, object);
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action load(JSONObject json) {
|
||||
super.load(json);
|
||||
if (json.has(SUBJECT)) subject = json.getString(SUBJECT);
|
||||
if (json.has(SUBJECT)) object = json.getString(SUBJECT);
|
||||
if (json.has(OBJECT)) object = json.getString(OBJECT);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm) {
|
||||
formInputs.add(t("Select subject"),typeSelector());
|
||||
formInputs.add(t("Select object"),typeSelector());
|
||||
return super.properties(preForm, formInputs, postForm);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return t("For each {} do:",subject);
|
||||
return t("For each {} do:",object);
|
||||
};
|
||||
|
||||
private Tag typeSelector() {
|
||||
Select select = new Select(SUBJECT);
|
||||
Select select = new Select(OBJECT);
|
||||
List<String> types = List.of(Block.class,Contact.class,Route.class,Signal.class,Train.class,Turnout.class)
|
||||
.stream()
|
||||
.map(cls -> cls.getSimpleName())
|
||||
@@ -89,7 +91,7 @@ public class Loop extends ActionList {
|
||||
.collect(Collectors.toList());
|
||||
for (String cls : types) {
|
||||
Tag option = select.addOption(cls,t(cls));
|
||||
if (cls.equals(subject)) option.attr("selected", "selected");
|
||||
if (cls.equals(object)) option.attr("selected", "selected");
|
||||
}
|
||||
return select;
|
||||
}
|
||||
@@ -97,8 +99,8 @@ public class Loop extends ActionList {
|
||||
@Override
|
||||
protected Object update(HashMap<String, String> params) {
|
||||
LOG.debug("update: {}",params);
|
||||
String newSubject = params.get(SUBJECT);
|
||||
if (isSet(newSubject)) subject = newSubject;
|
||||
String newObject = params.get(OBJECT);
|
||||
if (isSet(newObject)) object = newObject;
|
||||
return super.update(params);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package de.srsoftware.web4rail.actions;
|
||||
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
import de.srsoftware.web4rail.moving.Train;
|
||||
|
||||
public class StopAllTrains extends Action {
|
||||
|
||||
public StopAllTrains(BaseClass parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context) {
|
||||
BaseClass.listElements(Train.class).forEach(train -> train.stopNow());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
23
src/main/java/de/srsoftware/web4rail/actions/StopTrain.java
Normal file
23
src/main/java/de/srsoftware/web4rail/actions/StopTrain.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package de.srsoftware.web4rail.actions;
|
||||
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
|
||||
public class StopTrain extends Action{
|
||||
|
||||
public StopTrain(BaseClass parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(context.train())) return false;
|
||||
LOG.debug("{}.fire() called, context = {}",this,context);
|
||||
context.train().stopNow();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return t("Stop train immediately");
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
if (stop) return;
|
||||
if (isNull(route)) { // may have been set by start action in between
|
||||
Object o = Train.this.start();
|
||||
LOG.debug("Train.start called, route now is {}",route);
|
||||
LOG.debug("{}.start called, route now is {}",this,route);
|
||||
if (isSet(route)) {
|
||||
if (o instanceof String) plan.stream((String)o);
|
||||
//if (isSet(destination)) Thread.sleep(1000); // limit load on PathFinder
|
||||
@@ -190,10 +190,12 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
if (active) {
|
||||
trace.addFirst(tile);
|
||||
} else {
|
||||
Tile dummy = trace.getFirst();
|
||||
if (dummy == tile) active = true;
|
||||
if (trace.getFirst() == tile) active = true;
|
||||
}
|
||||
}
|
||||
if (!active) { // newTiles and old trace do not "touch" : add all new tiles
|
||||
for (Tile tile : newTiles) trace.addFirst(tile);
|
||||
}
|
||||
Route.LOG.debug("new trace: {}",trace);
|
||||
showTrace();
|
||||
}
|
||||
@@ -636,7 +638,6 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
while (!trace.isEmpty()) reversed.addFirst(trace.removeFirst());
|
||||
trace = reversed;
|
||||
LOG.debug("reversed: {}",trace);
|
||||
reversed = null;
|
||||
}
|
||||
|
||||
public static void saveAll(String filename) throws IOException {
|
||||
@@ -714,6 +715,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
|
||||
public void setSpeed(int newSpeed) {
|
||||
LOG.debug("{}.setSpeed({})",this,newSpeed);
|
||||
if (speed == 0 && newSpeed > 0) Thread.dumpStack();
|
||||
speed = Math.min(newSpeed,maxSpeed());
|
||||
if (speed < 0) speed = 0;
|
||||
cars.stream().filter(c -> c instanceof Locomotive).forEach(car -> ((Locomotive)car).setSpeed(speed));
|
||||
@@ -741,7 +743,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
||||
tile.setTrain(this);
|
||||
} else {
|
||||
tile.setTrain(null);
|
||||
if (Route.freeBehindTrace) try {
|
||||
if (Route.freeBehindTrain) try {
|
||||
tile.unset(route);
|
||||
} catch (IllegalArgumentException e) {}
|
||||
trace.remove(i);
|
||||
|
||||
@@ -81,8 +81,6 @@ public class Contact extends Tile{
|
||||
context = route.context();
|
||||
actions.fire(context);
|
||||
route.contact(this);
|
||||
} else if (getClass() != Contact.class) {
|
||||
plan.warn(this);
|
||||
}
|
||||
if (isNull(context)) {
|
||||
context = new Context(this);
|
||||
|
||||
Reference in New Issue
Block a user