- return;
- if (process == 0)
- process = process_csv;
- if ((process & process_csv) != 0) {
- String output = Altos.replace_extension(input,".csv");
- System.out.printf("Processing \"%s\" to \"%s\"\n", input, output);
- if (input.equals(output)) {
- System.out.printf("Not processing '%s'\n", input);
- } else {
- AltosWriter writer = open_csv(output);
- if (writer != null) {
- writer.write(iterable);
- writer.close();
- }
- }
+ return false;
+
+ File output = Altos.replace_extension(input,".csv");
+ System.out.printf("Processing \"%s\" to \"%s\"\n", input, output);
+ if (input.equals(output)) {
+ System.out.printf("Not processing '%s'\n", input);
+ return false;
+ } else {
+ AltosWriter writer = open_csv(output);
+ if (writer == null)
+ return false;
+ writer.write(iterable);
+ writer.close();
+ }
+ return true;
+ }
+
+ static boolean process_kml(File input) {
+ AltosRecordIterable iterable = open_logfile(input);
+ if (iterable == null)
+ return false;
+
+ File output = Altos.replace_extension(input,".kml");
+ System.out.printf("Processing \"%s\" to \"%s\"\n", input, output);
+ if (input.equals(output)) {
+ System.out.printf("Not processing '%s'\n", input);
+ return false;
+ } else {
+ AltosWriter writer = open_kml(output);
+ if (writer == null)
+ return false;
+ writer.write(iterable);
+ writer.close();
+ return true;
+ }
+ }
+
+ static AltosRecordIterable 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;
+ }
+ AltosRecordIterable recs;
+ //AltosReplayReader reader;
+ if (file.getName().endsWith("eeprom")) {
+ recs = new AltosEepromIterable(in);
+ } else if (file.getName().endsWith("mega")) {
+ recs = new AltosEepromMegaIterable(in);
+ } else if (file.getName().endsWith("mini")) {
+ recs = new AltosEepromMiniIterable(in);
+ } else {
+ recs = new AltosTelemetryIterable(in);
+ }
+ return recs;
+ }
+
+ static AltosReplayReader replay_file(File file) {
+ AltosRecordIterable recs = record_iterable(file);
+ if (recs == null)
+ return null;
+ return new AltosReplayReader(recs.iterator(), file);
+ }
+
+ static boolean process_replay(File file) {
+ AltosReplayReader reader = replay_file(file);
+ if (reader == null)
+ return false;
+ AltosFlightUI flight_ui = new AltosFlightUI(new AltosVoice(), reader);
+ flight_ui.set_exit_on_close();
+ return true;
+ }
+
+ static boolean process_graph(File file) {
+ AltosRecordIterable recs = record_iterable(file);
+ if (recs == null)
+ return false;
+ try {
+ new AltosGraphUI(recs, file);
+ return true;
+ } catch (InterruptedException ie) {
+ } catch (IOException ie) {