* verbesserte Geschwindigkeitsregelung
* erweiterung der Aktion „Zug in Block bestimmen“ * verbesserungen beim Rangieren
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.4.30</version>
|
<version>1.4.31</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>
|
||||||
|
|||||||
@@ -448,3 +448,93 @@ svg.Block.disabled text{
|
|||||||
#history table td:nth-child(2) {
|
#history table td:nth-child(2) {
|
||||||
padding-left: 30px;
|
padding-left: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input[type=range] {
|
||||||
|
height: 39px;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 10px 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
input[type=range]:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
input[type=range]::-webkit-slider-runnable-track {
|
||||||
|
width: 100%;
|
||||||
|
height: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
animate: 0.2s;
|
||||||
|
box-shadow: 1px 1px 1px #000000;
|
||||||
|
background: #3071A9;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #000000;
|
||||||
|
}
|
||||||
|
input[type=range]::-webkit-slider-thumb {
|
||||||
|
box-shadow: 1px 1px 1px #000000;
|
||||||
|
border: 2px solid #000000;
|
||||||
|
height: 30px;
|
||||||
|
width: 30px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
cursor: pointer;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin-top: -11.5px;
|
||||||
|
}
|
||||||
|
input[type=range]:focus::-webkit-slider-runnable-track {
|
||||||
|
background: #3071A9;
|
||||||
|
}
|
||||||
|
input[type=range]::-moz-range-track {
|
||||||
|
width: 100%;
|
||||||
|
height: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
animate: 0.2s;
|
||||||
|
box-shadow: 1px 1px 1px #000000;
|
||||||
|
background: #3071A9;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #000000;
|
||||||
|
}
|
||||||
|
input[type=range]::-moz-range-thumb {
|
||||||
|
box-shadow: 1px 1px 1px #000000;
|
||||||
|
border: 2px solid #000000;
|
||||||
|
height: 30px;
|
||||||
|
width: 30px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
input[type=range]::-ms-track {
|
||||||
|
width: 100%;
|
||||||
|
height: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
animate: 0.2s;
|
||||||
|
background: transparent;
|
||||||
|
border-color: transparent;
|
||||||
|
color: transparent;
|
||||||
|
}
|
||||||
|
input[type=range]::-ms-fill-lower {
|
||||||
|
background: #3071A9;
|
||||||
|
border: 1px solid #000000;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 1px 1px 1px #000000;
|
||||||
|
}
|
||||||
|
input[type=range]::-ms-fill-upper {
|
||||||
|
background: #3071A9;
|
||||||
|
border: 1px solid #000000;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 1px 1px 1px #000000;
|
||||||
|
}
|
||||||
|
input[type=range]::-ms-thumb {
|
||||||
|
margin-top: 1px;
|
||||||
|
box-shadow: 1px 1px 1px #000000;
|
||||||
|
border: 2px solid #000000;
|
||||||
|
height: 30px;
|
||||||
|
width: 30px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
input[type=range]:focus::-ms-fill-lower {
|
||||||
|
background: #3071A9;
|
||||||
|
}
|
||||||
|
input[type=range]:focus::-ms-fill-upper {
|
||||||
|
background: #3071A9;
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,6 +65,17 @@ function assign(context){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeSpeed(inputId){
|
||||||
|
console.log(inputId);
|
||||||
|
let parts = inputId.split('_');
|
||||||
|
let val = $('#'+inputId).val();
|
||||||
|
let data = { realm : parts[0], id : parts[1], action : "setSpeed", speed : val};
|
||||||
|
console.log(data);
|
||||||
|
let caption = $('#'+inputId+'_caption');
|
||||||
|
caption.text(caption.text().replace(/\d+/,val));
|
||||||
|
request(data);
|
||||||
|
}
|
||||||
|
|
||||||
function clickLegend(ev){
|
function clickLegend(ev){
|
||||||
lastTab = ev.data;
|
lastTab = ev.data;
|
||||||
$('.window > .tabs > legend').removeClass('front');
|
$('.window > .tabs > legend').removeClass('front');
|
||||||
@@ -76,7 +87,7 @@ function clickLegend(ev){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clickTile(x,y,shift){
|
function clickTile(x,y,shift){
|
||||||
console.log("clickTile("+x+","+y+")");
|
console.log("clickTile("+x+","+y+")");
|
||||||
var id = x+"-"+y;
|
var id = x+"-"+y;
|
||||||
var tiles = $('#'+id);
|
var tiles = $('#'+id);
|
||||||
if (tiles.length > 0) {
|
if (tiles.length > 0) {
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ Event : Ereignis
|
|||||||
Faster ({} {}) : {} {} schneller
|
Faster ({} {}) : {} {} schneller
|
||||||
Final speed after breaking, before halting : Endgeschwindigkeit nach Bremsvorgang, vor dem Anhalten
|
Final speed after breaking, before halting : Endgeschwindigkeit nach Bremsvorgang, vor dem Anhalten
|
||||||
FinishRoute : Route abschließen
|
FinishRoute : Route abschließen
|
||||||
|
first parked train : ersten abgestellten Zug wählen
|
||||||
Firing {} : starte {}
|
Firing {} : starte {}
|
||||||
For each {} do : Mit jedem {}
|
For each {} do : Mit jedem {}
|
||||||
forward : vorwärts
|
forward : vorwärts
|
||||||
@@ -192,6 +193,7 @@ Inverts the direction {} is heading to. : Kehrt die Richtung, in welche {} fähr
|
|||||||
{} is off : {} ist Aus
|
{} is off : {} ist Aus
|
||||||
{} is on : {} ist Ein
|
{} is on : {} ist Ein
|
||||||
{} is oriented {} : {} ist {} gerichtet
|
{} is oriented {} : {} ist {} gerichtet
|
||||||
|
JSON code of {} : JSON-Code von {}
|
||||||
known cars : bekannte Waggons
|
known cars : bekannte Waggons
|
||||||
known locomotives : bekannte Lokomotiven
|
known locomotives : bekannte Lokomotiven
|
||||||
known trains : bekannte Züge
|
known trains : bekannte Züge
|
||||||
@@ -235,6 +237,7 @@ new locomotive : neue Lok
|
|||||||
new tag : neue Markierung
|
new tag : neue Markierung
|
||||||
new train : neuer Zug
|
new train : neuer Zug
|
||||||
No : keine
|
No : keine
|
||||||
|
No direct route from {} to {} : keine direkte Verbindung von {} zu {}
|
||||||
No free routes from {} : keine Route von {} frei
|
No free routes from {} : keine Route von {} frei
|
||||||
NORTH : Norden
|
NORTH : Norden
|
||||||
Not connected to other bridge part! : Nicht mit anderem Brücken-Teil verbunden!
|
Not connected to other bridge part! : Nicht mit anderem Brücken-Teil verbunden!
|
||||||
@@ -262,6 +265,7 @@ other train properties : andere Zug-Eigenschaften
|
|||||||
other trains in {} : andere Züge in {}
|
other trains in {} : andere Züge in {}
|
||||||
Origin and destination : Start und Ziel
|
Origin and destination : Start und Ziel
|
||||||
Origin\: {} to {} : Start: {} nach {}
|
Origin\: {} to {} : Start: {} nach {}
|
||||||
|
parked train : abgestellter Zug
|
||||||
parked trains : abgestellte Züge
|
parked trains : abgestellte Züge
|
||||||
Plan saved as "{}". : Plan als „{}“ gespeichert.
|
Plan saved as "{}". : Plan als „{}“ gespeichert.
|
||||||
Plan updated. : Plan aktualisiert.
|
Plan updated. : Plan aktualisiert.
|
||||||
@@ -336,6 +340,7 @@ SetTurnout : Weiche stellen
|
|||||||
Setup actions : Vorbereitung-Aktionen
|
Setup actions : Vorbereitung-Aktionen
|
||||||
ShowText : Text anzeigen
|
ShowText : Text anzeigen
|
||||||
Shunting : Rangieren
|
Shunting : Rangieren
|
||||||
|
shunting destination : Rangier-Ziel
|
||||||
Signals : Signale
|
Signals : Signale
|
||||||
simplify all names : alle Namen vereinfachen
|
simplify all names : alle Namen vereinfachen
|
||||||
simplify name : Name vereinfachen
|
simplify name : Name vereinfachen
|
||||||
@@ -435,6 +440,7 @@ Turns the train, as if it went through a loop. : Dreht den ZUg, als wenn er eine
|
|||||||
Unknown action\: {} : Unbekannte Aktion: {}
|
Unknown action\: {} : Unbekannte Aktion: {}
|
||||||
Use negative number to count from end. : Nutze negative Nummern, um von Ende zu zählen.
|
Use negative number to count from end. : Nutze negative Nummern, um von Ende zu zählen.
|
||||||
unset : ungesetzt
|
unset : ungesetzt
|
||||||
|
update : aktualisieren
|
||||||
value : Wert
|
value : Wert
|
||||||
WaitForContact : Auf Kontakt warten
|
WaitForContact : Auf Kontakt warten
|
||||||
Wait for {}, then : auf {} warten, dann
|
Wait for {}, then : auf {} warten, dann
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public interface Constants {
|
|||||||
public static final String ACTION_PROPS = "props";
|
public static final String ACTION_PROPS = "props";
|
||||||
public static final String ACTION_QUIT = "quit";
|
public static final String ACTION_QUIT = "quit";
|
||||||
public static final String ACTION_SAVE = "save";
|
public static final String ACTION_SAVE = "save";
|
||||||
|
public static final String ACTION_SET_SPEED = "setSpeed";
|
||||||
public static final String ACTION_SLOWER10 = "slower10";
|
public static final String ACTION_SLOWER10 = "slower10";
|
||||||
public static final String ACTION_START = "start";
|
public static final String ACTION_START = "start";
|
||||||
public static final String ACTION_STOP = "stop";
|
public static final String ACTION_STOP = "stop";
|
||||||
@@ -36,6 +37,7 @@ public interface Constants {
|
|||||||
public static final String ACTION_TOGGLE_F2 = "f2";
|
public static final String ACTION_TOGGLE_F2 = "f2";
|
||||||
public static final String ACTION_TOGGLE_F3 = "f3";
|
public static final String ACTION_TOGGLE_F3 = "f3";
|
||||||
public static final String ACTION_TOGGLE_F4 = "f4";
|
public static final String ACTION_TOGGLE_F4 = "f4";
|
||||||
|
public static final String ACTION_TOGGLE_SHUNTING = "shunt";
|
||||||
public static final String ACTION_TURN = "turn";
|
public static final String ACTION_TURN = "turn";
|
||||||
public static final String ACTION_UPDATE = "update";
|
public static final String ACTION_UPDATE = "update";
|
||||||
|
|
||||||
@@ -75,6 +77,7 @@ public interface Constants {
|
|||||||
public static final String RELAY = "relay";
|
public static final String RELAY = "relay";
|
||||||
public static final String RESERVED = "reserved";
|
public static final String RESERVED = "reserved";
|
||||||
public static final String ROUTE = "route";
|
public static final String ROUTE = "route";
|
||||||
|
public static final String SPEED = "speed";
|
||||||
public static final String STATE = "state";
|
public static final String STATE = "state";
|
||||||
public static final String TIME = "time";
|
public static final String TIME = "time";
|
||||||
public static final String TURNOUT = "turnout";
|
public static final String TURNOUT = "turnout";
|
||||||
|
|||||||
@@ -392,8 +392,10 @@ public class Route extends BaseClass {
|
|||||||
|
|
||||||
public void finish(Train train) {
|
public void finish(Train train) {
|
||||||
LOG.debug("{}.finish()",this);
|
LOG.debug("{}.finish()",this);
|
||||||
context.onInvalidate(null); // do in invalidate context of route's nextRoute
|
if (isSet(context)) {
|
||||||
context.invalidate();
|
context.onInvalidate(null); // do in invalidate context of route's nextRoute
|
||||||
|
context.invalidate();
|
||||||
|
}
|
||||||
train.endRoute(this);
|
train.endRoute(this);
|
||||||
setSignals(Signal.RED);
|
setSignals(Signal.RED);
|
||||||
freeIgnoring(null);
|
freeIgnoring(null);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.json.JSONObject;
|
|||||||
import de.srsoftware.web4rail.BaseClass;
|
import de.srsoftware.web4rail.BaseClass;
|
||||||
import de.srsoftware.web4rail.LoadCallback;
|
import de.srsoftware.web4rail.LoadCallback;
|
||||||
import de.srsoftware.web4rail.moving.Train;
|
import de.srsoftware.web4rail.moving.Train;
|
||||||
|
import de.srsoftware.web4rail.tags.Checkbox;
|
||||||
import de.srsoftware.web4rail.tags.Fieldset;
|
import de.srsoftware.web4rail.tags.Fieldset;
|
||||||
import de.srsoftware.web4rail.tags.Window;
|
import de.srsoftware.web4rail.tags.Window;
|
||||||
import de.srsoftware.web4rail.tiles.Block;
|
import de.srsoftware.web4rail.tiles.Block;
|
||||||
@@ -16,27 +17,28 @@ import de.srsoftware.web4rail.tiles.Tile;
|
|||||||
|
|
||||||
public class DetermineTrainInBlock extends Action {
|
public class DetermineTrainInBlock extends Action {
|
||||||
|
|
||||||
|
private static final String PARKED_TRAIN = "parked-train";
|
||||||
|
|
||||||
public DetermineTrainInBlock(BaseClass parent) {
|
public DetermineTrainInBlock(BaseClass parent) {
|
||||||
super(parent);
|
super(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean parked = false;
|
||||||
private Block block = null;
|
private Block block = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean fire(Context context,Object cause) {
|
public boolean fire(Context context,Object cause) {
|
||||||
if (isNull(block)) return false;
|
if (isNull(block)) return false;
|
||||||
Train train = block.occupyingTrain();
|
Train train = parked ? (block.trains().isEmpty() ? null : block.trains().firstElement()) : block.occupyingTrain();
|
||||||
if (isSet(train)) {
|
context.train(train);
|
||||||
context.block(block);
|
return (isSet(train));
|
||||||
context.train(block.occupyingTrain());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject json() {
|
public JSONObject json() {
|
||||||
JSONObject json = super.json();
|
JSONObject json = super.json();
|
||||||
if (isSet(block)) json.put(BLOCK, block.id());
|
if (isSet(block)) json.put(BLOCK, block.id());
|
||||||
|
if (parked) json.put(PARKED_TRAIN, true);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,12 +53,14 @@ public class DetermineTrainInBlock extends Action {
|
|||||||
block = Block.get(blockId);
|
block = Block.get(blockId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (json.has(PARKED_TRAIN)) parked = json.getBoolean(PARKED_TRAIN);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm,String...errors) {
|
protected Window properties(List<Fieldset> preForm, FormInput formInputs, List<Fieldset> postForm,String...errors) {
|
||||||
formInputs.add(t("Block")+": "+(isNull(block) ? t("unset") : block),button(t("Select from plan"),Map.of(ACTION,ACTION_UPDATE,ASSIGN,BLOCK)));
|
formInputs.add(t("Block")+": "+(isNull(block) ? t("unset") : block),button(t("Select from plan"),Map.of(ACTION,ACTION_UPDATE,ASSIGN,BLOCK)));
|
||||||
|
formInputs.add(t("parked train"),new Checkbox(PARKED_TRAIN, t("first parked train"), parked));
|
||||||
return super.properties(preForm, formInputs, postForm,errors);
|
return super.properties(preForm, formInputs, postForm,errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +83,7 @@ public class DetermineTrainInBlock extends Action {
|
|||||||
block = (Block) tile;
|
block = (Block) tile;
|
||||||
} else return t("Clicked tile is not a {}!",t("block"));
|
} else return t("Clicked tile is not a {}!",t("block"));
|
||||||
}
|
}
|
||||||
|
parked = ("on".equals(params.get(PARKED_TRAIN)));
|
||||||
return context().properties();
|
return context().properties();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import de.srsoftware.web4rail.tags.Form;
|
|||||||
import de.srsoftware.web4rail.tags.Input;
|
import de.srsoftware.web4rail.tags.Input;
|
||||||
import de.srsoftware.web4rail.tags.Label;
|
import de.srsoftware.web4rail.tags.Label;
|
||||||
import de.srsoftware.web4rail.tags.Radio;
|
import de.srsoftware.web4rail.tags.Radio;
|
||||||
|
import de.srsoftware.web4rail.tags.Range;
|
||||||
import de.srsoftware.web4rail.tags.Table;
|
import de.srsoftware.web4rail.tags.Table;
|
||||||
import de.srsoftware.web4rail.tags.Window;
|
import de.srsoftware.web4rail.tags.Window;
|
||||||
import de.srsoftware.web4rail.tiles.Block;
|
import de.srsoftware.web4rail.tiles.Block;
|
||||||
@@ -71,6 +72,8 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
return loco.update(params);
|
return loco.update(params);
|
||||||
case ACTION_PROPS:
|
case ACTION_PROPS:
|
||||||
return loco == null ? Locomotive.manager() : loco.properties();
|
return loco == null ? Locomotive.manager() : loco.properties();
|
||||||
|
case ACTION_SET_SPEED:
|
||||||
|
return loco.setSpeed(Integer.parseInt(params.get(SPEED)));
|
||||||
case ACTION_SLOWER10:
|
case ACTION_SLOWER10:
|
||||||
return loco.faster(-Train.defaultSpeedStep);
|
return loco.faster(-Train.defaultSpeedStep);
|
||||||
case ACTION_STOP:
|
case ACTION_STOP:
|
||||||
@@ -98,42 +101,48 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Fieldset cockpit(Object locoOrTrain) {
|
public static Fieldset cockpit(BaseClass locoOrTrain) {
|
||||||
Id id = null;
|
|
||||||
int speed = 0;
|
int speed = 0;
|
||||||
String realm = null;
|
String realm = null;
|
||||||
Train train = null;
|
Train train = null;
|
||||||
Locomotive loco = null;
|
Locomotive loco = null;
|
||||||
|
int maxSpeed = 0;
|
||||||
boolean fun1=false,fun2=false,fun3=false,fun4=false;
|
boolean fun1=false,fun2=false,fun3=false,fun4=false;
|
||||||
|
String id = null;
|
||||||
if (locoOrTrain instanceof Locomotive) {
|
if (locoOrTrain instanceof Locomotive) {
|
||||||
loco = (Locomotive) locoOrTrain;
|
loco = (Locomotive) locoOrTrain;
|
||||||
realm = REALM_LOCO;
|
realm = REALM_LOCO;
|
||||||
id = loco.id();
|
|
||||||
speed = loco.speed;
|
speed = loco.speed;
|
||||||
fun1 = loco.f1;
|
fun1 = loco.f1;
|
||||||
fun2 = loco.f2;
|
fun2 = loco.f2;
|
||||||
fun3 = loco.f3;
|
fun3 = loco.f3;
|
||||||
fun4 = loco.f4;
|
fun4 = loco.f4;
|
||||||
|
maxSpeed = loco.orientation ? loco.maxSpeedForward : loco.maxSpeedReverse;
|
||||||
|
id = "loco_"+loco.id();
|
||||||
} else if (locoOrTrain instanceof Train) {
|
} else if (locoOrTrain instanceof Train) {
|
||||||
train = (Train)locoOrTrain;
|
train = (Train)locoOrTrain;
|
||||||
realm = REALM_TRAIN;
|
realm = REALM_TRAIN;
|
||||||
id = train.id();
|
|
||||||
speed = train.speed;
|
speed = train.speed;
|
||||||
fun1 = train.getFunction(1);
|
fun1 = train.getFunction(1);
|
||||||
fun2 = train.getFunction(2);
|
fun2 = train.getFunction(2);
|
||||||
fun3 = train.getFunction(3);
|
fun3 = train.getFunction(3);
|
||||||
fun4 = train.getFunction(4);
|
fun4 = train.getFunction(4);
|
||||||
}
|
maxSpeed = train.maxSpeed();
|
||||||
|
id = "train_"+train.id();
|
||||||
|
} else return null;
|
||||||
|
|
||||||
HashMap<String,Object> params = new HashMap<String, Object>(Map.of(REALM,realm,ID,id));
|
HashMap<String,Object> params = new HashMap<String, Object>(Map.of(REALM,realm,ID,locoOrTrain.id()));
|
||||||
|
|
||||||
Fieldset fieldset = new Fieldset(t("Control")).id("props-cockpit");
|
Fieldset fieldset = new Fieldset(t("Control")).id("props-cockpit");
|
||||||
fieldset.clazz("cockpit");
|
fieldset.clazz("cockpit");
|
||||||
|
|
||||||
new Tag("span").content(t("Current velocity: {} {}",speed,speedUnit)).addTo(fieldset);
|
|
||||||
|
|
||||||
Tag par = new Tag("p");
|
Tag par = new Tag("p");
|
||||||
|
|
||||||
|
Range range = new Range(t("Current velocity: {} {}",speed,speedUnit),"speed",speed,0,maxSpeed);
|
||||||
|
range.id(id).onChange("changeSpeed('"+id+"');");
|
||||||
|
range.addTo(par);
|
||||||
|
|
||||||
|
|
||||||
params.put(ACTION, ACTION_FASTER10);
|
params.put(ACTION, ACTION_FASTER10);
|
||||||
new Button(t("Faster ({} {})",Train.defaultSpeedStep,speedUnit),params).addTo(par);
|
new Button(t("Faster ({} {})",Train.defaultSpeedStep,speedUnit),params).addTo(par);
|
||||||
|
|
||||||
@@ -149,7 +158,7 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
}
|
}
|
||||||
|
|
||||||
params.put(ACTION, ACTION_TURN);
|
params.put(ACTION, ACTION_TURN);
|
||||||
new Button(t("Turn"),params).title(t("Inverts the direction {} is heading to.",locoOrTrain)).clazz(ACTION_TURN).addTo(direction);
|
new Button(t("Turn"),params).title(t("Inverts the direction {} is heading to.",locoOrTrain)).clazz(ACTION_TURN).addTo(par);
|
||||||
|
|
||||||
if (isSet(train)) {
|
if (isSet(train)) {
|
||||||
Block currentBlock = train.currentBlock();
|
Block currentBlock = train.currentBlock();
|
||||||
@@ -192,7 +201,12 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
b4.addTo(functions);
|
b4.addTo(functions);
|
||||||
functions.addTo(fieldset);
|
functions.addTo(fieldset);
|
||||||
|
|
||||||
if (isSet(train)) train.button(t("Select destination"),Map.of(ACTION,ACTION_MOVE,ASSIGN,DESTINATION)).addTo(fieldset);
|
if (isSet(train)) {
|
||||||
|
train.button(t("Select destination"),Map.of(ACTION,ACTION_MOVE,ASSIGN,DESTINATION)).addTo(direction);
|
||||||
|
Button toggleShunbting = train.button(t("Shunting"),Map.of(ACTION,ACTION_TOGGLE_SHUNTING));
|
||||||
|
if (train.isShunting()) toggleShunbting.clazz(toggleShunbting.get("class")+" active");
|
||||||
|
toggleShunbting.addTo(functions);
|
||||||
|
}
|
||||||
|
|
||||||
return fieldset;
|
return fieldset;
|
||||||
}
|
}
|
||||||
@@ -202,9 +216,8 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Object faster(int steps) {
|
public Tag faster(int steps) {
|
||||||
setSpeed(speed + steps);
|
return setSpeed(speed + steps);
|
||||||
return properties();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
@@ -415,14 +428,16 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
* @param newSpeed
|
* @param newSpeed
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String setSpeed(int newSpeed) {
|
public Tag setSpeed(int newSpeed) {
|
||||||
LOG.debug(this.detail()+".setSpeed({})",newSpeed);
|
LOG.debug(this.detail()+".setSpeed({})",newSpeed);
|
||||||
speed = newSpeed;
|
speed = newSpeed;
|
||||||
if (speed > maxSpeedForward && maxSpeedForward > 0) speed = maxSpeed();
|
if (speed > maxSpeedForward && maxSpeedForward > 0) speed = maxSpeed();
|
||||||
if (speed < 0) speed = 0;
|
if (speed < 0) speed = 0;
|
||||||
|
|
||||||
queue();
|
queue();
|
||||||
return t("Speed of {} set to {}.",this,speed);
|
plan.stream(t("Speed of {} set to {} {}.",this,speed,BaseClass.speedUnit));
|
||||||
|
return properties();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object setting(int cv) {
|
private Object setting(int cv) {
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
|
|
||||||
public int speed = 0;
|
public int speed = 0;
|
||||||
private static final String SHUNTING = "shunting";
|
private static final String SHUNTING = "shunting";
|
||||||
|
|
||||||
|
public static final String SHUNT = "SHUNT";
|
||||||
private boolean shunting = false;
|
private boolean shunting = false;
|
||||||
private RoutePrepper routePrepper = null;
|
private RoutePrepper routePrepper = null;
|
||||||
|
|
||||||
@@ -141,6 +143,8 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
case ACTION_REVERSE:
|
case ACTION_REVERSE:
|
||||||
train.quitAutopilot();
|
train.quitAutopilot();
|
||||||
return train.reverse().properties();
|
return train.reverse().properties();
|
||||||
|
case ACTION_SET_SPEED:
|
||||||
|
return train.setSpeed(Integer.parseInt(params.get(SPEED)));
|
||||||
case ACTION_SLOWER10:
|
case ACTION_SLOWER10:
|
||||||
return train.slower(Train.defaultSpeedStep);
|
return train.slower(Train.defaultSpeedStep);
|
||||||
case ACTION_START:
|
case ACTION_START:
|
||||||
@@ -149,6 +153,9 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
return train.stopNow();
|
return train.stopNow();
|
||||||
case ACTION_TIMES:
|
case ACTION_TIMES:
|
||||||
return train.removeBrakeTimes();
|
return train.removeBrakeTimes();
|
||||||
|
case ACTION_TOGGLE_SHUNTING:
|
||||||
|
train.shunting = !train.shunting;
|
||||||
|
return train.properties();
|
||||||
case ACTION_TURN:
|
case ACTION_TURN:
|
||||||
return train.turn().properties();
|
return train.turn().properties();
|
||||||
case ACTION_UPDATE:
|
case ACTION_UPDATE:
|
||||||
@@ -526,8 +533,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Tag faster(int steps) {
|
private Tag faster(int steps) {
|
||||||
setSpeed(speed+steps);
|
return setSpeed(speed+steps);
|
||||||
return properties();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getFunction(int num) {
|
public boolean getFunction(int num) {
|
||||||
@@ -703,7 +709,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int maxSpeed() {
|
int maxSpeed() {
|
||||||
int maxSpeed = Integer.MAX_VALUE;
|
int maxSpeed = Integer.MAX_VALUE;
|
||||||
for (Car car : cars) {
|
for (Car car : cars) {
|
||||||
int max = car.maxSpeed();
|
int max = car.maxSpeed();
|
||||||
@@ -907,6 +913,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
|
|
||||||
private Object setDestination(HashMap<String, String> params) {
|
private Object setDestination(HashMap<String, String> params) {
|
||||||
String dest = params.get(DESTINATION);
|
String dest = params.get(DESTINATION);
|
||||||
|
if (isNull(currentBlock)) return properties("{} is not in a block!");
|
||||||
if (isNull(dest)) return properties(t("No destination supplied!"));
|
if (isNull(dest)) return properties(t("No destination supplied!"));
|
||||||
if (dest.isEmpty()) {
|
if (dest.isEmpty()) {
|
||||||
destination = null;
|
destination = null;
|
||||||
@@ -915,6 +922,11 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
Tile tile = plan.get(new Id(dest), true);
|
Tile tile = plan.get(new Id(dest), true);
|
||||||
if (isNull(tile)) return properties(t("Tile {} not known!",dest));
|
if (isNull(tile)) return properties(t("Tile {} not known!",dest));
|
||||||
if (tile instanceof Block) {
|
if (tile instanceof Block) {
|
||||||
|
if (shunting) {
|
||||||
|
boolean connection = currentBlock.routes().stream().anyMatch(route -> route.startBlock() == currentBlock && route.endBlock() == tile);
|
||||||
|
if (!connection) return t("No direct route from {} to {}",currentBlock,tile);
|
||||||
|
}
|
||||||
|
|
||||||
destination = (Block) tile;
|
destination = (Block) tile;
|
||||||
start(true);
|
start(true);
|
||||||
return t("{} now heading for {}",this,destination);
|
return t("{} now heading for {}",this,destination);
|
||||||
@@ -953,17 +965,17 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpeed(int newSpeed) {
|
public Tag setSpeed(int newSpeed) {
|
||||||
LOG.debug("{}.setSpeed({})",this,newSpeed);
|
LOG.debug("{}.setSpeed({})",this,newSpeed);
|
||||||
speed = Math.min(newSpeed,maxSpeed());
|
speed = Math.min(newSpeed,maxSpeed());
|
||||||
if (speed < 0) speed = 0;
|
if (speed < 0) speed = 0;
|
||||||
cars.stream().filter(c -> c instanceof Locomotive).forEach(car -> ((Locomotive)car).setSpeed(speed));
|
cars.stream().filter(c -> c instanceof Locomotive).forEach(car -> ((Locomotive)car).setSpeed(speed));
|
||||||
plan.stream(t("Set {} to {} {}",this,speed,speedUnit));
|
plan.stream(t("Set {} to {} {}",this,speed,speedUnit));
|
||||||
|
return properties();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tag slower(int steps) {
|
private Tag slower(int steps) {
|
||||||
setSpeed(speed-steps);
|
return setSpeed(speed-steps);
|
||||||
return properties();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean splitAfter(int position) {
|
public boolean splitAfter(int position) {
|
||||||
|
|||||||
34
src/main/java/de/srsoftware/web4rail/tags/Range.java
Normal file
34
src/main/java/de/srsoftware/web4rail/tags/Range.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package de.srsoftware.web4rail.tags;
|
||||||
|
|
||||||
|
import de.srsoftware.tools.Tag;
|
||||||
|
|
||||||
|
public class Range extends Tag{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1865176096163142641L;
|
||||||
|
private Tag range;
|
||||||
|
private Tag caption;
|
||||||
|
|
||||||
|
public Range(String caption, String name, int current, int min, int max) {
|
||||||
|
super("div");
|
||||||
|
this.caption = new Tag("span").content(caption);
|
||||||
|
this.caption.addTo(this);
|
||||||
|
Tag label = new Tag("label").content(""+min);
|
||||||
|
range = new Input(name).attr("type","range").attr("min",min).attr("max",max).attr("value",current);
|
||||||
|
range.addTo(label);
|
||||||
|
label.content(""+max);
|
||||||
|
label.addTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Range id(String id) {
|
||||||
|
range.id(id);
|
||||||
|
caption.id(id+"_caption");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Range onChange(String script) {
|
||||||
|
range.attr("onchange", script);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,7 +71,7 @@ public abstract class Block extends StretchableTile{
|
|||||||
return trains.isEmpty() ? null : trains.getLast();
|
return trains.isEmpty() ? null : trains.getLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Train> list() {
|
public Vector<Train> list() {
|
||||||
return new Vector<>(trains);
|
return new Vector<>(trains);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,7 +496,7 @@ public abstract class Block extends StretchableTile{
|
|||||||
return fieldset;
|
return fieldset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Train> trains(){
|
public Vector<Train> trains(){
|
||||||
return parkedTrains.list();
|
return parkedTrains.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user