* Track flight state from telemetry or eeprom data stream
*/
-package org.altusmetrum.altoslib_3;
+package org.altusmetrum.altoslib_4;
public class AltosState implements Cloneable {
private double set_time;
private double prev_set_time;
+ boolean can_max() { return true; }
+
void set(double new_value, double time) {
if (new_value != AltosLib.MISSING) {
value = new_value;
- if (max_value == AltosLib.MISSING || value > max_value) {
+ if (can_max() && (max_value == AltosLib.MISSING || value > max_value))
max_value = value;
- }
set_time = time;
}
}
void set_derivative(AltosValue in) {
double n = in.rate();
-
+
if (n == AltosLib.MISSING)
return;
/* Clip changes to reduce noise */
double ddt = in.time() - pt;
double ddv = (n - p) / ddt;
-
+
final double max = 100000;
/* 100gs */
void set_integral(AltosValue in) {
computed.set_integral(in);
}
-
+
void set_integral(AltosCValue in) {
set_integral(in.altos_value());
}
-
+
void copy(AltosCValue old) {
measured.copy(old.measured);
computed.copy(old.computed);
}
private AltosGroundPressure ground_pressure;
-
+
public double ground_pressure() {
return ground_pressure.value();
}
}
class AltosSpeed extends AltosCValue {
-
+
+ boolean can_max() {
+ return state < AltosLib.ao_flight_fast;
+ }
+
void set_accel() {
acceleration.set_derivative(this);
}
}
class AltosAccel extends AltosCValue {
+
+ boolean can_max() {
+ return state < AltosLib.ao_flight_fast;
+ }
+
void set_measured(double a, double time) {
super.set_measured(a, time);
if (ascent)
public double ground_accel_avg;
public int log_format;
+ public String product;
public AltosMs5607 baro;
public AltosCompanion companion;
+ public int pyro_fired;
+
public void set_npad(int npad) {
this.npad = npad;
gps_waiting = MIN_PAD_SAMPLES - npad;
ground_accel_avg = AltosLib.MISSING;
log_format = AltosLib.MISSING;
+ product = null;
serial = AltosLib.MISSING;
receiver_serial = AltosLib.MISSING;
baro = null;
companion = null;
+
+ pyro_fired = 0;
}
void finish_update() {
time = old.time;
time_change = old.time_change;
prev_time = old.time;
-
+
tick = old.tick;
prev_tick = old.tick;
boost_tick = old.boost_tick;
apogee_delay = old.apogee_delay;
main_deploy = old.main_deploy;
flight_log_max = old.flight_log_max;
-
+
set = 0;
ground_pressure.copy(old.ground_pressure);
ground_accel_avg = old.ground_accel_avg;
log_format = old.log_format;
+ product = old.product;
serial = old.serial;
receiver_serial = old.receiver_serial;
baro = old.baro;
companion = old.companion;
+
+ pyro_fired = old.pyro_fired;
}
-
+
void update_time() {
}
void update_gps() {
elevation = 0;
range = -1;
- gps_height = 0;
if (gps == null)
return;
this.ignitor_voltage = voltage;
}
+ public void set_pyro_fired(int fired) {
+ this.pyro_fired = fired;
+ }
+
public double time_since_boost() {
if (tick == AltosLib.MISSING)
return 0.0;