summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-05-15 13:59:12 -0700
committerKeith Packard <keithp@keithp.com>2016-05-15 13:59:12 -0700
commit1ea855f95772a8a394407e0070be1ed9cc0f6650 (patch)
tree202d17d35c367cbcbf07208fa3a06160988a860c
parentdf276262900551a5eecd94903eefe9a264b161ec (diff)
telegps: Add monitor idle mode
This monitors directly connected devices. No support for doing monitor idle using packet mode, as TeleGPS doesn't support that. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--telegps/TeleGPS.java69
1 files changed, 58 insertions, 11 deletions
diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java
index c97ef5e4..d347fe41 100644
--- a/telegps/TeleGPS.java
+++ b/telegps/TeleGPS.java
@@ -53,6 +53,7 @@ public class TeleGPS
AltosFlightReader reader;
TeleGPSDisplayThread thread;
+ boolean idle_mode;
JMenuBar menu_bar;
@@ -186,12 +187,43 @@ public class TeleGPS
disable_rate_menu();
}
- void connect(AltosDevice device) {
- if (reader != null)
- disconnect();
+ void connect_flight(AltosDevice device) {
try {
AltosFlightReader reader = new AltosTelemetryReader(new AltosSerial(device));
- set_reader(reader, device);
+ set_reader(reader, device, false);
+ } catch (FileNotFoundException ee) {
+ JOptionPane.showMessageDialog(this,
+ ee.getMessage(),
+ String.format ("Cannot open %s", device.toShortString()),
+ JOptionPane.ERROR_MESSAGE);
+ } catch (AltosSerialInUseException si) {
+ JOptionPane.showMessageDialog(this,
+ String.format("Device \"%s\" already in use",
+ device.toShortString()),
+ "Device in use",
+ JOptionPane.ERROR_MESSAGE);
+ } catch (IOException ee) {
+ JOptionPane.showMessageDialog(this,
+ String.format ("Unknown I/O error on %s", device.toShortString()),
+ "Unknown I/O error",
+ JOptionPane.ERROR_MESSAGE);
+ } catch (TimeoutException te) {
+ JOptionPane.showMessageDialog(this,
+ String.format ("Timeout on %s", device.toShortString()),
+ "Timeout error",
+ JOptionPane.ERROR_MESSAGE);
+ } catch (InterruptedException ie) {
+ JOptionPane.showMessageDialog(this,
+ String.format("Interrupted %s", device.toShortString()),
+ "Interrupted exception",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ void connect_idle(AltosDevice device) {
+ try {
+ AltosFlightReader reader = new AltosIdleReader(new AltosSerial(device), false);
+ set_reader(reader, device, true);
} catch (FileNotFoundException ee) {
JOptionPane.showMessageDialog(this,
ee.getMessage(),
@@ -221,9 +253,18 @@ public class TeleGPS
}
}
+ void connect(AltosDevice device) {
+ if (reader != null)
+ disconnect();
+ if (device.matchProduct(AltosLib.product_basestation))
+ connect_flight(device);
+ else
+ connect_idle(device);
+ }
+
void connect() {
AltosDevice device = AltosDeviceUIDialog.show(this,
- AltosLib.product_basestation);
+ AltosLib.product_any);
if (device == null)
return;
connect(device);
@@ -397,7 +438,8 @@ public class TeleGPS
}
- public void set_reader(AltosFlightReader reader, AltosDevice device) {
+ public void set_reader(AltosFlightReader reader, AltosDevice device, boolean idle_mode) {
+ this.idle_mode = idle_mode;
status_update = new TeleGPSStatusUpdate(telegps_status);
telegps_status.start(status_update);
@@ -407,8 +449,13 @@ public class TeleGPS
thread.start();
if (device != null) {
- enable_frequency_menu(device.getSerial(), reader);
- enable_rate_menu(device.getSerial(), reader);
+ if (idle_mode) {
+ disable_frequency_menu();
+ disable_rate_menu();
+ } else {
+ enable_frequency_menu(device.getSerial(), reader);
+ enable_rate_menu(device.getSerial(), reader);
+ }
}
}
@@ -554,9 +601,9 @@ public class TeleGPS
add_window();
}
- public TeleGPS(AltosFlightReader reader) {
+ public TeleGPS(AltosFlightReader reader, boolean idle_mode) {
this();
- set_reader(reader, null);
+ set_reader(reader, null, idle_mode);
}
public TeleGPS(AltosDevice device) {
@@ -602,7 +649,7 @@ public class TeleGPS
if (new_reader == null)
return false;
- new TeleGPS(new_reader);
+ new TeleGPS(new_reader, true);
return true;
}