X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=ao-tools%2Faltosui%2FAltosUI.java;h=37625e8e47f1944d899527f64dfa0f11eefe14fe;hb=828e9e4c68e3ac90b6ba2e9fd5f131a9975f7e4a;hp=e63a004c67c5f5ef2e747da9373c2259f3ae50b5;hpb=71191ecef3ba0e00d0f8a7cd1a24982bfa44ec72;p=fw%2Faltos diff --git a/ao-tools/altosui/AltosUI.java b/ao-tools/altosui/AltosUI.java index e63a004c..37625e8e 100644 --- a/ao-tools/altosui/AltosUI.java +++ b/ao-tools/altosui/AltosUI.java @@ -44,6 +44,7 @@ import altosui.AltosChannelMenu; import altosui.AltosFlashUI; import altosui.AltosLogfileChooser; import altosui.AltosCSVUI; +import altosui.AltosLine; import libaltosJNI.*; @@ -74,6 +75,10 @@ public class AltosUI extends JFrame { String[] statusNames = { "Height (m)", "State", "RSSI (dBm)", "Speed (m/s)" }; Object[][] statusData = { { "0", "pad", "-50", "0" } }; + java.net.URL imgURL = AltosUI.class.getResource("/altus-metrum-16x16.jpg"); + if (imgURL != null) + setIconImage(new ImageIcon(imgURL).getImage()); + AltosPreferences.init(this); vbox = Box.createVerticalBox(); @@ -169,6 +174,8 @@ public class AltosUI extends JFrame { } public void show(AltosState state, int crc_errors) { + if (state == null) + return; flightStatusModel.set(state); info_reset(); @@ -367,7 +374,7 @@ public class AltosUI extends JFrame { void init() { } - AltosRecord read() throws InterruptedException, ParseException, AltosCRCException { return null; } + AltosRecord read() throws InterruptedException, ParseException, AltosCRCException, IOException { return null; } void close() { } @@ -403,6 +410,11 @@ public class AltosUI extends JFrame { } } } catch (InterruptedException ee) { + } catch (IOException ie) { + JOptionPane.showMessageDialog(AltosUI.this, + String.format("Error reading from \"%s\"", name), + "Telemetry Read Error", + JOptionPane.ERROR_MESSAGE); } finally { close(); idle_thread.interrupt(); @@ -417,10 +429,13 @@ public class AltosUI extends JFrame { class DeviceThread extends DisplayThread { AltosSerial serial; - LinkedBlockingQueue telem; + LinkedBlockingQueue telem; - AltosRecord read() throws InterruptedException, ParseException, AltosCRCException { - return new AltosTelemetry(telem.take()); + AltosRecord read() throws InterruptedException, ParseException, AltosCRCException, IOException { + AltosLine l = telem.take(); + if (l.line == null) + throw new IOException("IO error"); + return new AltosTelemetry(l.line); } void close() { @@ -428,11 +443,11 @@ public class AltosUI extends JFrame { serial.remove_monitor(telem); } - public DeviceThread(AltosSerial s) { + public DeviceThread(AltosSerial s, String in_name) { serial = s; - telem = new LinkedBlockingQueue(); + telem = new LinkedBlockingQueue(); serial.add_monitor(telem); - name = "telemetry"; + name = in_name; } } @@ -443,7 +458,7 @@ public class AltosUI extends JFrame { try { stop_display(); serial_line.open(device); - DeviceThread thread = new DeviceThread(serial_line); + DeviceThread thread = new DeviceThread(serial_line, device.getPath()); serial_line.set_channel(AltosPreferences.channel()); serial_line.set_callsign(AltosPreferences.callsign()); run_display(thread);