diff options
author | Bdale Garbee <bdale@gag.com> | 2017-07-21 17:44:03 -0600 |
---|---|---|
committer | Bdale Garbee <bdale@gag.com> | 2017-07-21 17:44:03 -0600 |
commit | c8dbcaf69cd538a31ab6e2b568237ae7c8656a9a (patch) | |
tree | 213ec02db2e80f2e8c39772c0bde95d802900e53 /altoslib/AltosIdleReader.java | |
parent | 0cbfa444a9f9159cb509bb47ca5590fc1d709f64 (diff) | |
parent | ea3b5815b27005b2f4c3034715f656d28ea8534e (diff) |
Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
Diffstat (limited to 'altoslib/AltosIdleReader.java')
-rw-r--r-- | altoslib/AltosIdleReader.java | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/altoslib/AltosIdleReader.java b/altoslib/AltosIdleReader.java index 5903c968..d15e2174 100644 --- a/altoslib/AltosIdleReader.java +++ b/altoslib/AltosIdleReader.java @@ -16,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_11; +package org.altusmetrum.altoslib_12; import java.text.*; import java.io.*; @@ -25,6 +25,7 @@ import java.util.concurrent.*; public class AltosIdleReader extends AltosFlightReader { AltosLink link; boolean remote; + AltosCalData cal_data = null; AltosState state = null; AltosIdleFetch fetch; long next_millis; @@ -44,15 +45,23 @@ public class AltosIdleReader extends AltosFlightReader { return link.reply_abort; } + public AltosCalData cal_data() { + if (cal_data == null) { + try { + cal_data = new AltosCalData(link.config_data()); + } catch (InterruptedException ie) { + } catch (TimeoutException te) { + } + if (cal_data == null) + cal_data = new AltosCalData(); + } + return cal_data; + } + public AltosState read() throws InterruptedException, ParseException, AltosCRCException, IOException { boolean worked = false; boolean aborted = false; - if (state == null) - state = new AltosState(); - else - state = state.clone(); - long delay = next_millis - System.currentTimeMillis(); if (delay > 0) @@ -61,7 +70,9 @@ public class AltosIdleReader extends AltosFlightReader { try { try { start_link(); - fetch.update_state(state); + if (state == null) + state = new AltosState(cal_data()); + fetch.provide_data(state); if (!link.has_error && !link.reply_abort) worked = true; } catch (TimeoutException te) { |