diff options
author | Keith Packard <keithp@keithp.com> | 2013-08-27 21:28:07 -0600 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-08-29 06:47:37 -0600 |
commit | 04d7d0f829ba953ffeca8ad9887a4b6b2b5d5087 (patch) | |
tree | 5a0c085740c465adb7f52442f34eaf4ee08ce7dc /altoslib/AltosGPS.java | |
parent | dcc51bb18985c24fa35bce0dd42ea3d847b960bf (diff) |
altoslib: Start restructuring AltosState harder
Make per-packet code update state itself rather than having all state
updates done centrally. Will make adding new packet types easier.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosGPS.java')
-rw-r--r-- | altoslib/AltosGPS.java | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index f23842f3..f7929a4c 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -19,7 +19,7 @@ package org.altusmetrum.altoslib_1; import java.text.*; -public class AltosGPS { +public class AltosGPS implements Cloneable { public final static int MISSING = AltosRecord.MISSING; @@ -216,6 +216,39 @@ public class AltosGPS { cc_gps_sat = null; } + public AltosGPS clone() { + AltosGPS g = new AltosGPS(); + + g.nsat = nsat; + g.locked = locked; + g.connected = connected; + g.lat = lat; g./* degrees (+N -S) */ + g.lon = lon; /* degrees (+E -W) */ + g.alt = alt; /* m */ + g.year = year; + g.month = month; + g.day = day; + g.hour = hour; + g.minute = minute; + g.second = second; + + g.ground_speed = ground_speed; /* m/s */ + g.course = course; /* degrees */ + g.climb_rate = climb_rate; /* m/s */ + g.hdop = hdop; /* unitless? */ + g.h_error = h_error; /* m */ + g.v_error = v_error; /* m */ + + if (cc_gps_sat != null) { + g.cc_gps_sat = new AltosGPSSat[cc_gps_sat.length]; + for (int i = 0; i < cc_gps_sat.length; i++) { + g.cc_gps_sat[i] = new AltosGPSSat(); + g.cc_gps_sat[i].svid = cc_gps_sat[i].svid; + g.cc_gps_sat[i].c_n0 = cc_gps_sat[i].c_n0; + } + } + } + public AltosGPS(AltosGPS old) { if (old != null) { nsat = old.nsat; |