summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
f4c812b)
Anything run from the UI thread blocks the UI entirely; the Fire
Igniters startup code to collect the number of pyro channels when
building the UI was doing that from the UI thread. Switch that around
so that the UI doesn't get built until that reply comes back, allowing
the user to see the 'connecting' dialog, and cancel it if required.
Signed-off-by: Keith Packard <keithp@keithp.com>
LinkedBlockingQueue<String> command_queue;
LinkedBlockingQueue<String> command_queue;
- LinkedBlockingQueue<String> reply_queue;
-
class Igniter {
JRadioButton button;
JLabel status_label;
class Igniter {
JRadioButton button;
JLabel status_label;
}
reply = "status";
} else if (command.equals("get_npyro")) {
}
reply = "status";
} else if (command.equals("get_npyro")) {
- put_reply(String.format("%d", ignite.npyro()));
- continue;
+ reply = String.format("npyro %d", ignite.npyro());
} else if (command.equals("quit")) {
ignite.close();
break;
} else if (command.equals("quit")) {
ignite.close();
break;
set_ignite_status();
} else if (reply.equals("fired")) {
fired();
set_ignite_status();
} else if (reply.equals("fired")) {
fired();
+ } else if (reply.startsWith("npyro")) {
+ npyro = Integer.parseInt(reply.substring(6));
+ make_ui();
- void put_reply(String reply) {
- try {
- reply_queue.put(reply);
- } catch (Exception ex) {
- ignite_exception(ex);
- }
- }
-
- String get_reply() {
- String reply = "";
- try {
- reply = reply_queue.take();
- } catch (Exception ex) {
- ignite_exception(ex);
- }
- return reply;
- }
-
boolean getting_status = false;
boolean visible = false;
boolean getting_status = false;
boolean visible = false;
- int get_npyro() {
- send_command("get_npyro");
- String reply = get_reply();
- return Integer.parseInt(reply);
- }
-
boolean firing = false;
void start_fire(String which) {
boolean firing = false;
void start_fire(String which) {
void close() {
if (opened) {
send_command("quit");
void close() {
if (opened) {
send_command("quit");
+ if (timer != null)
+ timer.stop();
setVisible(false);
dispose();
}
setVisible(false);
dispose();
}
private boolean open() {
command_queue = new LinkedBlockingQueue<String>();
private boolean open() {
command_queue = new LinkedBlockingQueue<String>();
- reply_queue = new LinkedBlockingQueue<String>();
opened = false;
device = AltosDeviceUIDialog.show(owner, Altos.product_any);
opened = false;
device = AltosDeviceUIDialog.show(owner, Altos.product_any);
- public AltosIgniteUI(JFrame in_owner) {
-
- owner = in_owner;
-
- if (!open())
- return;
-
+ private void make_ui() {
group = new ButtonGroup();
Container pane = getContentPane();
group = new ButtonGroup();
Container pane = getContentPane();
timer_running = false;
timer.restart();
timer_running = false;
timer.restart();
pane.setLayout(new GridBagLayout());
c.fill = GridBagConstraints.NONE;
pane.setLayout(new GridBagLayout());
c.fill = GridBagConstraints.NONE;
- int npyro = get_npyro();
-
igniters = new Igniter[2 + npyro];
igniters[0] = new Igniter(this, "Apogee", AltosIgnite.Apogee, y++);
igniters = new Igniter[2 + npyro];
igniters[0] = new Igniter(this, "Apogee", AltosIgnite.Apogee, y++);
addWindowListener(new ConfigListener(this));
}
addWindowListener(new ConfigListener(this));
}
-}
\ No newline at end of file
+
+ public AltosIgniteUI(JFrame in_owner) {
+
+ owner = in_owner;
+
+ if (!open())
+ return;
+
+ send_command("get_npyro");
+ }
+}