implemented directional speeds and turning of train
This commit is contained in:
2
pom.xml
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.2.33</version>
|
<version>1.2.34</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>
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ public class Car extends BaseClass implements Comparable<Car>{
|
|||||||
return car.moveUp();
|
return car.moveUp();
|
||||||
case ACTION_PROPS:
|
case ACTION_PROPS:
|
||||||
return car == null ? Car.manager() : car.properties();
|
return car == null ? Car.manager() : car.properties();
|
||||||
|
case ACTION_TURN:
|
||||||
|
return car.turn();
|
||||||
case ACTION_UPDATE:
|
case ACTION_UPDATE:
|
||||||
return car.update(params);
|
return car.update(params);
|
||||||
}
|
}
|
||||||
@@ -198,7 +200,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int maxSpeed() {
|
public int maxSpeed() {
|
||||||
return maxSpeedForward;
|
return orientation == FORWARD ? maxSpeedForward : maxSpeedReverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Window moveUp() {
|
protected Window moveUp() {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import java.util.Map;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import de.srsoftware.tools.Tag;
|
import de.srsoftware.tools.Tag;
|
||||||
|
import de.srsoftware.web4rail.BaseClass;
|
||||||
import de.srsoftware.web4rail.Command;
|
import de.srsoftware.web4rail.Command;
|
||||||
import de.srsoftware.web4rail.Constants;
|
import de.srsoftware.web4rail.Constants;
|
||||||
import de.srsoftware.web4rail.Device;
|
import de.srsoftware.web4rail.Device;
|
||||||
@@ -232,13 +233,14 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
new Tag("p").content(t("Click on a name to edit the entry.")).addTo(win);
|
new Tag("p").content(t("Click on a name to edit the entry.")).addTo(win);
|
||||||
|
|
||||||
Table table = new Table().addHead(t("Stock ID"),t("Name"),t("Max. Speed",speedUnit),t("Protocol"),t("Address"),t("Length"),t("Tags"));
|
Table table = new Table().addHead(t("Stock ID"),t("Name"),t("Max. Speed",speedUnit),t("Protocol"),t("Address"),t("Length"),t("Tags"));
|
||||||
cars.values()
|
List<Locomotive> locos = BaseClass.listElements(Locomotive.class);
|
||||||
.stream()
|
locos.sort(Comparator.comparing(loco -> loco.address));
|
||||||
.filter(car -> car instanceof Locomotive)
|
locos.sort(Comparator.comparing(loco -> loco.stockId));
|
||||||
.map(car -> (Locomotive)car)
|
for (Locomotive loco : locos) {
|
||||||
.sorted(Comparator.comparing(loco -> loco.address))
|
String maxSpeed = (loco.maxSpeedForward == 0 ? "–":""+loco.maxSpeedForward)+NBSP;
|
||||||
.sorted(Comparator.comparing(loco -> loco.stockId))
|
if (loco.maxSpeedReverse != loco.maxSpeedForward) maxSpeed += "("+loco.maxSpeedReverse+")"+NBSP;
|
||||||
.forEach(loco -> table.addRow(loco.stockId,loco.link(),loco.maxSpeedForward == 0 ? "–":loco.maxSpeedForward+NBSP+speedUnit,loco.proto,loco.address,loco.length+NBSP+lengthUnit,String.join(", ", loco.tags())));
|
table.addRow(loco.stockId,loco.link(),maxSpeed+speedUnit,loco.proto,loco.address,loco.length+NBSP+lengthUnit,String.join(", ", loco.tags()));
|
||||||
|
}
|
||||||
table.addTo(win);
|
table.addTo(win);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.io.FileWriter;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@@ -215,12 +216,12 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
Tag locoProp = new Tag("li").content(t("Locomotives and cars:"));
|
Tag locoProp = new Tag("li").content(t("Locomotives and cars:"));
|
||||||
Tag carList = new Tag("ul").clazz("carlist");
|
Tag carList = new Tag("ul").clazz("carlist");
|
||||||
|
|
||||||
for (Car loco : this.cars) {
|
for (Car car : this.cars) {
|
||||||
Tag li = new Tag("li");
|
Tag li = new Tag("li");
|
||||||
loco.link(loco.name()+(loco.stockId.isEmpty() ? "" : " ("+loco.stockId+")")).addTo(li).content(NBSP);
|
car.link(car.name()+(car.stockId.isEmpty() ? "" : " ("+car.stockId+")")).addTo(li).content(NBSP);
|
||||||
loco.button(t("turn within train"),Map.of(ACTION,ACTION_TURN)).addTo(li);
|
car.button(t("turn within train"),Map.of(ACTION,ACTION_TURN)).addTo(li);
|
||||||
loco.button("↑",Map.of(ACTION,ACTION_MOVE)).addTo(li);
|
car.button("↑",Map.of(ACTION,ACTION_MOVE)).addTo(li);
|
||||||
button(t("delete"),Map.of(ACTION,ACTION_DROP,LOCO_ID,loco.id().toString())).addTo(li);
|
button(t("delete"),Map.of(ACTION,ACTION_DROP,LOCO_ID,car.id().toString())).addTo(li);
|
||||||
li.addTo(carList);
|
li.addTo(carList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -769,6 +770,9 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
|
|
||||||
public Tag turn() {
|
public Tag turn() {
|
||||||
LOG.debug("train.turn()");
|
LOG.debug("train.turn()");
|
||||||
|
|
||||||
|
for (Car car : cars) car.turn();
|
||||||
|
Collections.reverse(cars);
|
||||||
if (isSet(direction)) {
|
if (isSet(direction)) {
|
||||||
direction = direction.inverse();
|
direction = direction.inverse();
|
||||||
reverseTrace();
|
reverseTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user