X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosStateIterable.java;h=4154b71ceec90a8d77473e0432977b0c47ae6f32;hb=368c7d583380b4453f432d5a965a1e4c45a92f92;hp=f7cd424d554a82422b8f403775f178ad717e3b84;hpb=c8078d352a7f54a4a97d25af080155d3f875536a;p=fw%2Faltos 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 { } 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); + } }