diff options
| author | Keith Packard <keithp@keithp.com> | 2013-05-14 00:24:53 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2013-05-14 00:24:53 -0700 | 
| commit | 43f94e923a6a87520edcbb8fb4829e6ddf708908 (patch) | |
| tree | 418a5faf0b502845450f092961aa78235d5d22ea /altoslib/AltosState.java | |
| parent | c88aa32b979f379e3cf316dcb651e264c32a5283 (diff) | |
altoslib: Use sequence numbers to track GPS updates to AltosRecord
State objects now record what GPS sequence ID they have to know when
the GPS data has been updated. Record objects bump the GPS sequence
each time new GPS data is recorded. This way, record objects aren't
modified as they're iterated over to generate the list of state
objects which makes it possible to iterate multiple times and get the
same resulting set of states.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosState.java')
| -rw-r--r-- | altoslib/AltosState.java | 7 | 
1 files changed, 5 insertions, 2 deletions
| diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index ccbe498d..825306be 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -54,6 +54,7 @@ public class AltosState {  	public double	max_baro_speed;  	public AltosGPS	gps; +	public int gps_sequence;  	public AltosIMU	imu;  	public AltosMag	mag; @@ -133,6 +134,7 @@ public class AltosState {  			npad = prev_state.npad;  			ngps = prev_state.ngps;  			gps = prev_state.gps; +			gps_sequence = prev_state.gps_sequence;  			pad_lat = prev_state.pad_lat;  			pad_lon = prev_state.pad_lon;  			pad_alt = prev_state.pad_alt; @@ -187,6 +189,7 @@ public class AltosState {  			npad = 0;  			ngps = 0;  			gps = null; +			gps_sequence = 0;  			baro_speed = AltosRecord.MISSING;  			accel_speed = AltosRecord.MISSING;  			pad_alt = AltosRecord.MISSING; @@ -199,7 +202,7 @@ public class AltosState {  		time = tick / 100.0; -		if (cur.new_gps && (state < AltosLib.ao_flight_boost)) { +		if (data.gps != null && data.gps_sequence != gps_sequence && (state < AltosLib.ao_flight_boost)) {  			/* Track consecutive 'good' gps reports, waiting for 10 of them */  			if (data.gps != null && data.gps.locked && data.gps.nsat >= 4) @@ -226,7 +229,7 @@ public class AltosState {  				pad_alt = ground_altitude;  		} -		data.new_gps = false; +		gps_sequence = data.gps_sequence;  		gps_waiting = MIN_PAD_SAMPLES - npad;  		if (gps_waiting < 0) | 
