|
|
@ -135,10 +135,12 @@ public class Train implements Constants { |
|
|
|
return train.automatic(); |
|
|
|
return train.automatic(); |
|
|
|
case ACTION_PROPS: |
|
|
|
case ACTION_PROPS: |
|
|
|
return train.props(); |
|
|
|
return train.props(); |
|
|
|
|
|
|
|
case ACTION_QUIT: |
|
|
|
|
|
|
|
return train.quitAutopilot(); |
|
|
|
case ACTION_START: |
|
|
|
case ACTION_START: |
|
|
|
return train.start(); |
|
|
|
return train.start(); |
|
|
|
case ACTION_STOP: |
|
|
|
case ACTION_STOP: |
|
|
|
return train.stop(); |
|
|
|
return train.stopNow(); |
|
|
|
case ACTION_TURN: |
|
|
|
case ACTION_TURN: |
|
|
|
return train.turn(); |
|
|
|
return train.turn(); |
|
|
|
case ACTION_UPDATE: |
|
|
|
case ACTION_UPDATE: |
|
|
@ -147,7 +149,6 @@ public class Train implements Constants { |
|
|
|
return t("Unknown action: {}",params.get(ACTION)); |
|
|
|
return t("Unknown action: {}",params.get(ACTION)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Object addCar(HashMap<String, String> params) { |
|
|
|
private Object addCar(HashMap<String, String> params) { |
|
|
|
LOG.debug("addCar({})",params); |
|
|
|
LOG.debug("addCar({})",params); |
|
|
|
if (!params.containsKey(CAR_ID)) return t("No car id passed to Train.addCar!"); |
|
|
|
if (!params.containsKey(CAR_ID)) return t("No car id passed to Train.addCar!"); |
|
|
@ -346,7 +347,7 @@ public class Train implements Constants { |
|
|
|
if (autopilot == null) { |
|
|
|
if (autopilot == null) { |
|
|
|
new Button(t("auto"),"train("+id+",'"+ACTION_AUTO+"')").addTo(actions); |
|
|
|
new Button(t("auto"),"train("+id+",'"+ACTION_AUTO+"')").addTo(actions); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
new Button(t("stop"),"train("+id+",'"+ACTION_STOP+"')").addTo(actions); |
|
|
|
new Button(t("quit autopilot"),"train("+id+",'"+ACTION_QUIT+"')").addTo(actions); |
|
|
|
} |
|
|
|
} |
|
|
|
actions.addTo(propList); |
|
|
|
actions.addTo(propList); |
|
|
|
|
|
|
|
|
|
|
@ -361,6 +362,14 @@ public class Train implements Constants { |
|
|
|
return window; |
|
|
|
return window; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Object quitAutopilot() { |
|
|
|
|
|
|
|
if (autopilot != null) { |
|
|
|
|
|
|
|
autopilot.stop = true; |
|
|
|
|
|
|
|
autopilot = null; |
|
|
|
|
|
|
|
return t("{} stopping at next block.",this); |
|
|
|
|
|
|
|
} else return t("autopilot not active."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void saveAll(String filename) throws IOException { |
|
|
|
public static void saveAll(String filename) throws IOException { |
|
|
|
BufferedWriter file = new BufferedWriter(new FileWriter(filename)); |
|
|
|
BufferedWriter file = new BufferedWriter(new FileWriter(filename)); |
|
|
|
for (Entry<Long, Train> entry:trains.entrySet()) { |
|
|
|
for (Entry<Long, Train> entry:trains.entrySet()) { |
|
|
@ -414,10 +423,17 @@ public class Train implements Constants { |
|
|
|
return error; |
|
|
|
return error; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Object stop() { |
|
|
|
private Object stopNow() { |
|
|
|
autopilot.stop = true; |
|
|
|
setSpeed(0); |
|
|
|
autopilot = null; |
|
|
|
if (route != null) try { |
|
|
|
return t("{} stopping at next block.",this); |
|
|
|
route.unlock(); |
|
|
|
|
|
|
|
route.endBlock().train(null); |
|
|
|
|
|
|
|
route.startBlock().train(this); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
route = null; |
|
|
|
|
|
|
|
return t("Stopped {}.",this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String t(String message, Object...fills) { |
|
|
|
private static String t(String message, Object...fills) { |
|
|
|