- 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;
- }
+ 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]++;