X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosIdleReader.java;h=24477d623bcbb997f352938488010bc9caab7915;hp=795593f7750575cea02ce3312d885679236fe152;hb=fab890328d4e1151932621a317226bc291b853da;hpb=9287122edc0e2dec6b2542f4cc8cb9cf2900bb33 diff --git a/altoslib/AltosIdleReader.java b/altoslib/AltosIdleReader.java index 795593f7..24477d62 100644 --- a/altoslib/AltosIdleReader.java +++ b/altoslib/AltosIdleReader.java @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_11; +package org.altusmetrum.altoslib_13; import java.text.*; import java.io.*; @@ -24,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; @@ -43,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) @@ -60,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) {