import java.io.*;
import java.util.concurrent.*;
import java.util.Arrays;
-import org.altusmetrum.altoslib_4.*;
-import org.altusmetrum.altosuilib_2.*;
+import org.altusmetrum.altoslib_6.*;
+import org.altusmetrum.altosuilib_6.*;
public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDisplay, AltosIdleMonitorListener, DocumentListener {
AltosDevice device;
AltosPad pad;
AltosInfoTable flightInfo;
AltosFlightStatus flightStatus;
+ AltosIgnitor ignitor;
AltosIdleMonitor thread;
int serial;
boolean remote;
+ boolean has_ignitor;
void stop_display() {
if (thread != null) {
public void show(AltosState state, AltosListenerState listener_state) {
status_update.saved_state = state;
+ if (ignitor.should_show(state)) {
+ if (!has_ignitor) {
+ pane.add("Ignitor", ignitor);
+ has_ignitor = true;
+ }
+ } else {
+ if (has_ignitor) {
+ pane.remove(ignitor);
+ has_ignitor = false;
+ }
+ }
// try {
pad.show(state, listener_state);
flightStatus.show(state, listener_state);
flightInfo.show(state, listener_state);
+ ignitor.show(state, listener_state);
// } catch (Exception e) {
// System.out.print("Show exception " + e);
// }
SwingUtilities.invokeLater(r);
}
+ public void failed() {
+ Runnable r = new Runnable() {
+ public void run() {
+ close();
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+
Container bag;
- AltosFreqList frequencies;
+ AltosUIFreqList frequencies;
JTextField callsign_value;
/* DocumentListener interface methods */
}
}
+ private void close() {
+ try {
+ disconnect();
+ } catch (Exception ex) {
+ System.out.printf("Exception %s\n", ex.toString());
+ for (StackTraceElement el : ex.getStackTrace())
+ System.out.printf("%s\n", el.toString());
+ }
+ setVisible(false);
+ dispose();
+ AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this);
+ }
+
public AltosIdleMonitorUI(JFrame in_owner)
throws FileNotFoundException, TimeoutException, InterruptedException {
serial = device.getSerial();
- AltosLink link;
+ AltosSerial link;
try {
link = new AltosSerial(device);
+ link.set_frame(this);
} catch (Exception ex) {
idle_exception(in_owner, ex);
return;
/* Stick frequency selector at top of table for telemetry monitoring */
if (remote && serial >= 0) {
// Frequency menu
- frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial));
+ frequencies = new AltosUIFreqList(AltosUIPreferences.frequency(serial));
frequencies.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
double frequency = frequencies.frequency();
flightInfo = new AltosInfoTable();
pane.add("Table", new JScrollPane(flightInfo));
+ ignitor = new AltosIgnitor();
+
/* Make the tabbed pane use the rest of the window space */
bag.add(pane, constraints(0, 3, GridBagConstraints.BOTH));
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
- try {
- disconnect();
- } catch (Exception ex) {
- System.out.printf("Exception %s\n", ex.toString());
- for (StackTraceElement el : ex.getStackTrace())
- System.out.printf("%s\n", el.toString());
- }
- setVisible(false);
- dispose();
- AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this);
+ close();
}
});