X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosIgnite.java;h=3e52ea369d471f82efb91d96281745670a816bb2;hp=d36381407c53ee0d46e0bda72c1fc1cd36c3aa59;hb=c3314dae2d3df82e188daf6ba8520cce833592c6;hpb=97517ee585462c2d355f23f999fb8d9ebd908ec1 diff --git a/altosui/AltosIgnite.java b/altosui/AltosIgnite.java index d3638140..3e52ea36 100644 --- a/altosui/AltosIgnite.java +++ b/altosui/AltosIgnite.java @@ -19,6 +19,12 @@ package altosui; import java.io.*; import java.util.concurrent.*; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import javax.swing.event.*; public class AltosIgnite { AltosDevice device; @@ -34,7 +40,7 @@ public class AltosIgnite { final static int Active = 2; final static int Open = 3; - private void start_serial() throws InterruptedException { + private void start_serial() throws InterruptedException, TimeoutException { serial_started = true; if (remote) serial.start_remote(); @@ -96,26 +102,29 @@ public class AltosIgnite { if (serial == null) return status; string_ref status_name = new string_ref(); - start_serial(); - serial.printf("t\n"); - for (;;) { - String line = serial.get_reply(5000); - if (line == null) - throw new TimeoutException(); - if (get_string(line, "Igniter: drogue Status: ", status_name)) - if (igniter == Apogee) - status = status(status_name.get()); - if (get_string(line, "Igniter: main Status: ", status_name)) { - if (igniter == Main) - status = status(status_name.get()); - break; + try { + start_serial(); + serial.printf("t\n"); + for (;;) { + String line = serial.get_reply(5000); + if (line == null) + throw new TimeoutException(); + if (get_string(line, "Igniter: drogue Status: ", status_name)) + if (igniter == Apogee) + status = status(status_name.get()); + if (get_string(line, "Igniter: main Status: ", status_name)) { + if (igniter == Main) + status = status(status_name.get()); + break; + } } + } finally { + stop_serial(); } - stop_serial(); return status; } - public String status_string(int status) { + public static String status_string(int status) { switch (status) { case Unknown: return "Unknown"; case Ready: return "Ready"; @@ -139,6 +148,7 @@ public class AltosIgnite { break; } } catch (InterruptedException ie) { + } catch (TimeoutException te) { } finally { try { stop_serial(); @@ -156,13 +166,18 @@ public class AltosIgnite { serial = null; } - public AltosIgnite(AltosDevice in_device) throws FileNotFoundException, AltosSerialInUseException { + public void set_frame(Frame frame) { + serial.set_frame(frame); + } + + public AltosIgnite(AltosDevice in_device) + throws FileNotFoundException, AltosSerialInUseException, TimeoutException, InterruptedException { device = in_device; serial = new AltosSerial(device); remote = false; - if (!device.matchProduct(AltosDevice.product_telemetrum)) + if (!device.matchProduct(Altos.product_telemetrum)) remote = true; } } \ No newline at end of file