- 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]++;
- }
- if (state_start[state_id] == 0.0)
- state_start[state_id] = state.time;
- if (state_end[state_id] < state.time)
- state_end[state_id] = state.time;
- }
- if (state.pad_lat != AltosLib.MISSING) {
- pad_lat = state.pad_lat;
- pad_lon = state.pad_lon;
+
+ for (int s = 0; s < AltosLib.ao_flight_invalid + 1; s++) {
+ state_speed[s] = AltosLib.MISSING;
+ state_enter_speed[s] = AltosLib.MISSING;
+ state_accel[s] = AltosLib.MISSING;
+ state_time[s] = 0;
+ speeds[s] = new AltosTimeValue(0, 0);
+ accels[s] = new AltosTimeValue(0, 0);
+ }
+
+ max_speed = AltosLib.MISSING;
+ max_acceleration = AltosLib.MISSING;
+
+ if (series.state_series != null) {
+ AltosTimeValue prev = null;
+ for (AltosTimeValue state : series.state_series) {
+ if (prev != null)
+ add_times(series, (int) prev.value, prev.time, state.time);
+ prev = state;