altoslib: Hack up AltosEepromFile to support new eeprom code
[fw/altos] / altoslib / AltosEepromFile.java
index d23116a66a71bb57866ca641a1461bf63e0fe3d6..bb8abf87fa334cfa3be713ba271a464f7804a780 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -57,6 +58,7 @@ public class AltosEepromFile extends AltosStateIterable {
 
        AltosEepromIterable     headers;
        AltosEepromIterable     body;
+       AltosEepromRecordSet    set;
        AltosState              start;
 
        public void write_comments(PrintStream out) {
@@ -68,6 +70,11 @@ public class AltosEepromFile extends AltosStateIterable {
                body.write(out);
        }
 
+       public AltosEepromFile(Reader input) throws IOException {
+               set = new AltosEepromRecordSet(input);
+
+       }
+
        public AltosEepromFile(FileInputStream input) {
                headers = new AltosEepromIterable(AltosEepromHeader.read(input));
 
@@ -100,13 +107,17 @@ public class AltosEepromFile extends AltosStateIterable {
                case AltosLib.AO_LOG_FORMAT_TELEMETRUM:
                        body = new AltosEepromIterable(AltosEepromMetrum2.read(input));
                        break;
-               case AltosLib.AO_LOG_FORMAT_TELEMINI:
+               case AltosLib.AO_LOG_FORMAT_TELEMINI2:
+               case AltosLib.AO_LOG_FORMAT_TELEMINI3:
                case AltosLib.AO_LOG_FORMAT_EASYMINI:
                        body = new AltosEepromIterable(AltosEepromMini.read(input));
                        break;
                case AltosLib.AO_LOG_FORMAT_TELEGPS:
                        body = new AltosEepromIterable(AltosEepromGPS.read(input));
                        break;
+               case AltosLib.AO_LOG_FORMAT_TELEFIRETWO:
+                       body = new AltosEepromIterable(AltosEepromFireTwo.read(input));
+                       break;
                default:
                        body = new AltosEepromIterable(new LinkedList<AltosEeprom>());
                        break;
@@ -125,6 +136,9 @@ public class AltosEepromFile extends AltosStateIterable {
        }
 
        public Iterator<AltosState> iterator() {
+               if (set != null)
+                       return set.iterator();
+
                AltosState              state = start.clone();
                Iterator<AltosEeprom>   i = body.iterator();