javax.swing.Timer timer;
JButton close;
ButtonGroup group;
+ Boolean opened;
int npyro;
class IgniteHandler implements Runnable {
AltosIgnite ignite;
JFrame owner;
+ AltosLink link;
void send_exception(Exception e) {
final Exception f_e = e;
public void run () {
try {
- AltosSerial serial = new AltosSerial(device);
- serial.set_frame(owner);
- ignite = new AltosIgnite(serial,
+ ignite = new AltosIgnite(link,
!device.matchProduct(Altos.product_altimeter));
} catch (Exception e) {
}
}
- public IgniteHandler(JFrame in_owner) {
+ public IgniteHandler(JFrame in_owner, AltosLink in_link) {
owner = in_owner;
+ link = in_link;
}
}
}
void close() {
- send_command("quit");
- timer.stop();
+ if (opened) {
+ send_command("quit");
+ timer.stop();
+ }
setVisible(false);
dispose();
}
command_queue = new LinkedBlockingQueue<String>();
reply_queue = new LinkedBlockingQueue<String>();
+ opened = false;
device = AltosDeviceUIDialog.show(owner, Altos.product_any);
if (device != null) {
- IgniteHandler handler = new IgniteHandler(owner);
+ try {
+ AltosSerial serial = new AltosSerial(device);
+ serial.set_frame(owner);
+ IgniteHandler handler = new IgniteHandler(owner, serial);
Thread t = new Thread(handler);
t.start();
+ opened = true;
return true;
+ } catch (Exception ex) {
+ ignite_exception(ex);
+ }
}
return false;
}