altosui: Complete split out of separate java library
authorKeith Packard <keithp@keithp.com>
Tue, 3 Jan 2012 01:26:59 +0000 (17:26 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 3 Jun 2012 02:26:29 +0000 (19:26 -0700)
Signed-off-by: Keith Packard <keithp@keithp.com>
85 files changed:
altosui/Altos.java
altosui/AltosAscent.java
altosui/AltosBTManage.java
altosui/AltosCSV.java
altosui/AltosCSVUI.java
altosui/AltosChannelMenu.java
altosui/AltosCompanionInfo.java
altosui/AltosConfig.java
altosui/AltosConfigData.java
altosui/AltosConfigFreqUI.java
altosui/AltosConfigUI.java
altosui/AltosConfigureUI.java
altosui/AltosDataChooser.java
altosui/AltosDataPointReader.java
altosui/AltosDebug.java
altosui/AltosDescent.java
altosui/AltosDialog.java
altosui/AltosDisplayThread.java
altosui/AltosEepromChunk.java
altosui/AltosEepromDelete.java
altosui/AltosEepromDownload.java
altosui/AltosEepromIterable.java
altosui/AltosEepromList.java
altosui/AltosEepromLog.java
altosui/AltosEepromManage.java
altosui/AltosEepromMonitor.java
altosui/AltosEepromRecord.java
altosui/AltosEepromTeleScience.java
altosui/AltosFile.java
altosui/AltosFlash.java
altosui/AltosFlashUI.java
altosui/AltosFlightInfoTableModel.java
altosui/AltosFlightReader.java
altosui/AltosFlightStats.java
altosui/AltosFlightStatsTable.java
altosui/AltosFlightStatus.java
altosui/AltosFlightStatusTableModel.java
altosui/AltosFlightUI.java
altosui/AltosFrame.java
altosui/AltosFreqList.java
altosui/AltosGraph.java
altosui/AltosGraphTime.java
altosui/AltosGraphUI.java
altosui/AltosGreatCircle.java
altosui/AltosHexfile.java
altosui/AltosIdleMonitorUI.java
altosui/AltosIgnite.java
altosui/AltosIgniteUI.java
altosui/AltosInfoTable.java
altosui/AltosKML.java
altosui/AltosLanded.java
altosui/AltosLaunch.java
altosui/AltosLaunchUI.java
altosui/AltosLed.java
altosui/AltosLights.java
altosui/AltosLog.java
altosui/AltosPad.java
altosui/AltosPreferences.java [deleted file]
altosui/AltosReader.java
altosui/AltosReplayReader.java
altosui/AltosRomconfig.java
altosui/AltosRomconfigUI.java
altosui/AltosScanUI.java
altosui/AltosSerial.java
altosui/AltosSiteMap.java
altosui/AltosSiteMapCache.java
altosui/AltosSiteMapPreload.java
altosui/AltosSiteMapTile.java
altosui/AltosState.java
altosui/AltosTelemetryReader.java [new file with mode: 0644]
altosui/AltosUI.java
altosui/AltosUIPreferences.java
altosui/AltosWriter.java
altosui/GrabNDrag.java
altosui/Makefile.am
altosui/altoslib/Makefile.am
altosui/altoslib/src/org/altusmetrum/AltosLib/AltosConvert.java
altosui/altoslib/src/org/altusmetrum/AltosLib/AltosFrequency.java
altosui/altoslib/src/org/altusmetrum/AltosLib/AltosGPS.java
altosui/altoslib/src/org/altusmetrum/AltosLib/AltosGPSSat.java
altosui/altoslib/src/org/altusmetrum/AltosLib/AltosParse.java
altosui/altoslib/src/org/altusmetrum/AltosLib/AltosPreferences.java [new file with mode: 0644]
altosui/altoslib/src/org/altusmetrum/AltosLib/AltosRecord.java
altosui/altoslib/src/org/altusmetrum/AltosLib/AltosRecordCompanion.java
altosui/altoslib/src/org/altusmetrum/AltosLib/AltosTelemetryReader.java [deleted file]

index 3e2a7a4..380796c 100644 (file)
@@ -96,6 +96,7 @@ public class Altos extends AltosLib {
        static boolean map_initialized = false;
 
        static final int tab_elt_pad = 5;
+
        static Font label_font;
        static Font value_font;
        static Font status_font;
index c8e5f3a..38b3b30 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosAscent extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
index 6d46070..d2899d6 100644 (file)
@@ -29,6 +29,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index db398a6..be86a45 100644 (file)
@@ -21,6 +21,7 @@ import java.lang.*;
 import java.io.*;
 import java.text.*;
 import java.util.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosCSV implements AltosWriter {
        File                    name;
index 6d3e906..2702668 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosCSVUI
        extends AltosDialog
index abbb86f..0249a0b 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosChannelMenu extends JComboBox implements ActionListener {
        int                             channel;
index 82bde62..4ba8fe9 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosCompanionInfo extends JTable {
        private AltosFlightInfoTableModel model;
index bd93020..35fef08 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index 64d9f09..ef34dd3 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index ecb5544..7958a21 100644 (file)
@@ -29,6 +29,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 class AltosEditFreqUI extends AltosDialog implements ActionListener {
        Frame           frame;
index eddb223..62394fa 100644 (file)
@@ -28,6 +28,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index 1789cd2..deb179d 100644 (file)
@@ -30,6 +30,7 @@ import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
 import javax.swing.plaf.basic.*;
+import org.altusmetrum.AltosLib.*;
 
 class DelegatingRenderer implements ListCellRenderer {
 
index c4a46d0..0d629b3 100644 (file)
@@ -26,6 +26,7 @@ import java.io.*;
 import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosDataChooser extends JFileChooser {
        JFrame  frame;
index c3aabb0..821b077 100644 (file)
@@ -9,6 +9,7 @@ import java.text.ParseException;
 import java.lang.UnsupportedOperationException;
 import java.util.NoSuchElementException;
 import java.util.Iterator;
+import org.altusmetrum.AltosLib.*;
 
 class AltosDataPointReader implements Iterable<AltosDataPoint> {
     Iterator<AltosRecord> iter;
index ce1cf5d..23e38bc 100644 (file)
@@ -21,6 +21,7 @@ import java.lang.*;
 import java.io.*;
 import java.util.concurrent.*;
 import java.util.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index 0fcd690..664c5ea 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosDescent extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
index 1e8e538..ff38c3e 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index ce8d915..03ce4ef 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosDisplayThread extends Thread {
 
index 77707f7..e4d1165 100644 (file)
@@ -21,6 +21,7 @@ import java.io.*;
 import java.util.*;
 import java.text.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosEepromChunk {
 
index fcce815..73f3a00 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index 8f7a854..080bfc9 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index b8e21ec..11cb97e 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 /*
  * AltosRecords with an index field so they can be sorted by tick while preserving
index 945746d..6a65621 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index 475d7f1..a24e82c 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index 1e06f4c..563c90b 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index 34f5b89..7564344 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosEepromMonitor extends AltosDialog {
 
index d8a0795..ea003a1 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index ee1840b..0c237e1 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosEepromTeleScience {
        int     type;
index e2b6d5a..4cf7de3 100644 (file)
@@ -20,6 +20,7 @@ package altosui;
 import java.lang.*;
 import java.io.File;
 import java.util.*;
+import org.altusmetrum.AltosLib.*;
 
 class AltosFile extends File {
 
index e91e980..bd0c8a5 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosFlash {
        File            file;
index f91c542..4ab73a6 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosFlashUI
        extends AltosDialog
index e23eff6..77969a8 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosFlightInfoTableModel extends AbstractTableModel {
        final static private String[] columnNames = {"Field", "Value"};
index 3ddf171..1ac9f84 100644 (file)
@@ -21,6 +21,7 @@ import java.lang.*;
 import java.text.*;
 import java.io.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosFlightReader {
        String name;
index 578be3f..ab094c8 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosFlightStats {
        double          max_height;
index 2d34c6e..c311b23 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosFlightStatsTable extends JComponent {
        GridBagLayout   layout;
index 45e55b4..6a35100 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosFlightStatus extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
index 4c24b6a..75bf16e 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosFlightStatusTableModel extends AbstractTableModel {
        private String[] columnNames = {"Height (m)", "State", "RSSI (dBm)", "Speed (m/s)" };
index 5c6e062..ddc54cb 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosFlightUI extends AltosFrame implements AltosFlightDisplay, AltosFontListener {
        AltosVoice              voice;
index 36ddcae..7059863 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index e4135df..1bbc97c 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosFreqList extends JComboBox {
 
index fbcefd6..54d2bb0 100644 (file)
@@ -8,6 +8,7 @@ import java.io.*;
 
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.ChartUtilities;
+import org.altusmetrum.AltosLib.*;
 
 abstract class AltosGraph {
     public String filename;
index 6a084b2..0955f6e 100644 (file)
@@ -12,6 +12,7 @@ import java.text.*;
 import java.awt.Color;
 import java.util.ArrayList;
 import java.util.HashMap;
+import org.altusmetrum.AltosLib.*;
 
 import org.jfree.chart.ChartUtilities;
 import org.jfree.chart.JFreeChart;
index c30dc47..527a7d2 100644 (file)
@@ -12,6 +12,7 @@ import java.awt.event.*;
 import javax.swing.*;
 import javax.swing.filechooser.FileNameExtensionFilter;
 import javax.swing.table.*;
+import org.altusmetrum.AltosLib.*;
 
 import org.jfree.chart.ChartPanel;
 import org.jfree.chart.ChartUtilities;
index fb1b6ab..e4af3c1 100644 (file)
@@ -18,6 +18,7 @@
 package altosui;
 
 import java.lang.Math;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosGreatCircle {
        double  distance;
index 19e35ae..d52b46c 100644 (file)
@@ -23,6 +23,7 @@ import java.util.concurrent.LinkedBlockingQueue;
 import java.util.LinkedList;
 import java.util.Iterator;
 import java.util.Arrays;
+import org.altusmetrum.AltosLib.*;
 
 class HexFileInputStream extends PushbackInputStream {
        public int line;
index 8eb0d52..02295ea 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 class AltosADC {
        int     tick;
index 3e52ea3..c0cd44f 100644 (file)
@@ -25,6 +25,7 @@ import javax.swing.*;
 import javax.swing.filechooser.FileNameExtensionFilter;
 import javax.swing.table.*;
 import javax.swing.event.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosIgnite {
        AltosDevice     device;
index 8623cbe..076d99b 100644 (file)
@@ -28,6 +28,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosIgniteUI
        extends AltosDialog
index c023369..aa6a6d4 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosInfoTable extends JTable {
        private AltosFlightInfoTableModel model;
index 6bdbecc..2993607 100644 (file)
@@ -21,6 +21,7 @@ import java.lang.*;
 import java.io.*;
 import java.text.*;
 import java.util.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosKML implements AltosWriter {
 
index 4dd9a2d..a47e1cb 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener {
        GridBagLayout   layout;
index 77f681b..0e493b9 100644 (file)
@@ -25,6 +25,7 @@ import javax.swing.*;
 import javax.swing.filechooser.FileNameExtensionFilter;
 import javax.swing.table.*;
 import javax.swing.event.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosLaunch {
        AltosDevice     device;
index a6c3660..eb76243 100644 (file)
@@ -28,6 +28,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 class FireButton extends JButton {
        protected void processMouseEvent(MouseEvent e) {
index e08e996..1358cd4 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosLed extends JLabel {
        ImageIcon       on, off;
index 2fa3841..8bd9e7d 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosLights extends JComponent {
 
index a5f1830..740f0be 100644 (file)
@@ -22,6 +22,7 @@ import java.lang.*;
 import java.util.*;
 import java.text.ParseException;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 /*
  * This creates a thread to capture telemetry data and write it to
index 6ef66f7..0a3f3d6 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosPad extends JComponent implements AltosFlightDisplay {
        GridBagLayout   layout;
diff --git a/altosui/AltosPreferences.java b/altosui/AltosPreferences.java
deleted file mode 100644 (file)
index 7510c7c..0000000
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Copyright © 2010 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package altosui;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.awt.Component;
-import javax.swing.*;
-import javax.swing.filechooser.FileSystemView;
-
-class AltosPreferences {
-       public static Preferences preferences;
-
-       /* logdir preference name */
-       final static String logdirPreference = "LOGDIR";
-
-       /* channel preference name */
-       final static String channelPreferenceFormat = "CHANNEL-%d";
-
-       /* frequency preference name */
-       final static String frequencyPreferenceFormat = "FREQUENCY-%d";
-
-       /* telemetry format preference name */
-       final static String telemetryPreferenceFormat = "TELEMETRY-%d";
-
-       /* voice preference name */
-       final static String voicePreference = "VOICE";
-
-       /* callsign preference name */
-       final static String callsignPreference = "CALLSIGN";
-
-       /* firmware directory preference name */
-       final static String firmwaredirPreference = "FIRMWARE";
-
-       /* serial debug preference name */
-       final static String serialDebugPreference = "SERIAL-DEBUG";
-
-       /* scanning telemetry preferences name */
-       final static String scanningTelemetryPreference = "SCANNING-TELEMETRY";
-
-       /* Launcher serial preference name */
-       final static String launcherSerialPreference = "LAUNCHER-SERIAL";
-
-       /* Launcher channel preference name */
-       final static String launcherChannelPreference = "LAUNCHER-CHANNEL";
-       
-       /* Default logdir is ~/TeleMetrum */
-       final static String logdirName = "TeleMetrum";
-
-       /* Log directory */
-       static File logdir;
-
-       /* Map directory -- hangs of logdir */
-       static File mapdir;
-
-       /* Frequency (map serial to frequency) */
-       static Hashtable<Integer, Double> frequencies;
-
-       /* Telemetry (map serial to telemetry format) */
-       static Hashtable<Integer, Integer> telemetries;
-
-       /* Voice preference */
-       static boolean voice;
-
-       /* Callsign preference */
-       static String callsign;
-
-       /* Firmware directory */
-       static File firmwaredir;
-
-       /* Serial debug */
-       static boolean serial_debug;
-
-       /* Scanning telemetry */
-       static int scanning_telemetry;
-
-       /* List of frequencies */
-       final static String common_frequencies_node_name = "COMMON-FREQUENCIES";
-       static AltosFrequency[] common_frequencies;
-
-       final static String     frequency_count = "COUNT";
-       final static String     frequency_format = "FREQUENCY-%d";
-       final static String     description_format = "DESCRIPTION-%d";
-
-       static AltosFrequency[] load_common_frequencies() {
-               AltosFrequency[] frequencies = null;
-               boolean existing = false;
-               try {
-                       existing = preferences.nodeExists(common_frequencies_node_name);
-               } catch (BackingStoreException be) {
-                       existing = false;
-               }
-               if (existing) {
-                       Preferences     node = preferences.node(common_frequencies_node_name);
-                       int             count = node.getInt(frequency_count, 0);
-
-                       frequencies = new AltosFrequency[count];
-                       for (int i = 0; i < count; i++) {
-                               double  frequency;
-                               String  description;
-
-                               frequency = node.getDouble(String.format(frequency_format, i), 0.0);
-                               description = node.get(String.format(description_format, i), null);
-                               frequencies[i] = new AltosFrequency(frequency, description);
-                       }
-               } else {
-                       frequencies = new AltosFrequency[10];
-                       for (int i = 0; i < 10; i++) {
-                               frequencies[i] = new AltosFrequency(434.550 + i * .1,
-                                                                          String.format("Channel %d", i));
-                       }
-               }
-               return frequencies;
-       }
-
-       static void save_common_frequencies(AltosFrequency[] frequencies) {
-               Preferences     node = preferences.node(common_frequencies_node_name);
-
-               node.putInt(frequency_count, frequencies.length);
-               for (int i = 0; i < frequencies.length; i++) {
-                       node.putDouble(String.format(frequency_format, i), frequencies[i].frequency);
-                       node.put(String.format(description_format, i), frequencies[i].description);
-               }
-       }
-       static int launcher_serial;
-
-       static int launcher_channel;
-
-       public static void init() {
-               preferences = Preferences.userRoot().node("/org/altusmetrum/altosui");
-
-               /* Initialize logdir from preferences */
-               String logdir_string = preferences.get(logdirPreference, null);
-               if (logdir_string != null)
-                       logdir = new File(logdir_string);
-               else {
-                       /* Use the file system view default directory */
-                       logdir = new File(FileSystemView.getFileSystemView().getDefaultDirectory(), logdirName);
-                       if (!logdir.exists())
-                               logdir.mkdirs();
-               }
-               mapdir = new File(logdir, "maps");
-               if (!mapdir.exists())
-                       mapdir.mkdirs();
-
-               frequencies = new Hashtable<Integer, Double>();
-
-               telemetries = new Hashtable<Integer,Integer>();
-
-               voice = preferences.getBoolean(voicePreference, true);
-
-               callsign = preferences.get(callsignPreference,"N0CALL");
-
-               scanning_telemetry = preferences.getInt(scanningTelemetryPreference,(1 << Altos.ao_telemetry_standard));
-
-               launcher_serial = preferences.getInt(launcherSerialPreference, 0);
-
-               launcher_channel = preferences.getInt(launcherChannelPreference, 0);
-
-               String firmwaredir_string = preferences.get(firmwaredirPreference, null);
-               if (firmwaredir_string != null)
-                       firmwaredir = new File(firmwaredir_string);
-               else
-                       firmwaredir = null;
-
-               serial_debug = preferences.getBoolean(serialDebugPreference, false);
-               AltosSerial.set_debug(serial_debug);
-
-               common_frequencies = load_common_frequencies();
-
-       }
-
-       static { init(); }
-
-       static void flush_preferences() {
-               try {
-                       preferences.flush();
-               } catch (BackingStoreException ee) {
-/*
-                       if (component != null)
-                               JOptionPane.showMessageDialog(component,
-                                                             preferences.absolutePath(),
-                                                             "Cannot save prefernces",
-                                                             JOptionPane.ERROR_MESSAGE);
-                       else
-*/
-                               System.err.printf("Cannot save preferences\n");
-               }
-       }
-
-       public static void set_logdir(File new_logdir) {
-               logdir = new_logdir;
-               mapdir = new File(logdir, "maps");
-               if (!mapdir.exists())
-                       mapdir.mkdirs();
-               synchronized (preferences) {
-                       preferences.put(logdirPreference, logdir.getPath());
-                       flush_preferences();
-               }
-       }
-
-       public static File logdir() {
-               return logdir;
-       }
-
-       public static File mapdir() {
-               return mapdir;
-       }
-
-       public static void set_frequency(int serial, double new_frequency) {
-               frequencies.put(serial, new_frequency);
-               synchronized (preferences) {
-                       preferences.putDouble(String.format(frequencyPreferenceFormat, serial), new_frequency);
-                       flush_preferences();
-               }
-       }
-
-       public static double frequency(int serial) {
-               if (frequencies.containsKey(serial))
-                       return frequencies.get(serial);
-               double frequency = preferences.getDouble(String.format(frequencyPreferenceFormat, serial), 0);
-               if (frequency == 0.0) {
-                       int channel = preferences.getInt(String.format(channelPreferenceFormat, serial), 0);
-                       frequency = AltosConvert.radio_channel_to_frequency(channel);
-               }
-               frequencies.put(serial, frequency);
-               return frequency;
-       }
-
-       public static void set_telemetry(int serial, int new_telemetry) {
-               telemetries.put(serial, new_telemetry);
-               synchronized (preferences) {
-                       preferences.putInt(String.format(telemetryPreferenceFormat, serial), new_telemetry);
-                       flush_preferences();
-               }
-       }
-
-       public static int telemetry(int serial) {
-               if (telemetries.containsKey(serial))
-                       return telemetries.get(serial);
-               int telemetry = preferences.getInt(String.format(telemetryPreferenceFormat, serial),
-                                                  Altos.ao_telemetry_standard);
-               telemetries.put(serial, telemetry);
-               return telemetry;
-       }
-
-       public static void set_scanning_telemetry(int new_scanning_telemetry) {
-               scanning_telemetry = new_scanning_telemetry;
-               synchronized (preferences) {
-                       preferences.putInt(scanningTelemetryPreference, scanning_telemetry);
-                       flush_preferences();
-               }
-       }
-
-       public static int scanning_telemetry() {
-               return scanning_telemetry;
-       }
-
-       public static void set_voice(boolean new_voice) {
-               voice = new_voice;
-               synchronized (preferences) {
-                       preferences.putBoolean(voicePreference, voice);
-                       flush_preferences();
-               }
-       }
-
-       public static boolean voice() {
-               return voice;
-       }
-
-       public static void set_callsign(String new_callsign) {
-               callsign = new_callsign;
-               synchronized(preferences) {
-                       preferences.put(callsignPreference, callsign);
-                       flush_preferences();
-               }
-       }
-
-       public static String callsign() {
-               return callsign;
-       }
-
-       public static void set_firmwaredir(File new_firmwaredir) {
-               firmwaredir = new_firmwaredir;
-               synchronized (preferences) {
-                       preferences.put(firmwaredirPreference, firmwaredir.getPath());
-                       flush_preferences();
-               }
-       }
-
-       public static File firmwaredir() {
-               return firmwaredir;
-       }
-
-       public static void set_serial_debug(boolean new_serial_debug) {
-               serial_debug = new_serial_debug;
-               AltosSerial.set_debug(serial_debug);
-               synchronized (preferences) {
-                       preferences.putBoolean(serialDebugPreference, serial_debug);
-                       flush_preferences();
-               }
-       }
-
-       public static boolean serial_debug() {
-               return serial_debug;
-       }
-
-       public static void set_launcher_serial(int new_launcher_serial) {
-               launcher_serial = new_launcher_serial;
-               System.out.printf("set launcher serial to %d\n", new_launcher_serial);
-               synchronized (preferences) {
-                       preferences.putInt(launcherSerialPreference, launcher_serial);
-                       flush_preferences();
-               }
-       }
-
-       public static int launcher_serial() {
-               return launcher_serial;
-       }
-
-       public static void set_launcher_channel(int new_launcher_channel) {
-               launcher_channel = new_launcher_channel;
-               System.out.printf("set launcher channel to %d\n", new_launcher_channel);
-               synchronized (preferences) {
-                       preferences.putInt(launcherChannelPreference, launcher_channel);
-                       flush_preferences();
-               }
-       }
-
-       public static int launcher_channel() {
-               return launcher_channel;
-       }
-       
-       public static Preferences bt_devices() {
-               return preferences.node("bt_devices");
-       }
-
-       public static AltosFrequency[] common_frequencies() {
-               return common_frequencies;
-       }
-
-       public static void set_common_frequencies(AltosFrequency[] frequencies) {
-               common_frequencies = frequencies;
-               synchronized(preferences) {
-                       save_common_frequencies(frequencies);
-                       flush_preferences();
-               }
-       }
-
-       public static void add_common_frequency(AltosFrequency frequency) {
-               AltosFrequency[]        new_frequencies = new AltosFrequency[common_frequencies.length + 1];
-               int                     i;
-
-               for (i = 0; i < common_frequencies.length; i++) {
-                       if (frequency.frequency == common_frequencies[i].frequency)
-                               return;
-                       if (frequency.frequency < common_frequencies[i].frequency)
-                               break;
-                       new_frequencies[i] = common_frequencies[i];
-               }
-               new_frequencies[i] = frequency;
-               for (; i < common_frequencies.length; i++)
-                       new_frequencies[i+1] = common_frequencies[i];
-               set_common_frequencies(new_frequencies);
-       }
-}
index b9280a0..aafd5f8 100644 (file)
@@ -20,6 +20,7 @@ package altosui;
 import java.io.*;
 import java.util.*;
 import java.text.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosReader {
        public AltosRecord read() throws IOException, ParseException { return null; }
index eed56cf..f92c032 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.AltosLib.*;
 
 /*
  * Open an existing telemetry file and replay it in realtime
index 55056b5..0a283e5 100644 (file)
@@ -17,6 +17,7 @@
 
 package altosui;
 import java.io.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosRomconfig {
        public boolean  valid;
index e4e38c9..306b862 100644 (file)
@@ -27,6 +27,7 @@ import java.io.*;
 import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosRomconfigUI
        extends AltosDialog
index 2b9137d..1be8aa2 100644 (file)
@@ -28,6 +28,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 class AltosScanResult {
        String          callsign;
index afb9f21..74e945f 100644 (file)
@@ -31,6 +31,7 @@ import java.awt.event.*;
 import javax.swing.*;
 import javax.swing.filechooser.FileNameExtensionFilter;
 import javax.swing.table.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index 93c54d0..b57edca 100644 (file)
@@ -32,6 +32,7 @@ import java.lang.Math;
 import java.awt.geom.Point2D;
 import java.awt.geom.Line2D;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
        // preferred vertical step in a tile in naut. miles
index 2e62cc4..f729a29 100644 (file)
@@ -29,6 +29,7 @@ import java.text.*;
 import java.util.prefs.*;
 import java.net.URL;
 import java.net.URLConnection;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosSiteMapCache extends JLabel {
        public static boolean fetchMap(File file, String url) {
index 5de7a05..676b079 100644 (file)
@@ -33,6 +33,7 @@ import java.awt.geom.Point2D;
 import java.awt.geom.Line2D;
 import java.net.URL;
 import java.net.URLConnection;
+import org.altusmetrum.AltosLib.*;
 
 class AltosMapPos extends Box {
        AltosUI         owner;
index 9e62bb4..3455021 100644 (file)
@@ -30,6 +30,7 @@ import java.util.prefs.*;
 import java.lang.Math;
 import java.awt.geom.Point2D;
 import java.awt.geom.Line2D;
+import org.altusmetrum.AltosLib.*;
 
 public class AltosSiteMapTile extends JLayeredPane {
        JLabel mapLabel;
index 9c6f85e..403c74b 100644 (file)
@@ -21,6 +21,8 @@
 
 package altosui;
 
+import org.altusmetrum.AltosLib.*;
+
 public class AltosState {
        AltosRecord data;
 
diff --git a/altosui/AltosTelemetryReader.java b/altosui/AltosTelemetryReader.java
new file mode 100644 (file)
index 0000000..dc7e4a7
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright © 2010 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package altosui;
+
+import java.lang.*;
+import java.text.*;
+import java.io.*;
+import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
+
+class AltosTelemetryReader extends AltosFlightReader {
+       AltosDevice     device;
+       AltosSerial     serial;
+       AltosLog        log;
+       AltosRecord     previous;
+       double          frequency;
+       int             telemetry;
+
+       LinkedBlockingQueue<AltosLine> telem;
+
+       AltosRecord read() throws InterruptedException, ParseException, AltosCRCException, IOException {
+               AltosLine l = telem.take();
+               if (l.line == null)
+                       throw new IOException("IO error");
+               AltosRecord     next = AltosTelemetry.parse(l.line, previous);
+               previous = next;
+               return next;
+       }
+
+       void flush() {
+               telem.clear();
+       }
+
+       void close(boolean interrupted) {
+               serial.remove_monitor(telem);
+               log.close();
+               serial.close();
+       }
+
+       public void set_frequency(double in_frequency) throws InterruptedException, TimeoutException {
+               frequency = in_frequency;
+               serial.set_radio_frequency(frequency);
+       }
+
+       public boolean supports_telemetry(int telemetry) {
+
+               try {
+                       /* Version 1.0 or later firmware supports all telemetry formats */
+                       if (serial.config_data().compare_version("1.0") >= 0)
+                               return true;
+
+                       /* Version 0.9 firmware only supports 0.9 telemetry */
+                       if (serial.config_data().compare_version("0.9") >= 0) {
+                               if (telemetry == Altos.ao_telemetry_0_9)
+                                       return true;
+                               else
+                                       return false;
+                       }
+
+                       /* Version 0.8 firmware only supports 0.8 telemetry */
+                       if (telemetry == Altos.ao_telemetry_0_8)
+                               return true;
+                       else
+                               return false;
+               } catch (InterruptedException ie) {
+                       return true;
+               } catch (TimeoutException te) {
+                       return true;
+               }
+       }
+
+       void save_frequency() {
+               AltosPreferences.set_frequency(device.getSerial(), frequency);
+       }
+
+       void set_telemetry(int in_telemetry) {
+               telemetry = in_telemetry;
+               serial.set_telemetry(telemetry);
+       }
+
+       void save_telemetry() {
+               AltosPreferences.set_telemetry(device.getSerial(), telemetry);
+       }
+
+       File backing_file() {
+               return log.file();
+       }
+
+       public AltosTelemetryReader (AltosDevice in_device)
+               throws FileNotFoundException, AltosSerialInUseException, IOException, InterruptedException, TimeoutException {
+               device = in_device;
+               serial = new AltosSerial(device);
+               log = new AltosLog(serial);
+               name = device.toShortString();
+               previous = null;
+
+               telem = new LinkedBlockingQueue<AltosLine>();
+               frequency = AltosPreferences.frequency(device.getSerial());
+               set_frequency(frequency);
+               telemetry = AltosPreferences.telemetry(device.getSerial());
+               set_telemetry(telemetry);
+               serial.set_callsign(AltosUIPreferences.callsign());
+               serial.add_monitor(telem);
+       }
+}
index a2816a3..25c6c36 100644 (file)
@@ -27,6 +27,7 @@ import java.util.*;
 import java.text.*;
 import java.util.prefs.*;
 import java.util.concurrent.*;
+import org.altusmetrum.AltosLib.*;
 
 import libaltosJNI.*;
 
index da6c396..38af734 100644 (file)
@@ -25,10 +25,9 @@ import java.util.concurrent.LinkedBlockingQueue;
 import java.awt.Component;
 import javax.swing.*;
 import javax.swing.filechooser.FileSystemView;
+import org.altusmetrum.AltosLib.*;
 
-/* import org.altusmetrum.AltosLib.*; */
-
-class AltosUIPreferences extends AltosPreferences {
+public class AltosUIPreferences extends AltosPreferences {
 
        /* font size preferences name */
        final static String fontSizePreference = "FONT-SIZE";
@@ -47,6 +46,9 @@ class AltosUIPreferences extends AltosPreferences {
 
        static String look_and_feel = null;
 
+       /* Serial debug */
+       static boolean serial_debug;
+
        public static void init() {
                font_listeners = new LinkedList<AltosFontListener>();
 
@@ -55,6 +57,8 @@ class AltosUIPreferences extends AltosPreferences {
                look_and_feel = preferences.get(lookAndFeelPreference, UIManager.getSystemLookAndFeelClassName());
 
                ui_listeners = new LinkedList<AltosUIListener>();
+               serial_debug = preferences.getBoolean(serialDebugPreference, false);
+               AltosSerial.set_debug(serial_debug);
        }
 
        static { init(); }
@@ -156,4 +160,17 @@ class AltosUIPreferences extends AltosPreferences {
                        ui_listeners.remove(l);
                }
        }
+       public static void set_serial_debug(boolean new_serial_debug) {
+               serial_debug = new_serial_debug;
+               AltosSerial.set_debug(serial_debug);
+               synchronized (preferences) {
+                       preferences.putBoolean(serialDebugPreference, serial_debug);
+                       flush_preferences();
+               }
+       }
+
+       public static boolean serial_debug() {
+               return serial_debug;
+       }
+
 }
\ No newline at end of file
index a172dff..b737520 100644 (file)
@@ -21,6 +21,8 @@ import java.lang.*;
 import java.io.*;
 import java.text.*;
 import java.util.*;
+import org.altusmetrum.AltosLib.*;
+
 
 public interface AltosWriter {
 
index e6b87b5..c350efe 100644 (file)
@@ -27,6 +27,7 @@ import javax.swing.table.*;
 import java.io.*;
 import java.util.*;
 import java.text.*;
+import org.altusmetrum.AltosLib.*;
 
 class GrabNDrag extends MouseInputAdapter {
        private JComponent scroll;
index c3fd6bb..cfe4530 100644 (file)
@@ -6,7 +6,7 @@ man_MANS=altosui.1
 
 altoslibdir=$(libdir)/altos
 
-CLASSPATH_ENV=mkdir -p $(JAVAROOT); CLASSPATH=".:classes:libaltos:$(FREETTS)/*:/usr/share/java/*"
+CLASSPATH_ENV=mkdir -p $(JAVAROOT); CLASSPATH=".:classes:altoslib/bin:libaltos:$(FREETTS)/*:/usr/share/java/*"
 
 bin_SCRIPTS=altosui
 
@@ -66,10 +66,7 @@ altosui_JAVA = \
        AltosFlightStatusUpdate.java \
        AltosFlightUI.java \
        AltosFontListener.java \
-       AltosFrequency.java \
        AltosFreqList.java \
-       AltosGPS.java \
-       AltosGPSSat.java \
        AltosGreatCircle.java \
        AltosHexfile.java \
        Altos.java \
@@ -83,27 +80,11 @@ altosui_JAVA = \
        AltosLanded.java \
        AltosLed.java \
        AltosLights.java \
-       AltosLine.java \
        AltosLog.java \
        AltosPad.java \
-       AltosParse.java \
-       AltosUIPreferences.java \
-       AltosPreferences.java \
        AltosUIPreferences.java \
        AltosReader.java \
-       AltosRecord.java \
-       AltosRecordCompanion.java \
-       AltosRecordIterable.java \
        AltosTelemetryReader.java \
-       AltosTelemetryRecord.java \
-       AltosTelemetryRecordRaw.java \
-       AltosTelemetryRecordSensor.java \
-       AltosTelemetryRecordConfiguration.java \
-       AltosTelemetryRecordLocation.java \
-       AltosTelemetryRecordSatellite.java \
-       AltosTelemetryRecordCompanion.java \
-       AltosTelemetryRecordLegacy.java \
-       AltosTelemetryMap.java \
        AltosReplayReader.java \
        AltosRomconfig.java \
        AltosRomconfigUI.java \
@@ -116,8 +97,7 @@ altosui_JAVA = \
        AltosSiteMapCache.java \
        AltosSiteMapTile.java \
        AltosState.java \
-       AltosTelemetry.java \
-       AltosTelemetryIterable.java \
+       AltosTelemetryReader.java \
        AltosUI.java \
        AltosUIListener.java \
        AltosFrame.java \
@@ -148,6 +128,9 @@ FREETTS_CLASS= \
        en_us.jar \
        freetts.jar
 
+ALTOSLIB_CLASS=\
+       AltosLib.jar
+
 LIBALTOS= \
        libaltos.so \
        libaltos.dylib \
@@ -200,7 +183,7 @@ LINUX_DIST=Altos-Linux-$(VERSION).tar.bz2
 MACOSX_DIST=Altos-Mac-$(VERSION).zip
 WINDOWS_DIST=Altos-Windows-$(VERSION_DASH).exe
 
-FAT_FILES=$(FATJAR) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS)
+FAT_FILES=$(FATJAR) $(ALTOSLIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS)
 
 LINUX_FILES=$(FAT_FILES) libaltos.so $(FIRMWARE) $(DOC)
 LINUX_EXTRA=altosui-fat
@@ -214,7 +197,7 @@ all-local: classes/altosui $(JAR) altosui altosui-test altosui-jdb
 
 clean-local:
        -rm -rf classes $(JAR) $(FATJAR) \
-               $(LINUX_DIST) $(MACOSX_DIST) windows $(WINDOWS_DIST) $(FREETTS_CLASS) \
+               $(LINUX_DIST) $(MACOSX_DIST) windows $(WINDOWS_DIST) $(ALTOSLIB_CLASS) $(FREETTS_CLASS) \
                $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) Manifest.txt Manifest-fat.txt altos-windows.log \
                altosui altosui-test altosui-jdb macosx linux
 
@@ -256,13 +239,13 @@ install-altosuiJAVA: altosui.jar
 classes/altosui:
        mkdir -p classes/altosui
 
-$(JAR): classaltosui.stamp Manifest.txt $(JAVA_ICON)
+$(JAR): classaltosui.stamp Manifest.txt $(JAVA_ICON) $(ALTOSLIB_CLASS)
        jar cfm $@ Manifest.txt \
                $(ICONJAR) \
                -C classes altosui \
                -C libaltos libaltosJNI
 
-$(FATJAR): classaltosui.stamp Manifest-fat.txt $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) $(JAVA_ICON)
+$(FATJAR): classaltosui.stamp Manifest-fat.txt $(ALTOSLIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) $(JAVA_ICON)
        jar cfm $@ Manifest-fat.txt \
                $(ICONJAR) \
                -C classes altosui \
@@ -270,11 +253,11 @@ $(FATJAR): classaltosui.stamp Manifest-fat.txt $(FREETTS_CLASS) $(JFREECHART_CLA
 
 Manifest.txt: Makefile
        echo 'Main-Class: altosui.AltosUI' > $@
-       echo "Class-Path: $(FREETTS)/freetts.jar $(JFREECHART)/jfreechart.jar $(JCOMMON)/jcommon.jar" >> $@
+       echo "Class-Path: altoslib.jar $(FREETTS)/freetts.jar $(JFREECHART)/jfreechart.jar $(JCOMMON)/jcommon.jar" >> $@
 
 Manifest-fat.txt:
        echo 'Main-Class: altosui.AltosUI' > $@
-       echo "Class-Path: freetts.jar jfreechart.jar jcommon.jar" >> $@
+       echo "Class-Path: altoslib.jar freetts.jar jfreechart.jar jcommon.jar" >> $@
 
 altosui: Makefile
        echo "#!/bin/sh" > $@
@@ -283,7 +266,7 @@ altosui: Makefile
 
 altosui-test: Makefile
        echo "#!/bin/sh" > $@
-       echo 'exec java -cp "$(FREETTS)/*:$(JFREECHART)/*:$(JCOMMON)/*" -Djava.library.path="libaltos/.libs" -jar altosui.jar "$$@"' >> $@
+       echo 'exec java -cp ":altoslib/*:$(FREETTS)/*:$(JFREECHART)/*:$(JCOMMON)/*" -Djava.library.path="libaltos/.libs" -jar altosui.jar "$$@"' >> $@
        chmod +x $@
 
 altosui-jdb: Makefile
@@ -317,6 +300,10 @@ build-altos-dll:
 build-altos64-dll:
        +cd libaltos && make altos64.dll
 
+$(ALTOSLIB_CLASS):
+       -rm -f "$@"
+       $(LN_S) altoslib/"$@" .
+
 $(FREETTS_CLASS):
        -rm -f "$@"
        $(LN_S) "$(FREETTS)"/"$@" .
@@ -345,9 +332,11 @@ $(MACOSX_DIST): $(MACOSX_FILES) $(MACOSX_EXTRA)
        cp -a AltosUI.app macosx/
        mkdir -p macosx/AltOS macosx/AltosUI.app/Contents/Resources/Java
        cp -p $(FATJAR) macosx/AltosUI.app/Contents/Resources/Java/altosui.jar
-       cp -p $(FREETTS_CLASS) libaltos.dylib macosx/AltosUI.app/Contents/Resources/Java
-       cp -p $(JFREECHART_CLASS) libaltos.dylib macosx/AltosUI.app/Contents/Resources/Java
-       cp -p $(JCOMMON_CLASS) libaltos.dylib macosx/AltosUI.app/Contents/Resources/Java
+       cp -p libaltos.dylib macosx/AltosUI.app/Contents/Resources/Java
+       cp -p $(ALTOSLIB_CLASS) macosx/AltosUI.app/Contents/Resources/Java
+       cp -p $(FREETTS_CLASS) macosx/AltosUI.app/Contents/Resources/Java
+       cp -p $(JFREECHART_CLASS) macosx/AltosUI.app/Contents/Resources/Java
+       cp -p $(JCOMMON_CLASS) macosx/AltosUI.app/Contents/Resources/Java
        cp -p $(MACOSX_EXTRA) macosx/AltOS
        cd macosx && zip -r ../$@ AltosUI.app AltOS
 
index 9c65513..967c8d0 100644 (file)
@@ -18,11 +18,12 @@ AltosLib_JAVA = \
        $(SRC)/AltosGPSSat.java \
        $(SRC)/AltosLine.java \
        $(SRC)/AltosParse.java \
+       $(SRC)/AltosPreferences.java \
        $(SRC)/AltosRecordCompanion.java \
        $(SRC)/AltosRecordIterable.java \
        $(SRC)/AltosRecord.java \
-       $(SRC)/AltosTelemetryIterable.java \
        $(SRC)/AltosTelemetry.java \
+       $(SRC)/AltosTelemetryIterable.java \
        $(SRC)/AltosTelemetryMap.java \
        $(SRC)/AltosTelemetryRecordCompanion.java \
        $(SRC)/AltosTelemetryRecordConfiguration.java \
index 6773ab7..3527b57 100644 (file)
@@ -41,27 +41,27 @@ public class AltosConvert {
         *   in Joules/(kilogram-Kelvin).
         */
 
-       static final double GRAVITATIONAL_ACCELERATION = -9.80665;
-       static final double AIR_GAS_CONSTANT            = 287.053;
-       static final double NUMBER_OF_LAYERS            = 7;
-       static final double MAXIMUM_ALTITUDE            = 84852.0;
-       static final double MINIMUM_PRESSURE            = 0.3734;
-       static final double LAYER0_BASE_TEMPERATURE     = 288.15;
-       static final double LAYER0_BASE_PRESSURE        = 101325;
+       public static final double GRAVITATIONAL_ACCELERATION = -9.80665;
+       public static final double AIR_GAS_CONSTANT             = 287.053;
+       public static final double NUMBER_OF_LAYERS             = 7;
+       public static final double MAXIMUM_ALTITUDE             = 84852.0;
+       public static final double MINIMUM_PRESSURE             = 0.3734;
+       public static final double LAYER0_BASE_TEMPERATURE      = 288.15;
+       public static final double LAYER0_BASE_PRESSURE = 101325;
 
        /* lapse rate and base altitude for each layer in the atmosphere */
-       static final double[] lapse_rate = {
+       public static final double[] lapse_rate = {
                -0.0065, 0.0, 0.001, 0.0028, 0.0, -0.0028, -0.002
        };
 
-       static final int[] base_altitude = {
+       public static final int[] base_altitude = {
                0, 11000, 20000, 32000, 47000, 51000, 71000
        };
 
        /* outputs atmospheric pressure associated with the given altitude.
         * altitudes are measured with respect to the mean sea level
         */
-       static double
+       public static double
        altitude_to_pressure(double altitude)
        {
                double base_temperature = LAYER0_BASE_TEMPERATURE;
@@ -114,7 +114,7 @@ public class AltosConvert {
 
 /* outputs the altitude associated with the given pressure. the altitude
    returned is measured with respect to the mean sea level */
-       static double
+       public static double
        pressure_to_altitude(double pressure)
        {
 
@@ -178,19 +178,19 @@ public class AltosConvert {
                return altitude;
        }
 
-       static double
+       public static double
        cc_battery_to_voltage(double battery)
        {
                return battery / 32767.0 * 5.0;
        }
 
-       static double
+       public static double
        cc_ignitor_to_voltage(double ignite)
        {
                return ignite / 32767 * 15.0;
        }
 
-       static double radio_to_frequency(int freq, int setting, int cal, int channel) {
+       public static double radio_to_frequency(int freq, int setting, int cal, int channel) {
                double  f;
 
                if (freq > 0)
@@ -205,13 +205,13 @@ public class AltosConvert {
                return f + channel * 0.100;
        }
 
-       static int radio_frequency_to_setting(double frequency, int cal) {
+       public static int radio_frequency_to_setting(double frequency, int cal) {
                double  set = frequency / 434.550 * cal;
 
                return (int) Math.floor (set + 0.5);
        }
 
-       static int radio_frequency_to_channel(double frequency) {
+       public static int radio_frequency_to_channel(double frequency) {
                int     channel = (int) Math.floor ((frequency - 434.550) / 0.100 + 0.5);
 
                if (channel < 0)
@@ -221,11 +221,11 @@ public class AltosConvert {
                return channel;
        }
 
-       static double radio_channel_to_frequency(int channel) {
+       public static double radio_channel_to_frequency(int channel) {
                return 434.550 + channel * 0.100;
        }
 
-       static int[] ParseHex(String line) {
+       public static int[] ParseHex(String line) {
                String[] tokens = line.split("\\s+");
                int[] array = new int[tokens.length];
 
@@ -238,19 +238,19 @@ public class AltosConvert {
                return array;
        }
 
-       static double meters_to_feet(double meters) {
+       public static double meters_to_feet(double meters) {
                return meters * (100 / (2.54 * 12));
        }
 
-       static double meters_to_mach(double meters) {
+       public static double meters_to_mach(double meters) {
                return meters / 343;            /* something close to mach at usual rocket sites */
        }
 
-       static double meters_to_g(double meters) {
+       public static double meters_to_g(double meters) {
                return meters / 9.80665;
        }
 
-       static int checksum(int[] data, int start, int length) {
+       public static int checksum(int[] data, int start, int length) {
                int     csum = 0x5a;
                for (int i = 0; i < length; i++)
                        csum += data[i + start];
index 6fd26df..f08ff11 100644 (file)
@@ -22,8 +22,8 @@ import java.util.*;
 import java.text.*;
 
 public class AltosFrequency {
-       double  frequency;
-       String  description;
+       public double   frequency;
+       public String   description;
 
        public String toString() {
                return String.format("%7.3f MHz %-20s",
index 8cc7aa6..f078a46 100644 (file)
@@ -22,32 +22,32 @@ import java.text.*;
 
 public class AltosGPS {
 
-       final static int MISSING = AltosRecord.MISSING;
-
-       int     nsat;
-       boolean locked;
-       boolean connected;
-       double  lat;            /* degrees (+N -S) */
-       double  lon;            /* degrees (+E -W) */
-       int     alt;            /* m */
-       int     year;
-       int     month;
-       int     day;
-       int     hour;
-       int     minute;
-       int     second;
-
-       double  ground_speed;   /* m/s */
-       int     course;         /* degrees */
-       double  climb_rate;     /* m/s */
-       double  hdop;           /* unitless */
-       double  vdop;           /* unitless */
-       int     h_error;        /* m */
-       int     v_error;        /* m */
-
-       AltosGPSSat[] cc_gps_sat;       /* tracking data */
-
-       void ParseGPSDate(String date) throws ParseException {
+       public final static int MISSING = AltosRecord.MISSING;
+
+       public int      nsat;
+       public boolean  locked;
+       public boolean  connected;
+       public double   lat;            /* degrees (+N -S) */
+       public double   lon;            /* degrees (+E -W) */
+       public int      alt;            /* m */
+       public int      year;
+       public int      month;
+       public int      day;
+       public int      hour;
+       public int      minute;
+       public int      second;
+
+       public double   ground_speed;   /* m/s */
+       public int      course;         /* degrees */
+       public double   climb_rate;     /* m/s */
+       public double   hdop;           /* unitless */
+       public double   vdop;           /* unitless */
+       public int      h_error;        /* m */
+       public int      v_error;        /* m */
+
+       public AltosGPSSat[] cc_gps_sat;        /* tracking data */
+
+       public void ParseGPSDate(String date) throws ParseException {
                String[] ymd = date.split("-");
                if (ymd.length != 3)
                        throw new ParseException("error parsing GPS date " + date + " got " + ymd.length, 0);
@@ -56,7 +56,7 @@ public class AltosGPS {
                day = AltosParse.parse_int(ymd[2]);
        }
 
-       void ParseGPSTime(String time) throws ParseException {
+       public void ParseGPSTime(String time) throws ParseException {
                String[] hms = time.split(":");
                if (hms.length != 3)
                        throw new ParseException("Error parsing GPS time " + time + " got " + hms.length, 0);
@@ -65,7 +65,7 @@ public class AltosGPS {
                second = AltosParse.parse_int(hms[2]);
        }
 
-       void ClearGPSTime() {
+       public void ClearGPSTime() {
                year = month = day = 0;
                hour = minute = second = 0;
        }
index 5fa8f98..faa1ec8 100644 (file)
@@ -18,8 +18,8 @@
 package org.altusmetrum.AltosLib;
 
 public class AltosGPSSat {
-       int     svid;
-       int     c_n0;
+       public int      svid;
+       public int      c_n0;
 
        public AltosGPSSat(int s, int c) {
                svid = s;
index 4c0a59c..7d832f1 100644 (file)
@@ -21,11 +21,11 @@ import java.text.*;
 import java.lang.*;
 
 public class AltosParse {
-       static boolean isdigit(char c) {
+       public static boolean isdigit(char c) {
                return '0' <= c && c <= '9';
        }
 
-       static int parse_int(String v) throws ParseException {
+       public static int parse_int(String v) throws ParseException {
                try {
                        return AltosLib.fromdec(v);
                } catch (NumberFormatException e) {
@@ -33,7 +33,7 @@ public class AltosParse {
                }
        }
 
-       static int parse_hex(String v) throws ParseException {
+       public static int parse_hex(String v) throws ParseException {
                try {
                        return AltosLib.fromhex(v);
                } catch (NumberFormatException e) {
@@ -41,7 +41,7 @@ public class AltosParse {
                }
        }
 
-       static double parse_double(String v) throws ParseException {
+       public static double parse_double(String v) throws ParseException {
                try {
                        return Double.parseDouble(v);
                } catch (NumberFormatException e) {
@@ -49,7 +49,7 @@ public class AltosParse {
                }
        }
 
-       static double parse_coord(String coord) throws ParseException {
+       public static double parse_coord(String coord) throws ParseException {
                String[]        dsf = coord.split("\\D+");
 
                if (dsf.length != 3) {
@@ -65,13 +65,13 @@ public class AltosParse {
                return r;
        }
 
-       static String strip_suffix(String v, String suffix) {
+       public static String strip_suffix(String v, String suffix) {
                if (v.endsWith(suffix))
                        return v.substring(0, v.length() - suffix.length());
                return v;
        }
 
-       static void word(String v, String m) throws ParseException {
+       public static void word(String v, String m) throws ParseException {
                if (!v.equals(m)) {
                        throw new ParseException("error matching '" + v + "' '" + m + "'", 0);
                }
diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosPreferences.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosPreferences.java
new file mode 100644 (file)
index 0000000..43c7088
--- /dev/null
@@ -0,0 +1,365 @@
+/*
+ * Copyright © 2010 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.io.*;
+import java.util.*;
+import java.text.*;
+import java.util.prefs.*;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.awt.Component;
+import javax.swing.*;
+import javax.swing.filechooser.FileSystemView;
+
+public class AltosPreferences {
+       public static Preferences preferences;
+
+       /* logdir preference name */
+       public final static String logdirPreference = "LOGDIR";
+
+       /* channel preference name */
+       public final static String channelPreferenceFormat = "CHANNEL-%d";
+
+       /* frequency preference name */
+       public final static String frequencyPreferenceFormat = "FREQUENCY-%d";
+
+       /* telemetry format preference name */
+       public final static String telemetryPreferenceFormat = "TELEMETRY-%d";
+
+       /* voice preference name */
+       public final static String voicePreference = "VOICE";
+
+       /* callsign preference name */
+       public final static String callsignPreference = "CALLSIGN";
+
+       /* firmware directory preference name */
+       public final static String firmwaredirPreference = "FIRMWARE";
+
+       /* serial debug preference name */
+       public final static String serialDebugPreference = "SERIAL-DEBUG";
+
+       /* scanning telemetry preferences name */
+       public final static String scanningTelemetryPreference = "SCANNING-TELEMETRY";
+
+       /* Launcher serial preference name */
+       public final static String launcherSerialPreference = "LAUNCHER-SERIAL";
+
+       /* Launcher channel preference name */
+       public final static String launcherChannelPreference = "LAUNCHER-CHANNEL";
+       
+       /* Default logdir is ~/TeleMetrum */
+       public final static String logdirName = "TeleMetrum";
+
+       /* Log directory */
+       public static File logdir;
+
+       /* Map directory -- hangs of logdir */
+       public static File mapdir;
+
+       /* Frequency (map serial to frequency) */
+       public static Hashtable<Integer, Double> frequencies;
+
+       /* Telemetry (map serial to telemetry format) */
+       public static Hashtable<Integer, Integer> telemetries;
+
+       /* Voice preference */
+       public static boolean voice;
+
+       /* Callsign preference */
+       public static String callsign;
+
+       /* Firmware directory */
+       public static File firmwaredir;
+
+       /* Scanning telemetry */
+       public static int scanning_telemetry;
+
+       /* List of frequencies */
+       public final static String common_frequencies_node_name = "COMMON-FREQUENCIES";
+       public static AltosFrequency[] common_frequencies;
+
+       public final static String      frequency_count = "COUNT";
+       public final static String      frequency_format = "FREQUENCY-%d";
+       public final static String      description_format = "DESCRIPTION-%d";
+
+       public static AltosFrequency[] load_common_frequencies() {
+               AltosFrequency[] frequencies = null;
+               boolean existing = false;
+               try {
+                       existing = preferences.nodeExists(common_frequencies_node_name);
+               } catch (BackingStoreException be) {
+                       existing = false;
+               }
+               if (existing) {
+                       Preferences     node = preferences.node(common_frequencies_node_name);
+                       int             count = node.getInt(frequency_count, 0);
+
+                       frequencies = new AltosFrequency[count];
+                       for (int i = 0; i < count; i++) {
+                               double  frequency;
+                               String  description;
+
+                               frequency = node.getDouble(String.format(frequency_format, i), 0.0);
+                               description = node.get(String.format(description_format, i), null);
+                               frequencies[i] = new AltosFrequency(frequency, description);
+                       }
+               } else {
+                       frequencies = new AltosFrequency[10];
+                       for (int i = 0; i < 10; i++) {
+                               frequencies[i] = new AltosFrequency(434.550 + i * .1,
+                                                                          String.format("Channel %d", i));
+                       }
+               }
+               return frequencies;
+       }
+
+       public static void save_common_frequencies(AltosFrequency[] frequencies) {
+               Preferences     node = preferences.node(common_frequencies_node_name);
+
+               node.putInt(frequency_count, frequencies.length);
+               for (int i = 0; i < frequencies.length; i++) {
+                       node.putDouble(String.format(frequency_format, i), frequencies[i].frequency);
+                       node.put(String.format(description_format, i), frequencies[i].description);
+               }
+       }
+       public static int launcher_serial;
+
+       public static int launcher_channel;
+
+       public static void init() {
+               preferences = Preferences.userRoot().node("/org/altusmetrum/altosui");
+
+               /* Initialize logdir from preferences */
+               String logdir_string = preferences.get(logdirPreference, null);
+               if (logdir_string != null)
+                       logdir = new File(logdir_string);
+               else {
+                       /* Use the file system view default directory */
+                       logdir = new File(FileSystemView.getFileSystemView().getDefaultDirectory(), logdirName);
+                       if (!logdir.exists())
+                               logdir.mkdirs();
+               }
+               mapdir = new File(logdir, "maps");
+               if (!mapdir.exists())
+                       mapdir.mkdirs();
+
+               frequencies = new Hashtable<Integer, Double>();
+
+               telemetries = new Hashtable<Integer,Integer>();
+
+               voice = preferences.getBoolean(voicePreference, true);
+
+               callsign = preferences.get(callsignPreference,"N0CALL");
+
+               scanning_telemetry = preferences.getInt(scanningTelemetryPreference,(1 << AltosLib.ao_telemetry_standard));
+
+               launcher_serial = preferences.getInt(launcherSerialPreference, 0);
+
+               launcher_channel = preferences.getInt(launcherChannelPreference, 0);
+
+               String firmwaredir_string = preferences.get(firmwaredirPreference, null);
+               if (firmwaredir_string != null)
+                       firmwaredir = new File(firmwaredir_string);
+               else
+                       firmwaredir = null;
+
+               common_frequencies = load_common_frequencies();
+
+       }
+
+       static { init(); }
+
+       public static void flush_preferences() {
+               try {
+                       preferences.flush();
+               } catch (BackingStoreException ee) {
+/*
+                       if (component != null)
+                               JOptionPane.showMessageDialog(component,
+                                                             preferences.absolutePath(),
+                                                             "Cannot save prefernces",
+                                                             JOptionPane.ERROR_MESSAGE);
+                       else
+*/
+                               System.err.printf("Cannot save preferences\n");
+               }
+       }
+
+       public static void set_logdir(File new_logdir) {
+               logdir = new_logdir;
+               mapdir = new File(logdir, "maps");
+               if (!mapdir.exists())
+                       mapdir.mkdirs();
+               synchronized (preferences) {
+                       preferences.put(logdirPreference, logdir.getPath());
+                       flush_preferences();
+               }
+       }
+
+       public static File logdir() {
+               return logdir;
+       }
+
+       public static File mapdir() {
+               return mapdir;
+       }
+
+       public static void set_frequency(int serial, double new_frequency) {
+               frequencies.put(serial, new_frequency);
+               synchronized (preferences) {
+                       preferences.putDouble(String.format(frequencyPreferenceFormat, serial), new_frequency);
+                       flush_preferences();
+               }
+       }
+
+       public static double frequency(int serial) {
+               if (frequencies.containsKey(serial))
+                       return frequencies.get(serial);
+               double frequency = preferences.getDouble(String.format(frequencyPreferenceFormat, serial), 0);
+               if (frequency == 0.0) {
+                       int channel = preferences.getInt(String.format(channelPreferenceFormat, serial), 0);
+                       frequency = AltosConvert.radio_channel_to_frequency(channel);
+               }
+               frequencies.put(serial, frequency);
+               return frequency;
+       }
+
+       public static void set_telemetry(int serial, int new_telemetry) {
+               telemetries.put(serial, new_telemetry);
+               synchronized (preferences) {
+                       preferences.putInt(String.format(telemetryPreferenceFormat, serial), new_telemetry);
+                       flush_preferences();
+               }
+       }
+
+       public static int telemetry(int serial) {
+               if (telemetries.containsKey(serial))
+                       return telemetries.get(serial);
+               int telemetry = preferences.getInt(String.format(telemetryPreferenceFormat, serial),
+                                                  AltosLib.ao_telemetry_standard);
+               telemetries.put(serial, telemetry);
+               return telemetry;
+       }
+
+       public static void set_scanning_telemetry(int new_scanning_telemetry) {
+               scanning_telemetry = new_scanning_telemetry;
+               synchronized (preferences) {
+                       preferences.putInt(scanningTelemetryPreference, scanning_telemetry);
+                       flush_preferences();
+               }
+       }
+
+       public static int scanning_telemetry() {
+               return scanning_telemetry;
+       }
+
+       public static void set_voice(boolean new_voice) {
+               voice = new_voice;
+               synchronized (preferences) {
+                       preferences.putBoolean(voicePreference, voice);
+                       flush_preferences();
+               }
+       }
+
+       public static boolean voice() {
+               return voice;
+       }
+
+       public static void set_callsign(String new_callsign) {
+               callsign = new_callsign;
+               synchronized(preferences) {
+                       preferences.put(callsignPreference, callsign);
+                       flush_preferences();
+               }
+       }
+
+       public static String callsign() {
+               return callsign;
+       }
+
+       public static void set_firmwaredir(File new_firmwaredir) {
+               firmwaredir = new_firmwaredir;
+               synchronized (preferences) {
+                       preferences.put(firmwaredirPreference, firmwaredir.getPath());
+                       flush_preferences();
+               }
+       }
+
+       public static File firmwaredir() {
+               return firmwaredir;
+       }
+
+       public static void set_launcher_serial(int new_launcher_serial) {
+               launcher_serial = new_launcher_serial;
+               System.out.printf("set launcher serial to %d\n", new_launcher_serial);
+               synchronized (preferences) {
+                       preferences.putInt(launcherSerialPreference, launcher_serial);
+                       flush_preferences();
+               }
+       }
+
+       public static int launcher_serial() {
+               return launcher_serial;
+       }
+
+       public static void set_launcher_channel(int new_launcher_channel) {
+               launcher_channel = new_launcher_channel;
+               System.out.printf("set launcher channel to %d\n", new_launcher_channel);
+               synchronized (preferences) {
+                       preferences.putInt(launcherChannelPreference, launcher_channel);
+                       flush_preferences();
+               }
+       }
+
+       public static int launcher_channel() {
+               return launcher_channel;
+       }
+       
+       public static Preferences bt_devices() {
+               return preferences.node("bt_devices");
+       }
+
+       public static AltosFrequency[] common_frequencies() {
+               return common_frequencies;
+       }
+
+       public static void set_common_frequencies(AltosFrequency[] frequencies) {
+               common_frequencies = frequencies;
+               synchronized(preferences) {
+                       save_common_frequencies(frequencies);
+                       flush_preferences();
+               }
+       }
+
+       public static void add_common_frequency(AltosFrequency frequency) {
+               AltosFrequency[]        new_frequencies = new AltosFrequency[common_frequencies.length + 1];
+               int                     i;
+
+               for (i = 0; i < common_frequencies.length; i++) {
+                       if (frequency.frequency == common_frequencies[i].frequency)
+                               return;
+                       if (frequency.frequency < common_frequencies[i].frequency)
+                               break;
+                       new_frequencies[i] = common_frequencies[i];
+               }
+               new_frequencies[i] = frequency;
+               for (; i < common_frequencies.length; i++)
+                       new_frequencies[i+1] = common_frequencies[i];
+               set_common_frequencies(new_frequencies);
+       }
+}
index 120004a..e4915af 100644 (file)
@@ -23,64 +23,66 @@ import java.util.HashMap;
 import java.io.*;
 
 public class AltosRecord implements Comparable <AltosRecord> {
-       final static int        MISSING = 0x7fffffff;
-
-       static final int        seen_flight = 1;
-       static final int        seen_sensor = 2;
-       static final int        seen_temp_volt = 4;
-       static final int        seen_deploy = 8;
-       static final int        seen_gps_time = 16;
-       static final int        seen_gps_lat = 32;
-       static final int        seen_gps_lon = 64;
-       static final int        seen_companion = 128;
-       int                     seen;
-
-       int     version;
-       String  callsign;
-       int     serial;
-       int     flight;
-       int     rssi;
-       int     status;
-       int     state;
-       int     tick;
-
-       int     accel;
-       int     pres;
-       int     temp;
-       int     batt;
-       int     drogue;
-       int     main;
-
-       int     ground_accel;
-       int     ground_pres;
-       int     accel_plus_g;
-       int     accel_minus_g;
-
-       double  acceleration;
-       double  speed;
-       double  height;
-
-       int     flight_accel;
-       int     flight_vel;
-       int     flight_pres;
-
-       AltosGPS        gps;
-       boolean         new_gps;
-
-       AltosIMU        imu;
-       AltosMag        mag;
-
-       double  time;   /* seconds since boost */
-
-       int     device_type;
-       int     config_major;
-       int     config_minor;
-       int     apogee_delay;
-       int     main_deploy;
-       int     flight_log_max;
-       String  firmware_version;
-
-       AltosRecordCompanion companion;
+       public final static int MISSING = 0x7fffffff;
+
+       public static final int seen_flight = 1;
+       public static final int seen_sensor = 2;
+       public static final int seen_temp_volt = 4;
+       public static final int seen_deploy = 8;
+       public static final int seen_gps_time = 16;
+       public static final int seen_gps_lat = 32;
+       public static final int seen_gps_lon = 64;
+       public static final int seen_companion = 128;
+       public int                      seen;
+
+       public int      version;
+       public String   callsign;
+       public int      serial;
+       public int      flight;
+       public int      rssi;
+       public int      status;
+       public int      state;
+       public int      tick;
+
+       public int      accel;
+       public int      pres;
+       public int      temp;
+       public int      batt;
+       public int      drogue;
+       public int      main;
+
+       public int      ground_accel;
+       public int      ground_pres;
+       public int      accel_plus_g;
+       public int      accel_minus_g;
+
+       public double   acceleration;
+       public double   speed;
+       public double   height;
+
+       public int      flight_accel;
+       public int      flight_vel;
+       public int      flight_pres;
+
+       public AltosGPS gps;
+       public boolean          new_gps;
+
+       public AltosIMU imu;
+       public AltosMag mag;
+
+       public double   time;   /* seconds since boost */
+
+       public int      device_type;
+       public int      config_major;
+       public int      config_minor;
+       public int      apogee_delay;
+       public int      main_deploy;
+       public int      flight_log_max;
+       public String   firmware_version;
+
+       public AltosRecordCompanion companion;
+
+>>>>>>> 5a249bc... altosui: Complete split out of separate java library
        /*
         * Values for our MP3H6115A pressure sensor
         *
@@ -95,10 +97,10 @@ public class AltosRecord implements Comparable <AltosRecord> {
         * 2.82V * 2047 / 3.3 counts/V = 1749 counts/115 kPa
         */
 
-       static final double counts_per_kPa = 27 * 2047 / 3300;
-       static final double counts_at_101_3kPa = 1674.0;
+       public static final double counts_per_kPa = 27 * 2047 / 3300;
+       public static final double counts_at_101_3kPa = 1674.0;
 
-       static double
+       public static double
        barometer_to_pressure(double count)
        {
                return ((count / 16.0) / 2047.0 + 0.095) / 0.009 * 1000.0;
@@ -193,7 +195,7 @@ public class AltosRecord implements Comparable <AltosRecord> {
         *      = (value - 19791.268) / 32768 * 1.25 / 0.00247
         */
 
-       static double
+       public static double
        thermometer_to_temperature(double thermo)
        {
                return (thermo - 19791.268) / 32728.0 * 1.25 / 0.00247;
@@ -205,7 +207,7 @@ public class AltosRecord implements Comparable <AltosRecord> {
                return thermometer_to_temperature(temp);
        }
 
-       double accel_counts_per_mss() {
+       public double accel_counts_per_mss() {
                double  counts_per_g = Math.abs(accel_minus_g - accel_plus_g) / 2;
 
                return counts_per_g / 9.80665;
index 4f8e80d..c8cc6ca 100644 (file)
 package org.altusmetrum.AltosLib;
 
 public class AltosRecordCompanion {
-       final static int        board_id_telescience = 0x0a;
-       final static int        MAX_CHANNELS = 12;
+       public final static int board_id_telescience = 0x0a;
+       public final static int MAX_CHANNELS = 12;
 
-       int     tick;
-       int     board_id;
-       int     update_period;
-       int     channels;
-       int[]   companion_data;
+       public int      tick;
+       public int      board_id;
+       public int      update_period;
+       public int      channels;
+       public int[]    companion_data;
 
        public AltosRecordCompanion(int in_channels) {
                channels = in_channels;
diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosTelemetryReader.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosTelemetryReader.java
deleted file mode 100644 (file)
index bd94ee3..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright © 2010 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package org.altusmetrum.AltosLib;
-
-import java.lang.*;
-import java.text.*;
-import java.io.*;
-import java.util.concurrent.*;
-
-class AltosTelemetryReader extends AltosFlightReader {
-       AltosDevice     device;
-       AltosSerial     serial;
-       AltosLog        log;
-       AltosRecord     previous;
-       double          frequency;
-       int             telemetry;
-
-       LinkedBlockingQueue<AltosLine> telem;
-
-       AltosRecord read() throws InterruptedException, ParseException, AltosCRCException, IOException {
-               AltosLine l = telem.take();
-               if (l.line == null)
-                       throw new IOException("IO error");
-               AltosRecord     next = AltosTelemetry.parse(l.line, previous);
-               previous = next;
-               return next;
-       }
-
-       void flush() {
-               telem.clear();
-       }
-
-       void close(boolean interrupted) {
-               serial.remove_monitor(telem);
-               log.close();
-               serial.close();
-       }
-
-       public void set_frequency(double in_frequency) throws InterruptedException, TimeoutException {
-               frequency = in_frequency;
-               serial.set_radio_frequency(frequency);
-       }
-
-       public boolean supports_telemetry(int telemetry) {
-
-               try {
-                       /* Version 1.0 or later firmware supports all telemetry formats */
-                       if (serial.config_data().compare_version("1.0") >= 0)
-                               return true;
-
-                       /* Version 0.9 firmware only supports 0.9 telemetry */
-                       if (serial.config_data().compare_version("0.9") >= 0) {
-                               if (telemetry == Altos.ao_telemetry_0_9)
-                                       return true;
-                               else
-                                       return false;
-                       }
-
-                       /* Version 0.8 firmware only supports 0.8 telemetry */
-                       if (telemetry == Altos.ao_telemetry_0_8)
-                               return true;
-                       else
-                               return false;
-               } catch (InterruptedException ie) {
-                       return true;
-               } catch (TimeoutException te) {
-                       return true;
-               }
-       }
-
-       void save_frequency() {
-               AltosUIPreferences.set_frequency(device.getSerial(), frequency);
-       }
-
-       void set_telemetry(int in_telemetry) {
-               telemetry = in_telemetry;
-               serial.set_telemetry(telemetry);
-       }
-
-       void save_telemetry() {
-               AltosUIPreferences.set_telemetry(device.getSerial(), telemetry);
-       }
-
-       File backing_file() {
-               return log.file();
-       }
-
-       public AltosTelemetryReader (AltosDevice in_device)
-               throws FileNotFoundException, AltosSerialInUseException, IOException, InterruptedException, TimeoutException {
-               device = in_device;
-               serial = new AltosSerial(device);
-               log = new AltosLog(serial);
-               name = device.toShortString();
-               previous = null;
-
-               telem = new LinkedBlockingQueue<AltosLine>();
-               frequency = AltosUIPreferences.frequency(device.getSerial());
-               set_frequency(frequency);
-               telemetry = AltosUIPreferences.telemetry(device.getSerial());
-               set_telemetry(telemetry);
-               serial.set_callsign(AltosUIPreferences.callsign());
-               serial.add_monitor(telem);
-       }
-}