altoslib, altosui: Don't show apogee/main for EasyTimer Fire Igniter
authorKeith Packard <keithp@keithp.com>
Sat, 24 Oct 2020 00:05:37 +0000 (17:05 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 24 Oct 2020 00:05:37 +0000 (17:05 -0700)
Don't create igniter lines for a device which doesn't have them.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosIgnite.java
altosui/AltosIgniteUI.java

index d4acda374c6a30de2689e998d20411576052e670..d1ec5104386025bd4d347a03fe9e4e973b702638 100644 (file)
@@ -27,7 +27,8 @@ public class AltosIgnite {
        boolean         remote;
        boolean         close_on_exit;
        boolean         link_started;
-       boolean         have_npyro = false;
+       boolean         has_pyro_info = false;
+       boolean         has_standard = false;
        int             npyro;
        AltosConfigData config_data;
 
@@ -106,11 +107,14 @@ public class AltosIgnite {
                        npyro = config_data.npyro;
                else
                        npyro = 0;
-               have_npyro = true;
+               if (config_data != null)
+                       has_standard = config_data.ignite_mode != AltosLib.MISSING;
+
+               has_pyro_info = true;
        }
 
        public int npyro() throws InterruptedException, TimeoutException {
-               if (!have_npyro) {
+               if (!has_pyro_info) {
                        start_link();
                        get_npyro();
                        stop_link();
@@ -118,6 +122,15 @@ public class AltosIgnite {
                return npyro;
        }
 
+       public boolean has_standard() throws InterruptedException, TimeoutException {
+               if (!has_pyro_info) {
+                       start_link();
+                       get_npyro();
+                       stop_link();
+               }
+               return has_standard;
+       }
+
        public HashMap<String,Integer> status() throws InterruptedException, TimeoutException {
                HashMap<String,Integer> status = new HashMap<String,Integer>();
 
index 9f2f15dab9fc05fd42e27ce3cf74579dba14ad94..5a09252ecc14babaa5d101a7758ae3e33ff4d970 100644 (file)
@@ -42,6 +42,7 @@ public class AltosIgniteUI
        ButtonGroup     group;
        Boolean         opened;
 
+       boolean         has_standard;
        int             npyro;
 
        final static int        timeout = 1 * 1000;
@@ -151,7 +152,7 @@ public class AltosIgniteUI
                                                }
                                                reply = "status";
                                        } else if (command.equals("get_npyro")) {
-                                               reply = String.format("npyro %d", ignite.npyro());
+                                               reply = String.format("npyro %d %d", ignite.npyro(), ignite.has_standard() ? 1 : 0);
                                        } else if (command.equals("quit")) {
                                                ignite.close();
                                                break;
@@ -212,9 +213,11 @@ public class AltosIgniteUI
                } else if (reply.equals("fired")) {
                        fired();
                } else if (reply.startsWith("npyro")) {
-                       npyro = Integer.parseInt(reply.substring(6));
+                       String items[] = reply.split("\\s+");
+                       npyro = Integer.parseInt(items[1]);
                        if (npyro == AltosLib.MISSING)
                                npyro = 0;
+                       has_standard = Integer.parseInt(items[2]) != 0;
                        make_ui();
                }
        }
@@ -417,15 +420,21 @@ public class AltosIgniteUI
 
                y++;
 
-               igniters = new Igniter[2 + npyro];
+               int nstandard = 0;
+               if (has_standard)
+                       nstandard = 2;
 
-               igniters[0] = new Igniter(this, "Apogee", AltosIgnite.Apogee, y++);
-               igniters[1] = new Igniter(this, "Main", AltosIgnite.Main, y++);
+               igniters = new Igniter[nstandard + npyro];
+
+               if (has_standard) {
+                       igniters[0] = new Igniter(this, "Apogee", AltosIgnite.Apogee, y++);
+                       igniters[1] = new Igniter(this, "Main", AltosIgnite.Main, y++);
+               }
 
                for (int p = 0; p < npyro; p++) {
                        String  name = String.format("%d", p);
                        String  label = String.format("%c", 'A' + p);
-                       igniters[2+p] = new Igniter(this, label, name, y++);
+                       igniters[nstandard+p] = new Igniter(this, label, name, y++);
                }
 
                c.gridx = 0;