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.AltosRecord;
34 import altosui.AltosTelemetry;
35 import altosui.AltosState;
36 import altosui.AltosDeviceDialog;
37 import altosui.AltosPreferences;
38 import altosui.AltosLog;
39 import altosui.AltosVoice;
41 public class AltosEepromMonitor extends JDialog {
53 int min_state, max_state;
55 public AltosEepromMonitor(JFrame owner, int in_min_state, int in_max_state) {
56 super (owner, "Download Flight Data", false);
59 Insets il = new Insets(4,4,4,4);
60 Insets ir = new Insets(4,4,4,4);
62 pane = getContentPane();
63 pane.setLayout(new GridBagLayout());
65 c = new GridBagConstraints();
66 c.gridx = 0; c.gridy = 0;
67 c.fill = GridBagConstraints.NONE;
68 c.anchor = GridBagConstraints.LINE_START;
70 serial_label = new JLabel("Serial:");
71 pane.add(serial_label, c);
73 c = new GridBagConstraints();
74 c.gridx = 1; c.gridy = 0;
75 c.fill = GridBagConstraints.HORIZONTAL;
77 c.anchor = GridBagConstraints.LINE_START;
79 serial_value = new JLabel("");
80 pane.add(serial_value, c);
82 c = new GridBagConstraints();
83 c.fill = GridBagConstraints.NONE;
84 c.gridx = 0; c.gridy = 1;
85 c.anchor = GridBagConstraints.LINE_START;
87 flight_label = new JLabel("Flight:");
88 pane.add(flight_label, c);
90 c = new GridBagConstraints();
91 c.fill = GridBagConstraints.HORIZONTAL;
93 c.gridx = 1; c.gridy = 1;
94 c.anchor = GridBagConstraints.LINE_START;
96 flight_value = new JLabel("");
97 pane.add(flight_value, c);
99 c = new GridBagConstraints();
100 c.fill = GridBagConstraints.NONE;
101 c.gridx = 0; c.gridy = 2;
102 c.anchor = GridBagConstraints.LINE_START;
104 file_label = new JLabel("File:");
105 pane.add(file_label, c);
107 c = new GridBagConstraints();
108 c.fill = GridBagConstraints.HORIZONTAL;
110 c.gridx = 1; c.gridy = 2;
111 c.anchor = GridBagConstraints.LINE_START;
113 file_value = new JLabel("");
114 pane.add(file_value, c);
116 min_state = in_min_state;
117 max_state = in_max_state;
118 pbar = new JProgressBar();
120 pbar.setMaximum((max_state - min_state) * 100);
122 pbar.setString("startup");
123 pbar.setStringPainted(true);
124 pbar.setPreferredSize(new Dimension(600, 20));
125 c = new GridBagConstraints();
126 c.fill = GridBagConstraints.HORIZONTAL;
127 c.anchor = GridBagConstraints.CENTER;
128 c.gridx = 0; c.gridy = 3;
129 c.gridwidth = GridBagConstraints.REMAINDER;
130 Insets ib = new Insets(4,4,4,4);
135 cancel = new JButton("Cancel");
136 c = new GridBagConstraints();
137 c.fill = GridBagConstraints.NONE;
138 c.anchor = GridBagConstraints.CENTER;
139 c.gridx = 0; c.gridy = 4;
140 c.gridwidth = GridBagConstraints.REMAINDER;
141 Insets ic = new Insets(4,4,4,4);
146 setLocationRelativeTo(owner);
150 public void addActionListener (ActionListener l) {
151 cancel.addActionListener(l);
154 public void set_value(String state_name, int in_state, int in_block) {
155 int block = in_block;
156 int state = in_state;
160 if (state < min_state) state = min_state;
161 if (state >= max_state) state = max_state - 1;
164 int pos = state * 100 + block;
166 pbar.setString(state_name);
170 public void set_serial(int serial) {
171 serial_value.setText(String.format("%d", serial));
174 public void set_flight(int flight) {
175 flight_value.setText(String.format("%d", flight));
178 public void set_file(String file) {
179 file_value.setText(String.format("%s", file));