58f39de5efcd22868d8c69b7fbc617d4a6c725ab
[fw/altos] / ao-tools / altosui / AltosUI.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.filechooser.FileNameExtensionFilter;
24 import javax.swing.table.*;
25 import java.io.*;
26 import java.util.*;
27 import java.text.*;
28 import java.util.prefs.*;
29 import java.util.concurrent.LinkedBlockingQueue;
30
31 import altosui.Altos;
32 import altosui.AltosSerial;
33 import altosui.AltosSerialMonitor;
34 import altosui.AltosTelemetry;
35 import altosui.AltosState;
36 import altosui.AltosDeviceDialog;
37 import altosui.AltosPreferences;
38 import altosui.AltosLog;
39 import altosui.AltosVoice;
40 import altosui.AltosFlightStatusTableModel;
41 import altosui.AltosFlightInfoTableModel;
42
43 import libaltosJNI.*;
44
45 public class AltosUI extends JFrame {
46         private int channel = -1;
47
48         private AltosFlightStatusTableModel flightStatusModel;
49         private JTable flightStatus;
50
51         static final int info_columns = 3;
52
53         private AltosFlightInfoTableModel[] flightInfoModel;
54         private JTable[] flightInfo;
55         private AltosSerial serial_line;
56         private AltosLog altos_log;
57         private Box[] ibox;
58         private Box vbox;
59         private Box hbox;
60
61         private Font statusFont = new Font("SansSerif", Font.BOLD, 24);
62         private Font infoLabelFont = new Font("SansSerif", Font.PLAIN, 14);
63         private Font infoValueFont = new Font("Monospaced", Font.PLAIN, 14);
64
65         public AltosVoice voice = new AltosVoice();
66
67         public AltosUI() {
68
69                 String[] statusNames = { "Height (m)", "State", "RSSI (dBm)", "Speed (m/s)" };
70                 Object[][] statusData = { { "0", "pad", "-50", "0" } };
71
72                 AltosPreferences.init(this);
73
74                 vbox = Box.createVerticalBox();
75                 this.add(vbox);
76
77                 flightStatusModel = new AltosFlightStatusTableModel();
78                 flightStatus = new JTable(flightStatusModel);
79                 flightStatus.setFont(statusFont);
80                 TableColumnModel tcm = flightStatus.getColumnModel();
81                 for (int i = 0; i < flightStatusModel.getColumnCount(); i++) {
82                         DefaultTableCellRenderer       r = new DefaultTableCellRenderer();
83                         r.setFont(statusFont);
84                         r.setHorizontalAlignment(SwingConstants.CENTER);
85                         tcm.getColumn(i).setCellRenderer(r);
86                 }
87
88                 FontMetrics     statusMetrics = flightStatus.getFontMetrics(statusFont);
89                 int statusHeight = (statusMetrics.getHeight() + statusMetrics.getLeading()) * 15 / 10;
90                 flightStatus.setRowHeight(statusHeight);
91                 flightStatus.setShowGrid(false);
92
93                 vbox.add(flightStatus);
94
95                 hbox = Box.createHorizontalBox();
96                 vbox.add(hbox);
97
98                 flightInfo = new JTable[3];
99                 flightInfoModel = new AltosFlightInfoTableModel[3];
100                 ibox = new Box[3];
101                 FontMetrics     infoValueMetrics = flightStatus.getFontMetrics(infoValueFont);
102                 int infoHeight = (infoValueMetrics.getHeight() + infoValueMetrics.getLeading()) * 20 / 10;
103
104                 for (int i = 0; i < info_columns; i++) {
105                         ibox[i] = Box.createVerticalBox();
106                         flightInfoModel[i] = new AltosFlightInfoTableModel();
107                         flightInfo[i] = new JTable(flightInfoModel[i]);
108                         flightInfo[i].setFont(infoValueFont);
109                         flightInfo[i].setRowHeight(infoHeight);
110                         flightInfo[i].setShowGrid(true);
111                         ibox[i].add(flightInfo[i].getTableHeader());
112                         ibox[i].add(flightInfo[i]);
113                         hbox.add(ibox[i]);
114                 }
115
116                 setTitle("AltOS");
117
118                 createMenu();
119
120                 serial_line = new AltosSerial();
121                 altos_log = new AltosLog(serial_line);
122                 int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
123                 this.setSize(new Dimension (infoValueMetrics.charWidth('0') * 6 * 20,
124                                             statusHeight * 4 + infoHeight * 17));
125                 this.validate();
126                 setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
127                 addWindowListener(new WindowAdapter() {
128                         @Override
129                         public void windowClosing(WindowEvent e) {
130                                 System.exit(0);
131                         }
132                 });
133                 voice.speak("Rocket flight monitor ready.");
134         }
135
136         public void info_reset() {
137                 for (int i = 0; i < info_columns; i++)
138                         flightInfoModel[i].resetRow();
139         }
140
141         public void info_add_row(int col, String name, String value) {
142                 flightInfoModel[col].addRow(name, value);
143         }
144
145         public void info_add_row(int col, String name, String format, Object... parameters) {
146                 flightInfoModel[col].addRow(name, String.format(format, parameters));
147         }
148
149         public void info_add_deg(int col, String name, double v, int pos, int neg) {
150                 int     c = pos;
151                 if (v < 0) {
152                         c = neg;
153                         v = -v;
154                 }
155                 double  deg = Math.floor(v);
156                 double  min = (v - deg) * 60;
157
158                 flightInfoModel[col].addRow(name, String.format("%3.0f°%08.5f'", deg, min));
159         }
160
161         public void info_finish() {
162                 for (int i = 0; i < info_columns; i++)
163                         flightInfoModel[i].finish();
164         }
165
166         public void show(AltosState state) {
167                 flightStatusModel.set(state);
168
169                 info_reset();
170                 if (state.gps_ready)
171                         info_add_row(0, "Ground state", "%s", "ready");
172                 else
173                         info_add_row(0, "Ground state", "wait (%d)",
174                                      state.gps_waiting);
175                 info_add_row(0, "Rocket state", "%s", state.data.state);
176                 info_add_row(0, "Callsign", "%s", state.data.callsign);
177                 info_add_row(0, "Rocket serial", "%6d", state.data.serial);
178                 info_add_row(0, "Rocket flight", "%6d", state.data.flight);
179
180                 info_add_row(0, "RSSI", "%6d    dBm", state.data.rssi);
181                 info_add_row(0, "Height", "%6.0f    m", state.height);
182                 info_add_row(0, "Max height", "%6.0f    m", state.max_height);
183                 info_add_row(0, "Acceleration", "%8.1f  m/s²", state.acceleration);
184                 info_add_row(0, "Max acceleration", "%8.1f  m/s²", state.max_acceleration);
185                 info_add_row(0, "Speed", "%8.1f  m/s", state.ascent ? state.speed : state.baro_speed);
186                 info_add_row(0, "Max Speed", "%8.1f  m/s", state.max_speed);
187                 info_add_row(0, "Temperature", "%9.2f °C", state.temperature);
188                 info_add_row(0, "Battery", "%9.2f V", state.battery);
189                 info_add_row(0, "Drogue", "%9.2f V", state.drogue_sense);
190                 info_add_row(0, "Main", "%9.2f V", state.main_sense);
191                 info_add_row(0, "Pad altitude", "%6.0f    m", state.ground_altitude);
192                 if (state.gps == null) {
193                         info_add_row(1, "GPS", "not available");
194                 } else {
195                         if (state.data.gps.gps_locked)
196                                 info_add_row(1, "GPS", "   locked");
197                         else if (state.data.gps.gps_connected)
198                                 info_add_row(1, "GPS", " unlocked");
199                         else
200                                 info_add_row(1, "GPS", "  missing");
201                         info_add_row(1, "Satellites", "%6d", state.data.gps.nsat);
202                         info_add_deg(1, "Latitude", state.gps.lat, 'N', 'S');
203                         info_add_deg(1, "Longitude", state.gps.lon, 'E', 'W');
204                         info_add_row(1, "GPS altitude", "%6d", state.gps.alt);
205                         info_add_row(1, "GPS height", "%6.0f", state.gps_height);
206
207                         /* The SkyTraq GPS doesn't report these values */
208                         if (false) {
209                                 info_add_row(1, "GPS ground speed", "%8.1f m/s %3d°",
210                                              state.gps.ground_speed,
211                                              state.gps.course);
212                                 info_add_row(1, "GPS climb rate", "%8.1f m/s",
213                                              state.gps.climb_rate);
214                                 info_add_row(1, "GPS error", "%6d m(h)%3d m(v)",
215                                              state.gps.h_error, state.gps.v_error);
216                         }
217                         info_add_row(1, "GPS hdop", "%8.1f", state.gps.hdop);
218
219                         if (state.npad > 0) {
220                                 if (state.from_pad != null) {
221                                         info_add_row(1, "Distance from pad", "%6.0f m", state.from_pad.distance);
222                                         info_add_row(1, "Direction from pad", "%6.0f°", state.from_pad.bearing);
223                                 } else {
224                                         info_add_row(1, "Distance from pad", "unknown");
225                                         info_add_row(1, "Direction from pad", "unknown");
226                                 }
227                                 info_add_deg(1, "Pad latitude", state.pad_lat, 'N', 'S');
228                                 info_add_deg(1, "Pad longitude", state.pad_lon, 'E', 'W');
229                                 info_add_row(1, "Pad GPS alt", "%6.0f m", state.pad_alt);
230                         }
231                         info_add_row(1, "GPS date", "%04d-%02d-%02d",
232                                        state.gps.year,
233                                        state.gps.month,
234                                        state.gps.day);
235                         info_add_row(1, "GPS time", "  %02d:%02d:%02d",
236                                        state.gps.hour,
237                                        state.gps.minute,
238                                        state.gps.second);
239                         int     nsat_vis = 0;
240                         int     c;
241
242                         if (state.gps.cc_gps_sat == null)
243                                 info_add_row(2, "Satellites Visible", "%4d", 0);
244                         else {
245                                 info_add_row(2, "Satellites Visible", "%4d", state.gps.cc_gps_sat.length);
246                                 for (c = 0; c < state.gps.cc_gps_sat.length; c++) {
247                                         info_add_row(2, "Satellite id,C/N0",
248                                                      "%4d, %4d",
249                                                      state.gps.cc_gps_sat[c].svid,
250                                                      state.gps.cc_gps_sat[c].c_n0);
251                                 }
252                         }
253                 }
254                 info_finish();
255         }
256
257         class IdleThread extends Thread {
258
259                 private AltosState state;
260                 int     reported_landing;
261
262                 public void report(boolean last) {
263                         if (state == null)
264                                 return;
265
266                         /* reset the landing count once we hear about a new flight */
267                         if (state.state < Altos.ao_flight_drogue)
268                                 reported_landing = 0;
269
270                         /* Shut up once the rocket is on the ground */
271                         if (reported_landing > 2) {
272                                 return;
273                         }
274
275                         /* If the rocket isn't on the pad, then report height */
276                         if (state.state > Altos.ao_flight_pad) {
277                                 voice.speak("%d meters", (int) (state.height + 0.5));
278                         } else {
279                                 reported_landing = 0;
280                         }
281
282                         /* If the rocket is coming down, check to see if it has landed;
283                          * either we've got a landed report or we haven't heard from it in
284                          * a long time
285                          */
286                         if (!state.ascent &&
287                             (last ||
288                              System.currentTimeMillis() - state.report_time >= 15000 ||
289                              state.state == Altos.ao_flight_landed))
290                         {
291                                 if (Math.abs(state.baro_speed) < 20 && state.height < 100)
292                                         voice.speak("rocket landed safely");
293                                 else
294                                         voice.speak("rocket may have crashed");
295                                 if (state.from_pad != null)
296                                         voice.speak("bearing %d degrees, range %d meters",
297                                                     (int) (state.from_pad.bearing + 0.5),
298                                                     (int) (state.from_pad.distance + 0.5));
299                                 ++reported_landing;
300                         }
301                 }
302
303                 public void run () {
304
305                         reported_landing = 0;
306                         state = null;
307                         try {
308                                 for (;;) {
309                                         Thread.sleep(10000);
310                                         report(false);
311                                 }
312                         } catch (InterruptedException ie) {
313                         }
314                 }
315
316                 public void notice(AltosState new_state) {
317                         state = new_state;
318                 }
319         }
320
321         private void tell(AltosState state, AltosState old_state) {
322                 if (old_state == null || old_state.state != state.state) {
323                         voice.speak(state.data.state);
324                         if ((old_state == null || old_state.state <= Altos.ao_flight_boost) &&
325                             state.state > Altos.ao_flight_boost) {
326                                 voice.speak("max speed: %d meters per second.",
327                                             (int) (state.max_speed + 0.5));
328                         } else if ((old_state == null || old_state.state < Altos.ao_flight_drogue) &&
329                                    state.state >= Altos.ao_flight_drogue) {
330                                 voice.speak("max height: %d meters.",
331                                             (int) (state.max_height + 0.5));
332                         }
333                 }
334                 if (old_state == null || old_state.gps_ready != state.gps_ready) {
335                         if (state.gps_ready)
336                                 voice.speak("GPS ready");
337                         else if (old_state != null)
338                                 voice.speak("GPS lost");
339                 }
340                 old_state = state;
341         }
342
343         class DisplayThread extends Thread {
344                 IdleThread      idle_thread;
345
346                 String read() throws InterruptedException { return null; }
347
348                 void close() { }
349
350                 void update(AltosState state) throws InterruptedException { }
351
352                 public void run() {
353                         String          line;
354                         AltosState      state = null;
355                         AltosState      old_state = null;
356
357                         idle_thread = new IdleThread();
358
359                         info_reset();
360                         info_finish();
361                         idle_thread.start();
362                         try {
363                                 while ((line = read()) != null) {
364                                         try {
365                                                 AltosTelemetry  t = new AltosTelemetry(line);
366                                                 old_state = state;
367                                                 state = new AltosState(t, state);
368                                                 update(state);
369                                                 show(state);
370                                                 tell(state, old_state);
371                                                 idle_thread.notice(state);
372                                         } catch (ParseException pp) {
373                                                 System.out.printf("Parse error on %s\n", line);
374                                                 System.out.println("exception " + pp);
375                                         }
376                                 }
377                         } catch (InterruptedException ee) {
378                         } finally {
379                                 close();
380                                 idle_thread.interrupt();
381                         }
382                 }
383
384                 public void report() {
385                         if (idle_thread != null)
386                                 idle_thread.report(true);
387                 }
388         }
389
390         class DeviceThread extends DisplayThread {
391                 AltosSerial     serial;
392                 LinkedBlockingQueue<String> telem;
393
394                 String read() throws InterruptedException {
395                         return telem.take();
396                 }
397
398                 void close() {
399                         serial.close();
400                         serial.remove_monitor(telem);
401                 }
402
403                 public DeviceThread(AltosSerial s) {
404                         serial = s;
405                         telem = new LinkedBlockingQueue<String>();
406                         serial.add_monitor(telem);
407                 }
408         }
409
410         private void ConnectToDevice() {
411                 altos_device    device = AltosDeviceDialog.show(AltosUI.this, "TeleDongle");
412
413                 if (device != null) {
414                         try {
415                                 serial_line.open(device);
416                                 DeviceThread thread = new DeviceThread(serial_line);
417                                 serial_line.set_channel(AltosPreferences.channel());
418                                 run_display(thread);
419                         } catch (FileNotFoundException ee) {
420                                 JOptionPane.showMessageDialog(AltosUI.this,
421                                                               String.format("Cannot open device \"%s\"",
422                                                                             device.getPath()),
423                                                               "Cannot open target device",
424                                                               JOptionPane.ERROR_MESSAGE);
425                         } catch (IOException ee) {
426                                 JOptionPane.showMessageDialog(AltosUI.this,
427                                                               device.getPath(),
428                                                               "Unkonwn I/O error",
429                                                               JOptionPane.ERROR_MESSAGE);
430                         }
431                 }
432         }
433
434         void DisconnectFromDevice () {
435                 stop_display();
436         }
437
438         String readline(FileInputStream s) throws IOException {
439                 int c;
440                 String  line = "";
441
442                 while ((c = s.read()) != -1) {
443                         if (c == '\r')
444                                 continue;
445                         if (c == '\n') {
446                                 return line;
447                         }
448                         line = line + (char) c;
449                 }
450                 return null;
451         }
452
453         /*
454          * Open an existing telemetry file and replay it in realtime
455          */
456
457         class ReplayThread extends DisplayThread {
458                 FileInputStream replay;
459                 String filename;
460
461                 ReplayThread(FileInputStream in, String name) {
462                         replay = in;
463                         filename = name;
464                 }
465
466                 String read() {
467                         try {
468                                 return readline(replay);
469                         } catch (IOException ee) {
470                                 JOptionPane.showMessageDialog(AltosUI.this,
471                                                               filename,
472                                                               "error reading",
473                                                               JOptionPane.ERROR_MESSAGE);
474                         }
475                         return null;
476                 }
477
478                 void close () {
479                         try {
480                                 replay.close();
481                         } catch (IOException ee) {
482                         }
483                         report();
484                 }
485
486                 void update(AltosState state) throws InterruptedException {
487                         /* Make it run in realtime after the rocket leaves the pad */
488                         if (state.state > AltosTelemetry.ao_flight_pad)
489                                 Thread.sleep((int) (Math.min(state.time_change,10) * 1000));
490                 }
491         }
492
493         Thread          display_thread;
494
495         private void stop_display() {
496                 if (display_thread != null && display_thread.isAlive())
497                         display_thread.interrupt();
498                 display_thread = null;
499         }
500
501         private void run_display(Thread thread) {
502                 stop_display();
503                 display_thread = thread;
504                 display_thread.start();
505         }
506
507         /*
508          * Replay a flight from telemetry data
509          */
510         private void Replay() {
511                 JFileChooser    logfile_chooser = new JFileChooser();
512
513                 logfile_chooser.setDialogTitle("Select Telemetry File");
514                 logfile_chooser.setFileFilter(new FileNameExtensionFilter("Telemetry file", "telem"));
515                 logfile_chooser.setCurrentDirectory(AltosPreferences.logdir());
516                 int returnVal = logfile_chooser.showOpenDialog(AltosUI.this);
517
518                 if (returnVal == JFileChooser.APPROVE_OPTION) {
519                         File file = logfile_chooser.getSelectedFile();
520                         if (file == null)
521                                 System.out.println("No file selected?");
522                         String  filename = file.getName();
523                         try {
524                                 FileInputStream replay = new FileInputStream(file);
525                                 ReplayThread    thread = new ReplayThread(replay, filename);
526                                 run_display(thread);
527                         } catch (FileNotFoundException ee) {
528                                 JOptionPane.showMessageDialog(AltosUI.this,
529                                                               filename,
530                                                               "Cannot open telemetry file",
531                                                               JOptionPane.ERROR_MESSAGE);
532                         }
533                 }
534         }
535
536         /* Connect to TeleMetrum, either directly or through
537          * a TeleDongle over the packet link
538          */
539         private void SaveFlightData() {
540                 new AltosEepromDownload(AltosUI.this);
541         }
542
543         /* Create the AltosUI menus
544          */
545         private void createMenu() {
546                 JMenuBar menubar = new JMenuBar();
547                 JMenu menu;
548                 JMenuItem item;
549                 JRadioButtonMenuItem radioitem;
550
551                 // File menu
552                 {
553                         menu = new JMenu("File");
554                         menu.setMnemonic(KeyEvent.VK_F);
555                         menubar.add(menu);
556
557                         item = new JMenuItem("Quit",KeyEvent.VK_Q);
558                         item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
559                                                                    ActionEvent.CTRL_MASK));
560                         item.addActionListener(new ActionListener() {
561                                         public void actionPerformed(ActionEvent e) {
562                                                 System.exit(0);
563                                         }
564                                 });
565                         menu.add(item);
566                 }
567
568                 // Device menu
569                 {
570                         menu = new JMenu("Device");
571                         menu.setMnemonic(KeyEvent.VK_D);
572                         menubar.add(menu);
573
574                         item = new JMenuItem("Connect to Device",KeyEvent.VK_C);
575                         item.addActionListener(new ActionListener() {
576                                         public void actionPerformed(ActionEvent e) {
577                                                 ConnectToDevice();
578                                         }
579                                 });
580                         menu.add(item);
581
582                         item = new JMenuItem("Disconnect from Device",KeyEvent.VK_D);
583                         item.addActionListener(new ActionListener() {
584                                         public void actionPerformed(ActionEvent e) {
585                                                 DisconnectFromDevice();
586                                         }
587                                 });
588                         menu.add(item);
589
590                         menu.addSeparator();
591
592                         item = new JMenuItem("Save Flight Data",KeyEvent.VK_S);
593                         item.addActionListener(new ActionListener() {
594                                         public void actionPerformed(ActionEvent e) {
595                                                 SaveFlightData();
596                                         }
597                                 });
598                         menu.add(item);
599
600                         item = new JMenuItem("Replay",KeyEvent.VK_R);
601                         item.addActionListener(new ActionListener() {
602                                         public void actionPerformed(ActionEvent e) {
603                                                 Replay();
604                                         }
605                                 });
606                         menu.add(item);
607                 }
608                 // Log menu
609                 {
610                         menu = new JMenu("Log");
611                         menu.setMnemonic(KeyEvent.VK_L);
612                         menubar.add(menu);
613
614                         item = new JMenuItem("New Log",KeyEvent.VK_N);
615                         item.addActionListener(new ActionListener() {
616                                         public void actionPerformed(ActionEvent e) {
617                                         }
618                                 });
619                         menu.add(item);
620
621                         item = new JMenuItem("Configure Log",KeyEvent.VK_C);
622                         item.addActionListener(new ActionListener() {
623                                         public void actionPerformed(ActionEvent e) {
624                                                 AltosPreferences.ConfigureLog();
625                                         }
626                                 });
627                         menu.add(item);
628                 }
629                 // Voice menu
630                 {
631                         menu = new JMenu("Voice", true);
632                         menu.setMnemonic(KeyEvent.VK_V);
633                         menubar.add(menu);
634
635                         radioitem = new JRadioButtonMenuItem("Enable Voice", AltosPreferences.voice());
636                         radioitem.addActionListener(new ActionListener() {
637                                         public void actionPerformed(ActionEvent e) {
638                                                 JRadioButtonMenuItem item = (JRadioButtonMenuItem) e.getSource();
639                                                 boolean enabled = item.isSelected();
640                                                 AltosPreferences.set_voice(enabled);
641                                                 if (enabled)
642                                                         voice.speak_always("Enable voice.");
643                                                 else
644                                                         voice.speak_always("Disable voice.");
645                                         }
646                                 });
647                         menu.add(radioitem);
648                         item = new JMenuItem("Test Voice",KeyEvent.VK_T);
649                         item.addActionListener(new ActionListener() {
650                                         public void actionPerformed(ActionEvent e) {
651                                                 voice.speak("That's one small step for man; one giant leap for mankind.");
652                                         }
653                                 });
654                         menu.add(item);
655                 }
656
657                 // Channel menu
658                 {
659                         menu = new JMenu("Channel", true);
660                         menu.setMnemonic(KeyEvent.VK_C);
661                         menubar.add(menu);
662                         ButtonGroup group = new ButtonGroup();
663
664                         for (int c = 0; c <= 9; c++) {
665                                 radioitem = new JRadioButtonMenuItem(String.format("Channel %1d (%7.3fMHz)", c,
666                                                                                    434.550 + c * 0.1),
667                                                                      c == AltosPreferences.channel());
668                                 radioitem.setActionCommand(String.format("%d", c));
669                                 radioitem.addActionListener(new ActionListener() {
670                                                 public void actionPerformed(ActionEvent e) {
671                                                         int new_channel = Integer.parseInt(e.getActionCommand());
672                                                         AltosPreferences.set_channel(new_channel);
673                                                         serial_line.set_channel(new_channel);
674                                                 }
675                                         });
676                                 menu.add(radioitem);
677                                 group.add(radioitem);
678                         }
679                 }
680
681                 this.setJMenuBar(menubar);
682
683         }
684         public static void main(final String[] args) {
685                 AltosUI altosui = new AltosUI();
686                 altosui.setVisible(true);
687         }
688 }