+ for (AltosRecord record : iterable) {
+ state = new AltosState(record, state);
+
+ if (state.acceleration < 1)
+ boost_time = state.time;
+ if (state.state >= Altos.ao_flight_boost)
+ break;
+ }
+ if (boost_time == -1000)
+ boost_time = state.time;
+ return boost_time;
+ }
+
+
+ public AltosFlightStats(AltosRecordIterable iterable) throws InterruptedException, IOException {
+ AltosState state = null;
+ AltosState new_state = null;
+ double boost_time = boost_time(iterable);
+ double end_time = 0;
+ 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;
+ }
+ }
+ state_accel[state.state] += state.acceleration;
+ state_accel_speed[state.state] += state.accel_speed;
+ state_baro_speed[state.state] += state.baro_speed;
+ state_count[state.state]++;
+ if (state_start[state.state] == 0.0)
+ state_start[state.state] = state.time;
+ if (state_end[state.state] < state.time)
+ state_end[state.state] = state.time;
+ max_height = state.max_height;
+ if (state.max_accel_speed != 0)
+ max_speed = state.max_accel_speed;
+ else
+ max_speed = state.max_baro_speed;
+ max_acceleration = state.max_acceleration;