+ LinkedBlockingQueue<String> command_queue;
+
+ class IgniteHandler implements Runnable {
+ AltosIgnite ignite;
+
+ public void run () {
+ for (;;) {
+ Runnable r;
+
+ try {
+ String command = command_queue.take();
+ String reply = null;
+
+ if (command.equals("get_status")) {
+ apogee_status = ignite.status(AltosIgnite.Apogee);
+ main_status = ignite.status(AltosIgnite.Main);
+ reply = "status";
+ } else if (command.equals("main")) {
+ ignite.fire(AltosIgnite.Main);
+ reply = "fired";
+ } else if (command.equals("apogee")) {
+ ignite.fire(AltosIgnite.Apogee);
+ reply = "fired";
+ } else if (command.equals("quit")) {
+ ignite.close();
+ break;
+ } else {
+ throw new ParseException(String.format("invalid command %s", command), 0);
+ }
+ final String f_reply = reply;
+ r = new Runnable() {
+ public void run() {
+ ignite_reply(f_reply);
+ }
+ };
+ } catch (Exception e) {
+ final Exception f_e = e;
+ r = new Runnable() {
+ public void run() {
+ ignite_exception(f_e);
+ }
+ };
+ }
+ SwingUtilities.invokeLater(r);
+ }
+ }
+
+ public IgniteHandler(AltosIgnite in_ignite) {
+ ignite = in_ignite;
+ }
+ }
+
+ void ignite_exception(Exception e) {
+ abort();
+ }
+
+ void ignite_reply(String reply) {
+ if (reply.equals("status")) {
+ set_ignite_status();
+ } else if (reply.equals("fired")) {
+ fired();
+ }
+ }
+