summaryrefslogtreecommitdiff
path: root/altoslib/AltosSensorTM.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-09-05 11:33:48 -0700
committerKeith Packard <keithp@keithp.com>2013-09-05 11:35:14 -0700
commit5b976a6651f4eb05d30afc08b9e1f27c7e52ae00 (patch)
tree3a8f38d92fdc3b3e9e62d7744ff93a0f9ca8f7dc /altoslib/AltosSensorTM.java
parentb984ff81d6b8979574e0248ffe8876634b8e1942 (diff)
altoslib: Finish AltosState changes. Update version number.
Removes all of the AltosRecord bits, changes the monitor idle bits to have per-object state updaters. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosSensorTM.java')
-rw-r--r--altoslib/AltosSensorTM.java36
1 files changed, 28 insertions, 8 deletions
diff --git a/altoslib/AltosSensorTM.java b/altoslib/AltosSensorTM.java
index 754dc5bb..2696a308 100644
--- a/altoslib/AltosSensorTM.java
+++ b/altoslib/AltosSensorTM.java
@@ -15,14 +15,38 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-package org.altusmetrum.altoslib_1;
+package org.altusmetrum.altoslib_2;
import java.util.concurrent.TimeoutException;
-class AltosSensorTM extends AltosRecordTM {
+public class AltosSensorTM {
+ public int tick;
+ public int accel;
+ public int pres;
+ public int temp;
+ public int batt;
+ public int drogue;
+ public int main;
- public AltosSensorTM(AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException {
- super();
+ static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) {
+ try {
+ AltosSensorTM sensor_tm = new AltosSensorTM(link);
+
+ if (sensor_tm == null)
+ return;
+ state.set_accel(sensor_tm.accel);
+ state.set_pressure(AltosConvert.barometer_to_pressure(sensor_tm.pres));
+ state.set_temperature(AltosConvert.thermometer_to_temperature(sensor_tm.temp));
+ state.set_battery_voltage(AltosConvert.cc_battery_to_voltage(sensor_tm.batt));
+ state.set_apogee_voltage(AltosConvert.cc_ignitor_to_voltage(sensor_tm.drogue));
+ state.set_main_voltage(AltosConvert.cc_ignitor_to_voltage(sensor_tm.main));
+
+ } catch (TimeoutException te) {
+ } catch (InterruptedException ie) {
+ }
+ }
+
+ public AltosSensorTM(AltosLink link) throws InterruptedException, TimeoutException {
String[] items = link.adc();
for (int i = 0; i < items.length;) {
if (items[i].equals("tick:")) {
@@ -62,10 +86,6 @@ class AltosSensorTM extends AltosRecordTM {
}
i++;
}
- ground_accel = config_data.accel_cal_plus;
- ground_pres = pres;
- accel_plus_g = config_data.accel_cal_plus;
- accel_minus_g = config_data.accel_cal_minus;
}
}