import java.util.prefs.*;
import java.util.concurrent.LinkedBlockingQueue;
-import altosui.Altos;
-import altosui.AltosSerial;
-import altosui.AltosSerialMonitor;
-import altosui.AltosRecord;
-import altosui.AltosTelemetry;
-import altosui.AltosState;
-import altosui.AltosDeviceDialog;
-import altosui.AltosPreferences;
-import altosui.AltosLog;
-import altosui.AltosVoice;
-import altosui.AltosFlightStatusTableModel;
-import altosui.AltosFlightInfoTableModel;
-
import libaltosJNI.*;
-public class AltosConfigUI extends JDialog implements ActionListener, ItemListener, DocumentListener {
+public class AltosConfigUI
+ extends JDialog
+ implements ActionListener, ItemListener, DocumentListener
+{
Container pane;
Box box;
JLabel main_deploy_label;
JLabel apogee_delay_label;
JLabel radio_channel_label;
+ JLabel radio_calibration_label;
JLabel callsign_label;
public boolean dirty;
JComboBox main_deploy_value;
JComboBox apogee_delay_value;
JComboBox radio_channel_value;
+ JTextField radio_calibration_value;
JTextField callsign_value;
JButton save;
JButton reset;
+ JButton reboot;
JButton close;
ActionListener listener;
public void windowClosing(WindowEvent e) {
ui.actionPerformed(new ActionEvent(e.getSource(),
ActionEvent.ACTION_PERFORMED,
- "close"));
+ "Close"));
}
}
/* Product */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 0;
- c.gridwidth = 3;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
pane.add(product_label, c);
c = new GridBagConstraints();
- c.gridx = 3; c.gridy = 0;
- c.gridwidth = 3;
+ c.gridx = 4; c.gridy = 0;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
/* Version */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 1;
- c.gridwidth = 3;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
+ c.ipady = 5;
version_label = new JLabel("Software version:");
pane.add(version_label, c);
c = new GridBagConstraints();
- c.gridx = 3; c.gridy = 1;
- c.gridwidth = 3;
+ c.gridx = 4; c.gridy = 1;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
c.insets = ir;
+ c.ipady = 5;
version_value = new JLabel("");
pane.add(version_value, c);
/* Serial */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 2;
- c.gridwidth = 3;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
+ c.ipady = 5;
serial_label = new JLabel("Serial:");
pane.add(serial_label, c);
c = new GridBagConstraints();
- c.gridx = 3; c.gridy = 2;
- c.gridwidth = 3;
+ c.gridx = 4; c.gridy = 2;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
c.insets = ir;
+ c.ipady = 5;
serial_value = new JLabel("");
pane.add(serial_value, c);
/* Main deploy */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 3;
- c.gridwidth = 3;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
- c.ipady = 3;
+ c.ipady = 5;
main_deploy_label = new JLabel("Main Deploy Altitude(m):");
pane.add(main_deploy_label, c);
c = new GridBagConstraints();
- c.gridx = 3; c.gridy = 3;
- c.gridwidth = 3;
+ c.gridx = 4; c.gridy = 3;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
/* Apogee delay */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 4;
- c.gridwidth = 3;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
pane.add(apogee_delay_label, c);
c = new GridBagConstraints();
- c.gridx = 3; c.gridy = 4;
- c.gridwidth = 3;
+ c.gridx = 4; c.gridy = 4;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
/* Radio channel */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 5;
- c.gridwidth = 3;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
pane.add(radio_channel_label, c);
c = new GridBagConstraints();
- c.gridx = 3; c.gridy = 5;
- c.gridwidth = 3;
+ c.gridx = 4; c.gridy = 5;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
radio_channel_value.addItemListener(this);
pane.add(radio_channel_value, c);
- /* Callsign */
+ /* Radio Calibration */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 6;
- c.gridwidth = 3;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ c.ipady = 5;
+ radio_calibration_label = new JLabel("RF Calibration:");
+ pane.add(radio_calibration_label, c);
+
+ c = new GridBagConstraints();
+ c.gridx = 4; c.gridy = 6;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = ir;
+ c.ipady = 5;
+ radio_calibration_value = new JTextField(String.format("%d", 1186611));
+ radio_calibration_value.getDocument().addDocumentListener(this);
+ pane.add(radio_calibration_value, c);
+
+ /* Callsign */
+ c = new GridBagConstraints();
+ c.gridx = 0; c.gridy = 7;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
pane.add(callsign_label, c);
c = new GridBagConstraints();
- c.gridx = 3; c.gridy = 6;
- c.gridwidth = 3;
+ c.gridx = 4; c.gridy = 7;
+ c.gridwidth = 4;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.anchor = GridBagConstraints.LINE_START;
c.insets = ir;
c.ipady = 5;
- callsign_value = new JTextField("N0CALL");
+ callsign_value = new JTextField(AltosPreferences.callsign());
callsign_value.getDocument().addDocumentListener(this);
pane.add(callsign_value, c);
/* Buttons */
c = new GridBagConstraints();
- c.gridx = 0; c.gridy = 7;
+ c.gridx = 0; c.gridy = 8;
c.gridwidth = 2;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
save = new JButton("Save");
pane.add(save, c);
save.addActionListener(this);
- save.setActionCommand("save");
+ save.setActionCommand("Save");
c = new GridBagConstraints();
- c.gridx = 2; c.gridy = 7;
+ c.gridx = 2; c.gridy = 8;
c.gridwidth = 2;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
reset = new JButton("Reset");
pane.add(reset, c);
reset.addActionListener(this);
- reset.setActionCommand("reset");
+ reset.setActionCommand("Reset");
c = new GridBagConstraints();
- c.gridx = 4; c.gridy = 7;
+ c.gridx = 4; c.gridy = 8;
+ c.gridwidth = 2;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.CENTER;
+ c.insets = il;
+ reboot = new JButton("Reboot");
+ pane.add(reboot, c);
+ reboot.addActionListener(this);
+ reboot.setActionCommand("Reboot");
+
+ c = new GridBagConstraints();
+ c.gridx = 6; c.gridy = 8;
c.gridwidth = 2;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_END;
close = new JButton("Close");
pane.add(close, c);
close.addActionListener(this);
- close.setActionCommand("close");
+ close.setActionCommand("Close");
addWindowListener(new ConfigListener(this));
}
}
/* If any values have been changed, confirm before closing */
- public boolean check_dirty() {
+ public boolean check_dirty(String operation) {
if (dirty) {
- Object[] options = { "Close anyway", "Keep editing" };
+ Object[] options = { String.format("%s anyway", operation), "Keep editing" };
int i;
i = JOptionPane.showOptionDialog(this,
- "Configuration modified, close anyway?",
+ String.format("Configuration modified. %s anyway?", operation),
"Configuration Modified",
JOptionPane.DEFAULT_OPTION,
JOptionPane.WARNING_MESSAGE,
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
- if (cmd.equals("close"))
- if (!check_dirty())
+ if (cmd.equals("Close") || cmd.equals("Reboot"))
+ if (!check_dirty(cmd))
return;
listener.actionPerformed(e);
- if (cmd.equals("close")) {
+ if (cmd.equals("Close") || cmd.equals("Reboot")) {
setVisible(false);
dispose();
}
return radio_channel_value.getSelectedIndex();
}
+ public void set_radio_calibration(int new_radio_calibration) {
+ radio_calibration_value.setText(String.format("%d", new_radio_calibration));
+ }
+
+ public int radio_calibration() {
+ return Integer.parseInt(radio_calibration_value.getText());
+ }
+
public void set_callsign(String new_callsign) {
callsign_value.setText(new_callsign);
}