- year = month = day = -1;
- hour = minute = second = -1;
- serial = flight = -1;
- for (;;) {
- try {
- AltosRecord record = reader.read();
- if (record == null)
- break;
- 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 (0 <= state.state && state.state < Altos.ao_flight_invalid) {
- if (state.state >= Altos.ao_flight_boost) {
- if (boost_time == -1)
- boost_time = state.time;
- 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_speed[state.state] += state.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_speed != 0)
- max_speed = state.max_speed;
- else
- max_speed = state.max_baro_speed;
- max_acceleration = state.max_acceleration;
- }
- } catch (ParseException pp) {
- System.out.printf("Parse error: %d \"%s\"\n", pp.getErrorOffset(), pp.getMessage());
- } catch (AltosCRCException ce) {
+ 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;