minor improvement on autopilot
This commit is contained in:
@@ -501,7 +501,7 @@ public class Plan {
|
|||||||
|
|
||||||
public synchronized void stream(String data) {
|
public synchronized void stream(String data) {
|
||||||
data = data.replaceAll("\n", "").replaceAll("\r", "");
|
data = data.replaceAll("\n", "").replaceAll("\r", "");
|
||||||
LOG.debug("streaming: {}",data);
|
//LOG.debug("streaming: {}",data);
|
||||||
Vector<OutputStreamWriter> badClients = null;
|
Vector<OutputStreamWriter> badClients = null;
|
||||||
for (Entry<OutputStreamWriter, Integer> entry : clients.entrySet()) {
|
for (Entry<OutputStreamWriter, Integer> entry : clients.entrySet()) {
|
||||||
OutputStreamWriter client = entry.getKey();
|
OutputStreamWriter client = entry.getKey();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import de.srsoftware.web4rail.tags.Form;
|
|||||||
import de.srsoftware.web4rail.tiles.Block;
|
import de.srsoftware.web4rail.tiles.Block;
|
||||||
import de.srsoftware.web4rail.tiles.Contact;
|
import de.srsoftware.web4rail.tiles.Contact;
|
||||||
import de.srsoftware.web4rail.tiles.Signal;
|
import de.srsoftware.web4rail.tiles.Signal;
|
||||||
|
import de.srsoftware.web4rail.tiles.Tile;
|
||||||
|
|
||||||
public class Train {
|
public class Train {
|
||||||
|
|
||||||
@@ -27,18 +28,19 @@ public class Train {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Vector<Contact> contacts = null;
|
Vector<Tile> path = new Vector<Tile>();
|
||||||
while (true) {
|
while (true) {
|
||||||
if (route == null) {
|
if (route == null) {
|
||||||
|
Thread.sleep(3000);
|
||||||
Train.this.start();
|
Train.this.start();
|
||||||
contacts = route == null ? new Vector<Contact>() : route.contacts();
|
path = route == null ? new Vector<Tile>() : route.path();
|
||||||
} else {
|
} else {
|
||||||
if (!contacts.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
Contact contact = contacts.remove(0);
|
Tile t = path.remove(0);
|
||||||
contact.activate();
|
if (t instanceof Contact) ((Contact)t).activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Thread.sleep(1000);
|
Thread.sleep(500);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user