add --replay command line argument
authorAnthony Towns <aj@erisian.com.au>
Thu, 11 Nov 2010 05:40:37 +0000 (15:40 +1000)
committerAnthony Towns <aj@erisian.com.au>
Thu, 11 Nov 2010 05:40:37 +0000 (15:40 +1000)
ao-tools/altosui/AltosUI.java

index ded9e733441015274797cdf4834812622151f292..2861444da7b5e9008e875d3285d7f225226ea18a 100644 (file)
@@ -456,7 +456,26 @@ public class AltosUI extends JFrame {
        public static void main(final String[] args) {
                int     process = 0;
                /* Handle batch-mode */
-               if (args.length > 0) {
+        if (args.length == 2 && args[0].equals("--replay")) {
+            String filename = args[1];
+            FileInputStream in;
+            try {
+                in = new FileInputStream(filename);
+            } catch (Exception e) {
+                System.out.printf("Failed to open file '%s'\n", filename);
+                return;
+            }
+            AltosRecordIterable recs;
+            AltosReplayReader reader;
+            if (filename.endsWith("eeprom")) {
+              recs = new AltosEepromIterable(in);
+            } else {
+              recs = new AltosTelemetryIterable(in); 
+            }
+            reader = new AltosReplayReader(recs.iterator(), filename);
+            new AltosFlightUI(new AltosVoice(), reader);
+            return;
+        } else if (args.length > 0) {
                        for (int i = 0; i < args.length; i++) {
                                if (args[i].equals("--kml"))
                                        process |= process_kml;