altoslib: Make AltosState serializable
authorKeith Packard <keithp@keithp.com>
Sun, 16 Nov 2014 00:03:32 +0000 (16:03 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 16 Nov 2014 00:03:32 +0000 (16:03 -0800)
This involved making every class it references serializable as well

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosAccel.java
altoslib/AltosCompanion.java
altoslib/AltosGPS.java
altoslib/AltosGreatCircle.java
altoslib/AltosIMU.java
altoslib/AltosListenerState.java
altoslib/AltosMag.java
altoslib/AltosMs5607.java
altoslib/AltosSavedState.java [new file with mode: 0644]
altoslib/AltosState.java
altoslib/Makefile.am

index d91da4dab0235ec35742e142ad2b60dec8cb8165..e40a47b4ab8467d13f5deadf1e285bcae642d11e 100644 (file)
@@ -17,7 +17,9 @@
 
 package org.altusmetrum.altoslib_5;
 
-public class AltosAccel extends AltosUnits {
+import java.io.*;
+
+public class AltosAccel extends AltosUnits implements Serializable {
 
        public double value(double v, boolean imperial_units) {
                if (imperial_units)
@@ -46,4 +48,4 @@ public class AltosAccel extends AltosUnits {
        public int show_fraction(int width, boolean imperial_units) {
                return width / 9;
        }
-}
\ No newline at end of file
+}
index 47deb2a3dd1be6bb0212eb5ce767bd7d931ed8d2..7e9ab2f1501e94c844230b52aa2f4a05cd2c5bcf 100644 (file)
@@ -17,7 +17,9 @@
 
 package org.altusmetrum.altoslib_5;
 
-public class AltosCompanion {
+import java.io.*;
+
+public class AltosCompanion implements Serializable {
        public final static int board_id_telescience = 0x0a;
        public final static int MAX_CHANNELS = 12;
 
index 0154e95d7c96d3231d831d18973010a32f1989f9..285b5b45aca691e916ec000be19a4feff3f2a0b6 100644 (file)
@@ -19,8 +19,9 @@ package org.altusmetrum.altoslib_5;
 
 import java.text.*;
 import java.util.concurrent.*;
+import java.io.*;
 
-public class AltosGPS implements Cloneable {
+public class AltosGPS implements Cloneable, Serializable {
 
        public final static int MISSING = AltosLib.MISSING;
 
index 716eeef98396c61ad3ec3d6f063143ad4cfe1d8e..22a8e0e53149de59db01ae11633df35730eac57b 100644 (file)
@@ -18,8 +18,9 @@
 package org.altusmetrum.altoslib_5;
 
 import java.lang.Math;
+import java.io.*;
 
-public class AltosGreatCircle implements Cloneable {
+public class AltosGreatCircle implements Cloneable, Serializable {
        public double   distance;
        public double   bearing;
        public double   range;
index d7373f3c57ac7c47d88da8803e58a8f2e37ad89c..02b458b8fbb3f3660866d12da7d0199961a669ab 100644 (file)
@@ -18,8 +18,9 @@
 package org.altusmetrum.altoslib_5;
 
 import java.util.concurrent.*;
+import java.io.*;
 
-public class AltosIMU implements Cloneable {
+public class AltosIMU implements Cloneable, Serializable {
        public int              accel_along;
        public int              accel_across;
        public int              accel_through;
index 054ff1d06431d12bab7eb88bbc02c4012be94c9b..ed1f0f192ef53f1429fc8f7f7d1d268275d6f70d 100644 (file)
@@ -17,7 +17,9 @@
 
 package org.altusmetrum.altoslib_5;
 
-public class AltosListenerState {
+import java.io.*;
+
+public class AltosListenerState implements Serializable {
        public int      crc_errors;
        public double   battery;
 
index 1fa8877b9c639b4d1b5bdd714be5687424dd70be..8784bb810faae410d49d8140a6993622039b756f 100644 (file)
@@ -18,8 +18,9 @@
 package org.altusmetrum.altoslib_5;
 
 import java.util.concurrent.*;
+import java.io.*;
 
-public class AltosMag implements Cloneable {
+public class AltosMag implements Cloneable, Serializable {
        public int              along;
        public int              across;
        public int              through;
index 81e0641c2d9a8f42301dffbfba4fb29483ca8e49..97e17164bd03482c491a6ddd9cde62eb94ebe04e 100644 (file)
@@ -18,8 +18,9 @@
 package org.altusmetrum.altoslib_5;
 
 import java.util.concurrent.*;
+import java.io.*;
 
-public class AltosMs5607 {
+public class AltosMs5607 implements Serializable {
        public int      reserved;
        public int      sens;
        public int      off;
diff --git a/altoslib/AltosSavedState.java b/altoslib/AltosSavedState.java
new file mode 100644 (file)
index 0000000..4b010b3
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright © 2014 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.altoslib_5;
+
+import java.io.*;
+
+public class AltosSavedState implements Serializable {
+       public AltosState               state;
+       public AltosListenerState       listener_state;
+
+       public AltosSavedState(AltosState state, AltosListenerState listener_state) {
+               this.state = state;
+               this.listener_state = listener_state;
+       }
+}
index 830e95f311c19d6af0c0ef78821aa565bff55ef2..5be008b7ed524e694886fb3487fe20f5113786e6 100644 (file)
@@ -21,7 +21,9 @@
 
 package org.altusmetrum.altoslib_5;
 
-public class AltosState implements Cloneable {
+import java.io.*;
+
+public class AltosState implements Cloneable, Serializable {
 
        public static final int set_position = 1;
        public static final int set_gps = 2;
@@ -43,7 +45,7 @@ public class AltosState implements Cloneable {
        private int     prev_tick;
        public int      boost_tick;
 
-       class AltosValue {
+       class AltosValue implements Serializable{
                double  value;
                double  prev_value;
                private double  max_value;
@@ -179,9 +181,9 @@ public class AltosState implements Cloneable {
                }
        }
 
-       class AltosCValue {
+       class AltosCValue implements Serializable {
 
-               class AltosIValue extends AltosValue {
+               class AltosIValue extends AltosValue implements Serializable {
                        boolean can_max() {
                                return c_can_max();
                        }
@@ -312,7 +314,7 @@ public class AltosState implements Cloneable {
                ground_altitude.set_measured(a, time);
        }
 
-       class AltosGpsGroundAltitude extends AltosValue {
+       class AltosGpsGroundAltitude extends AltosValue implements Serializable {
                void set(double a, double t) {
                        super.set(a, t);
                        pad_alt = value();
@@ -336,7 +338,7 @@ public class AltosState implements Cloneable {
                gps_ground_altitude.set(a, time);
        }
 
-       class AltosGroundPressure extends AltosCValue {
+       class AltosGroundPressure extends AltosCValue implements Serializable {
                void set_filtered(double p, double time) {
                        computed.set_filtered(p, time);
                        if (!is_measured())
@@ -359,7 +361,7 @@ public class AltosState implements Cloneable {
                ground_pressure.set_measured(pressure, time);
        }
 
-       class AltosAltitude extends AltosCValue {
+       class AltosAltitude extends AltosCValue implements Serializable {
 
                private void set_speed(AltosValue v) {
                        if (!acceleration.is_measured() || !ascent)
@@ -381,7 +383,7 @@ public class AltosState implements Cloneable {
 
        private AltosAltitude   altitude;
 
-       class AltosGpsAltitude extends AltosValue {
+       class AltosGpsAltitude extends AltosValue implements Serializable {
 
                private void set_gps_height() {
                        double  a = value();
@@ -464,7 +466,7 @@ public class AltosState implements Cloneable {
                return gps_speed.max();
        }
 
-       class AltosPressure extends AltosValue {
+       class AltosPressure extends AltosValue implements Serializable {
                void set(double p, double time) {
                        super.set(p, time);
                        if (state == AltosLib.ao_flight_pad)
@@ -534,7 +536,7 @@ public class AltosState implements Cloneable {
                return AltosLib.MISSING;
        }
 
-       class AltosSpeed extends AltosCValue {
+       class AltosSpeed extends AltosCValue implements Serializable {
 
                boolean can_max() {
                        return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless;
@@ -588,7 +590,7 @@ public class AltosState implements Cloneable {
                return AltosLib.MISSING;
        }
 
-       class AltosAccel extends AltosCValue {
+       class AltosAccel extends AltosCValue implements Serializable {
 
                boolean can_max() {
                        return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless;
index 2805742e3e4eb626f91321685d95649d0eddbd88..8aff27679860983efca196fd102c64c7b29a704d 100644 (file)
@@ -82,6 +82,7 @@ altoslib_JAVA = \
        AltosProgrammer.java \
        AltosReplayReader.java \
        AltosRomconfig.java \
+       AltosSavedState.java \
        AltosSelfFlash.java \
        AltosSensorMM.java \
        AltosSensorEMini.java \