X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosIdleFetch.java;h=0095bb732899d81ffa445db1049bc5aece33efcb;hp=1cb43d6dd55b9df2437474f8b71f2788de3a30a0;hb=0b0b359cbce6b818257b44b2a6aee0edcbaee40d;hpb=c8078d352a7f54a4a97d25af080155d3f875536a diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index 1cb43d6d..0095bb73 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_10; import java.io.*; import java.util.*; @@ -38,8 +38,9 @@ class AltosIdler { static final int idle_sensor_mega = 12; static final int idle_sensor_emini = 13; static final int idle_sensor_tmini = 14; + static final int idle_sensor_tgps = 15; - public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException { + public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException, AltosUnknownProduct { for (int idler : idlers) { AltosIdle idle = null; switch (idler) { @@ -72,6 +73,10 @@ class AltosIdler { break; case idle_sensor_tmini: AltosSensorTMini.update_state(state, link, config_data); + break; + case idle_sensor_tgps: + AltosSensorTGPS.update_state(state, link, config_data); + break; } if (idle != null) idle.update_state(state); @@ -118,6 +123,13 @@ public class AltosIdleFetch implements AltosStateUpdate { AltosIdler.idle_ms5607, AltosIdler.idle_mma655x, AltosIdler.idle_imu, AltosIdler.idle_mag, AltosIdler.idle_sensor_mega), + new AltosIdler("EasyMega", + AltosIdler.idle_ms5607, AltosIdler.idle_mma655x, + AltosIdler.idle_imu, AltosIdler.idle_mag, + AltosIdler.idle_sensor_mega), + new AltosIdler("TeleGPS", + AltosIdler.idle_gps, + AltosIdler.idle_sensor_tgps), }; AltosLink link; @@ -125,20 +137,26 @@ public class AltosIdleFetch implements AltosStateUpdate { double frequency; String callsign; - public void update_state(AltosState state) throws InterruptedException { + public void update_state(AltosState state) throws InterruptedException, AltosUnknownProduct { try { + boolean matched = false; + /* Fetch config data from remote */ AltosConfigData config_data = new AltosConfigData(link); - state.set_state(AltosLib.ao_flight_startup); + state.set_state(AltosLib.ao_flight_stateless); state.set_serial(config_data.serial); state.set_callsign(config_data.callsign); state.set_ground_accel(config_data.accel_cal_plus); state.set_accel_g(config_data.accel_cal_plus, config_data.accel_cal_minus); + state.set_product(config_data.product); for (AltosIdler idler : idlers) { if (idler.matches(config_data)) { idler.update_state(state, link, config_data); + matched = true; break; } } + if (!matched) + throw new AltosUnknownProduct(config_data.product); state.set_received_time(System.currentTimeMillis()); } catch (TimeoutException te) { }