static AltosStateIterable open_logfile(File file) {
try {
- FileInputStream in;
-
- in = new FileInputStream(file);
if (file.getName().endsWith("telem"))
- return new AltosTelemetryFile(in);
+ return new AltosTelemetryFile(new FileInputStream(file));
else
- return new AltosEepromFile(in);
+ return new AltosEepromFile(new FileReader(file));
} catch (FileNotFoundException fe) {
System.out.printf("%s\n", fe.getMessage());
return null;
+ } catch (IOException ie) {
+ System.out.printf("%s\n", ie.getMessage());
+ return null;
}
}
static AltosStateIterable record_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")) {
+ try {
+ in = new FileInputStream(file);
+ return new AltosTelemetryFile(in);
+ } catch (Exception e) {
+ System.out.printf("Failed to open file '%s'\n", file);
+ }
+ } else {
+
+ try {
+ AltosEepromFile f = new AltosEepromFile(new FileReader(file));
+ return f;
+ } catch (Exception e) {
+ System.out.printf("Failed to open file '%s'\n", file);
+ }
}
- if (file.getName().endsWith("telem"))
- return new AltosTelemetryFile(in);
- else
- return new AltosEepromFile(in);
+ return null;
}
static AltosReplayReader replay_file(File file) {
AltosStateIterable eef = record_iterable(file);
for (AltosState state : eef) {
- System.out.printf ("tick %d state %d height %g\n",
- state.tick, state.state(), state.height());
- if ((state.set & AltosState.set_gps) != 0)
- System.out.printf ("time %g lat %g lon %g alt %g\n",
- state.time_since_boost(),
+ if ((state.set & AltosState.set_gps) != 0) {
+ System.out.printf ("time %d %d-%d-%d %d:%d:%d lat %g lon %g alt %g\n",
+ state.gps.seconds(),
+ state.gps.year,
+ state.gps.month,
+ state.gps.day,
+ state.gps.hour,
+ state.gps.minute,
+ state.gps.second,
state.gps.lat,
state.gps.lon,
state.gps.alt);
+ } else {
+ System.out.printf ("tick %d state %d height %g\n",
+ state.tick, state.state(), state.height());
+ }
}
} catch (Exception e) {