X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosDataPointReader.java;h=821b0771b7f7101ee200dd358822b34958020a3c;hb=50b343d389039eae082e82b8ac0b76ae3e2b3ad4;hp=ee57d2ce811ef14116c7b73d6db4b84fb34afc31;hpb=f3e68341f6f5daaf26dd162e4f9a06c29988986a;p=fw%2Faltos diff --git a/altosui/AltosDataPointReader.java b/altosui/AltosDataPointReader.java index ee57d2ce..821b0771 100644 --- a/altosui/AltosDataPointReader.java +++ b/altosui/AltosDataPointReader.java @@ -9,17 +9,24 @@ import java.text.ParseException; import java.lang.UnsupportedOperationException; import java.util.NoSuchElementException; import java.util.Iterator; +import org.altusmetrum.AltosLib.*; class AltosDataPointReader implements Iterable { Iterator iter; AltosState state; AltosRecord record; + boolean has_gps; + boolean has_accel; + boolean has_ignite; final static int MISSING = AltosRecord.MISSING; - public AltosDataPointReader(Iterable reader) { + public AltosDataPointReader(AltosRecordIterable reader) { this.iter = reader.iterator(); this.state = null; + has_accel = reader.has_accel(); + has_gps = reader.has_gps(); + has_ignite = reader.has_ignite(); } private void read_next_record() @@ -46,13 +53,14 @@ class AltosDataPointReader implements Iterable { public double acceleration() { return record.acceleration(); } public double pressure() { return record.raw_pressure(); } public double altitude() { return record.raw_altitude(); } - public double height() { return record.raw_height(); } + public double height() { return record.raw_height(); } public double accel_speed() { return record.accel_speed(); } public double baro_speed() { return state.baro_speed; } public double temperature() { return record.temperature(); } public double battery_voltage() { return record.battery_voltage(); } public double drogue_voltage() { return record.drogue_voltage(); } public double main_voltage() { return record.main_voltage(); } + public boolean has_accel() { return has_accel; } }; } @@ -62,10 +70,14 @@ class AltosDataPointReader implements Iterable { throw new UnsupportedOperationException(); } public boolean hasNext() { + if (record != null && record.state == Altos.ao_flight_landed) + return false; return iter.hasNext(); } public AltosDataPoint next() { - read_next_record(); + do { + read_next_record(); + } while (record.time < -1.0 && hasNext()); return current_dp(); } };