X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosState.java;h=5abc0c2d41a5a6e666039052e784f113f4b6a415;hp=889aa9a319e4b9067492b716639d162754bd1b77;hb=78b4bf77fca96bef2cce443ad4c9544ae83f0acc;hpb=222158581887b5f9e8b9843d14321c313fa023fa diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 889aa9a3..5abc0c2d 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -43,10 +43,6 @@ public class AltosState extends AltosDataListener { public int rssi; public int status; - public double time; - public double prev_time; - public double time_change; - class AltosValue { double value; double prev_value; @@ -290,17 +286,9 @@ public class AltosState extends AltosDataListener { } } - private int state; - public int altitude_32; - public int receiver_serial; public boolean landed; public boolean ascent; /* going up? */ public boolean boost; /* under power */ - public int config_major; - public int config_minor; - public int apogee_delay; - public int main_deploy; - public int flight_log_max; private double pressure_to_altitude(double p) { if (p == AltosLib.MISSING) @@ -515,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() { @@ -705,8 +677,6 @@ public class AltosState extends AltosDataListener { public double igniter_voltage[]; public AltosGPS gps; - public AltosGPS temp_gps; - public int temp_gps_sat_tick; public boolean gps_pending; public AltosIMU imu; @@ -731,17 +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 AltosMs5607 baro; - public AltosCompanion companion; public int pyro_fired; @@ -759,24 +720,16 @@ public class AltosState extends AltosDataListener { received_time = System.currentTimeMillis(); time = AltosLib.MISSING; - time_change = AltosLib.MISSING; - prev_time = AltosLib.MISSING; state = AltosLib.ao_flight_invalid; landed = false; boost = false; rssi = AltosLib.MISSING; status = 0; - config_major = AltosLib.MISSING; - config_minor = AltosLib.MISSING; - apogee_delay = AltosLib.MISSING; - main_deploy = AltosLib.MISSING; - flight_log_max = AltosLib.MISSING; ground_altitude = new AltosCValue(); ground_pressure = new AltosGroundPressure(); altitude = new AltosAltitude(); pressure = new AltosPressure(); - thrust = new AltosForce(); speed = new AltosSpeed(); acceleration = new AltosAccel(); orient = new AltosCValue(); @@ -793,8 +746,6 @@ public class AltosState extends AltosDataListener { kalman_acceleration = new AltosValue(); gps = null; - temp_gps = null; - temp_gps_sat_tick = 0; gps_pending = false; imu = null; @@ -803,9 +754,6 @@ public class AltosState extends AltosDataListener { ground_rotation = null; mag = null; - accel_zero_along = AltosLib.MISSING; - accel_zero_across = AltosLib.MISSING; - accel_zero_through = AltosLib.MISSING; accel_ground_along = AltosLib.MISSING; accel_ground_across = AltosLib.MISSING; @@ -835,18 +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; - receiver_serial = AltosLib.MISSING; - altitude_32 = AltosLib.MISSING; - - baro = null; companion = null; pyro_fired = 0; @@ -919,10 +857,6 @@ public class AltosState extends AltosDataListener { return AltosLib.state_name(state); } - public void set_product(String product) { - this.product = product; - } - public void set_state(int state) { if (state != AltosLib.ao_flight_invalid) { this.state = state; @@ -936,85 +870,8 @@ public class AltosState extends AltosDataListener { return state; } - public void set_log_format(int log_format) { - this.log_format = log_format; - switch (log_format) { - case AltosLib.AO_LOG_FORMAT_TELEGPS: - this.state = AltosLib.ao_flight_stateless; - break; - } - } - - public void set_log_space(int log_space) { - this.log_space = log_space; - } - - public void set_flight_params(int apogee_delay, int main_deploy) { - this.apogee_delay = apogee_delay; - this.main_deploy = main_deploy; - } - - public void set_config(int major, int minor, int flight_log_max) { - config_major = major; - config_minor = minor; - this.flight_log_max = flight_log_max; - } - - public void set_callsign(String callsign) { - this.callsign = callsign; - } - - public void set_firmware_version(String version) { - firmware_version = version; - } - - public int compare_version(String other_version) { - if (firmware_version == null) - return AltosLib.MISSING; - return AltosLib.compare_version(firmware_version, other_version); - } - private void re_init() { - int rs = receiver_serial; init(); - receiver_serial = rs; - } - -// public void set_flight(int flight) { -// -// /* When the flight changes, reset the state */ -// if (flight != AltosLib.MISSING) { -// if (this.flight != AltosLib.MISSING && -// this.flight != flight) { -// re_init(); -// } -// this.flight = flight; -// } -// } -// -// public void set_serial(int serial) { -// /* When the serial changes, reset the state */ -// if (serial != AltosLib.MISSING) { -// if (this.serial != AltosLib.MISSING && -// this.serial != serial) { -// re_init(); -// } -// this.serial = serial; -// } -// } -// -// public void set_receiver_serial(int serial) { -// if (serial != AltosLib.MISSING) -// receiver_serial = serial; -// } - - public boolean altitude_32() { - return altitude_32 == 1; - } - - public void set_altitude_32(int altitude_32) { - if (altitude_32 != AltosLib.MISSING) - this.altitude_32 = altitude_32; } public int rssi() { @@ -1043,30 +900,18 @@ public class AltosState extends AltosDataListener { } - public double accel_zero_along; - public double accel_zero_across; - public double accel_zero_through; - public AltosRotation rotation; public AltosRotation ground_rotation; - public void set_accel_zero(double zero_along, double zero_across, double zero_through) { - if (zero_along != AltosLib.MISSING) { - accel_zero_along = zero_along; - accel_zero_across = zero_across; - accel_zero_through = zero_through; - } - } - public int pad_orientation; public double accel_ground_along, accel_ground_across, accel_ground_through; void update_pad_rotation() { if (pad_orientation != AltosLib.MISSING && accel_ground_along != AltosLib.MISSING) { - rotation = new AltosRotation(AltosIMU.convert_accel(accel_ground_across - accel_zero_across), - AltosIMU.convert_accel(accel_ground_through - accel_zero_through), - AltosIMU.convert_accel(accel_ground_along - accel_zero_along), + rotation = new AltosRotation(AltosIMU.convert_accel(accel_ground_across - cal_data.accel_zero_across), + AltosIMU.convert_accel(accel_ground_through - cal_data.accel_zero_through), + AltosIMU.convert_accel(accel_ground_along - cal_data.accel_zero_along), pad_orientation); ground_rotation = rotation; orient.set_computed(rotation.tilt(), time); @@ -1229,8 +1074,15 @@ public class AltosState extends AltosDataListener { this.pyro_fired = fired; } + public AltosState() { + Thread.dumpStack(); + init(); + } + public AltosState (AltosCalData cal_data) { super(cal_data); + if (cal_data == null) + Thread.dumpStack(); init(); } }