Browse Source

working on directed destinations

master
Stephan Richter 4 years ago
parent
commit
fe63d40aa1
  1. 2
      pom.xml
  2. 2
      resources/logback.xml
  3. 1
      resources/translations/Application.de.translation
  4. 13
      src/main/java/de/srsoftware/web4rail/actions/AddRemoveDestination.java
  5. 22
      src/main/java/de/srsoftware/web4rail/moving/Train.java
  6. 2
      src/main/java/de/srsoftware/web4rail/threads/BrakeProcess.java

2
pom.xml

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

2
resources/logback.xml

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
</encoder>
<filter class="de.srsoftware.web4rail.ThreadFilter">
<level>WARN</level>
<keywords>Brake, Contact, Feed, Route, e, u</keywords>
<keywords>BaseClass, ControlUnit, RoutePrepper, Tile</keywords>
</filter>
</appender>

1
resources/translations/Application.de.translation

@ -87,6 +87,7 @@ Cars : Fahrzeuge @@ -87,6 +87,7 @@ Cars : Fahrzeuge
&nbsp;cars : &nbsp;Fahrzeugen teilen
Clear destinations : Ziele löschen
Clear destinations of train : Ziele des Zugs löschen
Clear trigger : Trigger löschen
Clicked tile is not a {}! : Angeklickte Kachel ist kein {}!
Click here to add conditions : Hier klicken, um Bedingungen hinzuzufügen
Click here to select block! : Hier klicken, um Block auszuwählen!

13
src/main/java/de/srsoftware/web4rail/actions/AddRemoveDestination.java

@ -117,7 +117,10 @@ public class AddRemoveDestination extends Action { @@ -117,7 +117,10 @@ public class AddRemoveDestination extends Action {
formInputs.add(t("Turn at destination"),new Checkbox(TURN, t("Turn"), destination.turn()));
formInputs.add(t("Shunting"),new Checkbox(SHUNTING, t("Shunting"), destination.shunting()));
}
formInputs.add(t("Trigger Contact/Switch at destination")+": "+(isNull(destinationTrigger) ? t("unset") : destinationTrigger),button(t("Select from plan"),Map.of(ACTION,ACTION_UPDATE,ASSIGN,CONTACT)));
span = new Tag("span");
button(t("Select from plan"),Map.of(ACTION,ACTION_UPDATE,ASSIGN,CONTACT)).addTo(span);
button(t("Clear trigger"),Map.of(ACTION,ACTION_UPDATE,CONTACT,"0")).addTo(span);
formInputs.add(t("Trigger Contact/Switch at destination")+": "+(isNull(destinationTrigger) ? t("unset") : destinationTrigger),span);
return super.properties(preForm, formInputs, postForm,errors);
}
@ -146,8 +149,14 @@ public class AddRemoveDestination extends Action { @@ -146,8 +149,14 @@ public class AddRemoveDestination extends Action {
}
}
if (params.containsKey(CONTACT)) {
Tile tile = Tile.get(Id.from(params,CONTACT));
Id id = Id.from(params,CONTACT);
if (id.equals(0)) {
destinationTrigger = null;
return properties();
}
Tile tile = Tile.get(id);
if (tile instanceof Contact || tile instanceof Switch) destinationTrigger = tile;
return properties();
}
if (isSet(destination)) {
destination.turn("on".equals(params.getString(TURN)));

22
src/main/java/de/srsoftware/web4rail/moving/Train.java

@ -9,6 +9,7 @@ import java.util.Collection; @@ -9,6 +9,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
@ -454,6 +455,7 @@ public class Train extends BaseClass implements Comparable<Train> { @@ -454,6 +455,7 @@ public class Train extends BaseClass implements Comparable<Train> {
Block endBlock = endedRoute.endBlock();
Block startBlock = endedRoute.startBlock();
boolean resetDest = endedRoute.endsAt(destination);
LinkedList<Tile> triggerRef = new LinkedList<>();
if (resetDest){
destination = null;
@ -467,17 +469,9 @@ public class Train extends BaseClass implements Comparable<Train> { @@ -467,17 +469,9 @@ public class Train extends BaseClass implements Comparable<Train> {
}
if (isNull(destTag)) {
Tile trigger = destinationTrigger; // quitAutopilot drops destinationTrigger
triggerRef.add(destinationTrigger); // quitAutopilot drops destinationTrigger
quitAutopilot();
plan.stream(t("{} reached it`s destination!",this));
if (isSet(trigger)) new DelayedExecution(1000,this) {
@Override
public void execute() {
if (trigger instanceof Contact) ((Contact)trigger).trigger(200);
if (trigger instanceof Switch) ((Switch)trigger).trigger(new Context(Train.this));
}
};
}
}
if (isSet(brake)) brake.updateTime();
@ -493,6 +487,16 @@ public class Train extends BaseClass implements Comparable<Train> { @@ -493,6 +487,16 @@ public class Train extends BaseClass implements Comparable<Train> {
trace.add(endBlock);
if (!trace.contains(startBlock)) startBlock.dropTrain(this);
stuckTrace = null;
if (!triggerRef.isEmpty()) new DelayedExecution(1000,this) {
@Override
public void execute() {
Tile trigger = triggerRef.getFirst();
if (trigger instanceof Contact) ((Contact)trigger).trigger(200);
if (trigger instanceof Switch) ((Switch)trigger).trigger(new Context(Train.this));
}
};
if (autopilot) {
if (isNull(waitTime)) waitTime = 0;
if (waitTime>0) plan.stream(t("{} waiting {} secs.",this,(int)(waitTime/1000)));

2
src/main/java/de/srsoftware/web4rail/threads/BrakeProcess.java

@ -101,7 +101,7 @@ public class BrakeProcess extends BaseClass implements Runnable{ @@ -101,7 +101,7 @@ public class BrakeProcess extends BaseClass implements Runnable{
route.brakeTime(brakeId,newTimeStep);
calculated = calcDistance(newTimeStep);
LOG.debug("Corrected brake timestep from {} to {} ms for {} @ {}.",timeStep,newTimeStep,train,route);
LOG.debug("Differemce from estimated distance: {} ({}%)",distance-calculated,100*(distance-calculated)/(float)distance);
LOG.debug("Difference from estimated distance: {} ({}%)",distance-calculated,100*(distance-calculated)/(float)distance);
}
}
}

Loading…
Cancel
Save