- boolean has_gps = false;
- boolean has_accel = false;
- boolean has_ignite = false;
- public boolean has_gps() { return has_gps; }
- public boolean has_accel() { return has_accel; }
- public boolean has_ignite() { return has_ignite; };
-
- public AltosTelemetryIterable (FileInputStream input) {
- boolean saw_boost = false;
- int current_tick = 0;
- int boost_tick = 0;
-
- AltosRecord previous = null;
- records = new TreeSet<AltosRecord> ();
-
- try {
- for (;;) {
- String line = AltosRecord.gets(input);
- if (line == null) {
- break;
- }
- try {
- AltosRecord record = AltosTelemetry.parse(line, previous);
- if (record == null)
- break;
- if (records.isEmpty()) {
- current_tick = record.tick;
- } else {
- int tick = record.tick;
- while (tick < current_tick - 0x1000)
- tick += 0x10000;
- current_tick = tick;
- record.tick = current_tick;
- }
- if (!saw_boost && record.state >= AltosLib.ao_flight_boost)
- {
- saw_boost = true;
- boost_tick = record.tick;
- }
- if (record.accel != AltosRecord.MISSING)
- has_accel = true;
- if (record.gps != null)
- has_gps = true;
- if (record.main != AltosRecord.MISSING)
- has_ignite = true;
- if (previous != null && previous.tick != record.tick)
- records.add(previous);
- previous = record;
- } catch (ParseException pe) {
- System.out.printf("parse exception %s\n", pe.getMessage());
- } catch (AltosCRCException ce) {
- }
- }
- } catch (IOException io) {
- System.out.printf("io exception\n");
- }
+ AltosTelemetryOrdered (AltosTelemetry telem, int index, int tick) {
+ this.telem = telem;
+ this.index = index;
+ this.tick = tick;
+ }
+}
+
+class AltosTelemetryOrderedIterator implements Iterator<AltosTelemetry> {
+ Iterator<AltosTelemetryOrdered> iterator;
+
+ public AltosTelemetryOrderedIterator(TreeSet<AltosTelemetryOrdered> telems) {
+ iterator = telems.iterator();
+ }
+
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }