added new reverse option

This commit is contained in:
Stephan Richter
2020-12-13 15:53:32 +01:00
parent 438befa969
commit e9b950fd51
6 changed files with 41 additions and 16 deletions

View File

@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.srsoftware</groupId>
<artifactId>web4rail</artifactId>
<version>1.2.45</version>
<version>1.2.46</version>
<name>Web4Rail</name>
<packaging>jar</packaging>
<description>Java Model Railway Control</description>

View File

@@ -100,6 +100,7 @@ export : exportieren
Faster (10 {}) : 10 {} schneller
Firing {} : starte {}
FinishRoute : Route abschließen
For each {} do: Für jede(n) {}:
forward : vorwärts
Found {} routes. : {} Routen gefunden.
FreeStartBlock : Start-Block freigeben
@@ -111,6 +112,7 @@ Help : Hilfe
(id\: {}, length\: {}) : (Id: {}, Länge: {})
if ({})\: : falls ({}):
inverted : invertiert
Inverts the direction {} is heading to. : Kehrt die Richtung, in welche {} fährt, um.
{} is oriented {} : {} ist {} gerichtet
known cars : bekannte Waggons
known locomotives : bekannte Lokomotiven
@@ -171,7 +173,7 @@ quit autopilot : Autopilot beenden
Relays and Turnouts : Relais und Weichen
Relay/Turnout : Relais/Weiche
Report Issue : Problem melden
reverse : rückwärts
reverse : wenden
Reversed {}. : {} umgedreht.
RIGHT : rechts
Right port\: : Port für rechts
@@ -272,6 +274,7 @@ TurnoutRW : WeicheRW
Turnouts : Weichen
TurnTrain : Fahrtrichtung umkehren
turn within train : innerhalb des Zugs drehen
Turns the train, as if it went through a loop. : Dreht den ZUg, als wenn er eine Wendeschleife passiert hätte.
Unknown action\: {} : Unbekannte Aktion: {}
unset : ungesetzt
Wait {} ms, then\: : {} ms warten, dann:

View File

@@ -265,7 +265,7 @@ public class Route extends BaseClass {
private Fieldset basicProperties() {
Fieldset fieldset = new Fieldset(t("Route properties"));
if (isSet(train)) train.link("span",t("Train: {}",train)).addTo(fieldset);
if (isSet(train)) train.link("span",t("Train")+": "+train).addTo(fieldset);
Tag list = new Tag("ul");
Plan.addLink(startBlock, t("Origin: {} to {}",startBlock.name,startDirection), list);
Plan.addLink(endBlock, t("Destination: {} from {}",endBlock.name,endDirection.inverse()), list);

View File

@@ -232,7 +232,7 @@ public class Car extends BaseClass implements Comparable<Car>{
formInputs.add(t("Tags"), new Input(TAGS,String.join(", ", tags)));
Tag div = new Tag("div");
new Input(MAX_SPEED, maxSpeedForward).numeric().addTo(new Tag("p")).content(NBSP+speedUnit+NBSP+t("forward")).addTo(div);
new Input(MAX_SPEED_REVERSE, maxSpeedReverse).numeric().addTo(new Tag("p")).content(NBSP+speedUnit+NBSP+t("reverse")).addTo(div);
new Input(MAX_SPEED_REVERSE, maxSpeedReverse).numeric().addTo(new Tag("p")).content(NBSP+speedUnit+NBSP+t("backward")).addTo(div);
formInputs.add(t("Maximum Speed"),div);
Fieldset fieldset = new Fieldset(t("Train"));

View File

@@ -122,7 +122,7 @@ public class Locomotive extends Car implements Constants,Device{
}
params.put(ACTION, ACTION_TURN);
new Button(t("Turn"),params).clazz(ACTION_TURN).addTo(direction);
new Button(t("Turn"),params).title(t("Inverts the direction {} is heading to.",locoOrTrain)).clazz(ACTION_TURN).addTo(direction);
if (isSet(train)) {
Block currentBlock = train.currentBlock();
@@ -149,7 +149,6 @@ public class Locomotive extends Car implements Constants,Device{
});
functions.addTo(fieldset);
return fieldset;
}

View File

@@ -72,6 +72,8 @@ public class Train extends BaseClass implements Comparable<Train> {
private static final String DESTINATION = "destination";
private static final String ACTION_REVERSE = "reverse";
private HashSet<String> tags = new HashSet<String>();
private boolean f1,f2,f3,f4;
@@ -157,6 +159,8 @@ public class Train extends BaseClass implements Comparable<Train> {
return train.properties();
case ACTION_QUIT:
return train.quitAutopilot();
case ACTION_REVERSE:
return train.reverse();
case ACTION_SLOWER10:
return train.slower(10);
case ACTION_START:
@@ -501,7 +505,10 @@ public class Train extends BaseClass implements Comparable<Train> {
carList().addTo(propList);
if (isSet(currentBlock)) currentBlock.button(currentBlock.toString()).addTo(new Tag("li").content(t("Current location:")+NBSP)).addTo(propList);
if (isSet(direction)) new Tag("li").content(t("Direction: heading {}",direction)).addTo(propList);
Tag directionLi = null;
if (isSet(direction)) directionLi = new Tag("li").content(t("Direction: heading {}",direction)+NBSP);
if (isNull(directionLi)) directionLi = new Tag("li");
button(t("reverse"), Map.of(ACTION,ACTION_REVERSE)).title(t("Turns the train, as if it went through a loop.")).addTo(directionLi).addTo(propList);
Tag dest = new Tag("li").content(t("Destination:")+NBSP);
if (isNull(destination)) {
@@ -584,6 +591,22 @@ public class Train extends BaseClass implements Comparable<Train> {
}
}
/**
* This turns the train as if it went through a loop. Example:
* before: CabCar→ MiddleCar→ Loco→
* after: ←Loco ←MiddleCar ←CabCar
*/
private Tag reverse() {
LOG.debug("train.reverse();");
if (isSet(direction)) {
direction = direction.inverse();
reverseTrace();
}
if (isSet(currentBlock)) plan.place(currentBlock);
return properties();
}
private void reverseTrace() {
LinkedList<Tile> reversed = new LinkedList<Tile>();
LOG.debug("Trace: {}",trace);
@@ -808,17 +831,17 @@ public class Train extends BaseClass implements Comparable<Train> {
return name();
}
/**
* this inverts the direction the train is heading to. Example:
* before: CabCar→ MiddleCar→ Loco→
* after: ←CabCar ←MiddleCar ←Loco
* @return
*/
public Tag turn() {
LOG.debug("train.turn()");
for (Car car : cars) car.turn();
Collections.reverse(cars);
if (isSet(direction)) {
direction = direction.inverse();
reverseTrace();
}
if (isSet(currentBlock)) plan.place(currentBlock);
return properties();
return reverse();
}
protected Train update(HashMap<String, String> params) {