2 * Copyright © 2010 Keith Packard <keithp@keithp.com>
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.
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.
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.
21 import java.awt.event.*;
23 import javax.swing.filechooser.FileNameExtensionFilter;
24 import javax.swing.table.*;
28 import java.util.prefs.*;
29 import java.util.concurrent.LinkedBlockingQueue;
31 import altosui.AltosSerial;
32 import altosui.AltosSerialMonitor;
33 import altosui.AltosTelemetry;
34 import altosui.AltosState;
35 import altosui.AltosDeviceDialog;
36 import altosui.AltosPreferences;
37 import altosui.AltosLog;
38 import altosui.AltosVoice;
40 public class AltosEepromMonitor extends JDialog {
48 int min_state, max_state;
50 public AltosEepromMonitor(JFrame owner, int in_min_state, int in_max_state) {
51 super (owner, "Download Flight Data");
53 box = Box.createVerticalBox();
55 serial_label = new JLabel("Serial:");
56 box.add(serial_label);
57 flight_label = new JLabel("Flight:");
58 box.add(flight_label);
59 file_label = new JLabel("File:");
62 min_state = in_min_state;
63 max_state = in_max_state;
64 pbar = new JProgressBar();
66 pbar.setMaximum((max_state - min_state) * 100);
68 pbar.setString("startup");
69 pbar.setStringPainted(true);
77 setMinimumSize(new Dimension(600, 0));
78 setContentPane(panel);
83 public void set_value(String state_name, int in_state, int in_block) {
89 if (state < min_state) state = min_state;
90 if (state >= max_state) state = max_state - 1;
93 int pos = state * 100 + block;
95 System.out.printf ("State %s (%d + %d) = %d\n",
96 state_name, in_state, in_block, pos);
98 pbar.setString(state_name);
102 public void set_serial(int serial) {
103 serial_label.setText(String.format("Serial: %d", serial));
106 public void set_flight(int flight) {
107 flight_label.setText(String.format("Flight: %d", flight));
110 public void set_file(String file) {
111 file_label.setText(String.format("File: %s", file));