- double prev_accel_speed = prev_state.accel_speed;
-
- if (prev_accel_speed == AltosRecord.MISSING)
- prev_accel_speed = 0;
-
- if (acceleration == AltosRecord.MISSING) {
- /* Fill in mising acceleration value */
- accel_speed = baro_speed;
-
- if (time_change > 0 && accel_speed != AltosRecord.MISSING)
- acceleration = (accel_speed - prev_accel_speed) / time_change;
- else
- acceleration = prev_state.acceleration;
- } else {
- /* compute accelerometer speed */
- accel_speed = prev_accel_speed + acceleration * time_change;
- }
- }
- } else {
- npad = 0;
- ngps = 0;
- gps = null;
- gps_sequence = 0;
- baro_speed = AltosRecord.MISSING;
- accel_speed = AltosRecord.MISSING;
- pad_alt = AltosRecord.MISSING;
- max_baro_speed = 0;
- max_accel_speed = 0;
- max_height = 0;
- max_acceleration = 0;
- time_change = 0;
- baro = new AltosMs5607();
- callsign = "";
- accel_plus_g = AltosRecord.MISSING;
- accel_minus_g = AltosRecord.MISSING;
- log_format = AltosRecord.MISSING;
- serial = AltosRecord.MISSING;
- }
-
- time = tick / 100.0;
-
- 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)
- set_npad(npad+1);
- else
- set_npad(0);
-
- /* Average GPS data while on the pad */
- if (data.gps != null && data.gps.locked && data.gps.nsat >= 4) {
- if (ngps > 1 && state == AltosLib.ao_flight_pad) {
- /* filter pad position */
- pad_lat = (pad_lat * 31.0 + data.gps.lat) / 32.0;
- pad_lon = (pad_lon * 31.0 + data.gps.lon) / 32.0;
- pad_alt = (pad_alt * 31.0 + data.gps.alt) / 32.0;
- } else {
- pad_lat = data.gps.lat;
- pad_lon = data.gps.lon;
- pad_alt = data.gps.alt;
- }
- ngps++;
- }
- } else {
- if (ngps == 0 && ground_altitude != AltosRecord.MISSING)
- pad_alt = ground_altitude;
- }
-
- gps_sequence = data.gps_sequence;
-
- /* Only look at accelerometer data under boost */
- if (boost && acceleration != AltosRecord.MISSING && (max_acceleration == AltosRecord.MISSING || acceleration > max_acceleration))
- max_acceleration = acceleration;
- if (boost && accel_speed != AltosRecord.MISSING && accel_speed > max_accel_speed)
- max_accel_speed = accel_speed;
- if (boost && baro_speed != AltosRecord.MISSING && baro_speed > max_baro_speed)
- max_baro_speed = baro_speed;
-
- if (height != AltosRecord.MISSING && height > max_height)
- max_height = height;
- elevation = 0;
- range = -1;
- gps_height = 0;
- if (data.gps != null) {
- gps = data.gps;
- if (ngps > 0 && gps.locked) {
- double h = height;
-
- if (h == AltosRecord.MISSING) h = 0;
- from_pad = new AltosGreatCircle(pad_lat, pad_lon, 0, gps.lat, gps.lon, h);
- elevation = from_pad.elevation;
- range = from_pad.range;
- gps_height = gps.alt - pad_alt;
- }
- }