* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-package org.altusmetrum.altoslib_3;
+package org.altusmetrum.altoslib_4;
import java.util.*;
import java.text.*;
/* Log listing replies */
public int stored_flight;
+ /* HAS_TRACKER */
+ public int[] tracker_distances;
+
public static String get_string(String line, String label) throws ParseException {
if (line.startsWith(label)) {
String quoted = line.substring(label.length()).trim();
throw new ParseException("mismatch", 0);
}
+ public static int[] get_distances(String line, String label) throws NumberFormatException, ParseException {
+ if (line.startsWith(label)) {
+ String tail = line.substring(label.length()).trim();
+ String[] tokens = tail.split("\\s+");
+ if (tokens.length > 1) {
+ int[] distances = new int[2];
+ distances[0] = Integer.parseInt(tokens[0]);
+ distances[1] = Integer.parseInt(tokens[1]);
+ return distances;
+ }
+ }
+ throw new ParseException("mismatch", 0);
+ }
+
public Iterator<String> iterator() {
return lines.iterator();
}
beep = -1;
+ tracker_distances = null;
+
storage_size = -1;
storage_erase_unit = -1;
stored_flight = 0;
try { aprs_interval = get_int(line, "APRS interval:"); } catch (Exception e) {}
/* HAS_BEEP */
- try { beep = get_int(line, "Beeper setting:"); System.out.printf ("beeper now %d\n", beep); } catch (Exception e) {}
+ try { beep = get_int(line, "Beeper setting:"); } catch (Exception e) {}
+
+ /* HAS_TRACKER */
+ try { tracker_distances = get_distances(line, "Tracker setting:"); } catch (Exception e) {}
/* Storage info replies */
try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {}
return 1024;
}
- public void get_values(AltosConfigValues source) {
+ public void get_values(AltosConfigValues source) throws AltosConfigDataException {
/* HAS_FLIGHT */
if (main_deploy >= 0)
/* HAS_BEEP */
if (beep >= 0)
beep = source.beep();
+ /* HAS_TRACKER */
+ if (tracker_distances != null)
+ tracker_distances = source.tracker_distances();
}
public void set_values(AltosConfigValues dest) {
dest.set_pyros(null);
dest.set_aprs_interval(aprs_interval);
dest.set_beep(beep);
+ dest.set_tracker_distances(tracker_distances);
}
public void save(AltosLink link, boolean remote) throws InterruptedException, TimeoutException {
if (beep >= 0)
link.printf("c b %d\n", beep);
+ /* HAS_TRACKER */
+ if (tracker_distances != null)
+ link.printf("c t %d %d\n", tracker_distances[0], tracker_distances[1]);
+
link.printf("c w\n");
link.flush_output();
}
link.printf("c s\nf\nv\n");
read_link(link, "software-version");
switch (log_format) {
- case AltosLib.AO_LOG_FORMAT_FULL:
- case AltosLib.AO_LOG_FORMAT_TINY:
- case AltosLib.AO_LOG_FORMAT_TELEMEGA:
+ case AltosLib.AO_LOG_FORMAT_UNKNOWN:
+ case AltosLib.AO_LOG_FORMAT_NONE:
+ break;
+ default:
link.printf("l\n");
read_link(link, "done");
- default:
break;
}
}