import java.text.*;
public class AltosTelemetryIterable extends AltosRecordIterable {
- LinkedList<AltosRecord> records;
+ TreeSet<AltosRecord> records;
public Iterator<AltosRecord> iterator () {
return records.iterator();
}
+ 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;
- records = new LinkedList<AltosRecord> ();
+ AltosRecord previous = null;
+ records = new TreeSet<AltosRecord> ();
try {
for (;;) {
break;
}
try {
- AltosTelemetry record = new AltosTelemetry(line);
+ AltosRecord record = AltosTelemetry.parse(line, previous);
if (record == null)
break;
if (records.isEmpty()) {
current_tick = record.tick;
} else {
- int tick = record.tick | (current_tick & ~ 0xffff);
- if (tick < current_tick - 0x1000)
+ int tick = record.tick;
+ while (tick < current_tick - 0x1000)
tick += 0x10000;
current_tick = tick;
record.tick = current_tick;
saw_boost = true;
boost_tick = record.tick;
}
- records.add(record);
+ 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) {
- System.out.printf("crc error\n");
}
}
} catch (IOException io) {
System.out.printf("io exception\n");
}
+ if (previous != null)
+ records.add(previous);
+
/* adjust all tick counts to be relative to boost time */
for (AltosRecord r : this)
r.time = (r.tick - boost_tick) / 100.0;