X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosState.java;h=12cd5adf7ee32611cf8b761b5141c7eda91a5469;hp=5be008b7ed524e694886fb3487fe20f5113786e6;hb=0afa07d3c1dcb5e301fcb8b4edfecdd961662478;hpb=60edcfe410e7fa848813d6c1ed8dc9808887d041 diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 5be008b7..12cd5adf 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -19,7 +19,7 @@ * Track flight state from telemetry or eeprom data stream */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_8; import java.io.*; @@ -31,8 +31,9 @@ public class AltosState implements Cloneable, Serializable { public int set; + static final double filter_len = 2.0; static final double ascent_filter_len = 0.5; - static final double descent_filter_len = 0.5; + static final double descent_filter_len = 5.0; /* derived data */ @@ -64,8 +65,10 @@ public class AltosState implements Cloneable, Serializable { } void set_filtered(double new_value, double time) { - if (prev_value != AltosLib.MISSING) - new_value = (prev_value * 15.0 + new_value) / 16.0; + if (prev_value != AltosLib.MISSING) { + double f = 1/Math.exp((time - prev_set_time) / filter_len); + new_value = f * new_value + (1-f) * prev_value; + } set(new_value, time); } @@ -281,7 +284,7 @@ public class AltosState implements Cloneable, Serializable { } } - public int state; + private int state; public int flight; public int serial; public int altitude_32; @@ -1040,6 +1043,10 @@ public class AltosState implements Cloneable, Serializable { 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; @@ -1049,6 +1056,10 @@ public class AltosState implements Cloneable, Serializable { } } + public int state() { + return state; + } + public void set_device_type(int device_type) { this.device_type = device_type; switch (device_type) { @@ -1351,11 +1362,6 @@ public class AltosState implements Cloneable, Serializable { } } - public void make_companion (int nchannels) { - if (companion == null) - companion = new AltosCompanion(nchannels); - } - public void set_companion(AltosCompanion companion) { this.companion = companion; }