altosdroid: Deal with AltosState changes
authorKeith Packard <keithp@keithp.com>
Sat, 27 May 2017 07:27:04 +0000 (00:27 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 27 May 2017 07:27:04 +0000 (00:27 -0700)
cal data split out from altos state.
altos state needed to have no-arguments constructor for JSON code.
Also messed with voice to make it stay quiet during app startup.

Signed-off-by: Keith Packard <keithp@keithp.com>
14 files changed:
altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferencesBackend.java
altosdroid/src/org/altusmetrum/AltosDroid/AltosMapOffline.java
altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java
altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java
altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java
altosdroid/src/org/altusmetrum/AltosDroid/TelemetryState.java
altoslib/AltosDataListener.java
altoslib/AltosFlightSeries.java
altoslib/AltosFlightStats.java
altoslib/AltosMapStore.java
altoslib/AltosState.java
altoslib/AltosTelemetryFile.java
altosui/AltosGraphUI.java

index 30a949d..36ba030 100644 (file)
@@ -54,6 +54,29 @@ import android.graphics.drawable.*;
 
 import org.altusmetrum.altoslib_11.*;
 
+class SavedState {
+       long    received_time;
+       int     state;
+       boolean locked;
+       String  callsign;
+       int     serial;
+       int     flight;
+       int     rssi;
+
+       SavedState(AltosState state) {
+               received_time = state.received_time;
+               this.state = state.state();
+               if (state.gps != null)
+                       locked = state.gps.locked;
+               else
+                       locked = false;
+               callsign = state.cal_data.callsign;
+               serial = state.cal_data.serial;
+               flight = state.cal_data.flight;
+               rssi = state.rssi;
+       }
+}
+
 public class AltosDroid extends FragmentActivity implements AltosUnitsListener, LocationListener {
 
        // Actions sent to the telemetry server at startup time
@@ -114,6 +137,9 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
 
        public Location location = null;
 
+       private AltosState      state;
+       private SavedState      saved_state;
+
        // Tabs
        TabHost         mTabHost;
        AltosViewPager  mViewPager;
@@ -123,7 +149,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
 
        // Timer and Saved flight state for Age calculation
        private Timer timer;
-       AltosState saved_state;
+
        TelemetryState  telemetry_state;
        Integer[]       serials;
 
@@ -307,7 +333,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
 
                if (telemetry_state.states.containsKey(current_serial)) {
                        state = telemetry_state.states.get(current_serial);
-                       int age = state_age(state);
+                       int age = state_age(state.received_time);
                        if (age < 20)
                                aged = false;
                        if (current_serial == selected_serial)
@@ -322,7 +348,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
 
                        for (int serial : telemetry_state.states.keySet()) {
                                AltosState      existing = telemetry_state.states.get(serial);
-                               int             existing_age = state_age(existing);
+                               int             existing_age = state_age(existing.received_time);
 
                                if (newest_state == null || existing_age < newest_age) {
                                        newest_state = existing;
@@ -334,7 +360,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
                                state = newest_state;
                }
 
-               update_ui(telemetry_state, state);
+               update_ui(telemetry_state, state, telemetry_state.quiet);
 
                start_timer();
        }
@@ -362,8 +388,8 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
                        blend_component(a, b, r, 24, 0xff));
        }
 
-       int state_age(AltosState state) {
-               return (int) ((System.currentTimeMillis() - state.received_time + 500) / 1000);
+       int state_age(long received_time) {
+               return (int) ((System.currentTimeMillis() - received_time + 500) / 1000);
        }
 
        void set_screen_on(int age) {
@@ -375,7 +401,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
 
        void update_age() {
                if (saved_state != null) {
-                       int age = state_age(saved_state);
+                       int age = state_age(saved_state.received_time);
 
                        double age_scale = age / 100.0;
 
@@ -399,17 +425,19 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
                }
        }
 
-       void update_ui(TelemetryState telem_state, AltosState state) {
+       void update_ui(TelemetryState telem_state, AltosState state, boolean quiet) {
+
+               this.state = state;
 
                int prev_state = AltosLib.ao_flight_invalid;
 
                AltosGreatCircle from_receiver = null;
 
                if (saved_state != null)
-                       prev_state = saved_state.state();
+                       prev_state = saved_state.state;
 
                if (state != null) {
-                       set_screen_on(state_age(state));
+                       set_screen_on(state_age(state.received_time));
 
                        if (state.state() == AltosLib.ao_flight_stateless) {
                                boolean prev_locked = false;
@@ -417,8 +445,8 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
 
                                if(state.gps != null)
                                        locked = state.gps.locked;
-                               if (saved_state != null && saved_state.gps != null)
-                                       prev_locked = saved_state.gps.locked;
+                               if (saved_state != null)
+                                       prev_locked = saved_state.locked;
                                if (prev_locked != locked) {
                                        String currentTab = mTabHost.getCurrentTabTag();
                                        if (locked) {
@@ -456,22 +484,22 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
                                                                     state.gps.alt);
                        }
 
-                       if (saved_state == null || !same_string(saved_state.callsign, state.callsign)) {
-                               mCallsignView.setText(state.callsign);
+                       if (saved_state == null || !same_string(saved_state.callsign, state.cal_data.callsign)) {
+                               mCallsignView.setText(state.cal_data.callsign);
                        }
-                       if (saved_state == null || state.serial != saved_state.serial) {
-                               if (state.serial == AltosLib.MISSING)
+                       if (saved_state == null || state.cal_data.serial != saved_state.serial) {
+                               if (state.cal_data.serial == AltosLib.MISSING)
                                        mSerialView.setText("");
                                else
-                                       mSerialView.setText(String.format("%d", state.serial));
+                                       mSerialView.setText(String.format("%d", state.cal_data.serial));
                        }
-                       if (saved_state == null || state.flight != saved_state.flight) {
-                               if (state.flight == AltosLib.MISSING)
+                       if (saved_state == null || state.cal_data.flight != saved_state.flight) {
+                               if (state.cal_data.flight == AltosLib.MISSING)
                                        mFlightView.setText("");
                                else
-                                       mFlightView.setText(String.format("%d", state.flight));
+                                       mFlightView.setText(String.format("%d", state.cal_data.flight));
                        }
-                       if (saved_state == null || state.state() != saved_state.state()) {
+                       if (saved_state == null || state.state() != saved_state.state) {
                                if (state.state() == AltosLib.ao_flight_stateless) {
                                        mStateLayout.setVisibility(View.GONE);
                                } else {
@@ -485,15 +513,16 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
                                else
                                        mRSSIView.setText(String.format("%d", state.rssi));
                        }
+                       saved_state = new SavedState(state);
                }
 
                for (AltosDroidTab mTab : mTabs)
                        mTab.update_ui(telem_state, state, from_receiver, location, mTab == mTabsAdapter.currentItem());
 
+               AltosDebug.debug("quiet %b\n", quiet);
                if (mAltosVoice != null)
-                       mAltosVoice.tell(telem_state, state, from_receiver, location, (AltosDroidTab) mTabsAdapter.currentItem());
+                       mAltosVoice.tell(telem_state, state, from_receiver, location, (AltosDroidTab) mTabsAdapter.currentItem(), quiet);
 
-               saved_state = state;
        }
 
        private void onTimerTick() {
@@ -567,8 +596,9 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
                // Display the Version
                mVersion = (TextView) findViewById(R.id.version);
                mVersion.setText("Version: " + BuildInfo.version +
-                                "  Built: " + BuildInfo.builddate + " " + BuildInfo.buildtime + " " + BuildInfo.buildtz +
-                                "  (" + BuildInfo.branch + "-" + BuildInfo.commitnum + "-" + BuildInfo.commithash + ")");
+                                (AltosVersion.has_google_maps_api_key() ? " maps" : "") +
+                                " Built: " + BuildInfo.builddate + " " + BuildInfo.buildtime + " " + BuildInfo.buildtz +
+                                " (" + BuildInfo.branch + "-" + BuildInfo.commitnum + "-" + BuildInfo.commithash + ")");
 
                mCallsignView  = (TextView) findViewById(R.id.callsign_value);
                mRSSIView      = (TextView) findViewById(R.id.rssi_value);
@@ -703,7 +733,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
                                         location.getLatitude(),
                                         location.getLongitude());
 
-               update_ui(telemetry_state, saved_state);
+               update_ui(telemetry_state, state, true);
        }
 
        @Override
@@ -1094,7 +1124,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
                AltosDebug.debug("Location changed to %f,%f",
                                 location.getLatitude(),
                                 location.getLongitude());
-               update_ui(telemetry_state, saved_state);
+               update_ui(telemetry_state, state, false);
        }
 
        public void onStatusChanged(String provider, int status, Bundle extras) {
index 2e6ccb3..2fceb53 100644 (file)
@@ -77,7 +77,17 @@ public class AltosDroidPreferencesBackend extends AltosPreferencesBackend {
        }
 
        public String getString(String key, String def) {
-               return prefs.getString(key, def);
+               String  ret;
+               ret = prefs.getString(key, def);
+//             AltosDebug.debug("AltosDroidPreferencesBackend get string %s:\n", key);
+//             if (ret == null)
+//                     AltosDebug.debug("      (null)\n");
+//             else {
+//                     String[] lines = ret.split("\n");
+//                     for (String l : lines)
+//                             AltosDebug.debug("        %s\n", l);
+//             }
+               return ret;
        }
 
        public byte[] getBytes(String key, byte[] def) {
@@ -103,6 +113,10 @@ public class AltosDroidPreferencesBackend extends AltosPreferencesBackend {
        }
 
        public void putString(String key, String value) {
+//             AltosDebug.debug("AltosDroidPreferencesBackend put string %s:\n", key);
+//             String[] lines = value.split("\n");
+//             for (String l : lines)
+//                     AltosDebug.debug("        %s\n", l);
                editor.putString(key, value);
        }
 
index 76771ad..3f74bbb 100644 (file)
@@ -164,6 +164,7 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal
                                                break;
                                        case AltosMapTile.forbidden:
                                                message = "Too many requests, try later";
+                                               AltosDebug.debug("Forbidden map response %d\n", AltosMapStore.forbidden_response);
                                                break;
                                        }
                                        if (message != null) {
@@ -476,11 +477,11 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal
                                if (t_state.gps != null) {
                                        AltosLatLon     latlon = new AltosLatLon(t_state.gps.lat, t_state.gps.lon);
                                        rocket.set_position(latlon, t_state.received_time);
-                                       if (state.serial == serial)
+                                       if (state.cal_data.serial == serial)
                                                there = latlon;
                                }
                                if (state != null)
-                                       rocket.set_active(state.serial == serial);
+                                       rocket.set_active(state.cal_data.serial == serial);
                        }
                }
                if (receiver != null) {
index 811b036..308c50e 100644 (file)
@@ -49,6 +49,7 @@ public class AltosVoice {
        private Location        last_receiver;
        private long            last_speak_time;
        private int             last_flight_tell = TELL_FLIGHT_NONE;
+       private boolean         quiet = false;
 
        private long now() {
                return System.currentTimeMillis();
@@ -80,7 +81,8 @@ public class AltosVoice {
        public synchronized void speak(String s) {
                if (!tts_enabled) return;
                last_speak_time = now();
-               tts.speak(s, TextToSpeech.QUEUE_ADD, null);
+               if (!quiet)
+                       tts.speak(s, TextToSpeech.QUEUE_ADD, null);
        }
 
        public synchronized long time_since_speak() {
@@ -121,6 +123,8 @@ public class AltosVoice {
                if (state == null)
                        return false;
 
+               AltosDebug.debug("tell_pad lag %b ltm %d\n", last_apogee_good, last_tell_mode);
+
                if (state.apogee_voltage != AltosLib.MISSING)
                        last_apogee_good = tell_gonogo("apogee",
                                                       state.apogee_voltage >= AltosLib.ao_igniter_good,
@@ -277,7 +281,9 @@ public class AltosVoice {
 
        public void tell(TelemetryState telem_state, AltosState state,
                         AltosGreatCircle from_receiver, Location receiver,
-                        AltosDroidTab tab) {
+                        AltosDroidTab tab, boolean quiet) {
+
+               this.quiet = quiet;
 
                boolean spoken = false;
 
@@ -288,7 +294,7 @@ public class AltosVoice {
                int     tell_serial = last_tell_serial;
 
                if (state != null)
-                       tell_serial = state.serial;
+                       tell_serial = state.cal_data.serial;
 
                if (tell_serial != last_tell_serial)
                        reset_last();
index 492f7f5..37e2df1 100644 (file)
@@ -178,10 +178,10 @@ public class TabPad extends AltosDroidTab {
                        }
                        main_lights.set(state.main_voltage >= AltosLib.ao_igniter_good, state.main_voltage == AltosLib.MISSING);
 
-                       int num_igniter = state.ignitor_voltage == null ? 0 : state.ignitor_voltage.length;
+                       int num_igniter = state.igniter_voltage == null ? 0 : state.igniter_voltage.length;
 
                        for (int i = 0; i < 4; i++) {
-                               double voltage = i >= num_igniter ? AltosLib.MISSING : state.ignitor_voltage[i];
+                               double voltage = i >= num_igniter ? AltosLib.MISSING : state.igniter_voltage[i];
                                if (voltage == AltosLib.MISSING) {
                                        ignite_row[i].setVisibility(View.GONE);
                                } else {
@@ -191,7 +191,7 @@ public class TabPad extends AltosDroidTab {
                                ignite_lights[i].set(voltage >= AltosLib.ao_igniter_good, voltage == AltosLib.MISSING);
                        }
 
-                       if (state.flight != 0) {
+                       if (state.cal_data.flight != 0) {
                                if (state.state() <= AltosLib.ao_flight_pad)
                                        data_logging_view.setText("Ready to record");
                                else if (state.state() < AltosLib.ao_flight_landed)
@@ -201,7 +201,7 @@ public class TabPad extends AltosDroidTab {
                        } else {
                                data_logging_view.setText("Storage full");
                        }
-                       data_logging_lights.set(state.flight != 0, state.flight == AltosLib.MISSING);
+                       data_logging_lights.set(state.cal_data.flight != 0, state.cal_data.flight == AltosLib.MISSING);
 
                        if (state.gps != null) {
                                int soln = state.gps.nsat;
index 34c86ce..45bb473 100644 (file)
@@ -259,14 +259,15 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene
        private void telemetry(AltosTelemetry telem) {
                AltosState      state;
 
-               if (telemetry_state.states.containsKey(telem.serial))
-                       state = telemetry_state.states.get(telem.serial).clone();
+               if (telemetry_state.states.containsKey(telem.serial()))
+                       state = telemetry_state.states.get(telem.serial());
                else
-                       state = new AltosState();
-               telem.update_state(state);
-               telemetry_state.states.put(telem.serial, state);
+                       state = new AltosState(new AltosCalData());
+               telem.provide_data(state, state.cal_data);
+               telemetry_state.states.put(telem.serial(), state);
+               telemetry_state.quiet = false;
                if (state != null) {
-                       AltosPreferences.set_state(state);
+                       AltosPreferences.set_state(state,telem.serial());
                }
                send_to_clients();
        }
@@ -615,6 +616,8 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene
 
                telemetry_state.latest_serial = AltosPreferences.latest_state();
 
+               telemetry_state.quiet = true;
+
                AltosDebug.debug("latest serial %d\n", telemetry_state.latest_serial);
 
                for (int serial : serials) {
@@ -625,7 +628,7 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene
 
                                AltosDebug.debug("recovered old state serial %d flight %d",
                                                 serial,
-                                                saved_state.flight);
+                                                saved_state.cal_data.flight);
                                if (saved_state.gps != null)
                                        AltosDebug.debug("\tposition %f,%f",
                                                         saved_state.gps.lat,
@@ -699,7 +702,7 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene
 
        /* AltosIdleMonitorListener */
        public void update(AltosState state, AltosListenerState listener_state) {
-               telemetry_state.states.put(state.serial, state);
+               telemetry_state.states.put(state.cal_data.serial, state);
                telemetry_state.receiver_battery = listener_state.battery;
                send_to_clients();
        }
index 32ba125..46b4027 100644 (file)
@@ -36,6 +36,8 @@ public class TelemetryState {
        double          frequency;
        int             telemetry_rate;
 
+       boolean         quiet;
+
        HashMap<Integer,AltosState>     states;
 
        int             latest_serial;
index 14c29d8..f8d3873 100644 (file)
@@ -16,9 +16,9 @@ package org.altusmetrum.altoslib_11;
 
 public abstract class AltosDataListener {
 
-       public AltosCalData     cal_data;
-
-       public double   time = AltosLib.MISSING;
+       public AltosCalData     cal_data = null;
+       public double           time = AltosLib.MISSING;
+       public int              state = AltosLib.MISSING;
 
        public void set_time(double time) {
                if (time != AltosLib.MISSING)
@@ -29,8 +29,6 @@ public abstract class AltosDataListener {
                return time;
        }
 
-       public int      state = AltosLib.MISSING;
-
        public void set_state(int state) {
                if (state != AltosLib.MISSING)
                        this.state = state;
@@ -67,6 +65,9 @@ public abstract class AltosDataListener {
        public abstract void set_pyro_fired(int pyro_mask);
        public abstract void set_companion(AltosCompanion companion);
 
+       public AltosDataListener() {
+       }
+
        public AltosDataListener(AltosCalData cal_data) {
                this.cal_data = cal_data;
        }
index 944cff3..5cf552f 100644 (file)
@@ -216,7 +216,7 @@ public class AltosFlightSeries extends AltosDataListener {
 
        private void compute_height() {
                double ground_altitude = cal_data.ground_altitude;
-               if (height_series == null && ground_altitude != AltosLib.MISSING) {
+               if (height_series == null && ground_altitude != AltosLib.MISSING && altitude_series != null) {
                        height_series = add_series(height_name, AltosConvert.height);
                        for (AltosTimeValue alt : altitude_series)
                                height_series.add(alt.time, alt.value - ground_altitude);
index 9ebdb9e..f48e6be 100644 (file)
@@ -51,21 +51,26 @@ public class AltosFlightStats {
        double landed_time(AltosFlightSeries series) {
                double  landed_state_time = AltosLib.MISSING;
 
-               for (AltosTimeValue state : series.state_series) {
-                       if (state.value == AltosLib.ao_flight_landed) {
-                               landed_state_time = state.time;
-                               break;
+               if (series.state_series != null) {
+                       for (AltosTimeValue state : series.state_series) {
+                               if (state.value == AltosLib.ao_flight_landed) {
+                                       landed_state_time = state.time;
+                                       break;
+                               }
                        }
                }
 
-               if (landed_state_time == AltosLib.MISSING)
+               if (landed_state_time == AltosLib.MISSING && series.height_series != null)
                        landed_state_time = series.height_series.get(series.height_series.size()-1).time;
 
                double landed_height = AltosLib.MISSING;
-               for (AltosTimeValue height : series.height_series) {
-                       if (height.time >= landed_state_time) {
-                               landed_height = height.value;
-                               break;
+
+               if (series.height_series != null) {
+                       for (AltosTimeValue height : series.height_series) {
+                               if (height.time >= landed_state_time) {
+                                       landed_height = height.value;
+                                       break;
+                               }
                        }
                }
 
@@ -76,13 +81,15 @@ public class AltosFlightStats {
 
                double  landed_time = AltosLib.MISSING;
 
-               for (AltosTimeValue height : series.height_series) {
-                       if (height.value > landed_height + 10) {
-                               above = true;
-                       } else {
-                               if (above && Math.abs(height.value - landed_height) < 2) {
-                                       above = false;
-                                       landed_time = height.time;
+               if (series.height_series != null) {
+                       for (AltosTimeValue height : series.height_series) {
+                               if (height.value > landed_height + 10) {
+                                       above = true;
+                               } else {
+                                       if (above && Math.abs(height.value - landed_height) < 2) {
+                                               above = false;
+                                               landed_time = height.time;
+                                       }
                                }
                        }
                }
@@ -93,17 +100,21 @@ public class AltosFlightStats {
                double          boost_time = AltosLib.MISSING;
                double          boost_state_time = AltosLib.MISSING;
 
-               for (AltosTimeValue state : series.state_series) {
-                       if (state.value >= AltosLib.ao_flight_boost && state.value <= AltosLib.ao_flight_landed) {
-                               boost_state_time = state.time;
-                               break;
+               if (series.state_series != null) {
+                       for (AltosTimeValue state : series.state_series) {
+                               if (state.value >= AltosLib.ao_flight_boost && state.value <= AltosLib.ao_flight_landed) {
+                                       boost_state_time = state.time;
+                                       break;
+                               }
                        }
                }
-               for (AltosTimeValue accel : series.accel_series) {
-                       if (accel.value < 1)
-                               boost_time = accel.time;
-                       if (boost_state_time != AltosLib.MISSING && accel.time >= boost_state_time)
-                               break;
+               if (series.accel_series != null) {
+                       for (AltosTimeValue accel : series.accel_series) {
+                               if (accel.value < 1)
+                                       boost_time = accel.time;
+                               if (boost_state_time != AltosLib.MISSING && accel.time >= boost_state_time)
+                                       break;
+                       }
                }
                return boost_time;
        }
@@ -136,12 +147,16 @@ public class AltosFlightStats {
 
                        if (s == AltosLib.ao_flight_boost)
                                state_start[s] = boost_time;
-                       else
+                       else if (series.state_series != null)
                                state_start[s] = series.state_series.time_of(s);
+                       else
+                               state_start[s] = AltosLib.MISSING;
                        if (s == AltosLib.ao_flight_main)
                                state_end[s] = landed_time;
-                       else
+                       else if (series.state_series != null)
                                state_end[s] = series.state_series.time_of(s+1);
+                       else
+                               state_end[s] = AltosLib.MISSING;
 
                        if (series.speed_series != null)
                                state_speed[s] = series.speed_series.average(state_start[s], state_end[s]);
index 7cce05a..460c52b 100644 (file)
@@ -91,6 +91,7 @@ public class AltosMapStore {
        static Object   forbidden_lock = new Object();
        static long     forbidden_time;
        static boolean  forbidden_set;
+       public static int forbidden_response;
 
        private int fetch_url() {
                URL u;
@@ -116,6 +117,7 @@ public class AltosMapStore {
                                        synchronized (forbidden_lock) {
                                                forbidden_time = System.nanoTime();
                                                forbidden_set = true;
+                                               forbidden_response = response;
                                                return AltosMapTile.forbidden;
                                        }
                                }
index d3929b8..e5a0541 100644 (file)
@@ -43,8 +43,6 @@ public class AltosState extends AltosDataListener {
        public int      rssi;
        public int      status;
 
-       public double   time;
-
        class AltosValue {
                double  value;
                double  prev_value;
@@ -288,7 +286,6 @@ public class AltosState extends AltosDataListener {
                }
        }
 
-       private int     state;
        public boolean  landed;
        public boolean  ascent; /* going up? */
        public boolean  boost;  /* under power */
@@ -506,23 +503,7 @@ public class AltosState extends AltosDataListener {
                pressure.set(p, time);
        }
 
-       class AltosForce extends AltosValue {
-               void set(double p, double time) {
-                       super.set(p, time);
-               }
-
-               AltosForce() {
-                       super();
-               }
-       }
-       private AltosForce      thrust;
-
-       public double thrust() {
-               return thrust.value();
-       }
-
        public void set_thrust(double N) {
-               thrust.set(N, time);
        }
 
        public double baro_height() {
@@ -720,15 +701,8 @@ public class AltosState extends AltosDataListener {
        public int      speak_tick;
        public double   speak_altitude;
 
-       public String   callsign;
-       public String   firmware_version;
-
        public double   ground_accel;
 
-       public int      log_format;
-       public int      log_space;
-       public String   product;
-
        public AltosCompanion   companion;
 
        public int      pyro_fired;
@@ -756,7 +730,6 @@ public class AltosState extends AltosDataListener {
                ground_pressure = new AltosGroundPressure();
                altitude = new AltosAltitude();
                pressure = new AltosPressure();
-               thrust = new AltosForce();
                speed = new AltosSpeed();
                acceleration = new AltosAccel();
                orient = new AltosCValue();
@@ -810,15 +783,8 @@ public class AltosState extends AltosDataListener {
                speak_tick = AltosLib.MISSING;
                speak_altitude = AltosLib.MISSING;
 
-               callsign = null;
-               firmware_version = null;
-
                ground_accel = AltosLib.MISSING;
 
-               log_format = AltosLib.MISSING;
-               log_space = AltosLib.MISSING;
-               product = null;
-
                companion = null;
 
                pyro_fired = 0;
@@ -1108,6 +1074,10 @@ public class AltosState extends AltosDataListener {
                this.pyro_fired = fired;
        }
 
+       public AltosState() {
+               init();
+       }
+
        public AltosState (AltosCalData cal_data) {
                super(cal_data);
                init();
index 46a5d06..40b9c9b 100644 (file)
@@ -123,6 +123,8 @@ public class AltosTelemetryFile implements AltosRecordSet {
                        cal_data.set_tick(tick);
                        if (cal_data.time() >= -1)
                                telem.provide_data(listener, cal_data);
+                       if (listener.state == AltosLib.ao_flight_landed)
+                               break;
                }
                listener.finish();
        }
index db0cac2..71aa0e6 100644 (file)
@@ -46,17 +46,19 @@ public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, Alt
                boolean                 any_gps = false;
                AltosGPSTimeValue       gtv_last = null;
 
-               for (AltosGPSTimeValue gtv : flight_series.gps_series) {
-                       gtv_last = gtv;
-                       AltosGPS gps = gtv.gps;
-                       if (gps != null &&
-                           gps.locked &&
-                           gps.nsat >= 4) {
-                               if (map == null)
-                                       map = new AltosUIMap();
-                               map.show(gps, (int) flight_series.value_before(AltosFlightSeries.state_name, gtv.time));
-                               this.gps = gps;
-                               has_gps = true;
+               if (flight_series.gps_series != null) {
+                       for (AltosGPSTimeValue gtv : flight_series.gps_series) {
+                               gtv_last = gtv;
+                               AltosGPS gps = gtv.gps;
+                               if (gps != null &&
+                                   gps.locked &&
+                                   gps.nsat >= 4) {
+                                       if (map == null)
+                                               map = new AltosUIMap();
+                                       map.show(gps, (int) flight_series.value_before(AltosFlightSeries.state_name, gtv.time));
+                                       this.gps = gps;
+                                       has_gps = true;
+                               }
                        }
                }
                if (gtv_last != null) {