preparing directional speed of all cars
This commit is contained in:
@@ -91,6 +91,7 @@ export : exportieren
|
||||
Faster (10 {}) : 10 {} schneller
|
||||
Firing {} : starte {}
|
||||
FinishRoute : Route abschließen
|
||||
forward : vorwärts
|
||||
Found {} routes. : {} Routen gefunden.
|
||||
FreeStartBlock : Start-Block freigeben
|
||||
Fullscreen : Vollbild
|
||||
@@ -156,6 +157,7 @@ quit autopilot : Autopilot beenden
|
||||
{} reached it`s destination! : {} ist am Ziel angekommen!
|
||||
Relay/Turnout : Relais/Weiche
|
||||
Report Issue : Problem melden
|
||||
reverse : rückwärts
|
||||
RIGHT : rechts
|
||||
Right port\: : Port für rechts
|
||||
Routes using this tile : Fahrstraßen, die diesen Abschnitt verwenden
|
||||
@@ -210,7 +212,6 @@ STRAIGHT : gerade
|
||||
Switch power off : Strom ausschalten
|
||||
Switch power on : Strom anschalten
|
||||
SYSTEM : Betriebssystem
|
||||
Tag : Markierung
|
||||
Tags : Markierungen
|
||||
Text to display on clients\: : Text, welcher auf den Clients angezeigt werden soll:
|
||||
Text to show on display\: : Text, welcher in der Anzeige dargestellt werden soll:
|
||||
|
||||
@@ -34,17 +34,22 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
static HashMap<Id,Car> cars = new HashMap<Id, Car>();
|
||||
|
||||
public static final String NAME = "name";
|
||||
public static boolean FORWARD = true;
|
||||
public static boolean REVERSE = false;
|
||||
private static final String LENGTH = "length";
|
||||
private static final String STOCK_ID = "stock-id";
|
||||
private static final String TAGS = "tags";
|
||||
private static final String MAX_SPEED = "max_speed";
|
||||
private static final String MAX_SPEED_REVERSE = "max_speed_reverse";
|
||||
protected HashSet<String> tags = new HashSet<String>();
|
||||
|
||||
private String name;
|
||||
public int length;
|
||||
protected String stockId = "";
|
||||
private Train train;
|
||||
protected int maxSpeed = 0;
|
||||
protected int maxSpeedForward = 0;
|
||||
protected int maxSpeedReverse = 0;
|
||||
private boolean orientation = FORWARD;
|
||||
|
||||
public Car(String name) {
|
||||
this(name,null);
|
||||
@@ -78,7 +83,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
|
||||
public Car clone() {
|
||||
Car clone = new Car(name);
|
||||
clone.maxSpeed = maxSpeed;
|
||||
clone.maxSpeedForward = maxSpeedForward;
|
||||
clone.length = length;
|
||||
clone.tags = new HashSet<String>(tags);
|
||||
clone.notes = notes;
|
||||
@@ -99,7 +104,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
JSONObject json = super.json();
|
||||
json.put(NAME, name);
|
||||
json.put(LENGTH, length);
|
||||
if (maxSpeed != 0) json.put(MAX_SPEED, maxSpeed);
|
||||
if (maxSpeedForward != 0) json.put(MAX_SPEED, maxSpeedForward);
|
||||
json.put(STOCK_ID, stockId);
|
||||
if (!tags.isEmpty()) json.put(TAGS, tags);
|
||||
return json;
|
||||
@@ -137,7 +142,11 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
public Car load(JSONObject json) {
|
||||
super.load(json);
|
||||
if (json.has(LENGTH)) length = json.getInt(LENGTH);
|
||||
if (json.has(MAX_SPEED)) maxSpeed = json.getInt(MAX_SPEED);
|
||||
if (json.has(MAX_SPEED)) {
|
||||
maxSpeedForward = json.getInt(MAX_SPEED);
|
||||
maxSpeedReverse = maxSpeedForward;
|
||||
}
|
||||
if (json.has(MAX_SPEED_REVERSE)) maxSpeedReverse = json.getInt(MAX_SPEED_REVERSE);
|
||||
if (json.has(STOCK_ID)) stockId = json.getString(STOCK_ID);
|
||||
if (json.has(TAGS)) json.getJSONArray(TAGS).forEach(elem -> { tags.add(elem.toString()); });
|
||||
return this;
|
||||
@@ -163,7 +172,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
.forEach(car -> table.addRow(
|
||||
car.stockId,
|
||||
car.link(),
|
||||
car.maxSpeed == 0 ? "–":(car.maxSpeed+NBSP+speedUnit),
|
||||
car.maxSpeedForward == 0 ? "–":(car.maxSpeedForward+NBSP+speedUnit),
|
||||
car.length+NBSP+lengthUnit,
|
||||
isSet(car.train) ? car.train.link("span", car.train) : "",
|
||||
String.join(", ", car.tags()),
|
||||
@@ -182,7 +191,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
}
|
||||
|
||||
public int maxSpeed() {
|
||||
return maxSpeed;
|
||||
return maxSpeedForward;
|
||||
}
|
||||
|
||||
String name(){
|
||||
@@ -194,8 +203,11 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
formInputs.add(t("Name"),new Input(NAME,name));
|
||||
formInputs.add(t("Stock ID"),new Input(STOCK_ID,stockId));
|
||||
formInputs.add(t("Length"),new Input(LENGTH,length).attr("type", "number").addTo(new Tag("span")).content(NBSP+lengthUnit));
|
||||
formInputs.add(t("Tag"), new Input(TAGS,String.join(", ", tags)));
|
||||
formInputs.add(t("Maximum Speed"),new Input(MAX_SPEED, maxSpeed).numeric().addTo(new Tag("span")).content(NBSP+speedUnit));
|
||||
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);
|
||||
formInputs.add(t("Maximum Speed"),div);
|
||||
|
||||
Fieldset fieldset = new Fieldset(t("Train"));
|
||||
if (train != null) train.link().addTo(fieldset);
|
||||
@@ -243,7 +255,8 @@ public class Car extends BaseClass implements Comparable<Car>{
|
||||
super.update(params);
|
||||
if (params.containsKey(NAME)) name = params.get(NAME).trim();
|
||||
if (params.containsKey(LENGTH)) length = Integer.parseInt(params.get(LENGTH));
|
||||
if (params.containsKey(MAX_SPEED)) maxSpeed = Integer.parseInt(params.get(MAX_SPEED));
|
||||
if (params.containsKey(MAX_SPEED)) maxSpeedForward = Integer.parseInt(params.get(MAX_SPEED));
|
||||
if (params.containsKey(MAX_SPEED_REVERSE)) maxSpeedReverse = Integer.parseInt(params.get(MAX_SPEED_REVERSE));
|
||||
if (params.containsKey(STOCK_ID)) stockId = params.get(STOCK_ID);
|
||||
if (params.containsKey(TAGS)) {
|
||||
String[] parts = params.get(TAGS).replace(",", " ").split(" ");
|
||||
|
||||
@@ -237,7 +237,7 @@ public class Locomotive extends Car implements Constants,Device{
|
||||
.map(car -> (Locomotive)car)
|
||||
.sorted(Comparator.comparing(loco -> loco.address))
|
||||
.sorted(Comparator.comparing(loco -> loco.stockId))
|
||||
.forEach(loco -> table.addRow(loco.stockId,loco.link(),loco.maxSpeed == 0 ? "–":loco.maxSpeed+NBSP+speedUnit,loco.proto,loco.address,loco.length+NBSP+lengthUnit,String.join(", ", loco.tags())));
|
||||
.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.addTo(win);
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ public class Locomotive extends Car implements Constants,Device{
|
||||
}
|
||||
|
||||
private void queue() {
|
||||
int step = proto.steps * speed / (maxSpeed == 0 ? 100 : maxSpeed);
|
||||
int step = proto.steps * speed / (maxSpeedForward == 0 ? 100 : maxSpeedForward);
|
||||
plan.queue(new Command("SET {} GL "+address+" "+(reverse?1:0)+" "+step+" "+proto.steps+" "+(f1?1:0)+" "+(f2?1:0)+" "+(f3?1:0)+" "+(f4?1:0)) {
|
||||
|
||||
@Override
|
||||
@@ -284,7 +284,7 @@ public class Locomotive extends Car implements Constants,Device{
|
||||
LOG.debug(this.detail()+".setSpeed({})",newSpeed);
|
||||
init();
|
||||
speed = newSpeed;
|
||||
if (speed > maxSpeed && maxSpeed > 0) speed = maxSpeed();
|
||||
if (speed > maxSpeedForward && maxSpeedForward > 0) speed = maxSpeed();
|
||||
if (speed < 0) speed = 0;
|
||||
|
||||
queue();
|
||||
|
||||
Reference in New Issue
Block a user