*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_8.*;
-import org.altusmetrum.altosuilib_8.*;
+import org.altusmetrum.altoslib_14.*;
+import org.altusmetrum.altosuilib_14.*;
public class AltosIgniteUI
extends AltosUIDialog
ButtonGroup group;
Boolean opened;
+ boolean has_standard;
int npyro;
final static int timeout = 1 * 1000;
int time_remaining;
boolean timer_running;
+ int poll_remaining;
+
LinkedBlockingQueue<String> command_queue;
class Igniter {
}
Igniter(AltosIgniteUI ui, String label, String name, int y) {
- Container pane = getContentPane();
+ Container pane = getScrollablePane();
GridBagConstraints c = new GridBagConstraints();
Insets i = new Insets(4,4,4,4);
public void run () {
try {
ignite = new AltosIgnite(link,
- !device.matchProduct(Altos.product_altimeter));
+ device.matchProduct(Altos.product_basestation));
} catch (Exception e) {
send_exception(e);
}
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;
} 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();
}
}
boolean getting_status = false;
- boolean visible = false;
-
void set_ignite_status() {
getting_status = false;
- if (!visible) {
- visible = true;
+ poll_remaining = 2;
+ if (!isVisible())
setVisible(true);
- }
}
void poll_ignite_status() {
+ if (poll_remaining > 0) {
+ --poll_remaining;
+ return;
+ }
if (!getting_status) {
getting_status = true;
send_command("get_status");
private void make_ui() {
group = new ButtonGroup();
- Container pane = getContentPane();
+ Container pane = getScrollablePane();
GridBagConstraints c = new GridBagConstraints();
Insets i = new Insets(4,4,4,4);
y++;
- igniters = new Igniter[2 + npyro];
+ int nstandard = 0;
+ if (has_standard)
+ nstandard = 2;
+
+ igniters = new Igniter[nstandard + npyro];
- igniters[0] = new Igniter(this, "Apogee", AltosIgnite.Apogee, y++);
- igniters[1] = new Igniter(this, "Main", AltosIgnite.Main, y++);
+ 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;