From 01bbf9e163e7178712262800f8c59fcbea3f82eb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Jan 2012 20:34:38 -0800 Subject: altosui: Move AltosConfigData.java to library Create a new 'AltosLink' which exposes how to talk to the remote device abstractly via 'get_reply' and 'printf' methods. Signed-off-by: Keith Packard --- .../org/altusmetrum/AltosLib/AltosConfigData.java | 13 +++-------- .../src/org/altusmetrum/AltosLib/AltosLink.java | 26 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 altosui/altoslib/src/org/altusmetrum/AltosLib/AltosLink.java (limited to 'altosui/altoslib/src') diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosConfigData.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosConfigData.java index a331a357..07eb14d8 100644 --- a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosConfigData.java +++ b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosConfigData.java @@ -17,11 +17,6 @@ package altosui; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.filechooser.FileNameExtensionFilter; -import javax.swing.table.*; import java.io.*; import java.util.*; import java.text.*; @@ -29,8 +24,6 @@ import java.util.prefs.*; import java.util.concurrent.*; import org.altusmetrum.AltosLib.*; -import libaltosJNI.*; - public class AltosConfigData implements Iterable { /* Version information */ @@ -104,13 +97,13 @@ public class AltosConfigData implements Iterable { } } - public AltosConfigData(AltosSerial serial_line) throws InterruptedException, TimeoutException { - serial_line.printf("c s\nf\nl\nv\n"); + public AltosConfigData(AltosLink link) throws InterruptedException, TimeoutException { + link.printf("c s\nf\nl\nv\n"); lines = new LinkedList(); radio_setting = 0; stored_flight = 0; for (;;) { - String line = serial_line.get_reply(); + String line = link.get_reply(); if (line == null) throw new TimeoutException(); if (line.contains("Syntax error")) diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosLink.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosLink.java new file mode 100644 index 00000000..80f3d712 --- /dev/null +++ b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosLink.java @@ -0,0 +1,26 @@ +/* + * Copyright © 2011 Keith Packard + * + * 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. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.AltosLib; + +public interface AltosLink { + public void printf(String format, Object ... arguments) throws InterruptedException; + + public String get_reply() throws InterruptedException; + + public String get_reply(int timeout) throws InterruptedException; +} -- cgit v1.2.3