Implementierung des neuen Routen-Algorithmus weitgehend abgeschlossen.

Was noch fehlt ist der Brems-Prozessor; außerdem muss der neue Code getestet werden.
This commit is contained in:
Stephan Richter
2021-03-17 23:58:38 +01:00
parent c62f75fa02
commit 5e50259d24
16 changed files with 225 additions and 110 deletions

View File

@@ -88,7 +88,7 @@ public abstract class Block extends StretchableTile{
@Override
public String toString() {
return trains.toString();
return trains.stream().map(t -> t+""+directionOf(t)).reduce((s1,s2) -> s1+", "+s2).orElse(t("empty"));
}
}
private static final String ALLOW_TURN = "allowTurn";
@@ -192,6 +192,7 @@ public abstract class Block extends StretchableTile{
private Vector<WaitTime> waitTimes = new Vector<WaitTime>();
public void add(Train train,Direction direction) {
if (isNull(train)) return;
train.register();
trains.add(train,direction);
}

View File

@@ -53,7 +53,7 @@ public class Contact extends Tile{
boolean aborted = false;
public OffTimer() {
setName(Application.threadName("OffTimer("+Contact.this+")"));
super(Application.threadName("OffTimer("+Contact.this+")"));
start();
}
@@ -112,7 +112,12 @@ public class Contact extends Tile{
@Override
public Object click(boolean shift) throws IOException {
if (!shift) trigger(200);
if (!shift) new Thread(Application.threadName(this)) {
@Override
public void run() {
trigger(200);
}
}.start();
return super.click(shift);
}

View File

@@ -164,7 +164,7 @@ public class Switch extends Tile{
public void state(boolean newState) {
state = newState;
Thread thread = new Thread() {
new Thread(Application.threadName(this)) {
@Override
public void run() {
@@ -173,9 +173,7 @@ public class Switch extends Tile{
actionsOn.fire(context,Switch.this);
} else actionsOff.fire(context,Switch.this);
}
};
thread.setName(Application.threadName(this));
thread.start();
}.start();
stream();
}

View File

@@ -161,7 +161,8 @@ public abstract class Turnout extends Tile implements Device{
public Reply state(State newState) {
if (is(Status.LOCKED,Status.OCCUPIED) && newState != state) return new Reply(415, t("{} locked by {}!",this,train()));
if (address == 0) {
state = newState;
sleep(300);
state = newState;
plan.place(this);
return new Reply(200,"OK");
}