altoslib: Reset transient AltosCalData values before processing data
[fw/altos] / altoslib / AltosTelemetryConfiguration.java
index f578e6adc5404f8e5ce2f99a0ae363a174b6fd9e..920c3187b1fe0a98d0613bab05577017d0886deb 100644 (file)
@@ -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
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altoslib_5;
+package org.altusmetrum.altoslib_11;
 
 
 public class AltosTelemetryConfiguration extends AltosTelemetryStandard {
-       int     device_type;
-       int     flight;
-       int     config_major;
-       int     config_minor;
-       int     apogee_delay;
-       int     main_deploy;
-       int     v_batt;
-       int     flight_log_max;
-       String  callsign;
-       String  version;
+       int     device_type() { return uint8(5); }
+       int     flight() { return uint16(6); }
+       int     config_major() { return uint8(8); }
+       int     config_minor() { return uint8(9); }
+       int     apogee_delay() { return uint16(10); }
+       int     main_deploy() { return uint16(12); }
+       int     v_batt() { return uint16(10); }
+       int     flight_log_max() { return uint16(14); }
+       String  callsign() { return string(16, 8); }
+       String  version() { return string(24, 8); }
 
-       public AltosTelemetryConfiguration(int[] bytes) {
+       public AltosTelemetryConfiguration(int[] bytes) throws AltosCRCException {
                super(bytes);
-
-               device_type    = uint8(5);
-               flight         = uint16(6);
-               config_major   = uint8(8);
-               config_minor   = uint8(9);
-               v_batt         = uint16(10);
-               apogee_delay   = uint16(10);
-               main_deploy    = uint16(12);
-               flight_log_max = uint16(14);
-               callsign       = string(16, 8);
-               version        = string(24, 8);
        }
 
-       public void update_state(AltosState state) {
-               super.update_state(state);
-               state.set_device_type(device_type);
-               state.set_flight(flight);
-               state.set_config(config_major, config_minor, flight_log_max);
-               if (device_type == AltosLib.product_telegps)
-                       state.set_battery_voltage(AltosConvert.tele_gps_voltage(v_batt));
+       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
+               super.provide_data(listener, cal_data);
+               cal_data.set_device_type(device_type());
+               cal_data.set_flight(flight());
+               cal_data.set_config(config_major(), config_minor(), flight_log_max());
+               if (device_type() == AltosLib.product_telegps)
+                       listener.set_battery_voltage(AltosConvert.tele_gps_voltage(v_batt()));
                else
-                       state.set_flight_params(apogee_delay, main_deploy);
+                       cal_data.set_flight_params(apogee_delay() / 100.0, main_deploy());
 
-               state.set_callsign(callsign);
-               state.set_firmware_version(version);
+               cal_data.set_callsign(callsign());
+               cal_data.set_firmware_version(version());
        }
 }