summaryrefslogtreecommitdiff
path: root/altoslib/AltosStateIterable.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-08-29 15:22:43 -0500
committerKeith Packard <keithp@keithp.com>2014-08-29 15:22:43 -0500
commit810f9a4f79b0480973d84595140d3f8948ce26d9 (patch)
treef0449f475eb57d23a669e0191f8195a3de569afd /altoslib/AltosStateIterable.java
parent5872bd10df14b47de0e541bff16d9220af0558aa (diff)
altosdroid: start restoring from log data on startup
Remember which flight was last being received and reload that file Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosStateIterable.java')
-rw-r--r--altoslib/AltosStateIterable.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/altoslib/AltosStateIterable.java b/altoslib/AltosStateIterable.java
index f7cd424d..4154b71c 100644
--- a/altoslib/AltosStateIterable.java
+++ b/altoslib/AltosStateIterable.java
@@ -26,4 +26,18 @@ public abstract class AltosStateIterable implements Iterable<AltosState> {
}
public abstract void write(PrintStream out);
+
+ public static AltosStateIterable iterable(File file) {
+ FileInputStream in;
+ try {
+ in = new FileInputStream(file);
+ } catch (Exception e) {
+ System.out.printf("Failed to open file '%s'\n", file);
+ return null;
+ }
+ if (file.getName().endsWith("telem"))
+ return new AltosTelemetryFile(in);
+ else
+ return new AltosEepromFile(in);
+ }
}