- double landed_time = landed_time(iterable);
-
- year = month = day = -1;
- hour = minute = second = -1;
- serial = flight = -1;
- for (AltosRecord record : iterable) {
- if (serial < 0)
- serial = record.serial;
- if ((record.seen & AltosRecord.seen_flight) != 0 && flight < 0)
- flight = record.flight;
- new_state = new AltosState(record, state);
- end_time = new_state.time;
- state = new_state;
- if (state.time >= boost_time && state.state < Altos.ao_flight_boost)
- state.state = Altos.ao_flight_boost;
- if (state.time >= landed_time && state.state < Altos.ao_flight_landed)
- state.state = Altos.ao_flight_landed;
- if (0 <= state.state && state.state < Altos.ao_flight_invalid) {
- if (state.state >= Altos.ao_flight_boost) {
- if (state.gps != null && state.gps.locked &&
- year < 0) {
- year = state.gps.year;
- month = state.gps.month;
- day = state.gps.day;
- hour = state.gps.hour;
- minute = state.gps.minute;
- second = state.gps.second;
- }
+ double landed_time = landed_time(states);
+
+ year = month = day = AltosLib.MISSING;
+ hour = minute = second = AltosLib.MISSING;
+ serial = flight = AltosLib.MISSING;
+ lat = lon = AltosLib.MISSING;
+ has_gps = false;
+ has_other_adc = false;
+ has_rssi = false;
+ 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_other_adc = true;
+ if (state.rssi != AltosLib.MISSING)
+ has_rssi = true;
+ end_time = state.time;
+
+ int state_id = state.state;
+ if (state.time >= boost_time && state_id < Altos.ao_flight_boost)
+ state_id = Altos.ao_flight_boost;
+ if (state.time >= landed_time && state_id < Altos.ao_flight_landed)
+ state_id = Altos.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;
+ }
+ if (0 <= state_id && state_id < Altos.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;
+ max_height = state.max_height();
+ max_speed = state.max_speed();
+ max_acceleration = state.max_acceleration();
+ }
+ if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) {
+ if (state_id <= Altos.ao_flight_pad) {
+ pad_lat = state.gps.lat;
+ pad_lon = state.gps.lon;