Bump java library versions
[fw/altos] / altosui / AltosConfigUI.java
1 /*
2  * Copyright © 2010 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 package altosui;
19
20 import java.awt.*;
21 import java.awt.event.*;
22 import javax.swing.*;
23 import javax.swing.event.*;
24 import java.text.*;
25 import org.altusmetrum.altoslib_11.*;
26 import org.altusmetrum.altosuilib_11.*;
27
28 public class AltosConfigUI
29         extends AltosUIDialog
30         implements ActionListener, ItemListener, DocumentListener, AltosConfigValues, AltosUnitsListener
31 {
32
33         Container               pane;
34         JLabel                  product_label;
35         JLabel                  version_label;
36         JLabel                  serial_label;
37         JLabel                  main_deploy_label;
38         JLabel                  apogee_delay_label;
39         JLabel                  apogee_lockout_label;
40         JLabel                  frequency_label;
41         JLabel                  radio_calibration_label;
42         JLabel                  radio_frequency_label;
43         JLabel                  radio_enable_label;
44         JLabel                  rate_label;
45         JLabel                  aprs_interval_label;
46         JLabel                  aprs_ssid_label;
47         JLabel                  aprs_format_label;
48         JLabel                  flight_log_max_label;
49         JLabel                  ignite_mode_label;
50         JLabel                  pad_orientation_label;
51         JLabel                  callsign_label;
52         JLabel                  beep_label;
53         JLabel                  tracker_motion_label;
54         JLabel                  tracker_interval_label;
55
56         public boolean          dirty;
57
58         JFrame                  owner;
59         JLabel                  product_value;
60         JLabel                  version_value;
61         JLabel                  serial_value;
62         JComboBox<String>       main_deploy_value;
63         JComboBox<String>       apogee_delay_value;
64         JComboBox<String>       apogee_lockout_value;
65         AltosUIFreqList         radio_frequency_value;
66         JLabel                  radio_calibration_value;
67         JRadioButton            radio_enable_value;
68         AltosUIRateList         rate_value;
69         JComboBox<String>       aprs_interval_value;
70         JComboBox<Integer>      aprs_ssid_value;
71         JComboBox<String>       aprs_format_value;
72         JComboBox<String>       flight_log_max_value;
73         JComboBox<String>       ignite_mode_value;
74         JComboBox<String>       pad_orientation_value;
75         JTextField              callsign_value;
76         JComboBox<String>       beep_value;
77         JComboBox<String>       tracker_motion_value;
78         JComboBox<String>       tracker_interval_value;
79
80         JButton                 pyro;
81
82         JButton                 save;
83         JButton                 reset;
84         JButton                 reboot;
85         JButton                 close;
86
87         AltosPyro[]             pyros;
88         double                  pyro_firing_time;
89
90         ActionListener          listener;
91
92         static String[]         main_deploy_values_m = {
93                 "100", "150", "200", "250", "300", "350",
94                 "400", "450", "500"
95         };
96
97         static String[]         main_deploy_values_ft = {
98                 "250", "500", "750", "1000", "1250", "1500",
99                 "1750", "2000"
100         };
101
102         static String[]         apogee_delay_values = {
103                 "0", "1", "2", "3", "4", "5"
104         };
105
106         static String[]         apogee_lockout_values = {
107                 "0", "5", "10", "15", "20"
108         };
109
110         static String[]         ignite_mode_values = {
111                 "Dual Deploy",
112                 "Redundant Apogee",
113                 "Redundant Main",
114         };
115
116         static String[]         aprs_interval_values = {
117                 "Disabled",
118                 "2",
119                 "5",
120                 "10"
121         };
122
123         static Integer[]        aprs_ssid_values = {
124                 0, 1, 2 ,3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
125         };
126
127         static String[]         beep_values = {
128                 "3750",
129                 "4000",
130                 "4250",
131         };
132
133         static String[]         pad_orientation_values = {
134                 "Antenna Up",
135                 "Antenna Down",
136         };
137
138         static String[]         tracker_motion_values_m = {
139                 "2",
140                 "5",
141                 "10",
142                 "25",
143         };
144
145         static String[]         tracker_motion_values_ft = {
146                 "5",
147                 "20",
148                 "50",
149                 "100"
150         };
151
152         static String[]         tracker_interval_values = {
153                 "1",
154                 "2",
155                 "5",
156                 "10"
157         };
158
159         /* A window listener to catch closing events and tell the config code */
160         class ConfigListener extends WindowAdapter {
161                 AltosConfigUI   ui;
162
163                 public ConfigListener(AltosConfigUI this_ui) {
164                         ui = this_ui;
165                 }
166
167                 public void windowClosing(WindowEvent e) {
168                         ui.actionPerformed(new ActionEvent(e.getSource(),
169                                                            ActionEvent.ACTION_PERFORMED,
170                                                            "Close"));
171                 }
172         }
173
174         boolean is_telemini_v1() {
175                 String  product = product_value.getText();
176                 return product != null && product.startsWith("TeleMini-v1");
177         }
178
179         boolean is_telemini() {
180                 String  product = product_value.getText();
181                 return product != null && product.startsWith("TeleMini");
182         }
183
184         boolean is_easymini() {
185                 String  product = product_value.getText();
186                 return product != null && product.startsWith("EasyMini");
187         }
188
189         boolean is_telemetrum() {
190                 String  product = product_value.getText();
191                 return product != null && product.startsWith("TeleMetrum");
192         }
193
194         void set_radio_enable_tool_tip() {
195                 if (radio_enable_value.isEnabled())
196                         radio_enable_value.setToolTipText("Enable/Disable telemetry and RDF transmissions");
197                 else
198                         radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
199         }
200
201         void set_rate_tool_tip() {
202                 if (rate_value.isEnabled())
203                         rate_value.setToolTipText("Select telemetry baud rate");
204                 else
205                         rate_value.setToolTipText("Firmware version does not support variable telemetry rates");
206         }
207
208         void set_aprs_interval_tool_tip() {
209                 if (aprs_interval_value.isEnabled())
210                         aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports");
211                 else
212                         aprs_interval_value.setToolTipText("Hardware doesn't support APRS");
213         }
214
215         void set_aprs_ssid_tool_tip() {
216                 if (aprs_ssid_value.isEnabled())
217                         aprs_ssid_value.setToolTipText("Set the APRS SSID (secondary station identifier)");
218                 else if (aprs_ssid_value.isEnabled())
219                         aprs_ssid_value.setToolTipText("Software version doesn't support setting the APRS SSID");
220                 else
221                         aprs_ssid_value.setToolTipText("Hardware doesn't support APRS");
222         }
223
224         void set_aprs_format_tool_tip() {
225                 if (aprs_format_value.isEnabled())
226                         aprs_format_value.setToolTipText("Set the APRS format (compressed/uncompressed)");
227                 else if (aprs_format_value.isEnabled())
228                         aprs_format_value.setToolTipText("Software version doesn't support setting the APRS format");
229                 else
230                         aprs_format_value.setToolTipText("Hardware doesn't support APRS");
231         }
232
233         void set_flight_log_max_tool_tip() {
234                 if (flight_log_max_value.isEnabled())
235                         flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)");
236                 else {
237                         if (is_telemini_v1())
238                                 flight_log_max_value.setToolTipText("TeleMini-v1 stores only one flight");
239                         else
240                                 flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory");
241                 }
242         }
243
244         void set_ignite_mode_tool_tip() {
245                 if (ignite_mode_value.isEnabled())
246                         ignite_mode_value.setToolTipText("Select when igniters will be fired");
247                 else
248                         ignite_mode_value.setToolTipText("Older firmware could not select ignite mode");
249         }
250
251         void set_pad_orientation_tool_tip() {
252                 if (pad_orientation_value.isEnabled())
253                         pad_orientation_value.setToolTipText("How will the computer be mounted in the airframe");
254                 else {
255                         if (is_telemetrum())
256                                 pad_orientation_value.setToolTipText("Older TeleMetrum firmware must fly antenna forward");
257                         else if (is_telemini() || is_easymini())
258                                 pad_orientation_value.setToolTipText("TeleMini and EasyMini don't care how they are mounted");
259                         else
260                                 pad_orientation_value.setToolTipText("Can't select orientation");
261                 }
262         }
263
264         void set_beep_tool_tip() {
265                 if (beep_value.isEnabled())
266                         beep_value.setToolTipText("What frequency the beeper will sound at");
267                 else
268                         beep_value.setToolTipText("Older firmware could not select beeper frequency");
269         }
270
271         /* Build the UI using a grid bag */
272         public AltosConfigUI(JFrame in_owner, boolean remote) {
273                 super (in_owner, "Configure Flight Computer", false);
274
275                 owner = in_owner;
276                 GridBagConstraints c;
277                 int row = 0;
278
279                 Insets il = new Insets(4,4,4,4);
280                 Insets ir = new Insets(4,4,4,4);
281
282                 pane = getContentPane();
283                 pane.setLayout(new GridBagLayout());
284
285                 /* Product */
286                 c = new GridBagConstraints();
287                 c.gridx = 0; c.gridy = row;
288                 c.gridwidth = 4;
289                 c.fill = GridBagConstraints.NONE;
290                 c.anchor = GridBagConstraints.LINE_START;
291                 c.insets = il;
292                 product_label = new JLabel("Product:");
293                 pane.add(product_label, c);
294
295                 c = new GridBagConstraints();
296                 c.gridx = 4; c.gridy = row;
297                 c.gridwidth = 4;
298                 c.fill = GridBagConstraints.HORIZONTAL;
299                 c.weightx = 1;
300                 c.anchor = GridBagConstraints.LINE_START;
301                 c.insets = ir;
302                 product_value = new JLabel("");
303                 pane.add(product_value, c);
304                 row++;
305
306                 /* Version */
307                 c = new GridBagConstraints();
308                 c.gridx = 0; c.gridy = row;
309                 c.gridwidth = 4;
310                 c.fill = GridBagConstraints.NONE;
311                 c.anchor = GridBagConstraints.LINE_START;
312                 c.insets = il;
313                 c.ipady = 5;
314                 version_label = new JLabel("Software version:");
315                 pane.add(version_label, c);
316
317                 c = new GridBagConstraints();
318                 c.gridx = 4; c.gridy = row;
319                 c.gridwidth = 4;
320                 c.fill = GridBagConstraints.HORIZONTAL;
321                 c.weightx = 1;
322                 c.anchor = GridBagConstraints.LINE_START;
323                 c.insets = ir;
324                 c.ipady = 5;
325                 version_value = new JLabel("");
326                 pane.add(version_value, c);
327                 row++;
328
329                 /* Serial */
330                 c = new GridBagConstraints();
331                 c.gridx = 0; c.gridy = row;
332                 c.gridwidth = 4;
333                 c.fill = GridBagConstraints.NONE;
334                 c.anchor = GridBagConstraints.LINE_START;
335                 c.insets = il;
336                 c.ipady = 5;
337                 serial_label = new JLabel("Serial:");
338                 pane.add(serial_label, c);
339
340                 c = new GridBagConstraints();
341                 c.gridx = 4; c.gridy = row;
342                 c.gridwidth = 4;
343                 c.fill = GridBagConstraints.HORIZONTAL;
344                 c.weightx = 1;
345                 c.anchor = GridBagConstraints.LINE_START;
346                 c.insets = ir;
347                 c.ipady = 5;
348                 serial_value = new JLabel("");
349                 pane.add(serial_value, c);
350                 row++;
351
352                 /* Main deploy */
353                 c = new GridBagConstraints();
354                 c.gridx = 0; c.gridy = row;
355                 c.gridwidth = 4;
356                 c.fill = GridBagConstraints.NONE;
357                 c.anchor = GridBagConstraints.LINE_START;
358                 c.insets = il;
359                 c.ipady = 5;
360                 main_deploy_label = new JLabel(get_main_deploy_label());
361                 pane.add(main_deploy_label, c);
362
363                 c = new GridBagConstraints();
364                 c.gridx = 4; c.gridy = row;
365                 c.gridwidth = 4;
366                 c.fill = GridBagConstraints.HORIZONTAL;
367                 c.weightx = 1;
368                 c.anchor = GridBagConstraints.LINE_START;
369                 c.insets = ir;
370                 c.ipady = 5;
371                 main_deploy_value = new JComboBox<String>(main_deploy_values());
372                 main_deploy_value.setEditable(true);
373                 main_deploy_value.addItemListener(this);
374                 pane.add(main_deploy_value, c);
375                 main_deploy_value.setToolTipText("Height above pad altitude to fire main charge");
376                 row++;
377
378                 /* Apogee delay */
379                 c = new GridBagConstraints();
380                 c.gridx = 0; c.gridy = row;
381                 c.gridwidth = 4;
382                 c.fill = GridBagConstraints.NONE;
383                 c.anchor = GridBagConstraints.LINE_START;
384                 c.insets = il;
385                 c.ipady = 5;
386                 apogee_delay_label = new JLabel("Apogee Delay(s):");
387                 pane.add(apogee_delay_label, c);
388
389                 c = new GridBagConstraints();
390                 c.gridx = 4; c.gridy = row;
391                 c.gridwidth = 4;
392                 c.fill = GridBagConstraints.HORIZONTAL;
393                 c.weightx = 1;
394                 c.anchor = GridBagConstraints.LINE_START;
395                 c.insets = ir;
396                 c.ipady = 5;
397                 apogee_delay_value = new JComboBox<String>(apogee_delay_values);
398                 apogee_delay_value.setEditable(true);
399                 apogee_delay_value.addItemListener(this);
400                 pane.add(apogee_delay_value, c);
401                 apogee_delay_value.setToolTipText("Delay after apogee before charge fires");
402                 row++;
403
404                 /* Apogee lockout */
405                 c = new GridBagConstraints();
406                 c.gridx = 0; c.gridy = row;
407                 c.gridwidth = 4;
408                 c.fill = GridBagConstraints.NONE;
409                 c.anchor = GridBagConstraints.LINE_START;
410                 c.insets = il;
411                 c.ipady = 5;
412                 apogee_lockout_label = new JLabel("Apogee Lockout(s):");
413                 pane.add(apogee_lockout_label, c);
414
415                 c = new GridBagConstraints();
416                 c.gridx = 4; c.gridy = row;
417                 c.gridwidth = 4;
418                 c.fill = GridBagConstraints.HORIZONTAL;
419                 c.weightx = 1;
420                 c.anchor = GridBagConstraints.LINE_START;
421                 c.insets = ir;
422                 c.ipady = 5;
423                 apogee_lockout_value = new JComboBox<String>(apogee_lockout_values);
424                 apogee_lockout_value.setEditable(true);
425                 apogee_lockout_value.addItemListener(this);
426                 pane.add(apogee_lockout_value, c);
427                 apogee_lockout_value.setToolTipText("Time after boost while apogee detection is locked out");
428                 row++;
429
430                 /* Frequency */
431                 c = new GridBagConstraints();
432                 c.gridx = 0; c.gridy = row;
433                 c.gridwidth = 4;
434                 c.fill = GridBagConstraints.NONE;
435                 c.anchor = GridBagConstraints.LINE_START;
436                 c.insets = il;
437                 c.ipady = 5;
438                 radio_frequency_label = new JLabel("Frequency:");
439                 pane.add(radio_frequency_label, c);
440
441                 c = new GridBagConstraints();
442                 c.gridx = 4; c.gridy = row;
443                 c.gridwidth = 4;
444                 c.fill = GridBagConstraints.HORIZONTAL;
445                 c.weightx = 1;
446                 c.anchor = GridBagConstraints.LINE_START;
447                 c.insets = ir;
448                 c.ipady = 5;
449                 radio_frequency_value = new AltosUIFreqList();
450                 radio_frequency_value.addItemListener(this);
451                 pane.add(radio_frequency_value, c);
452                 radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency");
453                 row++;
454
455                 /* Radio Calibration */
456                 c = new GridBagConstraints();
457                 c.gridx = 0; c.gridy = row;
458                 c.gridwidth = 4;
459                 c.fill = GridBagConstraints.NONE;
460                 c.anchor = GridBagConstraints.LINE_START;
461                 c.insets = il;
462                 c.ipady = 5;
463                 radio_calibration_label = new JLabel("RF Calibration:");
464                 pane.add(radio_calibration_label, c);
465
466                 c = new GridBagConstraints();
467                 c.gridx = 4; c.gridy = row;
468                 c.gridwidth = 4;
469                 c.fill = GridBagConstraints.HORIZONTAL;
470                 c.weightx = 1;
471                 c.anchor = GridBagConstraints.LINE_START;
472                 c.insets = ir;
473                 c.ipady = 5;
474                 radio_calibration_value = new JLabel(String.format("%d", 1186611));
475                 pane.add(radio_calibration_value, c);
476                 row++;
477
478                 /* Radio Enable */
479                 c = new GridBagConstraints();
480                 c.gridx = 0; c.gridy = row;
481                 c.gridwidth = 4;
482                 c.fill = GridBagConstraints.NONE;
483                 c.anchor = GridBagConstraints.LINE_START;
484                 c.insets = il;
485                 c.ipady = 5;
486                 radio_enable_label = new JLabel("Telemetry/RDF/APRS Enable:");
487                 pane.add(radio_enable_label, c);
488
489                 c = new GridBagConstraints();
490                 c.gridx = 4; c.gridy = row;
491                 c.gridwidth = 4;
492                 c.fill = GridBagConstraints.HORIZONTAL;
493                 c.weightx = 1;
494                 c.anchor = GridBagConstraints.LINE_START;
495                 c.insets = ir;
496                 c.ipady = 5;
497                 radio_enable_value = new JRadioButton("Enabled");
498                 radio_enable_value.addItemListener(this);
499                 pane.add(radio_enable_value, c);
500                 set_radio_enable_tool_tip();
501                 row++;
502
503                 /* Telemetry Rate */
504                 c = new GridBagConstraints();
505                 c.gridx = 0; c.gridy = row;
506                 c.gridwidth = 4;
507                 c.fill = GridBagConstraints.NONE;
508                 c.anchor = GridBagConstraints.LINE_START;
509                 c.insets = il;
510                 c.ipady = 5;
511                 rate_label = new JLabel("Telemetry baud rate:");
512                 pane.add(rate_label, c);
513
514                 c = new GridBagConstraints();
515                 c.gridx = 4; c.gridy = row;
516                 c.gridwidth = 4;
517                 c.fill = GridBagConstraints.HORIZONTAL;
518                 c.weightx = 1;
519                 c.anchor = GridBagConstraints.LINE_START;
520                 c.insets = ir;
521                 c.ipady = 5;
522                 rate_value = new AltosUIRateList();
523                 rate_value.addItemListener(this);
524                 pane.add(rate_value, c);
525                 set_rate_tool_tip();
526                 row++;
527
528                 /* APRS interval */
529                 c = new GridBagConstraints();
530                 c.gridx = 0; c.gridy = row;
531                 c.gridwidth = 4;
532                 c.fill = GridBagConstraints.NONE;
533                 c.anchor = GridBagConstraints.LINE_START;
534                 c.insets = il;
535                 c.ipady = 5;
536                 aprs_interval_label = new JLabel("APRS Interval(s):");
537                 pane.add(aprs_interval_label, c);
538
539                 c = new GridBagConstraints();
540                 c.gridx = 4; c.gridy = row;
541                 c.gridwidth = 4;
542                 c.fill = GridBagConstraints.HORIZONTAL;
543                 c.weightx = 1;
544                 c.anchor = GridBagConstraints.LINE_START;
545                 c.insets = ir;
546                 c.ipady = 5;
547                 aprs_interval_value = new JComboBox<String>(aprs_interval_values);
548                 aprs_interval_value.setEditable(true);
549                 aprs_interval_value.addItemListener(this);
550                 pane.add(aprs_interval_value, c);
551                 set_aprs_interval_tool_tip();
552                 row++;
553
554                 /* APRS SSID */
555                 c = new GridBagConstraints();
556                 c.gridx = 0; c.gridy = row;
557                 c.gridwidth = 4;
558                 c.fill = GridBagConstraints.NONE;
559                 c.anchor = GridBagConstraints.LINE_START;
560                 c.insets = il;
561                 c.ipady = 5;
562                 aprs_ssid_label = new JLabel("APRS SSID:");
563                 pane.add(aprs_ssid_label, c);
564
565                 c = new GridBagConstraints();
566                 c.gridx = 4; c.gridy = row;
567                 c.gridwidth = 4;
568                 c.fill = GridBagConstraints.HORIZONTAL;
569                 c.weightx = 1;
570                 c.anchor = GridBagConstraints.LINE_START;
571                 c.insets = ir;
572                 c.ipady = 5;
573                 aprs_ssid_value = new JComboBox<Integer>(aprs_ssid_values);
574                 aprs_ssid_value.setEditable(false);
575                 aprs_ssid_value.addItemListener(this);
576                 aprs_ssid_value.setMaximumRowCount(aprs_ssid_values.length);
577                 pane.add(aprs_ssid_value, c);
578                 set_aprs_ssid_tool_tip();
579                 row++;
580
581                 /* APRS format */
582                 c = new GridBagConstraints();
583                 c.gridx = 0; c.gridy = row;
584                 c.gridwidth = 4;
585                 c.fill = GridBagConstraints.NONE;
586                 c.anchor = GridBagConstraints.LINE_START;
587                 c.insets = il;
588                 c.ipady = 5;
589                 aprs_format_label = new JLabel("APRS format:");
590                 pane.add(aprs_format_label, c);
591
592                 c = new GridBagConstraints();
593                 c.gridx = 4; c.gridy = row;
594                 c.gridwidth = 4;
595                 c.fill = GridBagConstraints.HORIZONTAL;
596                 c.weightx = 1;
597                 c.anchor = GridBagConstraints.LINE_START;
598                 c.insets = ir;
599                 c.ipady = 5;
600                 aprs_format_value = new JComboBox<String>(AltosLib.ao_aprs_format_name);
601                 aprs_format_value.setEditable(false);
602                 aprs_format_value.addItemListener(this);
603                 aprs_format_value.setMaximumRowCount(AltosLib.ao_aprs_format_name.length);
604                 pane.add(aprs_format_value, c);
605                 set_aprs_format_tool_tip();
606                 row++;
607
608                 /* Callsign */
609                 c = new GridBagConstraints();
610                 c.gridx = 0; c.gridy = row;
611                 c.gridwidth = 4;
612                 c.fill = GridBagConstraints.NONE;
613                 c.anchor = GridBagConstraints.LINE_START;
614                 c.insets = il;
615                 c.ipady = 5;
616                 callsign_label = new JLabel("Callsign:");
617                 pane.add(callsign_label, c);
618
619                 c = new GridBagConstraints();
620                 c.gridx = 4; c.gridy = row;
621                 c.gridwidth = 4;
622                 c.fill = GridBagConstraints.HORIZONTAL;
623                 c.weightx = 1;
624                 c.anchor = GridBagConstraints.LINE_START;
625                 c.insets = ir;
626                 c.ipady = 5;
627                 callsign_value = new JTextField(AltosUIPreferences.callsign());
628                 callsign_value.getDocument().addDocumentListener(this);
629                 pane.add(callsign_value, c);
630                 callsign_value.setToolTipText("Callsign reported in telemetry data");
631                 row++;
632
633                 /* Flight log max */
634                 c = new GridBagConstraints();
635                 c.gridx = 0; c.gridy = row;
636                 c.gridwidth = 4;
637                 c.fill = GridBagConstraints.NONE;
638                 c.anchor = GridBagConstraints.LINE_START;
639                 c.insets = il;
640                 c.ipady = 5;
641                 flight_log_max_label = new JLabel("Maximum Flight Log Size (kB):");
642                 pane.add(flight_log_max_label, c);
643
644                 c = new GridBagConstraints();
645                 c.gridx = 4; c.gridy = row;
646                 c.gridwidth = 4;
647                 c.fill = GridBagConstraints.HORIZONTAL;
648                 c.weightx = 1;
649                 c.anchor = GridBagConstraints.LINE_START;
650                 c.insets = ir;
651                 c.ipady = 5;
652                 flight_log_max_value = new JComboBox<String>();
653                 flight_log_max_value.setEditable(true);
654                 flight_log_max_value.addItemListener(this);
655                 pane.add(flight_log_max_value, c);
656                 set_flight_log_max_tool_tip();
657                 row++;
658
659                 /* Ignite mode */
660                 c = new GridBagConstraints();
661                 c.gridx = 0; c.gridy = row;
662                 c.gridwidth = 4;
663                 c.fill = GridBagConstraints.NONE;
664                 c.anchor = GridBagConstraints.LINE_START;
665                 c.insets = il;
666                 c.ipady = 5;
667                 ignite_mode_label = new JLabel("Igniter Firing Mode:");
668                 pane.add(ignite_mode_label, c);
669
670                 c = new GridBagConstraints();
671                 c.gridx = 4; c.gridy = row;
672                 c.gridwidth = 4;
673                 c.fill = GridBagConstraints.HORIZONTAL;
674                 c.weightx = 1;
675                 c.anchor = GridBagConstraints.LINE_START;
676                 c.insets = ir;
677                 c.ipady = 5;
678                 ignite_mode_value = new JComboBox<String>(ignite_mode_values);
679                 ignite_mode_value.setEditable(false);
680                 ignite_mode_value.addItemListener(this);
681                 pane.add(ignite_mode_value, c);
682                 set_ignite_mode_tool_tip();
683                 row++;
684
685                 /* Pad orientation */
686                 c = new GridBagConstraints();
687                 c.gridx = 0; c.gridy = row;
688                 c.gridwidth = 4;
689                 c.fill = GridBagConstraints.NONE;
690                 c.anchor = GridBagConstraints.LINE_START;
691                 c.insets = il;
692                 c.ipady = 5;
693                 pad_orientation_label = new JLabel("Pad Orientation:");
694                 pane.add(pad_orientation_label, c);
695
696                 c = new GridBagConstraints();
697                 c.gridx = 4; c.gridy = row;
698                 c.gridwidth = 4;
699                 c.fill = GridBagConstraints.HORIZONTAL;
700                 c.weightx = 1;
701                 c.anchor = GridBagConstraints.LINE_START;
702                 c.insets = ir;
703                 c.ipady = 5;
704                 pad_orientation_value = new JComboBox<String>(pad_orientation_values);
705                 pad_orientation_value.setEditable(false);
706                 pad_orientation_value.addItemListener(this);
707                 pane.add(pad_orientation_value, c);
708                 set_pad_orientation_tool_tip();
709                 row++;
710
711                 /* Beeper */
712                 c = new GridBagConstraints();
713                 c.gridx = 0; c.gridy = row;
714                 c.gridwidth = 4;
715                 c.fill = GridBagConstraints.NONE;
716                 c.anchor = GridBagConstraints.LINE_START;
717                 c.insets = il;
718                 c.ipady = 5;
719                 beep_label = new JLabel("Beeper Frequency:");
720                 pane.add(beep_label, c);
721
722                 c = new GridBagConstraints();
723                 c.gridx = 4; c.gridy = row;
724                 c.gridwidth = 4;
725                 c.fill = GridBagConstraints.HORIZONTAL;
726                 c.weightx = 1;
727                 c.anchor = GridBagConstraints.LINE_START;
728                 c.insets = ir;
729                 c.ipady = 5;
730                 beep_value = new JComboBox<String>(beep_values);
731                 beep_value.setEditable(true);
732                 beep_value.addItemListener(this);
733                 pane.add(beep_value, c);
734                 set_beep_tool_tip();
735                 row++;
736
737                 /* Tracker triger horiz distances */
738                 c = new GridBagConstraints();
739                 c.gridx = 0; c.gridy = row;
740                 c.gridwidth = 4;
741                 c.fill = GridBagConstraints.NONE;
742                 c.anchor = GridBagConstraints.LINE_START;
743                 c.insets = il;
744                 c.ipady = 5;
745                 tracker_motion_label = new JLabel(get_tracker_motion_label());
746                 pane.add(tracker_motion_label, c);
747
748                 c = new GridBagConstraints();
749                 c.gridx = 4; c.gridy = row;
750                 c.gridwidth = 4;
751                 c.fill = GridBagConstraints.HORIZONTAL;
752                 c.weightx = 1;
753                 c.anchor = GridBagConstraints.LINE_START;
754                 c.insets = ir;
755                 c.ipady = 5;
756                 tracker_motion_value = new JComboBox<String>(tracker_motion_values());
757                 tracker_motion_value.setEditable(true);
758                 tracker_motion_value.addItemListener(this);
759                 pane.add(tracker_motion_value, c);
760                 row++;
761
762                 /* Tracker triger vert distances */
763                 c = new GridBagConstraints();
764                 c.gridx = 0; c.gridy = row;
765                 c.gridwidth = 4;
766                 c.fill = GridBagConstraints.NONE;
767                 c.anchor = GridBagConstraints.LINE_START;
768                 c.insets = il;
769                 c.ipady = 5;
770                 tracker_interval_label = new JLabel("Position Reporting Interval(s):");
771                 pane.add(tracker_interval_label, c);
772
773                 c = new GridBagConstraints();
774                 c.gridx = 4; c.gridy = row;
775                 c.gridwidth = 4;
776                 c.fill = GridBagConstraints.HORIZONTAL;
777                 c.weightx = 1;
778                 c.anchor = GridBagConstraints.LINE_START;
779                 c.insets = ir;
780                 c.ipady = 5;
781                 tracker_interval_value = new JComboBox<String>(tracker_interval_values);
782                 tracker_interval_value.setEditable(true);
783                 tracker_interval_value.addItemListener(this);
784                 pane.add(tracker_interval_value, c);
785                 set_tracker_tool_tip();
786                 row++;
787
788                 /* Pyro channels */
789                 c = new GridBagConstraints();
790                 c.gridx = 4; c.gridy = row;
791                 c.gridwidth = 4;
792                 c.fill = GridBagConstraints.HORIZONTAL;
793                 c.anchor = GridBagConstraints.LINE_START;
794                 c.insets = il;
795                 c.ipady = 5;
796                 pyro = new JButton("Configure Pyro Channels");
797                 pane.add(pyro, c);
798                 pyro.addActionListener(this);
799                 pyro.setActionCommand("Pyro");
800                 row++;
801
802                 /* Buttons */
803                 c = new GridBagConstraints();
804                 c.gridx = 0; c.gridy = row;
805                 c.gridwidth = 2;
806                 c.fill = GridBagConstraints.NONE;
807                 c.anchor = GridBagConstraints.LINE_START;
808                 c.insets = il;
809                 save = new JButton("Save");
810                 pane.add(save, c);
811                 save.addActionListener(this);
812                 save.setActionCommand("Save");
813
814                 c = new GridBagConstraints();
815                 c.gridx = 2; c.gridy = row;
816                 c.gridwidth = 2;
817                 c.fill = GridBagConstraints.NONE;
818                 c.anchor = GridBagConstraints.CENTER;
819                 c.insets = il;
820                 reset = new JButton("Reset");
821                 pane.add(reset, c);
822                 reset.addActionListener(this);
823                 reset.setActionCommand("Reset");
824
825                 c = new GridBagConstraints();
826                 c.gridx = 4; c.gridy = row;
827                 c.gridwidth = 2;
828                 c.fill = GridBagConstraints.NONE;
829                 c.anchor = GridBagConstraints.CENTER;
830                 c.insets = il;
831                 reboot = new JButton("Reboot");
832                 pane.add(reboot, c);
833                 reboot.addActionListener(this);
834                 reboot.setActionCommand("Reboot");
835
836                 c = new GridBagConstraints();
837                 c.gridx = 6; c.gridy = row;
838                 c.gridwidth = 2;
839                 c.fill = GridBagConstraints.NONE;
840                 c.anchor = GridBagConstraints.LINE_END;
841                 c.insets = il;
842                 close = new JButton("Close");
843                 pane.add(close, c);
844                 close.addActionListener(this);
845                 close.setActionCommand("Close");
846
847                 addWindowListener(new ConfigListener(this));
848                 AltosPreferences.register_units_listener(this);
849         }
850
851         /* Once the initial values are set, the config code will show the dialog */
852         public void make_visible() {
853                 pack();
854                 setLocationRelativeTo(owner);
855                 setVisible(true);
856         }
857
858         /* If any values have been changed, confirm before closing */
859         public boolean check_dirty(String operation) {
860                 if (dirty) {
861                         Object[] options = { String.format("%s anyway", operation), "Keep editing" };
862                         int i;
863                         i = JOptionPane.showOptionDialog(this,
864                                                          String.format("Configuration modified. %s anyway?", operation),
865                                                          "Configuration Modified",
866                                                          JOptionPane.DEFAULT_OPTION,
867                                                          JOptionPane.WARNING_MESSAGE,
868                                                          null, options, options[1]);
869                         if (i != 0)
870                                 return false;
871                 }
872                 return true;
873         }
874
875         void set_dirty() {
876                 dirty = true;
877                 save.setEnabled(true);
878         }
879
880         public void set_clean() {
881                 dirty = false;
882                 save.setEnabled(false);
883         }
884
885         AltosConfigPyroUI       pyro_ui;
886
887         public void dispose() {
888                 if (pyro_ui != null)
889                         pyro_ui.dispose();
890                 AltosPreferences.unregister_units_listener(this);
891                 super.dispose();
892         }
893
894         /* Listen for events from our buttons */
895         public void actionPerformed(ActionEvent e) {
896                 String  cmd = e.getActionCommand();
897
898                 if (cmd.equals("Pyro")) {
899                         if (pyro_ui == null && pyros != null)
900                                 pyro_ui = new AltosConfigPyroUI(this, pyros, pyro_firing_time);
901                         if (pyro_ui != null)
902                                 pyro_ui.make_visible();
903                         return;
904                 }
905
906                 if (cmd.equals("Close") || cmd.equals("Reboot"))
907                         if (!check_dirty(cmd))
908                                 return;
909                 listener.actionPerformed(e);
910                 if (cmd.equals("Close") || cmd.equals("Reboot")) {
911                         setVisible(false);
912                         dispose();
913                 }
914                 set_clean();
915         }
916
917         /* ItemListener interface method */
918         public void itemStateChanged(ItemEvent e) {
919                 set_dirty();
920         }
921
922         /* DocumentListener interface methods */
923         public void changedUpdate(DocumentEvent e) {
924                 set_dirty();
925         }
926
927         public void insertUpdate(DocumentEvent e) {
928                 set_dirty();
929         }
930
931         public void removeUpdate(DocumentEvent e) {
932                 set_dirty();
933         }
934
935         /* Let the config code hook on a listener */
936         public void addActionListener(ActionListener l) {
937                 listener = l;
938         }
939
940         /* set and get all of the dialog values */
941         public void set_product(String product) {
942                 radio_frequency_value.set_product(product);
943                 product_value.setText(product);
944                 set_pad_orientation_tool_tip();
945                 set_flight_log_max_tool_tip();
946         }
947
948         public void set_version(String version) {
949                 version_value.setText(version);
950         }
951
952         public void set_serial(int serial) {
953                 radio_frequency_value.set_serial(serial);
954                 serial_value.setText(String.format("%d", serial));
955         }
956
957         public void set_altitude_32(int altitude_32) {
958         }
959
960         public void set_main_deploy(int new_main_deploy) {
961                 main_deploy_value.setSelectedItem(AltosConvert.height.say(new_main_deploy));
962                 main_deploy_value.setEnabled(new_main_deploy >= 0);
963
964                 main_deploy_value.setVisible(new_main_deploy >= 0);
965                 main_deploy_label.setVisible(new_main_deploy >= 0);
966
967         }
968
969         public int main_deploy() throws AltosConfigDataException {
970                 String  str = main_deploy_value.getSelectedItem().toString();
971                 try {
972                         return (int) (AltosConvert.height.parse_locale(str) + 0.5);
973                 } catch (ParseException pe) {
974                         throw new AltosConfigDataException("invalid main deploy height %s", str);
975                 }
976         }
977
978         String get_main_deploy_label() {
979                 return String.format("Main Deploy Altitude(%s):", AltosConvert.height.parse_units());
980         }
981
982         String[] main_deploy_values() {
983                 if (AltosConvert.imperial_units)
984                         return main_deploy_values_ft;
985                 else
986                         return main_deploy_values_m;
987         }
988
989         void set_main_deploy_values() {
990                 String[]        v = main_deploy_values();
991                 while (main_deploy_value.getItemCount() > 0)
992                         main_deploy_value.removeItemAt(0);
993                 for (int i = 0; i < v.length; i++)
994                         main_deploy_value.addItem(v[i]);
995                 main_deploy_value.setMaximumRowCount(v.length);
996         }
997
998         public void units_changed(boolean imperial_units) {
999                 boolean was_dirty = dirty;
1000
1001                 String v = main_deploy_value.getSelectedItem().toString();
1002                 main_deploy_label.setText(get_main_deploy_label());
1003                 set_main_deploy_values();
1004                 try {
1005                         int m = (int) (AltosConvert.height.parse_locale(v, !imperial_units) + 0.5);
1006                         set_main_deploy(m);
1007                 } catch (ParseException pe) {
1008                 }
1009
1010                 if (tracker_motion_value.isEnabled()) {
1011                         String motion = tracker_motion_value.getSelectedItem().toString();
1012                         tracker_motion_label.setText(get_tracker_motion_label());
1013                         set_tracker_motion_values();
1014                         try {
1015                                 int m = (int) (AltosConvert.height.parse_locale(motion, !imperial_units) + 0.5);
1016                                 set_tracker_motion(m);
1017                         } catch (ParseException pe) {
1018                         }
1019                 }
1020
1021                 if (!was_dirty)
1022                         set_clean();
1023         }
1024
1025         public void set_apogee_delay(int new_apogee_delay) {
1026                 apogee_delay_value.setVisible(new_apogee_delay >= 0);
1027                 apogee_delay_label.setVisible(new_apogee_delay >= 0);
1028
1029                 apogee_delay_value.setSelectedItem(Integer.toString(new_apogee_delay));
1030                 apogee_delay_value.setEnabled(new_apogee_delay >= 0);
1031         }
1032
1033         private int parse_int(String name, String s, boolean split) throws AltosConfigDataException {
1034                 String v = s;
1035                 if (split)
1036                         v = s.split("\\s+")[0];
1037                 try {
1038                         return Integer.parseInt(v);
1039                 } catch (NumberFormatException ne) {
1040                         throw new AltosConfigDataException("Invalid %s \"%s\"", name, s);
1041                 }
1042         }
1043
1044         public int apogee_delay() throws AltosConfigDataException {
1045                 return parse_int("apogee delay", apogee_delay_value.getSelectedItem().toString(), false);
1046         }
1047
1048         public void set_apogee_lockout(int new_apogee_lockout) {
1049                 apogee_lockout_value.setSelectedItem(Integer.toString(new_apogee_lockout));
1050                 apogee_lockout_value.setEnabled(new_apogee_lockout >= 0);
1051
1052                 apogee_lockout_value.setVisible(new_apogee_lockout >= 0);
1053                 apogee_lockout_label.setVisible(new_apogee_lockout >= 0);
1054         }
1055
1056         public int apogee_lockout() throws AltosConfigDataException {
1057                 return parse_int("apogee lockout", apogee_lockout_value.getSelectedItem().toString(), false);
1058         }
1059
1060         public void set_radio_frequency(double new_radio_frequency) {
1061                 radio_frequency_label.setVisible(new_radio_frequency >= 0);
1062                 radio_frequency_value.set_frequency(new_radio_frequency);
1063         }
1064
1065         public double radio_frequency() {
1066                 return radio_frequency_value.frequency();
1067         }
1068
1069         public void set_radio_calibration(int new_radio_calibration) {
1070                 radio_calibration_value.setVisible(new_radio_calibration >= 0);
1071                 radio_calibration_label.setVisible(new_radio_calibration >= 0);
1072
1073                 if (new_radio_calibration < 0)
1074                         radio_calibration_value.setText("Disabled");
1075                 else
1076                         radio_calibration_value.setText(String.format("%d", new_radio_calibration));
1077         }
1078
1079         public void set_radio_enable(int new_radio_enable) {
1080                 radio_enable_label.setVisible(new_radio_enable >= 0);
1081                 radio_enable_value.setVisible(new_radio_enable >= 0);
1082
1083                 if (new_radio_enable >= 0) {
1084                         radio_enable_value.setSelected(new_radio_enable > 0);
1085                         radio_enable_value.setEnabled(true);
1086                 } else {
1087                         radio_enable_value.setSelected(true);
1088                         radio_enable_value.setEnabled(false);
1089                 }
1090                 set_radio_enable_tool_tip();
1091         }
1092
1093         public int radio_enable() {
1094                 if (radio_enable_value.isEnabled())
1095                         return radio_enable_value.isSelected() ? 1 : 0;
1096                 else
1097                         return -1;
1098         }
1099
1100         public void set_telemetry_rate(int new_rate) {
1101                 rate_label.setVisible(new_rate >= 0);
1102
1103                 rate_value.set_rate(new_rate);
1104         }
1105
1106         public int telemetry_rate() {
1107                 return rate_value.rate();
1108         }
1109
1110         public void set_callsign(String new_callsign) {
1111                 callsign_value.setVisible(new_callsign != null);
1112                 callsign_label.setVisible(new_callsign != null);
1113
1114                 callsign_value.setText(new_callsign);
1115         }
1116
1117         public String callsign() {
1118                 return callsign_value.getText();
1119         }
1120
1121         int     flight_log_max_limit;
1122         int     flight_log_max;
1123
1124         public String flight_log_max_label(int flight_log_max) {
1125                 if (flight_log_max_limit != 0) {
1126                         int     nflight = flight_log_max_limit / flight_log_max;
1127                         String  plural = nflight > 1 ? "s" : "";
1128
1129                         return String.format("%d (%d flight%s)", flight_log_max, nflight, plural);
1130                 }
1131                 return String.format("%d", flight_log_max);
1132         }
1133
1134         public void set_flight_log_max(int new_flight_log_max) {
1135                 flight_log_max_value.setVisible(new_flight_log_max >= 0);
1136                 flight_log_max_label.setVisible(new_flight_log_max >= 0);
1137
1138                 flight_log_max_value.setSelectedItem(flight_log_max_label(new_flight_log_max));
1139                 flight_log_max = new_flight_log_max;
1140                 set_flight_log_max_tool_tip();
1141         }
1142
1143         public void set_flight_log_max_enabled(boolean enable) {
1144                 flight_log_max_value.setEnabled(enable);
1145                 set_flight_log_max_tool_tip();
1146         }
1147
1148         public int flight_log_max() throws AltosConfigDataException {
1149                 return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true);
1150         }
1151
1152         public void set_flight_log_max_limit(int new_flight_log_max_limit) {
1153                 flight_log_max_limit = new_flight_log_max_limit;
1154                 flight_log_max_value.removeAllItems();
1155                 for (int i = 8; i >= 1; i--) {
1156                         int     size = flight_log_max_limit / i;
1157                         flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
1158                 }
1159                 if (flight_log_max != 0)
1160                         set_flight_log_max(flight_log_max);
1161         }
1162
1163         public void set_ignite_mode(int new_ignite_mode) {
1164                 ignite_mode_value.setVisible(new_ignite_mode >= 0);
1165                 ignite_mode_label.setVisible(new_ignite_mode >= 0);
1166
1167                 if (new_ignite_mode >= ignite_mode_values.length)
1168                         new_ignite_mode = 0;
1169                 if (new_ignite_mode < 0) {
1170                         ignite_mode_value.setEnabled(false);
1171                         new_ignite_mode = 0;
1172                 } else {
1173                         ignite_mode_value.setEnabled(true);
1174                 }
1175                 ignite_mode_value.setSelectedIndex(new_ignite_mode);
1176                 set_ignite_mode_tool_tip();
1177         }
1178
1179         public int ignite_mode() {
1180                 if (ignite_mode_value.isEnabled())
1181                         return ignite_mode_value.getSelectedIndex();
1182                 else
1183                         return -1;
1184         }
1185
1186
1187         public void set_pad_orientation(int new_pad_orientation) {
1188                 pad_orientation_value.setVisible(new_pad_orientation >= 0);
1189                 pad_orientation_label.setVisible(new_pad_orientation >= 0);
1190
1191                 if (new_pad_orientation >= pad_orientation_values.length)
1192                         new_pad_orientation = 0;
1193                 if (new_pad_orientation < 0)
1194                         new_pad_orientation = 0;
1195                 pad_orientation_value.setSelectedIndex(new_pad_orientation);
1196                 set_pad_orientation_tool_tip();
1197         }
1198
1199         public int pad_orientation() {
1200                 if (pad_orientation_value.isEnabled())
1201                         return pad_orientation_value.getSelectedIndex();
1202                 else
1203                         return -1;
1204         }
1205
1206         public void set_beep(int new_beep) {
1207                 beep_value.setVisible(new_beep >= 0);
1208                 beep_label.setVisible(new_beep >= 0);
1209
1210                 int new_freq = (int) Math.floor (AltosConvert.beep_value_to_freq(new_beep) + 0.5);
1211                 for (int i = 0; i < beep_values.length; i++)
1212                         if (new_beep == AltosConvert.beep_freq_to_value(Integer.parseInt(beep_values[i]))) {
1213                                 beep_value.setSelectedIndex(i);
1214                                 set_beep_tool_tip();
1215                                 return;
1216                         }
1217                 beep_value.setSelectedItem(String.format("%d", new_freq));
1218                 beep_value.setEnabled(new_beep >= 0);
1219                 set_beep_tool_tip();
1220         }
1221
1222         public int beep() {
1223                 if (beep_value.isEnabled())
1224                         return AltosConvert.beep_freq_to_value(Integer.parseInt(beep_value.getSelectedItem().toString()));
1225                 else
1226                         return -1;
1227         }
1228
1229         String[] tracker_motion_values() {
1230                 if (AltosConvert.imperial_units)
1231                         return tracker_motion_values_ft;
1232                 else
1233                         return tracker_motion_values_m;
1234         }
1235
1236         void set_tracker_motion_values() {
1237                 String[]        v = tracker_motion_values();
1238                 while (tracker_motion_value.getItemCount() > 0)
1239                         tracker_motion_value.removeItemAt(0);
1240                 for (int i = 0; i < v.length; i++)
1241                         tracker_motion_value.addItem(v[i]);
1242                 tracker_motion_value.setMaximumRowCount(v.length);
1243         }
1244
1245         String get_tracker_motion_label() {
1246                 return String.format("Logging Trigger Motion (%s):", AltosConvert.height.parse_units());
1247         }
1248
1249         void set_tracker_tool_tip() {
1250                 if (tracker_motion_value.isEnabled())
1251                         tracker_motion_value.setToolTipText("How far the device must move before logging");
1252                 else
1253                         tracker_motion_value.setToolTipText("This device doesn't disable logging when stationary");
1254                 if (tracker_interval_value.isEnabled())
1255                         tracker_interval_value.setToolTipText("How often to report GPS position");
1256                 else
1257                         tracker_interval_value.setToolTipText("This device can't configure interval");
1258         }
1259
1260         public void set_tracker_motion(int tracker_motion) {
1261                 tracker_motion_label.setVisible(tracker_motion >= 0);
1262                 tracker_motion_value.setVisible(tracker_motion >= 0);
1263
1264                 if (tracker_motion < 0) {
1265                         tracker_motion_value.setEnabled(false);
1266                 } else {
1267                         tracker_motion_value.setEnabled(true);
1268                         tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion));
1269                 }
1270         }
1271
1272         public int tracker_motion() throws AltosConfigDataException {
1273                 String str = tracker_motion_value.getSelectedItem().toString();
1274                 try {
1275                         return (int) (AltosConvert.height.parse_locale(str) + 0.5);
1276                 } catch (ParseException pe) {
1277                         throw new AltosConfigDataException("invalid tracker motion %s", str);
1278                 }
1279         }
1280
1281         public void set_tracker_interval(int tracker_interval) {
1282                 tracker_interval_label.setVisible(tracker_interval >= 0);
1283                 tracker_interval_value.setVisible(tracker_interval >= 0);
1284
1285                 if (tracker_interval< 0) {
1286                         tracker_interval_value.setEnabled(false);
1287                 } else {
1288                         tracker_interval_value.setEnabled(true);
1289                         tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval));
1290                 }
1291         }
1292
1293         public int tracker_interval() throws AltosConfigDataException {
1294                 return parse_int ("tracker interval", tracker_interval_value.getSelectedItem().toString(), false);
1295         }
1296
1297         public void set_pyros(AltosPyro[] new_pyros) {
1298                 pyros = new_pyros;
1299                 pyro.setVisible(pyros != null);
1300                 if (pyros != null && pyro_ui != null)
1301                         pyro_ui.set_pyros(pyros);
1302         }
1303
1304         public AltosPyro[] pyros() throws AltosConfigDataException {
1305                 if (pyro_ui != null)
1306                         pyros = pyro_ui.get_pyros();
1307                 return pyros;
1308         }
1309
1310         public void set_pyro_firing_time(double new_pyro_firing_time) {
1311                 pyro_firing_time = new_pyro_firing_time;
1312                 pyro.setVisible(pyro_firing_time >= 0);
1313                 if (pyro_firing_time >= 0 && pyro_ui != null)
1314                         pyro_ui.set_pyro_firing_time(pyro_firing_time);
1315         }
1316
1317         public double pyro_firing_time() throws AltosConfigDataException {
1318                 if (pyro_ui != null)
1319                         pyro_firing_time = pyro_ui.get_pyro_firing_time();
1320                 return pyro_firing_time;
1321         }
1322
1323         public void set_aprs_interval(int new_aprs_interval) {
1324                 aprs_interval_value.setVisible(new_aprs_interval >= 0);
1325                 aprs_interval_label.setVisible(new_aprs_interval >= 0);
1326
1327                 String  s;
1328
1329                 if (new_aprs_interval <= 0)
1330                         s = "Disabled";
1331                 else
1332                         s = Integer.toString(new_aprs_interval);
1333                 aprs_interval_value.setSelectedItem(s);
1334                 set_aprs_interval_tool_tip();
1335         }
1336
1337         public int aprs_interval() throws AltosConfigDataException {
1338                 String  s = aprs_interval_value.getSelectedItem().toString();
1339
1340                 if (s.equals("Disabled"))
1341                         return 0;
1342                 return parse_int("aprs interval", s, false);
1343         }
1344
1345         public void set_aprs_ssid(int new_aprs_ssid) {
1346                 aprs_ssid_value.setVisible(new_aprs_ssid >= 0);
1347                 aprs_ssid_label.setVisible(new_aprs_ssid >= 0);
1348
1349                 aprs_ssid_value.setSelectedItem(Math.max(0,new_aprs_ssid));
1350                 set_aprs_ssid_tool_tip();
1351         }
1352
1353         public int aprs_ssid() throws AltosConfigDataException {
1354                 Integer i = (Integer) aprs_ssid_value.getSelectedItem();
1355                 return i;
1356         }
1357
1358         public void set_aprs_format(int new_aprs_format) {
1359                 aprs_format_value.setVisible(new_aprs_format >= 0);
1360                 aprs_format_label.setVisible(new_aprs_format >= 0);
1361
1362                 aprs_format_value.setSelectedIndex(Math.max(0,new_aprs_format));
1363                 set_aprs_format_tool_tip();
1364         }
1365
1366         public int aprs_format() throws AltosConfigDataException {
1367                 return aprs_format_value.getSelectedIndex();
1368         }
1369 }