X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosTelemetryLegacy.java;h=027f601e1aa553fa022ae12636e55ee9ac8d7f58;hp=72a8bc4a0750b6faeb0c95b12f11f1045f4e49ac;hb=6e244a73d8c2a475416480f83328b7d363693402;hpb=b8fa4e9a077e8e04b922d0c434c139ad0a57ee66 diff --git a/altoslib/AltosTelemetryLegacy.java b/altoslib/AltosTelemetryLegacy.java index 72a8bc4a..027f601e 100644 --- a/altoslib/AltosTelemetryLegacy.java +++ b/altoslib/AltosTelemetryLegacy.java @@ -3,7 +3,8 @@ * * 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. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_12; import java.text.*; @@ -232,6 +233,17 @@ public class AltosTelemetryLegacy extends AltosTelemetry { final static String AO_TELEM_SAT_SVID = "s_v"; final static String AO_TELEM_SAT_C_N_0 = "s_c"; + public int tick; + public int serial; + public int rssi; + public int status; + + public int tick() { return tick; } + public int serial() { return serial; } + + public int rssi() { return rssi; } + public int status() { return status; } + public int version; public String callsign; public int flight; @@ -270,7 +282,6 @@ public class AltosTelemetryLegacy extends AltosTelemetry { flight = map.get_int(AO_TELEM_FLIGHT, AltosLib.MISSING); rssi = map.get_int(AO_TELEM_RSSI, AltosLib.MISSING); state = AltosLib.state(map.get_string(AO_TELEM_STATE, "invalid")); - tick = map.get_int(AO_TELEM_TICK, 0); /* raw sensor values */ accel = map.get_int(AO_TELEM_RAW_ACCEL, AltosLib.MISSING); @@ -419,7 +430,6 @@ public class AltosTelemetryLegacy extends AltosTelemetry { * Given a hex dump of a legacy telemetry line, construct an AltosRecordTM from that */ - int[] bytes; int adjust; /* @@ -451,8 +461,9 @@ public class AltosTelemetryLegacy extends AltosTelemetry { static final int AO_GPS_DATE_VALID = (1 << 6); static final int AO_GPS_COURSE_VALID = (1 << 7); - public AltosTelemetryLegacy(int[] in_bytes) { - bytes = in_bytes; + public AltosTelemetryLegacy(int[] in_bytes) throws AltosCRCException { + super(in_bytes); + version = 4; adjust = 0; @@ -462,6 +473,7 @@ public class AltosTelemetryLegacy extends AltosTelemetry { } else serial = uint16(0); + rssi = super.rssi(); callsign = string(62, 8); flight = uint16(2); state = uint8(4); @@ -536,23 +548,26 @@ public class AltosTelemetryLegacy extends AltosTelemetry { } } - public void update_state(AltosState state) { - state.set_tick(tick); - state.set_state(this.state); - state.set_flight(flight); - state.set_serial(serial); - state.set_rssi(rssi, status); + public void provide_data(AltosDataListener listener) { + listener.set_serial(serial); + listener.set_tick(tick); + listener.set_state(this.state); + listener.set_flight(flight); + listener.set_rssi(rssi, status); + + listener.set_pressure(AltosConvert.barometer_to_pressure(pres)); + + AltosCalData cal_data = listener.cal_data(); - state.set_pressure(AltosConvert.barometer_to_pressure(pres)); - state.set_accel_g(accel_plus_g, accel_minus_g); - state.set_accel(accel); + cal_data.set_accel_plus_minus(accel_plus_g, accel_minus_g); + listener.set_acceleration(cal_data.acceleration(accel)); if (kalman_height != AltosLib.MISSING) - state.set_kalman(kalman_height, kalman_speed, kalman_acceleration); - state.set_temperature(AltosConvert.thermometer_to_temperature(temp)); - state.set_battery_voltage(AltosConvert.cc_battery_to_voltage(batt)); - state.set_apogee_voltage(AltosConvert.cc_ignitor_to_voltage(apogee)); - state.set_main_voltage(AltosConvert.cc_ignitor_to_voltage(main)); + listener.set_kalman(kalman_height, kalman_speed, kalman_acceleration); + listener.set_temperature(AltosConvert.thermometer_to_temperature(temp)); + listener.set_battery_voltage(AltosConvert.cc_battery_to_voltage(batt)); + listener.set_apogee_voltage(AltosConvert.cc_igniter_to_voltage(apogee)); + listener.set_main_voltage(AltosConvert.cc_igniter_to_voltage(main)); if (gps != null) - state.set_gps(gps, gps_sequence); + listener.set_gps(gps); } }