- for (AltosState state : states) {
- if (serial == AltosLib.MISSING && state.serial != AltosLib.MISSING)
- serial = state.serial;
- if (flight == AltosLib.MISSING && state.flight != AltosLib.MISSING)
- flight = state.flight;
- if (state.battery_voltage != AltosLib.MISSING)
- has_battery = true;
- if (state.main_voltage != AltosLib.MISSING)
- has_flight_adc = true;
- if (state.rssi != AltosLib.MISSING)
- has_rssi = true;
- end_time = state.time;
-
- if (state.pressure() != AltosLib.MISSING)
- has_flight_data = true;
-
- int state_id = state.state;
- if (state.time >= boost_time && state_id < AltosLib.ao_flight_boost)
- state_id = AltosLib.ao_flight_boost;
- if (state.time >= landed_time && state_id < AltosLib.ao_flight_landed)
- state_id = AltosLib.ao_flight_landed;
- if (state.gps != null && state.gps.locked) {
- year = state.gps.year;
- month = state.gps.month;
- day = state.gps.day;
- hour = state.gps.hour;
- minute = state.gps.minute;
- second = state.gps.second;
- }
- max_height = state.max_height();
- max_speed = state.max_speed();
- max_acceleration = state.max_acceleration();
- max_gps_height = state.max_gps_height();
-
- if (0 <= state_id && state_id < AltosLib.ao_flight_invalid) {
- double acceleration = state.acceleration();
- double speed = state.speed();
- if (acceleration != AltosLib.MISSING && speed != AltosLib.MISSING) {
- state_accel[state_id] += acceleration;
- state_speed[state_id] += speed;
- state_count[state_id]++;
+
+ for (int s = AltosLib.ao_flight_startup; s <= AltosLib.ao_flight_landed; s++) {
+ state_count[s] = 0;
+
+ if (s == AltosLib.ao_flight_boost)
+ state_start[s] = boost_time;
+ else
+ state_start[s] = series.state_series.time_of(s);
+ if (s == AltosLib.ao_flight_main)
+ state_end[s] = landed_time;
+ else
+ state_end[s] = series.state_series.time_of(s+1);
+
+ if (series.speed_series != null)
+ state_speed[s] = series.speed_series.average(state_start[s], state_end[s]);
+
+ if (series.accel_series != null)
+ state_accel[s] = series.accel_series.average(state_start[s], state_end[s]);
+ }
+
+ serial = cal_data.serial;
+ flight = cal_data.flight;
+
+ has_battery = series.battery_voltage_series != null;
+ has_flight_adc = series.main_voltage_series != null;
+ has_rssi = series.rssi_series != null;
+ has_flight_data = series.pressure_series != null;
+
+ AltosGPS gps = series.cal_data.gps_pad;
+
+ if (gps != null) {
+ year = gps.year;
+ month = gps.month;
+ day = gps.day;
+ hour = gps.hour;
+ minute = gps.minute;
+ second = gps.second;
+ has_gps = true;
+ lat = pad_lat = gps.lat;
+ lon = pad_lon = gps.lon;
+ for (AltosGPSTimeValue gtv : series.gps_series) {
+ gps = gtv.gps;
+ if (gps.locked && gps.nsat >= 4) {
+ lat = gps.lat;
+ lon = gps.lon;