summaryrefslogtreecommitdiff
path: root/altosui/AltosConfig.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-10-22 21:35:06 -0700
committerKeith Packard <keithp@keithp.com>2012-10-22 21:35:06 -0700
commitfe00d1169c65cb289f77093cf281efbd0a5d4e64 (patch)
treebd896bf00b610a08ac7fc6fdc2dcfff660c94ad4 /altosui/AltosConfig.java
parentfd619a01bf3489b1df017aca20362757b087ec11 (diff)
altosui/altoslib: Add support for configuring pyro channels
This provides a UI on devices which have pyro channels other than main/apogee. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosConfig.java')
-rw-r--r--altosui/AltosConfig.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java
index 44e5a3fa..be9ab8bf 100644
--- a/altosui/AltosConfig.java
+++ b/altosui/AltosConfig.java
@@ -22,6 +22,7 @@ import javax.swing.*;
import java.io.*;
import java.util.concurrent.*;
import org.altusmetrum.AltosLib.*;
+import java.text.*;
public class AltosConfig implements ActionListener {
@@ -78,6 +79,8 @@ public class AltosConfig implements ActionListener {
string_ref version;
string_ref product;
string_ref callsign;
+ int_ref npyro;
+ AltosPyro[] pyros;
AltosConfigUI config_ui;
boolean serial_started;
boolean made_visible;
@@ -162,6 +165,8 @@ public class AltosConfig implements ActionListener {
config_ui.set_ignite_mode(ignite_mode.get());
config_ui.set_pad_orientation(pad_orientation.get());
config_ui.set_callsign(callsign.get());
+ config_ui.set_pyros(pyros);
+ config_ui.set_has_pyro(npyro.get() > 0);
config_ui.set_clean();
if (!made_visible) {
made_visible = true;
@@ -169,6 +174,8 @@ public class AltosConfig implements ActionListener {
}
}
+ int pyro;
+
void process_line(String line) {
if (line == null) {
abort();
@@ -179,6 +186,18 @@ public class AltosConfig implements ActionListener {
update_ui();
return;
}
+ if (pyro < npyro.get()) {
+ if (pyros == null)
+ pyros = new AltosPyro[npyro.get()];
+
+ try {
+ pyros[pyro] = new AltosPyro(pyro, line);
+ } catch (ParseException e) {
+ System.out.printf ("pyro parse failed %s\n", line);
+ }
+ ++pyro;
+ return;
+ }
get_int(line, "serial-number", serial);
get_int(line, "log-format", log_format);
get_int(line, "Main deploy:", main_deploy);
@@ -200,6 +219,7 @@ public class AltosConfig implements ActionListener {
get_string(line, "Callsign:", callsign);
get_string(line,"software-version", version);
get_string(line,"product", product);
+ get_int(line, "Pyro-count:", npyro);
}
final static int serial_mode_read = 0;
@@ -243,6 +263,8 @@ public class AltosConfig implements ActionListener {
callsign.set("N0CALL");
version.set("unknown");
product.set("unknown");
+ pyro = 0;
+ npyro.set(0);
}
void get_data() {
@@ -304,6 +326,12 @@ public class AltosConfig implements ActionListener {
serial_line.printf("c i %d\n", ignite_mode.get());
if (pad_orientation.get() >= 0)
serial_line.printf("c o %d\n", pad_orientation.get());
+ if (pyros.length > 0) {
+ for (int p = 0; p < pyros.length; p++) {
+ serial_line.printf("c P %s\n",
+ pyros[p].toString());
+ }
+ }
serial_line.printf("c w\n");
} catch (InterruptedException ie) {
} catch (TimeoutException te) {
@@ -431,6 +459,9 @@ public class AltosConfig implements ActionListener {
if (pad_orientation.get() >= 0)
pad_orientation.set(config_ui.pad_orientation());
callsign.set(config_ui.callsign());
+ if (npyro.get() > 0) {
+ pyros = config_ui.pyros();
+ }
run_serial_thread(serial_mode_save);
}
@@ -477,6 +508,7 @@ public class AltosConfig implements ActionListener {
callsign = new string_ref("N0CALL");
version = new string_ref("unknown");
product = new string_ref("unknown");
+ npyro = new int_ref(0);
device = AltosDeviceDialog.show(owner, Altos.product_any);
if (device != null) {