summaryrefslogtreecommitdiff
path: root/altosui
diff options
context:
space:
mode:
Diffstat (limited to 'altosui')
-rw-r--r--altosui/.gitignore1
-rw-r--r--altosui/Altos.java75
-rw-r--r--altosui/AltosAscent.java52
-rw-r--r--altosui/AltosBTDevice.java5
-rw-r--r--altosui/AltosBTDeviceIterator.java1
-rw-r--r--altosui/AltosBTKnown.java12
-rw-r--r--altosui/AltosBTManage.java12
-rw-r--r--altosui/AltosCSV.java12
-rw-r--r--altosui/AltosCSVUI.java11
-rw-r--r--altosui/AltosChannelMenu.java9
-rw-r--r--altosui/AltosCompanionInfo.java12
-rw-r--r--altosui/AltosConfig.java306
-rw-r--r--altosui/AltosConfigFreqUI.java15
-rw-r--r--altosui/AltosConfigPyroUI.java289
-rw-r--r--altosui/AltosConfigTD.java19
-rw-r--r--altosui/AltosConfigTDUI.java15
-rw-r--r--altosui/AltosConfigUI.java152
-rw-r--r--altosui/AltosConfigureUI.java388
-rw-r--r--altosui/AltosDataChooser.java15
-rw-r--r--altosui/AltosDataPoint.java30
-rw-r--r--altosui/AltosDataPointReader.java86
-rw-r--r--altosui/AltosDebug.java280
-rw-r--r--altosui/AltosDescent.java69
-rw-r--r--altosui/AltosDevice.java2
-rw-r--r--altosui/AltosDeviceDialog.java188
-rw-r--r--altosui/AltosDeviceUIDialog.java70
-rw-r--r--altosui/AltosDialog.java63
-rw-r--r--altosui/AltosDisplayThread.java65
-rw-r--r--altosui/AltosEepromDelete.java10
-rw-r--r--altosui/AltosEepromDownload.java22
-rw-r--r--altosui/AltosEepromList.java10
-rw-r--r--altosui/AltosEepromManage.java29
-rw-r--r--altosui/AltosEepromMonitor.java33
-rw-r--r--altosui/AltosEepromSelect.java13
-rw-r--r--altosui/AltosFlash.java380
-rw-r--r--altosui/AltosFlashUI.java32
-rw-r--r--altosui/AltosFlightDisplay.java4
-rw-r--r--altosui/AltosFlightInfoTableModel.java10
-rw-r--r--altosui/AltosFlightStats.java43
-rw-r--r--altosui/AltosFlightStatsTable.java66
-rw-r--r--altosui/AltosFlightStatus.java48
-rw-r--r--altosui/AltosFlightStatusTableModel.java5
-rw-r--r--altosui/AltosFlightStatusUpdate.java23
-rw-r--r--altosui/AltosFlightUI.java58
-rw-r--r--altosui/AltosFontListener.java22
-rw-r--r--altosui/AltosFrame.java80
-rw-r--r--altosui/AltosFreqList.java12
-rw-r--r--altosui/AltosGraph.java236
-rw-r--r--altosui/AltosGraphDataPoint.java122
-rw-r--r--altosui/AltosGraphDataSet.java98
-rw-r--r--altosui/AltosGraphTime.java236
-rw-r--r--altosui/AltosGraphUI.java330
-rw-r--r--altosui/AltosHexfile.java253
-rw-r--r--altosui/AltosIdleMonitorUI.java106
-rw-r--r--altosui/AltosIgniteUI.java12
-rw-r--r--altosui/AltosInfoTable.java211
-rw-r--r--altosui/AltosKML.java22
-rw-r--r--altosui/AltosLanded.java51
-rw-r--r--altosui/AltosLaunch.java7
-rw-r--r--altosui/AltosLaunchUI.java11
-rw-r--r--altosui/AltosLed.java10
-rw-r--r--altosui/AltosLights.java9
-rw-r--r--altosui/AltosPad.java209
-rw-r--r--altosui/AltosRomconfig.java148
-rw-r--r--altosui/AltosRomconfigUI.java12
-rw-r--r--altosui/AltosScanUI.java10
-rw-r--r--altosui/AltosSerial.java11
-rw-r--r--altosui/AltosSerialInUseException.java1
-rw-r--r--altosui/AltosSiteMap.java58
-rw-r--r--altosui/AltosSiteMapCache.java18
-rw-r--r--altosui/AltosSiteMapPreload.java13
-rw-r--r--altosui/AltosSiteMapTile.java12
-rw-r--r--altosui/AltosUI.java102
-rw-r--r--altosui/AltosUIListener.java22
-rw-r--r--altosui/AltosUIPreferences.java182
-rw-r--r--altosui/AltosUIPreferencesBackend.java101
-rw-r--r--altosui/AltosUSBDevice.java112
-rw-r--r--altosui/AltosVersion.java.in22
-rw-r--r--altosui/AltosVoice.java2
-rw-r--r--altosui/AltosWriter.java6
-rw-r--r--altosui/GrabNDrag.java7
-rw-r--r--altosui/Makefile.am100
-rw-r--r--altosui/ReadMe-Mac.rtf56
-rw-r--r--altosui/altos-windows.nsi.in (renamed from altosui/altos-windows.nsi)5
-rw-r--r--altosui/launch-sites.txt13
-rw-r--r--altosui/libaltos/.gitignore12
-rw-r--r--altosui/libaltos/Makefile-standalone126
-rw-r--r--altosui/libaltos/Makefile.am54
-rw-r--r--altosui/libaltos/cjnitest.c71
-rw-r--r--altosui/libaltos/libaltos.c1311
-rwxr-xr-xaltosui/libaltos/libaltos.dylibbin41648 -> 0 bytes
-rw-r--r--altosui/libaltos/libaltos.h119
-rw-r--r--altosui/libaltos/libaltos.i05
93 files changed, 2080 insertions, 5708 deletions
diff --git a/altosui/.gitignore b/altosui/.gitignore
index 6d2d8c23..f8554c6a 100644
--- a/altosui/.gitignore
+++ b/altosui/.gitignore
@@ -12,6 +12,7 @@ altosui
altosui-test
altosui-jdb
classaltosui.stamp
+altos-windows.nsi
Altos-Linux-*.tar.bz2
Altos-Mac-*.zip
Altos-Windows-*.exe
diff --git a/altosui/Altos.java b/altosui/Altos.java
index cd17a93e..d25736bf 100644
--- a/altosui/Altos.java
+++ b/altosui/Altos.java
@@ -18,80 +18,11 @@
package altosui;
import java.awt.*;
-import java.util.*;
-import java.text.*;
-import java.nio.charset.Charset;
-
import libaltosJNI.*;
-import org.altusmetrum.AltosLib.*;
-
-public class Altos extends AltosLib {
-
- static final int tab_elt_pad = 5;
-
- static Font label_font;
- static Font value_font;
- static Font status_font;
- static Font table_label_font;
- static Font table_value_font;
-
- final static int font_size_small = 1;
- final static int font_size_medium = 2;
- final static int font_size_large = 3;
-
- static void set_fonts(int size) {
- int brief_size;
- int table_size;
- int status_size;
-
- switch (size) {
- case font_size_small:
- brief_size = 16;
- status_size = 18;
- table_size = 11;
- break;
- default:
- case font_size_medium:
- brief_size = 22;
- status_size = 24;
- table_size = 14;
- break;
- case font_size_large:
- brief_size = 26;
- status_size = 30;
- table_size = 17;
- break;
- }
- label_font = new Font("Dialog", Font.PLAIN, brief_size);
- value_font = new Font("Monospaced", Font.PLAIN, brief_size);
- status_font = new Font("SansSerif", Font.BOLD, status_size);
- table_label_font = new Font("SansSerif", Font.PLAIN, table_size);
- table_value_font = new Font("Monospaced", Font.PLAIN, table_size);
- }
-
- static final int text_width = 20;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
- static public boolean initialized = false;
- static public boolean loaded_library = false;
+public class Altos extends AltosUILib {
- public static boolean load_library() {
- if (!initialized) {
- try {
- System.loadLibrary("altos");
- libaltos.altos_init();
- loaded_library = true;
- } catch (UnsatisfiedLinkError e) {
- try {
- System.loadLibrary("altos64");
- libaltos.altos_init();
- loaded_library = true;
- } catch (UnsatisfiedLinkError e2) {
- loaded_library = false;
- }
- }
- initialized = true;
- }
- return loaded_library;
- }
}
diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java
index 3fe517aa..4da4d591 100644
--- a/altosui/AltosAscent.java
+++ b/altosui/AltosAscent.java
@@ -18,16 +18,8 @@
package altosui;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosAscent extends JComponent implements AltosFlightDisplay {
GridBagLayout layout;
@@ -50,7 +42,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
label.setVisible(false);
}
- void show(AltosState state, int crc_errors) {}
+ void show(AltosState state, AltosListenerState listener_state) {}
void show(String s) {
show();
@@ -115,7 +107,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
public class AscentValue {
JLabel label;
JTextField value;
- void show(AltosState state, int crc_errors) {}
+ void show(AltosState state, AltosListenerState listener_state) {}
void reset() {
value.setText("");
@@ -182,7 +174,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
JTextField max_value;
double max;
- void show(AltosState state, int crc_errors) {}
+ void show(AltosState state, AltosListenerState listener_state) {}
void reset() {
value.setText("");
@@ -247,7 +239,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Height extends AscentValueHold {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show(AltosConvert.height, state.height);
}
public Height (GridBagLayout layout, int y) {
@@ -258,8 +250,8 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
Height height;
class Speed extends AscentValueHold {
- void show (AltosState state, int crc_errors) {
- double speed = state.speed;
+ void show (AltosState state, AltosListenerState listener_state) {
+ double speed = state.accel_speed;
if (!state.ascent)
speed = state.baro_speed;
show(AltosConvert.speed, speed);
@@ -272,7 +264,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
Speed speed;
class Accel extends AscentValueHold {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show(AltosConvert.accel, state.acceleration);
}
public Accel (GridBagLayout layout, int y) {
@@ -294,7 +286,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
}
class Apogee extends AscentStatus {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show("%4.2f V", state.drogue_sense);
lights.set(state.drogue_sense > 3.2);
}
@@ -306,7 +298,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
Apogee apogee;
class Main extends AscentStatus {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show("%4.2f V", state.main_sense);
lights.set(state.main_sense > 3.2);
}
@@ -318,7 +310,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
Main main;
class Lat extends AscentValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
if (state.gps != null)
show(pos(state.gps.lat,"N", "S"));
else
@@ -332,7 +324,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
Lat lat;
class Lon extends AscentValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
if (state.gps != null)
show(pos(state.gps.lon,"E", "W"));
else
@@ -367,25 +359,25 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
accel.set_font();
}
- public void show(AltosState state, int crc_errors) {
+ public void show(AltosState state, AltosListenerState listener_state) {
if (state.gps != null && state.gps.connected) {
- lat.show(state, crc_errors);
- lon.show(state, crc_errors);
+ lat.show(state, listener_state);
+ lon.show(state, listener_state);
} else {
lat.hide();
lon.hide();
}
- height.show(state, crc_errors);
+ height.show(state, listener_state);
if (state.main_sense != AltosRecord.MISSING)
- main.show(state, crc_errors);
+ main.show(state, listener_state);
else
main.hide();
if (state.drogue_sense != AltosRecord.MISSING)
- apogee.show(state, crc_errors);
+ apogee.show(state, listener_state);
else
apogee.hide();
- speed.show(state, crc_errors);
- accel.show(state, crc_errors);
+ speed.show(state, listener_state);
+ accel.show(state, listener_state);
}
public void labels(GridBagLayout layout, int y) {
@@ -406,6 +398,10 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
add(max);
}
+ public String getName() {
+ return "Ascent";
+ }
+
public AltosAscent() {
layout = new GridBagLayout();
diff --git a/altosui/AltosBTDevice.java b/altosui/AltosBTDevice.java
index 5e353fdd..727a9f66 100644
--- a/altosui/AltosBTDevice.java
+++ b/altosui/AltosBTDevice.java
@@ -16,9 +16,8 @@
*/
package altosui;
-import java.lang.*;
-import java.util.*;
import libaltosJNI.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosBTDevice extends altos_bt_device implements AltosDevice {
@@ -79,11 +78,13 @@ public class AltosBTDevice extends altos_bt_device implements AltosDevice {
return libaltos.altos_bt_open(this);
}
+ /*
private boolean isAltusMetrum() {
if (getName().startsWith(Altos.bt_product_telebt))
return true;
return false;
}
+ */
public boolean matchProduct(int want_product) {
diff --git a/altosui/AltosBTDeviceIterator.java b/altosui/AltosBTDeviceIterator.java
index 58ed86d5..4be5edf5 100644
--- a/altosui/AltosBTDeviceIterator.java
+++ b/altosui/AltosBTDeviceIterator.java
@@ -16,7 +16,6 @@
*/
package altosui;
-import java.lang.*;
import java.util.*;
import libaltosJNI.*;
diff --git a/altosui/AltosBTKnown.java b/altosui/AltosBTKnown.java
index 6a8e53cb..1d42365b 100644
--- a/altosui/AltosBTKnown.java
+++ b/altosui/AltosBTKnown.java
@@ -16,21 +16,20 @@
*/
package altosui;
-import java.lang.*;
import java.util.*;
-import libaltosJNI.*;
-import java.util.prefs.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosBTKnown implements Iterable<AltosBTDevice> {
LinkedList<AltosBTDevice> devices = new LinkedList<AltosBTDevice>();
- Preferences bt_pref = AltosUIPreferences.bt_devices();
+ AltosPreferencesBackend bt_pref = AltosUIPreferences.bt_devices();
private String get_address(String name) {
- return bt_pref.get(name, "");
+ return bt_pref.getString(name, "");
}
private void set_address(String name, String addr) {
- bt_pref.put(name, addr);
+ bt_pref.putString(name, addr);
}
private void remove(String name) {
@@ -45,7 +44,6 @@ public class AltosBTKnown implements Iterable<AltosBTDevice> {
String addr = get_address(name);
devices.add(new AltosBTDevice(name, addr));
}
- } catch (BackingStoreException be) {
} catch (IllegalStateException ie) {
}
}
diff --git a/altosui/AltosBTManage.java b/altosui/AltosBTManage.java
index aeb964bb..4c9b7a6c 100644
--- a/altosui/AltosBTManage.java
+++ b/altosui/AltosBTManage.java
@@ -20,20 +20,12 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import javax.swing.event.*;
import javax.swing.plaf.basic.*;
-import java.io.*;
import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib_1.*;
-import libaltosJNI.*;
-
-public class AltosBTManage extends AltosDialog implements ActionListener, Iterable<AltosBTDevice> {
+public class AltosBTManage extends AltosUIDialog implements ActionListener, Iterable<AltosBTDevice> {
LinkedBlockingQueue<AltosBTDevice> found_devices;
Frame frame;
LinkedList<ActionListener> listeners;
diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java
index c876d9ca..0676f99d 100644
--- a/altosui/AltosCSV.java
+++ b/altosui/AltosCSV.java
@@ -17,11 +17,9 @@
package altosui;
-import java.lang.*;
import java.io.*;
-import java.text.*;
import java.util.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosCSV implements AltosWriter {
File name;
@@ -130,10 +128,10 @@ public class AltosCSV implements AltosWriter {
void write_basic(AltosRecord record) {
out.printf("%8.2f,%10.2f,%8.2f,%8.2f,%8.2f,%8.2f,%5.1f,%5.2f,%5.2f,%5.2f",
record.acceleration(),
- record.raw_pressure(),
- record.raw_altitude(),
- record.raw_height(),
- record.accel_speed(),
+ record.pressure(),
+ record.altitude(),
+ record.height(),
+ state.accel_speed,
state.baro_speed,
record.temperature(),
record.battery_voltage(),
diff --git a/altosui/AltosCSVUI.java b/altosui/AltosCSVUI.java
index 2702668b..42508346 100644
--- a/altosui/AltosCSVUI.java
+++ b/altosui/AltosCSVUI.java
@@ -20,17 +20,12 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosCSVUI
- extends AltosDialog
+ extends AltosUIDialog
implements ActionListener
{
JFileChooser csv_chooser;
diff --git a/altosui/AltosChannelMenu.java b/altosui/AltosChannelMenu.java
index 0249a0bd..f90a11c0 100644
--- a/altosui/AltosChannelMenu.java
+++ b/altosui/AltosChannelMenu.java
@@ -17,17 +17,8 @@
package altosui;
-import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-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;
diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java
index 4ba8fe98..ebe1d1f9 100644
--- a/altosui/AltosCompanionInfo.java
+++ b/altosui/AltosCompanionInfo.java
@@ -18,16 +18,8 @@
package altosui;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosCompanionInfo extends JTable {
private AltosFlightInfoTableModel model;
@@ -91,7 +83,7 @@ public class AltosCompanionInfo extends JTable {
}
}
- public void show(AltosState state, int crc_errors) {
+ public void show(AltosState state, AltosListenerState listener_state) {
if (state == null)
return;
if (state.data.companion != null)
diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java
index cae41858..4927d3f8 100644
--- a/altosui/AltosConfig.java
+++ b/altosui/AltosConfig.java
@@ -17,19 +17,13 @@
package altosui;
-import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
-
-import libaltosJNI.*;
+import java.text.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosConfig implements ActionListener {
@@ -65,62 +59,12 @@ public class AltosConfig implements ActionListener {
AltosDevice device;
AltosSerial serial_line;
boolean remote;
- AltosConfigData remote_config_data;
- double remote_frequency;
- int_ref serial;
- int_ref log_format;
- int_ref main_deploy;
- int_ref apogee_delay;
- int_ref apogee_lockout;
- int_ref radio_channel;
- int_ref radio_calibration;
- int_ref flight_log_max;
- int_ref ignite_mode;
- int_ref pad_orientation;
- int_ref radio_setting;
- int_ref radio_frequency;
- int_ref storage_size;
- int_ref storage_erase_unit;
- int_ref stored_flight;
- int_ref radio_enable;
- string_ref version;
- string_ref product;
- string_ref callsign;
+
+ AltosConfigData data;
AltosConfigUI config_ui;
boolean serial_started;
boolean made_visible;
- boolean get_int(String line, String label, int_ref x) {
- if (line.startsWith(label)) {
- try {
- String tail = line.substring(label.length()).trim();
- String[] tokens = tail.split("\\s+");
- if (tokens.length > 0) {
- int i = Integer.parseInt(tokens[0]);
- x.set(i);
- return true;
- }
- } catch (NumberFormatException ne) {
- }
- }
- return false;
- }
-
- boolean get_string(String line, String label, string_ref s) {
- if (line.startsWith(label)) {
- String quoted = line.substring(label.length()).trim();
-
- if (quoted.startsWith("\""))
- quoted = quoted.substring(1);
- if (quoted.endsWith("\""))
- quoted = quoted.substring(0,quoted.length()-1);
- s.set(quoted);
- return true;
- } else {
- return false;
- }
- }
-
void start_serial() throws InterruptedException, TimeoutException {
serial_started = true;
if (remote)
@@ -135,41 +79,8 @@ public class AltosConfig implements ActionListener {
serial_line.stop_remote();
}
- int log_limit() {
- if (storage_size.get() > 0 && storage_erase_unit.get() > 0) {
- int log_limit = storage_size.get() - storage_erase_unit.get();
- if (log_limit > 0)
- return log_limit / 1024;
- }
- return 1024;
- }
-
void update_ui() {
- config_ui.set_serial(serial.get());
- config_ui.set_product(product.get());
- config_ui.set_version(version.get());
- config_ui.set_main_deploy(main_deploy.get());
- config_ui.set_apogee_delay(apogee_delay.get());
- config_ui.set_apogee_lockout(apogee_lockout.get());
- config_ui.set_radio_calibration(radio_calibration.get());
- config_ui.set_radio_frequency(frequency());
- boolean max_enabled = true;
- switch (log_format.get()) {
- case Altos.AO_LOG_FORMAT_TINY:
- max_enabled = false;
- break;
- default:
- if (stored_flight.get() >= 0)
- max_enabled = false;
- break;
- }
- config_ui.set_flight_log_max_enabled(max_enabled);
- config_ui.set_radio_enable(radio_enable.get());
- config_ui.set_flight_log_max_limit(log_limit());
- config_ui.set_flight_log_max(flight_log_max.get());
- config_ui.set_ignite_mode(ignite_mode.get());
- config_ui.set_pad_orientation(pad_orientation.get());
- config_ui.set_callsign(callsign.get());
+ data.set_values(config_ui);
config_ui.set_clean();
if (!made_visible) {
made_visible = true;
@@ -177,38 +88,7 @@ public class AltosConfig implements ActionListener {
}
}
- void process_line(String line) {
- if (line == null) {
- abort();
- return;
- }
- if (line.equals("all finished")) {
- if (serial_line != null)
- update_ui();
- return;
- }
- get_int(line, "serial-number", serial);
- get_int(line, "log-format", log_format);
- get_int(line, "Main deploy:", main_deploy);
- get_int(line, "Apogee delay:", apogee_delay);
- get_int(line, "Apogee lockout:", apogee_lockout);
- get_int(line, "Radio channel:", radio_channel);
- get_int(line, "Radio cal:", radio_calibration);
- get_int(line, "Max flight log:", flight_log_max);
- get_int(line, "Ignite mode:", ignite_mode);
- get_int(line, "Pad orientation:", pad_orientation);
- get_int(line, "Radio setting:", radio_setting);
- if (get_int(line, "Frequency:", radio_frequency))
- if (radio_frequency.get() < 0)
- radio_frequency.set(434550);
- get_int(line, "Radio enable:", radio_enable);
- get_int(line, "Storage size:", storage_size);
- get_int(line, "Storage erase unit:", storage_erase_unit);
- get_int(line, "flight", stored_flight);
- get_string(line, "Callsign:", callsign);
- get_string(line,"software-version", version);
- get_string(line,"product", product);
- }
+ int pyro;
final static int serial_mode_read = 0;
final static int serial_mode_save = 1;
@@ -218,61 +98,33 @@ public class AltosConfig implements ActionListener {
AltosConfig config;
int serial_mode;
- void process_line(String line) {
- config.process_line(line);
- }
- void callback(String in_line) {
- final String line = in_line;
+ void callback(String in_cmd) {
+ final String cmd = in_cmd;
Runnable r = new Runnable() {
public void run() {
- process_line(line);
+ if (cmd.equals("abort")) {
+ abort();
+ } else if (cmd.equals("all finished")) {
+ if (serial_line != null)
+ update_ui();
+ }
}
};
SwingUtilities.invokeLater(r);
}
- void reset_data() {
- serial.set(0);
- log_format.set(Altos.AO_LOG_FORMAT_UNKNOWN);
- main_deploy.set(250);
- apogee_delay.set(0);
- apogee_lockout.set(0);
- radio_channel.set(0);
- radio_setting.set(0);
- radio_frequency.set(0);
- radio_calibration.set(1186611);
- radio_enable.set(-1);
- flight_log_max.set(0);
- ignite_mode.set(-1);
- pad_orientation.set(-1);
- storage_size.set(-1);
- storage_erase_unit.set(-1);
- stored_flight.set(-1);
- callsign.set("N0CALL");
- version.set("unknown");
- product.set("unknown");
- }
-
void get_data() {
+ data = null;
try {
- config.start_serial();
- reset_data();
-
- config.serial_line.printf("c s\nf\nl\nv\n");
- for (;;) {
- try {
- String line = config.serial_line.get_reply(5000);
- if (line == null)
- stop_serial();
- callback(line);
- if (line.startsWith("software-version"))
- break;
- } catch (Exception e) {
- break;
- }
- }
+ start_serial();
+ data = new AltosConfigData(config.serial_line);
} catch (InterruptedException ie) {
} catch (TimeoutException te) {
+ try {
+ stop_serial();
+ callback("abort");
+ } catch (InterruptedException ie) {
+ }
} finally {
try {
stop_serial();
@@ -284,35 +136,11 @@ public class AltosConfig implements ActionListener {
void save_data() {
try {
- double frequency = frequency();
- boolean has_frequency = radio_frequency.get() > 0;
- boolean has_setting = radio_setting.get() > 0;
start_serial();
- serial_line.printf("c m %d\n", main_deploy.get());
- serial_line.printf("c d %d\n", apogee_delay.get());
- serial_line.printf("c L %d\n", apogee_lockout.get());
- if (!remote)
- serial_line.printf("c f %d\n", radio_calibration.get());
- serial_line.set_radio_frequency(frequency,
- has_frequency,
- has_setting,
- radio_calibration.get());
- if (remote) {
- serial_line.stop_remote();
- serial_line.set_radio_frequency(frequency);
- AltosUIPreferences.set_frequency(device.getSerial(), frequency);
- serial_line.start_remote();
- }
- serial_line.printf("c c %s\n", callsign.get());
- if (flight_log_max.get() != 0)
- serial_line.printf("c l %d\n", flight_log_max.get());
- if (radio_enable.get() >= 0)
- serial_line.printf("c e %d\n", radio_enable.get());
- if (ignite_mode.get() >= 0)
- serial_line.printf("c i %d\n", ignite_mode.get());
- if (pad_orientation.get() >= 0)
- serial_line.printf("c o %d\n", pad_orientation.get());
- serial_line.printf("c w\n");
+ data.save(serial_line, remote);
+ if (remote)
+ AltosUIPreferences.set_frequency(device.getSerial(),
+ data.frequency());
} catch (InterruptedException ie) {
} catch (TimeoutException te) {
} finally {
@@ -373,8 +201,10 @@ public class AltosConfig implements ActionListener {
}
void abort() {
- serial_line.close();
- serial_line = null;
+ if (serial_line != null) {
+ serial_line.close();
+ serial_line = null;
+ }
JOptionPane.showMessageDialog(owner,
String.format("Connection to \"%s\" failed",
device.toShortString()),
@@ -391,54 +221,29 @@ public class AltosConfig implements ActionListener {
}
double frequency() {
- return AltosConvert.radio_to_frequency(radio_frequency.get(),
- radio_setting.get(),
- radio_calibration.get(),
- radio_channel.get());
- }
-
- void set_frequency(double freq) {
- int frequency = radio_frequency.get();
- int setting = radio_setting.get();
-
- if (frequency > 0) {
- radio_frequency.set((int) Math.floor (freq * 1000 + 0.5));
- radio_channel.set(0);
- } else if (setting > 0) {
- radio_setting.set(AltosConvert.radio_frequency_to_setting(freq,
- radio_calibration.get()));
- radio_channel.set(0);
- } else {
- radio_channel.set(AltosConvert.radio_frequency_to_channel(freq));
- }
+ return AltosConvert.radio_to_frequency(data.radio_frequency,
+ data.radio_setting,
+ data.radio_calibration,
+ data.radio_channel);
}
void save_data() {
/* bounds check stuff */
- if (config_ui.flight_log_max() > log_limit()) {
+ if (config_ui.flight_log_max() > data.log_limit()) {
JOptionPane.showMessageDialog(owner,
String.format("Requested flight log, %dk, is larger than the available space, %dk.\n",
config_ui.flight_log_max(),
- log_limit()),
+ data.log_limit()),
"Maximum Flight Log Too Large",
JOptionPane.ERROR_MESSAGE);
return;
}
- main_deploy.set(config_ui.main_deploy());
- apogee_delay.set(config_ui.apogee_delay());
- apogee_lockout.set(config_ui.apogee_lockout());
- radio_calibration.set(config_ui.radio_calibration());
- set_frequency(config_ui.radio_frequency());
- flight_log_max.set(config_ui.flight_log_max());
- if (radio_enable.get() >= 0)
- radio_enable.set(config_ui.radio_enable());
- if (ignite_mode.get() >= 0)
- ignite_mode.set(config_ui.ignite_mode());
- if (pad_orientation.get() >= 0)
- pad_orientation.set(config_ui.pad_orientation());
- callsign.set(config_ui.callsign());
+ /* Pull data out of the UI and stuff back into our local data record */
+
+ data.get_values(config_ui);
+
run_serial_thread(serial_mode_save);
}
@@ -466,32 +271,12 @@ public class AltosConfig implements ActionListener {
public AltosConfig(JFrame given_owner) {
owner = given_owner;
- serial = new int_ref(0);
- log_format = new int_ref(Altos.AO_LOG_FORMAT_UNKNOWN);
- main_deploy = new int_ref(250);
- apogee_delay = new int_ref(0);
- apogee_lockout = new int_ref(0);
- radio_channel = new int_ref(0);
- radio_setting = new int_ref(0);
- radio_frequency = new int_ref(0);
- radio_calibration = new int_ref(1186611);
- radio_enable = new int_ref(-1);
- flight_log_max = new int_ref(0);
- ignite_mode = new int_ref(-1);
- pad_orientation = new int_ref(-1);
- storage_size = new int_ref(-1);
- storage_erase_unit = new int_ref(-1);
- stored_flight = new int_ref(-1);
- callsign = new string_ref("N0CALL");
- version = new string_ref("unknown");
- product = new string_ref("unknown");
-
- device = AltosDeviceDialog.show(owner, Altos.product_any);
+ device = AltosDeviceUIDialog.show(owner, Altos.product_any);
if (device != null) {
try {
serial_line = new AltosSerial(device);
try {
- if (!device.matchProduct(Altos.product_altimeter))
+ if (device.matchProduct(Altos.product_basestation))
remote = true;
init_ui();
} catch (InterruptedException ie) {
@@ -510,11 +295,6 @@ public class AltosConfig implements ActionListener {
device.toShortString()),
"Device in use",
JOptionPane.ERROR_MESSAGE);
- } catch (IOException ee) {
- JOptionPane.showMessageDialog(owner,
- device.toShortString(),
- ee.getLocalizedMessage(),
- JOptionPane.ERROR_MESSAGE);
}
}
}
diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java
index 7958a21c..c90b168f 100644
--- a/altosui/AltosConfigFreqUI.java
+++ b/altosui/AltosConfigFreqUI.java
@@ -20,18 +20,11 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import javax.swing.event.*;
-import javax.swing.plaf.basic.*;
-import java.io.*;
import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
-class AltosEditFreqUI extends AltosDialog implements ActionListener {
+class AltosEditFreqUI extends AltosUIDialog implements ActionListener {
Frame frame;
JTextField frequency;
JTextField description;
@@ -166,7 +159,7 @@ class AltosEditFreqUI extends AltosDialog implements ActionListener {
}
}
-public class AltosConfigFreqUI extends AltosDialog implements ActionListener {
+public class AltosConfigFreqUI extends AltosUIDialog implements ActionListener {
Frame frame;
LinkedList<ActionListener> listeners;
diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java
new file mode 100644
index 00000000..3cac56c3
--- /dev/null
+++ b/altosui/AltosConfigPyroUI.java
@@ -0,0 +1,289 @@
+/*
+ * Copyright © 2012 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.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
+
+public class AltosConfigPyroUI
+ extends AltosUIDialog
+ implements ItemListener, DocumentListener
+{
+ AltosConfigUI owner;
+ Container pane;
+
+ static Insets il = new Insets(4,4,4,4);
+ static Insets ir = new Insets(4,4,4,4);
+
+ static String[] state_names;
+
+ static void make_state_names() {
+ if (state_names == null) {
+
+ state_names = new String[AltosLib.ao_flight_landed - AltosLib.ao_flight_boost + 1];
+ for (int state = AltosLib.ao_flight_boost; state <= AltosLib.ao_flight_landed; state++)
+ state_names[state - AltosLib.ao_flight_boost] = AltosLib.state_name_capital(state);
+ }
+ }
+
+ class PyroItem implements ItemListener, DocumentListener
+ {
+ public int flag;
+ public JRadioButton enable;
+ public JTextField value;
+ public JComboBox combo;
+ AltosConfigPyroUI ui;
+
+ public void set_enable(boolean enable) {
+ if (value != null)
+ value.setEnabled(enable);
+ if (combo != null)
+ combo.setEnabled(enable);
+ }
+
+ public void itemStateChanged(ItemEvent e) {
+ set_enable(enable.isSelected());
+ ui.set_dirty();
+ }
+
+ public void changedUpdate(DocumentEvent e) {
+ ui.set_dirty();
+ }
+
+ public void insertUpdate(DocumentEvent e) {
+ ui.set_dirty();
+ }
+
+ public void removeUpdate(DocumentEvent e) {
+ ui.set_dirty();
+ }
+
+ public void set(boolean new_enable, double new_value) {
+ enable.setSelected(new_enable);
+ set_enable(new_enable);
+ if (value != null) {
+ double scale = AltosPyro.pyro_to_scale(flag);
+ String format = "%6.0f";
+ if (scale >= 10)
+ format = "%6.1f";
+ else if (scale >= 100)
+ format = "%6.2f";
+ value.setText(String.format(format, new_value));
+ }
+ if (combo != null)
+ if (new_value >= AltosLib.ao_flight_boost && new_value <= AltosLib.ao_flight_landed)
+ combo.setSelectedIndex((int) new_value - AltosLib.ao_flight_boost);
+ }
+
+ public boolean enabled() {
+ return enable.isSelected();
+ }
+
+ public double value() {
+ if (value != null)
+ return Double.parseDouble(value.getText());
+ if (combo != null)
+ return combo.getSelectedIndex() + AltosLib.ao_flight_boost;
+ return 0;
+ }
+
+ public PyroItem(AltosConfigPyroUI in_ui, int in_flag, int x, int y) {
+
+ ui = in_ui;
+ flag = in_flag;
+
+ GridBagConstraints c;
+ c = new GridBagConstraints();
+ c.gridx = x; c.gridy = y;
+ c.gridwidth = 1;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ enable = new JRadioButton();
+ enable.addItemListener(this);
+ pane.add(enable, c);
+
+ if ((flag & AltosPyro.pyro_no_value) == 0) {
+ c = new GridBagConstraints();
+ c.gridx = x+1; c.gridy = y;
+ c.gridwidth = 1;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ if ((flag & AltosPyro.pyro_state_value) != 0) {
+ make_state_names();
+ combo = new JComboBox(state_names);
+ combo.addItemListener(this);
+ pane.add(combo, c);
+ } else {
+ value = new JTextField(10);
+ value.getDocument().addDocumentListener(this);
+ pane.add(value, c);
+ }
+ }
+ }
+ }
+
+ class PyroColumn {
+ public PyroItem[] items;
+ public JLabel label;
+ int channel;
+
+ public void set(AltosPyro pyro) {
+ int row = 0;
+ for (int flag = 1; flag < AltosPyro.pyro_all; flag <<= 1) {
+ if ((AltosPyro.pyro_all & flag) != 0) {
+ items[row].set((pyro.flags & flag) != 0,
+ pyro.get_value(flag));
+ row++;
+ }
+ }
+ }
+
+ public AltosPyro get() {
+ AltosPyro p = new AltosPyro(channel);
+
+ int row = 0;
+ for (int flag = 1; flag < AltosPyro.pyro_all; flag <<= 1) {
+ if ((AltosPyro.pyro_all & flag) != 0) {
+ if (items[row].enabled()) {
+ System.out.printf ("Flag %x enabled\n", flag);
+ p.flags |= flag;
+ p.set_value(flag, items[row].value());
+ }
+ row++;
+ }
+ }
+ System.out.printf ("Pyro %x %s\n", p.flags, p.toString());
+ return p;
+ }
+
+ public PyroColumn(AltosConfigPyroUI ui, int x, int y, int in_channel) {
+
+ channel = in_channel;
+
+ int nrow = 0;
+ for (int flag = 1; flag < AltosPyro.pyro_all; flag <<= 1)
+ if ((flag & AltosPyro.pyro_all) != 0)
+ nrow++;
+
+ items = new PyroItem[nrow];
+ int row = 0;
+
+ GridBagConstraints c;
+ c = new GridBagConstraints();
+ c.gridx = x; c.gridy = y;
+ c.gridwidth = 2;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.CENTER;
+ c.insets = il;
+ label = new JLabel(String.format("Pyro Channel %d", channel));
+ pane.add(label, c);
+ y++;
+
+ for (int flag = 1; flag < AltosPyro.pyro_all; flag <<= 1)
+ if ((flag & AltosPyro.pyro_all) != 0) {
+ items[row] = new PyroItem(ui, flag, x, y + row);
+ row++;
+ }
+ }
+ }
+
+ PyroColumn[] columns;
+
+ public void set_pyros(AltosPyro[] pyros) {
+ for (int i = 0; i < pyros.length; i++) {
+ if (pyros[i].channel < columns.length)
+ columns[pyros[i].channel].set(pyros[i]);
+ }
+ }
+
+ public AltosPyro[] get_pyros() {
+ AltosPyro[] pyros = new AltosPyro[columns.length];
+ for (int c = 0; c < columns.length; c++)
+ pyros[c] = columns[c].get();
+ return pyros;
+ }
+
+ public void set_dirty() {
+ owner.set_dirty();
+ }
+
+ public void itemStateChanged(ItemEvent e) {
+ owner.set_dirty();
+ }
+
+ public void changedUpdate(DocumentEvent e) {
+ owner.set_dirty();
+ }
+
+ public void insertUpdate(DocumentEvent e) {
+ owner.set_dirty();
+ }
+
+ public void removeUpdate(DocumentEvent e) {
+ owner.set_dirty();
+ }
+
+ public AltosConfigPyroUI(AltosConfigUI in_owner, AltosPyro[] pyros) {
+
+ super(in_owner, "Configure Pyro Channels", false);
+
+ owner = in_owner;
+
+ GridBagConstraints c;
+
+ pane = getContentPane();
+ pane.setLayout(new GridBagLayout());
+
+ int row = 1;
+
+ for (int flag = 1; flag <= AltosPyro.pyro_all; flag <<= 1) {
+ String n;
+
+ n = AltosPyro.pyro_to_name(flag);
+ if (n != null) {
+ c = new GridBagConstraints();
+ c.gridx = 0; c.gridy = row;
+ c.gridwidth = 1;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ JLabel label = new JLabel(n);
+ pane.add(label, c);
+ row++;
+ }
+ }
+
+ columns = new PyroColumn[pyros.length];
+
+ for (int i = 0; i < pyros.length; i++) {
+ columns[i] = new PyroColumn(this, i*2 + 1, 0, i);
+ columns[i].set(pyros[i]);
+ }
+ }
+
+ public void make_visible() {
+ pack();
+ setVisible(true);
+ }
+}
diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java
index 71d628b3..16c9e357 100644
--- a/altosui/AltosConfigTD.java
+++ b/altosui/AltosConfigTD.java
@@ -17,20 +17,12 @@
package altosui;
-import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-
-import libaltosJNI.*;
-
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosConfigTD implements ActionListener {
@@ -323,7 +315,7 @@ public class AltosConfigTD implements ActionListener {
version = new string_ref("unknown");
product = new string_ref("unknown");
- device = AltosDeviceDialog.show(owner, Altos.product_basestation);
+ device = AltosDeviceUIDialog.show(owner, Altos.product_basestation);
if (device != null) {
try {
serial_line = new AltosSerial(device);
@@ -345,11 +337,6 @@ public class AltosConfigTD implements ActionListener {
device.toShortString()),
"Device in use",
JOptionPane.ERROR_MESSAGE);
- } catch (IOException ee) {
- JOptionPane.showMessageDialog(owner,
- device.toShortString(),
- ee.getLocalizedMessage(),
- JOptionPane.ERROR_MESSAGE);
}
}
}
diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java
index f2058f69..125780a9 100644
--- a/altosui/AltosConfigTDUI.java
+++ b/altosui/AltosConfigTDUI.java
@@ -20,21 +20,12 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import javax.swing.event.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import libaltosJNI.*;
-
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosConfigTDUI
- extends AltosDialog
+ extends AltosUIDialog
implements ActionListener, ItemListener, DocumentListener
{
diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java
index 62394fa6..11f40593 100644
--- a/altosui/AltosConfigUI.java
+++ b/altosui/AltosConfigUI.java
@@ -20,25 +20,16 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import javax.swing.event.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
-
-import libaltosJNI.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosConfigUI
- extends AltosDialog
- implements ActionListener, ItemListener, DocumentListener
+ extends AltosUIDialog
+ implements ActionListener, ItemListener, DocumentListener, AltosConfigValues
{
Container pane;
- Box box;
JLabel product_label;
JLabel version_label;
JLabel serial_label;
@@ -49,6 +40,7 @@ public class AltosConfigUI
JLabel radio_calibration_label;
JLabel radio_frequency_label;
JLabel radio_enable_label;
+ JLabel aprs_interval_label;
JLabel flight_log_max_label;
JLabel ignite_mode_label;
JLabel pad_orientation_label;
@@ -66,16 +58,21 @@ public class AltosConfigUI
AltosFreqList radio_frequency_value;
JTextField radio_calibration_value;
JRadioButton radio_enable_value;
+ JComboBox aprs_interval_value;
JComboBox flight_log_max_value;
JComboBox ignite_mode_value;
JComboBox pad_orientation_value;
JTextField callsign_value;
+ JButton pyro;
+
JButton save;
JButton reset;
JButton reboot;
JButton close;
+ AltosPyro[] pyros;
+
ActionListener listener;
static String[] main_deploy_values = {
@@ -103,6 +100,13 @@ public class AltosConfigUI
"Redundant Main",
};
+ static String[] aprs_interval_values = {
+ "Disabled",
+ "2",
+ "5",
+ "10"
+ };
+
static String[] pad_orientation_values = {
"Antenna Up",
"Antenna Down",
@@ -147,6 +151,13 @@ public class AltosConfigUI
radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
}
+ void set_aprs_interval_tool_tip() {
+ if (aprs_interval_value.isEnabled())
+ aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports");
+ else
+ aprs_interval_value.setToolTipText("Hardware doesn't support APRS");
+ }
+
void set_flight_log_max_tool_tip() {
if (flight_log_max_value.isEnabled())
flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)");
@@ -399,7 +410,7 @@ public class AltosConfigUI
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
c.ipady = 5;
- radio_enable_label = new JLabel("Telemetry/RDF Enable:");
+ radio_enable_label = new JLabel("Telemetry/RDF/APRS Enable:");
pane.add(radio_enable_label, c);
c = new GridBagConstraints();
@@ -416,6 +427,32 @@ public class AltosConfigUI
set_radio_enable_tool_tip();
row++;
+ /* APRS interval */
+ c = new GridBagConstraints();
+ c.gridx = 0; c.gridy = row;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ c.ipady = 5;
+ aprs_interval_label = new JLabel("APRS Interval(s):");
+ pane.add(aprs_interval_label, c);
+
+ c = new GridBagConstraints();
+ c.gridx = 4; c.gridy = row;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = ir;
+ c.ipady = 5;
+ aprs_interval_value = new JComboBox(aprs_interval_values);
+ aprs_interval_value.setEditable(true);
+ aprs_interval_value.addItemListener(this);
+ pane.add(aprs_interval_value, c);
+ set_aprs_interval_tool_tip();
+ row++;
+
/* Callsign */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = row;
@@ -519,6 +556,20 @@ public class AltosConfigUI
set_pad_orientation_tool_tip();
row++;
+ /* Pyro channels */
+ c = new GridBagConstraints();
+ c.gridx = 4; c.gridy = row;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ c.ipady = 5;
+ pyro = new JButton("Configure Pyro Channels");
+ pane.add(pyro, c);
+ pyro.addActionListener(this);
+ pyro.setActionCommand("Pyro");
+ row++;
+
/* Buttons */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = row;
@@ -591,10 +642,30 @@ public class AltosConfigUI
return true;
}
+ void set_dirty() {
+ dirty = true;
+ save.setEnabled(true);
+ }
+
+ public void set_clean() {
+ dirty = false;
+ save.setEnabled(false);
+ }
+
+ AltosConfigPyroUI pyro_ui;
+
/* Listen for events from our buttons */
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
+ if (cmd.equals("Pyro")) {
+ if (pyro_ui == null && pyros != null) {
+ pyro_ui = new AltosConfigPyroUI(this, pyros);
+ pyro_ui.make_visible();
+ }
+ return;
+ }
+
if (cmd.equals("Close") || cmd.equals("Reboot"))
if (!check_dirty(cmd))
return;
@@ -603,25 +674,25 @@ public class AltosConfigUI
setVisible(false);
dispose();
}
- dirty = false;
+ set_clean();
}
/* ItemListener interface method */
public void itemStateChanged(ItemEvent e) {
- dirty = true;
+ set_dirty();
}
/* DocumentListener interface methods */
public void changedUpdate(DocumentEvent e) {
- dirty = true;
+ set_dirty();
}
public void insertUpdate(DocumentEvent e) {
- dirty = true;
+ set_dirty();
}
public void removeUpdate(DocumentEvent e) {
- dirty = true;
+ set_dirty();
}
/* Let the config code hook on a listener */
@@ -648,6 +719,7 @@ public class AltosConfigUI
public void set_main_deploy(int new_main_deploy) {
main_deploy_value.setSelectedItem(Integer.toString(new_main_deploy));
+ main_deploy_value.setEnabled(new_main_deploy >= 0);
}
public int main_deploy() {
@@ -656,6 +728,7 @@ public class AltosConfigUI
public void set_apogee_delay(int new_apogee_delay) {
apogee_delay_value.setSelectedItem(Integer.toString(new_apogee_delay));
+ apogee_delay_value.setEnabled(new_apogee_delay >= 0);
}
public int apogee_delay() {
@@ -664,6 +737,7 @@ public class AltosConfigUI
public void set_apogee_lockout(int new_apogee_lockout) {
apogee_lockout_value.setSelectedItem(Integer.toString(new_apogee_lockout));
+ apogee_lockout_value.setEnabled(new_apogee_lockout >= 0);
}
public int apogee_lockout() {
@@ -734,8 +808,7 @@ public class AltosConfigUI
}
public void set_flight_log_max(int new_flight_log_max) {
- if (new_flight_log_max == 0)
- flight_log_max_value.setEnabled(false);
+ flight_log_max_value.setEnabled(new_flight_log_max > 0);
flight_log_max_value.setSelectedItem(Integer.toString(new_flight_log_max));
set_flight_log_max_tool_tip();
}
@@ -750,12 +823,12 @@ public class AltosConfigUI
}
public void set_flight_log_max_limit(int flight_log_max_limit) {
- boolean any_added = false;
+ //boolean any_added = false;
flight_log_max_value.removeAllItems();
for (int i = 0; i < flight_log_max_values.length; i++) {
if (Integer.parseInt(flight_log_max_values[i]) < flight_log_max_limit){
flight_log_max_value.addItem(flight_log_max_values[i]);
- any_added = true;
+ //any_added = true;
}
}
flight_log_max_value.addItem(String.format("%d", flight_log_max_limit));
@@ -802,7 +875,36 @@ public class AltosConfigUI
return -1;
}
- public void set_clean() {
- dirty = false;
+ public void set_pyros(AltosPyro[] new_pyros) {
+ pyros = new_pyros;
+ pyro.setEnabled(pyros != null);
+ if (pyros != null && pyro_ui != null)
+ pyro_ui.set_pyros(pyros);
+ }
+
+ public AltosPyro[] pyros() {
+ if (pyro_ui != null)
+ pyros = pyro_ui.get_pyros();
+ return pyros;
+ }
+
+ public void set_aprs_interval(int new_aprs_interval) {
+ String s;
+
+ if (new_aprs_interval <= 0)
+ s = "Disabled";
+ else
+ s = Integer.toString(new_aprs_interval);
+ aprs_interval_value.setSelectedItem(s);
+ aprs_interval_value.setEnabled(new_aprs_interval >= 0);
+ set_aprs_interval_tool_tip();
+ }
+
+ public int aprs_interval() {
+ String s = aprs_interval_value.getSelectedItem().toString();
+
+ if (s.equals("Disabled"))
+ return 0;
+ return Integer.parseInt(s);
}
}
diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java
index 249fc35a..5e42f430 100644
--- a/altosui/AltosConfigureUI.java
+++ b/altosui/AltosConfigureUI.java
@@ -21,96 +21,19 @@ import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import javax.swing.event.*;
-import java.io.*;
-import java.util.*;
-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 {
-
- // ...
- public static void install(JComboBox comboBox) {
- DelegatingRenderer renderer = new DelegatingRenderer(comboBox);
- renderer.initialise();
- comboBox.setRenderer(renderer);
- }
-
- // ...
- private final JComboBox comboBox;
-
- // ...
- private ListCellRenderer delegate;
-
- // ...
- private DelegatingRenderer(JComboBox comboBox) {
- this.comboBox = comboBox;
- }
-
- // ...
- private void initialise() {
- delegate = new JComboBox().getRenderer();
- comboBox.addPropertyChangeListener("UI", new PropertyChangeListener() {
-
- public void propertyChange(PropertyChangeEvent evt) {
- delegate = new JComboBox().getRenderer();
- }
- });
- }
-
- // ...
- public Component getListCellRendererComponent(JList list,
- Object value, int index, boolean isSelected, boolean cellHasFocus) {
-
- return delegate.getListCellRendererComponent(list,
- ((UIManager.LookAndFeelInfo) value).getName(),
- index, isSelected, cellHasFocus);
- }
-}
+import org.altusmetrum.altosuilib_1.*;
public class AltosConfigureUI
- extends AltosDialog
+ extends AltosUIConfigure
implements DocumentListener
{
- JFrame owner;
AltosVoice voice;
- Container pane;
-
- JRadioButton enable_voice;
- JButton test_voice;
- JButton close;
-
- JButton configure_log;
- JTextField log_directory;
-
- JLabel callsign_label;
- JTextField callsign_value;
-
- JRadioButton imperial_units;
-
- JLabel font_size_label;
- JComboBox font_size_value;
- JLabel look_and_feel_label;
- JComboBox look_and_feel_value;
-
- JRadioButton serial_debug;
-
- JButton manage_bluetooth;
- JButton manage_frequencies;
-
- final static String[] font_size_names = { "Small", "Medium", "Large" };
+ public JTextField callsign_value;
+ public JComboBox position_value;
/* DocumentListener interface methods */
- public void changedUpdate(DocumentEvent e) {
- AltosUIPreferences.set_callsign(callsign_value.getText());
- }
-
public void insertUpdate(DocumentEvent e) {
changedUpdate(e);
}
@@ -119,49 +42,17 @@ public class AltosConfigureUI
changedUpdate(e);
}
- public AltosConfigureUI(JFrame in_owner, AltosVoice in_voice) {
- super(in_owner, "Configure AltosUI", false);
-
- GridBagConstraints c;
-
- Insets insets = new Insets(4, 4, 4, 4);
-
- int row = 0;
-
- owner = in_owner;
- voice = in_voice;
- pane = getContentPane();
- pane.setLayout(new GridBagLayout());
-
- c = new GridBagConstraints();
- c.insets = insets;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
-
- /* Nice label at the top */
- c.gridx = 0;
- c.gridy = row++;
- c.gridwidth = 3;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.CENTER;
- pane.add(new JLabel ("Configure AltOS UI"), c);
+ public void changedUpdate(DocumentEvent e) {
+ if (callsign_value != null)
+ AltosUIPreferences.set_callsign(callsign_value.getText());
+ }
- c.gridx = 0;
- c.gridy = row++;
- c.gridwidth = 3;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.CENTER;
- pane.add(new JLabel (String.format("AltOS version %s", AltosVersion.version)), c);
+ public void add_voice() {
/* Voice settings */
- c.gridx = 0;
- c.gridy = row;
- c.gridwidth = 1;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- pane.add(new JLabel("Voice"), c);
+ pane.add(new JLabel("Voice"), constraints(0, 1));
- enable_voice = new JRadioButton("Enable", AltosUIPreferences.voice());
+ JRadioButton enable_voice = new JRadioButton("Enable", AltosUIPreferences.voice());
enable_voice.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JRadioButton item = (JRadioButton) e.getSource();
@@ -173,244 +64,87 @@ public class AltosConfigureUI
voice.speak_always("Disable voice.");
}
});
- c.gridx = 1;
- c.gridy = row;
- c.gridwidth = 1;
- c.weightx = 1;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- pane.add(enable_voice, c);
+ pane.add(enable_voice, constraints(1, 1));
enable_voice.setToolTipText("Enable/Disable all audio in-flight announcements");
- c.gridx = 2;
- c.gridy = row++;
- c.gridwidth = 1;
- c.weightx = 1;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.EAST;
- test_voice = new JButton("Test Voice");
+ JButton test_voice = new JButton("Test Voice");
test_voice.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
voice.speak("That's one small step for man; one giant leap for mankind.");
}
});
- pane.add(test_voice, c);
+ pane.add(test_voice, constraints(2, 1));
test_voice.setToolTipText("Play a stock audio clip to check volume");
+ row++;
+ }
- /* Log directory settings */
- c.gridx = 0;
- c.gridy = row;
- c.gridwidth = 1;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- pane.add(new JLabel("Log Directory"), c);
-
- configure_log = new JButton(AltosUIPreferences.logdir().getPath());
- configure_log.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- AltosUIPreferences.ConfigureLog();
- configure_log.setText(AltosUIPreferences.logdir().getPath());
- }
- });
- c.gridx = 1;
- c.gridy = row++;
- c.gridwidth = 2;
- c.fill = GridBagConstraints.BOTH;
- c.anchor = GridBagConstraints.WEST;
- pane.add(configure_log, c);
- configure_log.setToolTipText("Which directory flight logs are stored in");
-
+ public void add_callsign() {
/* Callsign setting */
- c.gridx = 0;
- c.gridy = row;
- c.gridwidth = 1;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- pane.add(new JLabel("Callsign"), c);
+ pane.add(new JLabel("Callsign"), constraints(0, 1));
callsign_value = new JTextField(AltosUIPreferences.callsign());
callsign_value.getDocument().addDocumentListener(this);
- c.gridx = 1;
- c.gridy = row++;
- c.gridwidth = 2;
- c.fill = GridBagConstraints.BOTH;
- c.anchor = GridBagConstraints.WEST;
- pane.add(callsign_value, c);
callsign_value.setToolTipText("Callsign sent in packet mode");
+ pane.add(callsign_value, constraints(1, 2, GridBagConstraints.BOTH));
+ row++;
+ }
- /* Imperial units setting */
- c.gridx = 0;
- c.gridy = row;
- c.gridwidth = 1;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- pane.add(new JLabel("Imperial Units"), c);
-
- imperial_units = new JRadioButton("Enable", AltosUIPreferences.imperial_units());
- imperial_units.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- JRadioButton item = (JRadioButton) e.getSource();
- boolean enabled = item.isSelected();
- AltosUIPreferences.set_imperial_units(enabled);
- }
- });
- imperial_units.setToolTipText("Use Imperial units instead of metric");
-
- c.gridx = 1;
- c.gridy = row++;
- c.gridwidth = 3;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- pane.add(imperial_units, c);
-
- /* Font size setting */
- c.gridx = 0;
- c.gridy = row;
- c.gridwidth = 1;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- pane.add(new JLabel("Font size"), c);
-
- font_size_value = new JComboBox(font_size_names);
- int font_size = AltosUIPreferences.font_size();
- font_size_value.setSelectedIndex(font_size - Altos.font_size_small);
- font_size_value.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- int size = font_size_value.getSelectedIndex() + Altos.font_size_small;
-
- AltosUIPreferences.set_font_size(size);
- }
- });
- c.gridx = 1;
- c.gridy = row++;
- c.gridwidth = 2;
- c.fill = GridBagConstraints.BOTH;
- c.anchor = GridBagConstraints.WEST;
- pane.add(font_size_value, c);
- font_size_value.setToolTipText("Font size used in telemetry window");
-
- /* Look & Feel setting */
- c.gridx = 0;
- c.gridy = row;
- c.gridwidth = 1;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- pane.add(new JLabel("Look & feel"), c);
-
- class LookAndFeelRenderer extends BasicComboBoxRenderer implements ListCellRenderer {
-
- public LookAndFeelRenderer() {
- super();
- }
-
- public Component getListCellRendererComponent(
- JList list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus)
- {
- super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- setText(((UIManager.LookAndFeelInfo) value).getName());
- return this;
- }
- }
-
- final UIManager.LookAndFeelInfo[] look_and_feels = UIManager.getInstalledLookAndFeels();
-
- look_and_feel_value = new JComboBox(look_and_feels);
-
- DelegatingRenderer.install(look_and_feel_value);
-
- String look_and_feel = AltosUIPreferences.look_and_feel();
- for (int i = 0; i < look_and_feels.length; i++)
- if (look_and_feel.equals(look_and_feels[i].getClassName()))
- look_and_feel_value.setSelectedIndex(i);
-
- look_and_feel_value.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- int id = look_and_feel_value.getSelectedIndex();
-
- AltosUIPreferences.set_look_and_feel(look_and_feels[id].getClassName());
- }
- });
- c.gridx = 1;
- c.gridy = row++;
- c.gridwidth = 2;
- c.fill = GridBagConstraints.BOTH;
- c.anchor = GridBagConstraints.WEST;
- pane.add(look_and_feel_value, c);
- look_and_feel_value.setToolTipText("Look&feel used for new windows");
-
- /* Serial debug setting */
- c.gridx = 0;
- c.gridy = row;
- c.gridwidth = 1;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- pane.add(new JLabel("Serial Debug"), c);
-
- serial_debug = new JRadioButton("Enable", AltosUIPreferences.serial_debug());
- serial_debug.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- JRadioButton item = (JRadioButton) e.getSource();
- boolean enabled = item.isSelected();
- AltosUIPreferences.set_serial_debug(enabled);
- }
- });
- serial_debug.setToolTipText("Enable/Disable USB I/O getting sent to the console");
-
- c.gridx = 1;
- c.gridy = row++;
- c.gridwidth = 3;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- pane.add(serial_debug, c);
-
- manage_bluetooth = new JButton("Manage Bluetooth");
+ public void add_bluetooth() {
+ JButton manage_bluetooth = new JButton("Manage Bluetooth");
manage_bluetooth.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AltosBTManage.show(owner, AltosBTKnown.bt_known());
}
});
- c.gridx = 0;
- c.gridy = row;
- c.gridwidth = 2;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- pane.add(manage_bluetooth, c);
+ pane.add(manage_bluetooth, constraints(0, 2));
+ /* in the same row as add_frequencies, so don't bump row */
+ }
- manage_frequencies = new JButton("Manage Frequencies");
+ public void add_frequencies() {
+ JButton manage_frequencies = new JButton("Manage Frequencies");
manage_frequencies.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AltosConfigFreqUI.show(owner);
}
});
manage_frequencies.setToolTipText("Configure which values are shown in frequency menus");
- c.gridx = 2;
- c.gridx = 2;
- c.gridy = row++;
- c.gridwidth = 2;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.WEST;
- pane.add(manage_frequencies, c);
+ pane.add(manage_frequencies, constraints(2, 1));
+ row++;
+ }
- /* And a close button at the bottom */
- close = new JButton("Close");
- close.addActionListener(new ActionListener() {
+ final static String[] position_names = {
+ "Top left",
+ "Top",
+ "Top right",
+ "Left",
+ "Center",
+ "Right",
+ "Bottom left",
+ "Bottom",
+ "Bottom right",
+ };
+
+ public void add_position() {
+ pane.add(new JLabel ("Menu position"), constraints(0, 1));
+
+ position_value = new JComboBox (position_names);
+ position_value.setMaximumRowCount(position_names.length);
+ int position = AltosUIPreferences.position();
+ position_value.setSelectedIndex(position);
+ position_value.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- setVisible(false);
+ int position = position_value.getSelectedIndex();
+ AltosUIPreferences.set_position(position);
}
});
- c.gridx = 0;
- c.gridy = row++;
- c.gridwidth = 3;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.CENTER;
- pane.add(close, c);
+ pane.add(position_value, constraints(1, 2, GridBagConstraints.BOTH));
+ position_value.setToolTipText("Position of main AltosUI window");
+ row++;
+ }
+
+ public AltosConfigureUI(JFrame owner, AltosVoice voice) {
+ super(owner);
- pack();
- setLocationRelativeTo(owner);
- setVisible(true);
+ this.voice = voice;
}
}
diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java
index 4bd51c39..f914f138 100644
--- a/altosui/AltosDataChooser.java
+++ b/altosui/AltosDataChooser.java
@@ -17,16 +17,11 @@
package altosui;
-import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosDataChooser extends JFileChooser {
JFrame frame;
@@ -76,6 +71,12 @@ public class AltosDataChooser extends JFileChooser {
public AltosDataChooser(JFrame in_frame) {
frame = in_frame;
setDialogTitle("Select Flight Record File");
+ setFileFilter(new FileNameExtensionFilter("TeleMetrum eeprom file",
+ "eeprom"));
+ setFileFilter(new FileNameExtensionFilter("Telemetry file",
+ "telem"));
+ setFileFilter(new FileNameExtensionFilter("TeleMega eeprom file",
+ "mega"));
setFileFilter(new FileNameExtensionFilter("Flight data file",
"telem", "eeprom", "mega"));
setCurrentDirectory(AltosUIPreferences.logdir());
diff --git a/altosui/AltosDataPoint.java b/altosui/AltosDataPoint.java
deleted file mode 100644
index 5e077320..00000000
--- a/altosui/AltosDataPoint.java
+++ /dev/null
@@ -1,30 +0,0 @@
-
-// Copyright (c) 2010 Anthony Towns
-// GPL v2 or later
-
-package altosui;
-
-interface AltosDataPoint {
- int version();
- int serial();
- int flight();
- String callsign();
- double time();
- double rssi();
-
- int state();
- String state_name();
-
- double acceleration();
- double pressure();
- double altitude();
- double height();
- double accel_speed();
- double baro_speed();
- double temperature();
- double battery_voltage();
- double drogue_voltage();
- double main_voltage();
- boolean has_accel();
-}
-
diff --git a/altosui/AltosDataPointReader.java b/altosui/AltosDataPointReader.java
deleted file mode 100644
index 821b0771..00000000
--- a/altosui/AltosDataPointReader.java
+++ /dev/null
@@ -1,86 +0,0 @@
-
-// Copyright (c) 2010 Anthony Towns
-// GPL v2 or later
-
-package altosui;
-
-import java.io.IOException;
-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;
- AltosState state;
- AltosRecord record;
- boolean has_gps;
- boolean has_accel;
- boolean has_ignite;
-
- final static int MISSING = AltosRecord.MISSING;
-
- public AltosDataPointReader(AltosRecordIterable reader) {
- this.iter = reader.iterator();
- this.state = null;
- has_accel = reader.has_accel();
- has_gps = reader.has_gps();
- has_ignite = reader.has_ignite();
- }
-
- private void read_next_record()
- throws NoSuchElementException
- {
- record = iter.next();
- state = new AltosState(record, state);
- }
-
- private AltosDataPoint current_dp() {
- assert this.record != null;
-
- return new AltosDataPoint() {
- public int version() { return record.version; }
- public int serial() { return record.serial; }
- public int flight() { return record.flight; }
- public String callsign() { return record.callsign; }
- public double time() { return record.time; }
- public double rssi() { return record.rssi; }
-
- public int state() { return record.state; }
- public String state_name() { return record.state(); }
-
- public double acceleration() { return record.acceleration(); }
- public double pressure() { return record.raw_pressure(); }
- public double altitude() { return record.raw_altitude(); }
- public double height() { return record.raw_height(); }
- public double accel_speed() { return record.accel_speed(); }
- public double baro_speed() { return state.baro_speed; }
- public double temperature() { return record.temperature(); }
- public double battery_voltage() { return record.battery_voltage(); }
- public double drogue_voltage() { return record.drogue_voltage(); }
- public double main_voltage() { return record.main_voltage(); }
- public boolean has_accel() { return has_accel; }
- };
- }
-
- public Iterator<AltosDataPoint> iterator() {
- return new Iterator<AltosDataPoint>() {
- public void remove() {
- throw new UnsupportedOperationException();
- }
- public boolean hasNext() {
- if (record != null && record.state == Altos.ao_flight_landed)
- return false;
- return iter.hasNext();
- }
- public AltosDataPoint next() {
- do {
- read_next_record();
- } while (record.time < -1.0 && hasNext());
- return current_dp();
- }
- };
- }
-}
-
diff --git a/altosui/AltosDebug.java b/altosui/AltosDebug.java
deleted file mode 100644
index 23e38bc0..00000000
--- a/altosui/AltosDebug.java
+++ /dev/null
@@ -1,280 +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.lang.*;
-import java.io.*;
-import java.util.concurrent.*;
-import java.util.*;
-import org.altusmetrum.AltosLib.*;
-
-import libaltosJNI.*;
-
-public class AltosDebug extends AltosSerial {
-
- public static final byte WR_CONFIG = 0x1d;
- public static final byte RD_CONFIG = 0x24;
- public static final byte CONFIG_TIMERS_OFF = (1 << 3);
- public static final byte CONFIG_DMA_PAUSE = (1 << 2);
- public static final byte CONFIG_TIMER_SUSPEND = (1 << 1);
- public static final byte SET_FLASH_INFO_PAGE = (1 << 0);
-
- public static final byte GET_PC = 0x28;
- public static final byte READ_STATUS = 0x34;
- public static final byte STATUS_CHIP_ERASE_DONE = (byte) (1 << 7);
- public static final byte STATUS_PCON_IDLE = (1 << 6);
- public static final byte STATUS_CPU_HALTED = (1 << 5);
- public static final byte STATUS_POWER_MODE_0 = (1 << 4);
- public static final byte STATUS_HALT_STATUS = (1 << 3);
- public static final byte STATUS_DEBUG_LOCKED = (1 << 2);
- public static final byte STATUS_OSCILLATOR_STABLE = (1 << 1);
- public static final byte STATUS_STACK_OVERFLOW = (1 << 0);
-
- public static final byte SET_HW_BRKPNT = 0x3b;
- public static byte HW_BRKPNT_N(byte n) { return (byte) ((n) << 3); }
- public static final byte HW_BRKPNT_N_MASK = (0x3 << 3);
- public static final byte HW_BRKPNT_ENABLE = (1 << 2);
-
- public static final byte HALT = 0x44;
- public static final byte RESUME = 0x4c;
- public static byte DEBUG_INSTR(byte n) { return (byte) (0x54|(n)); }
- public static final byte STEP_INSTR = 0x5c;
- public static byte STEP_REPLACE(byte n) { return (byte) (0x64|(n)); }
- public static final byte GET_CHIP_ID = 0x68;
-
-
- boolean debug_mode;
-
- void ensure_debug_mode() {
- if (!debug_mode) {
- printf("D\n");
- try {
- flush_input();
- } catch (InterruptedException ie) {
- }
- debug_mode = true;
- }
- }
-
- void dump_memory(String header, int address, byte[] bytes, int start, int len) {
- System.out.printf("%s\n", header);
- for (int j = 0; j < len; j++) {
- if ((j & 15) == 0) {
- if (j != 0)
- System.out.printf("\n");
- System.out.printf ("%04x:", address + j);
- }
- System.out.printf(" %02x", bytes[start + j]);
- }
- System.out.printf("\n");
- }
-
- /*
- * Write target memory
- */
- public void write_memory(int address, byte[] bytes, int start, int len) {
- ensure_debug_mode();
-// dump_memory("write_memory", address, bytes, start, len);
- printf("O %x %x\n", len, address);
- for (int i = 0; i < len; i++)
- printf("%02x", bytes[start + i]);
- }
-
- public void write_memory(int address, byte[] bytes) {
- write_memory(address, bytes, 0, bytes.length);
- }
-
- /*
- * Read target memory
- */
- public byte[] read_memory(int address, int length)
- throws IOException, InterruptedException {
- byte[] data = new byte[length];
-
- flush_input();
- ensure_debug_mode();
- printf("I %x %x\n", length, address);
- int i = 0;
- int start = 0;
- while (i < length) {
- String line = get_reply().trim();
- if (!Altos.ishex(line) || line.length() % 2 != 0)
- throw new IOException(
- String.format
- ("Invalid reply \"%s\"", line));
- int this_time = line.length() / 2;
- for (int j = 0; j < this_time; j++)
- data[start + j] = (byte) ((Altos.fromhex(line.charAt(j*2)) << 4) +
- Altos.fromhex(line.charAt(j*2+1)));
- start += this_time;
- i += this_time;
- }
-// dump_memory("read_memory", address, data, 0, length);
-
- return data;
- }
-
- /*
- * Write raw bytes to the debug link using the 'P' command
- */
- public void write_bytes(byte[] bytes) throws IOException {
- int i = 0;
- ensure_debug_mode();
- while (i < bytes.length) {
- int this_time = bytes.length - i;
- if (this_time > 8)
- this_time = 0;
- printf("P");
- for (int j = 0; j < this_time; j++)
- printf(" %02x", bytes[i+j]);
- printf("\n");
- i += this_time;
- }
- }
-
- public void write_byte(byte b) throws IOException {
- byte[] bytes = { b };
- write_bytes(bytes);
- }
-
- /*
- * Read raw bytes from the debug link using the 'G' command
- */
- public byte[] read_bytes(int length)
- throws IOException, InterruptedException {
-
- flush_input();
- ensure_debug_mode();
- printf("G %x\n", length);
- int i = 0;
- byte[] data = new byte[length];
- while (i < length) {
- String line = get_reply();
-
- if (line == null)
- throw new IOException("Timeout in read_bytes");
- line = line.trim();
- String tokens[] = line.split("\\s+");
- for (int j = 0; j < tokens.length; j++) {
- if (!Altos.ishex(tokens[j]) ||
- tokens[j].length() != 2)
- throw new IOException(
- String.format
- ("Invalid read_bytes reply \"%s\"", line));
- try {
- if (i + j >= length)
- throw new IOException(
- String.format
- ("Invalid read_bytes reply \"%s\"", line));
- else
- data[i + j] = (byte) Integer.parseInt(tokens[j], 16);
- } catch (NumberFormatException ne) {
- throw new IOException(
- String.format
- ("Invalid read_bytes reply \"%s\"", line));
- }
- }
- i += tokens.length;
- }
- return data;
- }
-
- public byte read_byte() throws IOException, InterruptedException {
- return read_bytes(1)[0];
- }
-
- public byte debug_instr(byte[] instruction) throws IOException, InterruptedException {
- byte[] command = new byte[1 + instruction.length];
- command[0] = DEBUG_INSTR((byte) instruction.length);
- for (int i = 0; i < instruction.length; i++)
- command[i+1] = instruction[i];
- write_bytes(command);
- return read_byte();
- }
-
- public byte resume() throws IOException, InterruptedException {
- write_byte(RESUME);
- return read_byte();
- }
-
- public int read_uint16() throws IOException, InterruptedException {
- byte[] d = read_bytes(2);
- return ((int) (d[0] & 0xff) << 8) | (d[1] & 0xff);
- }
-
- public int read_uint8() throws IOException, InterruptedException {
- byte[] d = read_bytes(1);
- return (int) (d[0] & 0xff);
- }
-
- public int get_chip_id() throws IOException, InterruptedException {
- write_byte(GET_CHIP_ID);
- return read_uint16();
- }
-
- public int get_pc() throws IOException, InterruptedException {
- write_byte(GET_PC);
- return read_uint16();
- }
-
- public byte read_status() throws IOException, InterruptedException {
- write_byte(READ_STATUS);
- return read_byte();
- }
-
- static final byte LJMP = 0x02;
-
- public void set_pc(int pc) throws IOException, InterruptedException {
- byte high = (byte) (pc >> 8);
- byte low = (byte) pc;
- byte[] jump_mem = { LJMP, high, low };
- debug_instr(jump_mem);
- }
-
- public boolean check_connection() throws IOException, InterruptedException {
- byte reply = read_status();
- if ((reply & STATUS_CHIP_ERASE_DONE) == 0)
- return false;
- if ((reply & STATUS_PCON_IDLE) != 0)
- return false;
- if ((reply & STATUS_POWER_MODE_0) == 0)
- return false;
- return true;
- }
-
- public AltosRomconfig romconfig() {
- try {
- byte[] bytes = read_memory(0xa0, 10);
- return new AltosRomconfig(bytes, 0);
- } catch (IOException ie) {
- } catch (InterruptedException ie) {
- }
- return new AltosRomconfig();
- }
-
- /*
- * Reset target
- */
- public void reset() {
- printf ("R\n");
- }
-
- public AltosDebug (AltosDevice in_device) throws FileNotFoundException, AltosSerialInUseException {
- super(in_device);
- }
-} \ No newline at end of file
diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java
index 2fe7d544..29d33ddc 100644
--- a/altosui/AltosDescent.java
+++ b/altosui/AltosDescent.java
@@ -18,16 +18,8 @@
package altosui;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosDescent extends JComponent implements AltosFlightDisplay {
GridBagLayout layout;
@@ -37,7 +29,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
JTextField value;
AltosLights lights;
- abstract void show(AltosState state, int crc_errors);
+ abstract void show(AltosState state, AltosListenerState listener_state);
void show() {
label.setVisible(true);
@@ -116,7 +108,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
value.setText("");
}
- abstract void show(AltosState state, int crc_errors);
+ abstract void show(AltosState state, AltosListenerState listener_state);
void show() {
label.setVisible(true);
@@ -200,7 +192,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
value2.setFont(Altos.value_font);
}
- abstract void show(AltosState state, int crc_errors);
+ abstract void show(AltosState state, AltosListenerState listener_state);
void show(String v1, String v2) {
show();
@@ -252,7 +244,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
}
class Height extends DescentValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show(AltosConvert.height, state.height);
}
public Height (GridBagLayout layout, int x, int y) {
@@ -263,8 +255,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
Height height;
class Speed extends DescentValue {
- void show (AltosState state, int crc_errors) {
- double speed = state.speed;
+ void show (AltosState state, AltosListenerState listener_state) {
+ double speed = state.accel_speed;
if (!state.ascent)
speed = state.baro_speed;
show(AltosConvert.speed, speed);
@@ -288,7 +280,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
}
class Lat extends DescentValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
if (state.gps != null && state.gps.connected)
show(pos(state.gps.lat,"N", "S"));
else
@@ -302,7 +294,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
Lat lat;
class Lon extends DescentValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
if (state.gps != null && state.gps.connected)
show(pos(state.gps.lon,"W", "E"));
else
@@ -316,8 +308,11 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
Lon lon;
class Distance extends DescentValue {
- void show(AltosState state, int crc_errors) {
- show(AltosConvert.distance, state.from_pad.distance);
+ void show(AltosState state, AltosListenerState listener_state) {
+ if (state.from_pad != null)
+ show(AltosConvert.distance, state.from_pad.distance);
+ else
+ show("???");
}
public Distance (GridBagLayout layout, int x, int y) {
@@ -329,7 +324,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
class Apogee extends DescentStatus {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show("%4.2f V", state.drogue_sense);
lights.set(state.drogue_sense > 3.2);
}
@@ -341,7 +336,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
Apogee apogee;
class Main extends DescentStatus {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show("%4.2f V", state.main_sense);
lights.set(state.main_sense > 3.2);
}
@@ -353,7 +348,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
Main main;
class Bearing extends DescentDualValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
if (state.from_pad != null) {
show( String.format("%3.0f°", state.from_pad.bearing),
state.from_pad.bearing_words(
@@ -370,7 +365,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
Bearing bearing;
class Range extends DescentValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show(AltosConvert.distance, state.range);
}
public Range (GridBagLayout layout, int x, int y) {
@@ -381,7 +376,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
Range range;
class Elevation extends DescentValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show("%3.0f°", state.elevation);
}
public Elevation (GridBagLayout layout, int x, int y) {
@@ -417,16 +412,16 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
apogee.set_font();
}
- public void show(AltosState state, int crc_errors) {
- height.show(state, crc_errors);
- speed.show(state, crc_errors);
+ public void show(AltosState state, AltosListenerState listener_state) {
+ height.show(state, listener_state);
+ speed.show(state, listener_state);
if (state.gps != null && state.gps.connected) {
- bearing.show(state, crc_errors);
- range.show(state, crc_errors);
- distance.show(state, crc_errors);
- elevation.show(state, crc_errors);
- lat.show(state, crc_errors);
- lon.show(state, crc_errors);
+ bearing.show(state, listener_state);
+ range.show(state, listener_state);
+ distance.show(state, listener_state);
+ elevation.show(state, listener_state);
+ lat.show(state, listener_state);
+ lon.show(state, listener_state);
} else {
bearing.hide();
range.hide();
@@ -436,15 +431,19 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
lon.hide();
}
if (state.main_sense != AltosRecord.MISSING)
- main.show(state, crc_errors);
+ main.show(state, listener_state);
else
main.hide();
if (state.drogue_sense != AltosRecord.MISSING)
- apogee.show(state, crc_errors);
+ apogee.show(state, listener_state);
else
apogee.hide();
}
+ public String getName() {
+ return "Descent";
+ }
+
public AltosDescent() {
layout = new GridBagLayout();
diff --git a/altosui/AltosDevice.java b/altosui/AltosDevice.java
index 1b5c1a91..d1bc5fd7 100644
--- a/altosui/AltosDevice.java
+++ b/altosui/AltosDevice.java
@@ -16,8 +16,6 @@
*/
package altosui;
-import java.lang.*;
-import java.util.*;
import libaltosJNI.*;
public interface AltosDevice {
diff --git a/altosui/AltosDeviceDialog.java b/altosui/AltosDeviceDialog.java
deleted file mode 100644
index fa9d0013..00000000
--- a/altosui/AltosDeviceDialog.java
+++ /dev/null
@@ -1,188 +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.lang.*;
-import java.util.*;
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.*;
-import libaltosJNI.*;
-
-public class AltosDeviceDialog extends AltosDialog implements ActionListener {
-
- private AltosDevice value;
- private JList list;
- private JButton cancel_button;
- private JButton select_button;
- private JButton manage_bluetooth_button;
- private Frame frame;
- private int product;
-
- private AltosDevice getValue() {
- return value;
- }
-
- private AltosDevice[] devices() {
- java.util.List<AltosDevice> usb_devices = AltosUSBDevice.list(product);
- int num_devices = usb_devices.size();
- java.util.List<AltosDevice> bt_devices = AltosBTKnown.bt_known().list(product);
- num_devices += bt_devices.size();
- AltosDevice[] devices = new AltosDevice[num_devices];
-
- for (int i = 0; i < usb_devices.size(); i++)
- devices[i] = usb_devices.get(i);
- int off = usb_devices.size();
- for (int j = 0; j < bt_devices.size(); j++)
- devices[off + j] = bt_devices.get(j);
- return devices;
- }
-
- private void update_devices() {
- AltosDevice[] devices = devices();
- list.setListData(devices);
- select_button.setEnabled(devices.length > 0);
- }
-
- private AltosDeviceDialog (Frame in_frame, Component location, int in_product) {
- super(in_frame, "Device Selection", true);
-
- product = in_product;
- frame = in_frame;
- value = null;
-
- AltosDevice[] devices = devices();
-
- cancel_button = new JButton("Cancel");
- cancel_button.setActionCommand("cancel");
- cancel_button.addActionListener(this);
-
- manage_bluetooth_button = new JButton("Manage Bluetooth");
- manage_bluetooth_button.setActionCommand("manage");
- manage_bluetooth_button.addActionListener(this);
-
- select_button = new JButton("Select");
- select_button.setActionCommand("select");
- select_button.addActionListener(this);
- if (devices.length == 0)
- select_button.setEnabled(false);
- getRootPane().setDefaultButton(select_button);
-
- list = new JList(devices) {
- //Subclass JList to workaround bug 4832765, which can cause the
- //scroll pane to not let the user easily scroll up to the beginning
- //of the list. An alternative would be to set the unitIncrement
- //of the JScrollBar to a fixed value. You wouldn't get the nice
- //aligned scrolling, but it should work.
- public int getScrollableUnitIncrement(Rectangle visibleRect,
- int orientation,
- int direction) {
- int row;
- if (orientation == SwingConstants.VERTICAL &&
- direction < 0 && (row = getFirstVisibleIndex()) != -1) {
- Rectangle r = getCellBounds(row, row);
- if ((r.y == visibleRect.y) && (row != 0)) {
- Point loc = r.getLocation();
- loc.y--;
- int prevIndex = locationToIndex(loc);
- Rectangle prevR = getCellBounds(prevIndex, prevIndex);
-
- if (prevR == null || prevR.y >= r.y) {
- return 0;
- }
- return prevR.height;
- }
- }
- return super.getScrollableUnitIncrement(
- visibleRect, orientation, direction);
- }
- };
-
- list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
- list.setVisibleRowCount(-1);
- list.addMouseListener(new MouseAdapter() {
- public void mouseClicked(MouseEvent e) {
- if (e.getClickCount() == 2) {
- select_button.doClick(); //emulate button click
- }
- }
- });
- JScrollPane listScroller = new JScrollPane(list);
- listScroller.setPreferredSize(new Dimension(400, 80));
- listScroller.setAlignmentX(LEFT_ALIGNMENT);
-
- //Create a container so that we can add a title around
- //the scroll pane. Can't add a title directly to the
- //scroll pane because its background would be white.
- //Lay out the label and scroll pane from top to bottom.
- JPanel listPane = new JPanel();
- listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
-
- JLabel label = new JLabel("Select Device");
- label.setLabelFor(list);
- listPane.add(label);
- listPane.add(Box.createRigidArea(new Dimension(0,5)));
- listPane.add(listScroller);
- listPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-
- //Lay out the buttons from left to right.
- JPanel buttonPane = new JPanel();
- buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
- buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
- buttonPane.add(Box.createHorizontalGlue());
- buttonPane.add(cancel_button);
- buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
- buttonPane.add(manage_bluetooth_button);
- buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
- buttonPane.add(select_button);
-
- //Put everything together, using the content pane's BorderLayout.
- Container contentPane = getContentPane();
- contentPane.add(listPane, BorderLayout.CENTER);
- contentPane.add(buttonPane, BorderLayout.PAGE_END);
-
- //Initialize values.
- if (devices != null && devices.length != 0)
- list.setSelectedValue(devices[0], true);
- pack();
- setLocationRelativeTo(location);
- }
-
- //Handle clicks on the Set and Cancel buttons.
- public void actionPerformed(ActionEvent e) {
- if ("select".equals(e.getActionCommand()))
- value = (AltosDevice)(list.getSelectedValue());
- if ("manage".equals(e.getActionCommand())) {
- AltosBTManage.show(frame, AltosBTKnown.bt_known());
- update_devices();
- return;
- }
- setVisible(false);
- }
-
- public static AltosDevice show (Component frameComp, int product) {
-
- Frame frame = JOptionPane.getFrameForComponent(frameComp);
- AltosDeviceDialog dialog;
-
- dialog = new AltosDeviceDialog(frame, frameComp, product);
- dialog.setVisible(true);
- return dialog.getValue();
- }
-}
diff --git a/altosui/AltosDeviceUIDialog.java b/altosui/AltosDeviceUIDialog.java
new file mode 100644
index 00000000..ceabe843
--- /dev/null
+++ b/altosui/AltosDeviceUIDialog.java
@@ -0,0 +1,70 @@
+/*
+ * 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 javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import org.altusmetrum.altosuilib_1.*;
+
+public class AltosDeviceUIDialog extends AltosDeviceDialog {
+
+ public AltosDevice[] devices() {
+ java.util.List<AltosDevice> usb_devices = AltosUSBDevice.list(product);
+ int num_devices = usb_devices.size();
+ java.util.List<AltosDevice> bt_devices = AltosBTKnown.bt_known().list(product);
+ num_devices += bt_devices.size();
+ AltosDevice[] devices = new AltosDevice[num_devices];
+
+ for (int i = 0; i < usb_devices.size(); i++)
+ devices[i] = usb_devices.get(i);
+ int off = usb_devices.size();
+ for (int j = 0; j < bt_devices.size(); j++)
+ devices[off + j] = bt_devices.get(j);
+ return devices;
+ }
+
+ public void add_bluetooth() {
+ JButton manage_bluetooth_button = new JButton("Manage Bluetooth");
+ manage_bluetooth_button.setActionCommand("manage");
+ manage_bluetooth_button.addActionListener(this);
+ buttonPane.add(manage_bluetooth_button);
+ buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ super.actionPerformed(e);
+ if ("manage".equals(e.getActionCommand())) {
+ AltosBTManage.show(frame, AltosBTKnown.bt_known());
+ update_devices();
+ }
+ }
+
+ public AltosDeviceUIDialog (Frame in_frame, Component location, int in_product) {
+ super(in_frame, location, in_product);
+ }
+
+ public static AltosDevice show (Component frameComp, int product) {
+ Frame frame = JOptionPane.getFrameForComponent(frameComp);
+ AltosDeviceUIDialog dialog;
+
+ dialog = new AltosDeviceUIDialog(frame, frameComp, product);
+ dialog.setVisible(true);
+ return dialog.getValue();
+ }
+}
diff --git a/altosui/AltosDialog.java b/altosui/AltosDialog.java
deleted file mode 100644
index ff38c3e4..00000000
--- a/altosui/AltosDialog.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright © 2011 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.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
-
-import libaltosJNI.*;
-
-class AltosDialogListener extends WindowAdapter {
- public void windowClosing (WindowEvent e) {
- AltosUIPreferences.unregister_ui_listener((AltosDialog) e.getWindow());
- }
-}
-
-public class AltosDialog extends JDialog implements AltosUIListener {
-
- public void ui_changed(String look_and_feel) {
- SwingUtilities.updateComponentTreeUI(this);
- this.pack();
- }
-
- public AltosDialog() {
- AltosUIPreferences.register_ui_listener(this);
- addWindowListener(new AltosDialogListener());
- }
-
- public AltosDialog(Frame frame, String label, boolean modal) {
- super(frame, label, modal);
- AltosUIPreferences.register_ui_listener(this);
- addWindowListener(new AltosDialogListener());
- }
-
- public AltosDialog(Frame frame, boolean modal) {
- super(frame, modal);
- AltosUIPreferences.register_ui_listener(this);
- addWindowListener(new AltosDialogListener());
- }
-}
diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java
index cf69c414..095bed99 100644
--- a/altosui/AltosDisplayThread.java
+++ b/altosui/AltosDisplayThread.java
@@ -18,16 +18,10 @@
package altosui;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosDisplayThread extends Thread {
@@ -35,21 +29,17 @@ public class AltosDisplayThread extends Thread {
IdleThread idle_thread;
AltosVoice voice;
AltosFlightReader reader;
- int crc_errors;
+ AltosState old_state, state;
+ AltosListenerState listener_state;
AltosFlightDisplay display;
- void show_internal(AltosState state, int crc_errors) {
- if (state != null)
- display.show(state, crc_errors);
- }
-
- void show_safely(AltosState in_state, int in_crc_errors) {
- final AltosState state = in_state;
- final int crc_errors = in_crc_errors;
+ synchronized void show_safely() {
+ final AltosState my_state = state;
+ final AltosListenerState my_listener_state = listener_state;
Runnable r = new Runnable() {
public void run() {
try {
- show_internal(state, crc_errors);
+ display.show(my_state, my_listener_state);
} catch (Exception ex) {
}
}
@@ -79,7 +69,6 @@ public class AltosDisplayThread extends Thread {
class IdleThread extends Thread {
boolean started;
- private AltosState state;
int reported_landing;
int report_interval;
long report_time;
@@ -135,7 +124,7 @@ public class AltosDisplayThread extends Thread {
++reported_landing;
if (state.state != Altos.ao_flight_landed) {
state.state = Altos.ao_flight_landed;
- show_safely(state, 0);
+ show_safely();
}
}
}
@@ -151,6 +140,10 @@ public class AltosDisplayThread extends Thread {
public void run () {
try {
for (;;) {
+ if (reader.has_monitor_battery()) {
+ listener_state.battery = reader.monitor_battery();
+ show_safely();
+ }
set_report_time();
for (;;) {
voice.drain();
@@ -161,6 +154,7 @@ public class AltosDisplayThread extends Thread {
wait(sleep_time);
}
}
+
report(false);
}
} catch (InterruptedException ie) {
@@ -170,18 +164,7 @@ public class AltosDisplayThread extends Thread {
}
}
- public synchronized void notice(AltosState new_state, boolean spoken) {
- AltosState old_state = state;
- state = new_state;
- if (!started && state.state > Altos.ao_flight_pad) {
- started = true;
- start();
- }
-
- if (state.state < Altos.ao_flight_drogue)
- report_interval = 10000;
- else
- report_interval = 20000;
+ public synchronized void notice(boolean spoken) {
if (old_state != null && old_state.state != state.state) {
report_time = now();
this.notify();
@@ -190,20 +173,19 @@ public class AltosDisplayThread extends Thread {
}
public IdleThread() {
- state = null;
reported_landing = 0;
report_interval = 10000;
}
}
- boolean tell(AltosState state, AltosState old_state) {
+ synchronized boolean tell() {
boolean ret = false;
if (old_state == null || old_state.state != state.state) {
voice.speak(state.data.state());
if ((old_state == null || old_state.state <= Altos.ao_flight_boost) &&
state.state > Altos.ao_flight_boost) {
voice.speak("max speed: %s.",
- AltosConvert.speed.say_units(state.max_speed + 0.5));
+ AltosConvert.speed.say_units(state.max_accel_speed + 0.5));
ret = true;
} else if ((old_state == null || old_state.state < Altos.ao_flight_drogue) &&
state.state >= Altos.ao_flight_drogue) {
@@ -228,12 +210,10 @@ public class AltosDisplayThread extends Thread {
public void run() {
boolean interrupted = false;
- String line;
- AltosState state = null;
- AltosState old_state = null;
boolean told;
idle_thread = new IdleThread();
+ idle_thread.start();
try {
for (;;) {
@@ -244,14 +224,14 @@ public class AltosDisplayThread extends Thread {
old_state = state;
state = new AltosState(record, state);
reader.update(state);
- show_safely(state, crc_errors);
- told = tell(state, old_state);
- idle_thread.notice(state, told);
+ show_safely();
+ told = tell();
+ idle_thread.notice(told);
} catch (ParseException pp) {
System.out.printf("Parse error: %d \"%s\"\n", pp.getErrorOffset(), pp.getMessage());
} catch (AltosCRCException ce) {
- ++crc_errors;
- show_safely(state, crc_errors);
+ ++listener_state.crc_errors;
+ show_safely();
}
}
} catch (InterruptedException ee) {
@@ -270,6 +250,7 @@ public class AltosDisplayThread extends Thread {
}
public AltosDisplayThread(Frame in_parent, AltosVoice in_voice, AltosFlightDisplay in_display, AltosFlightReader in_reader) {
+ listener_state = new AltosListenerState();
parent = in_parent;
voice = in_voice;
display = in_display;
diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java
index 73f3a00f..e81a35d1 100644
--- a/altosui/AltosEepromDelete.java
+++ b/altosui/AltosEepromDelete.java
@@ -17,19 +17,11 @@
package altosui;
-import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
-
-import libaltosJNI.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosEepromDelete implements Runnable {
AltosEepromList flights;
diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java
index 65cac7bd..a0523b58 100644
--- a/altosui/AltosEepromDownload.java
+++ b/altosui/AltosEepromDownload.java
@@ -17,19 +17,13 @@
package altosui;
-import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
import java.util.*;
import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
-
-import libaltosJNI.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosEepromDownload implements Runnable {
@@ -113,7 +107,7 @@ public class AltosEepromDownload implements Runnable {
extension = "eeprom";
set_serial(flights.config_data.serial);
- for (int i = 0; i < eechunk.chunk_size && !done; i += AltosEepromRecord.record_length) {
+ for (int i = 0; i < AltosEepromChunk.chunk_size && !done; i += AltosEepromRecord.record_length) {
try {
AltosEepromRecord r = new AltosEepromRecord(eechunk, i);
if (r.cmd == Altos.AO_LOG_FLIGHT)
@@ -220,7 +214,7 @@ public class AltosEepromDownload implements Runnable {
boolean any_valid = false;
extension = "science";
- for (int i = 0; i < eechunk.chunk_size && !done; i += AltosEepromTeleScience.record_length) {
+ for (int i = 0; i < AltosEepromChunk.chunk_size && !done; i += AltosEepromTeleScience.record_length) {
try {
AltosEepromTeleScience r = new AltosEepromTeleScience(eechunk, i);
if (r.type == AltosEepromTeleScience.AO_LOG_TELESCIENCE_START) {
@@ -273,7 +267,7 @@ public class AltosEepromDownload implements Runnable {
extension = "mega";
set_serial(flights.config_data.serial);
- for (int i = 0; i < eechunk.chunk_size && !done; i += AltosEepromMega.record_length) {
+ for (int i = 0; i < AltosEepromChunk.chunk_size && !done; i += AltosEepromMega.record_length) {
try {
AltosEepromMega r = new AltosEepromMega(eechunk, i);
if (r.cmd == Altos.AO_LOG_FLIGHT)
@@ -289,7 +283,7 @@ public class AltosEepromDownload implements Runnable {
if (r.cmd == Altos.AO_LOG_GPS_TIME) {
year = 2000 + r.data8(14);
month = r.data8(15);
- day = r.data8(14);
+ day = r.data8(16);
want_file = true;
}
@@ -320,7 +314,7 @@ public class AltosEepromDownload implements Runnable {
done = false;
start = true;
- if (flights.config_data.serial == 0)
+ if (flights.config_data.serial < 0)
throw new IOException("no serial number found");
/* Reset per-capture variables */
@@ -337,7 +331,7 @@ public class AltosEepromDownload implements Runnable {
state = 0; state_block = log.start_block;
for (block = log.start_block; !done && block < log.end_block; block++) {
- monitor.set_value(AltosLib.state_name(state), state, block - state_block);
+ monitor.set_value(AltosLib.state_name(state), state, block - state_block, block - log.start_block);
AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block, block == log.start_block);
@@ -372,7 +366,7 @@ public class AltosEepromDownload implements Runnable {
extension = "science";
CaptureTeleScience(eechunk);
break;
- case AltosLib.AO_LOG_FORMAT_MEGAMETRUM:
+ case AltosLib.AO_LOG_FORMAT_TELEMEGA:
extension = "mega";
CaptureMega(eechunk);
}
diff --git a/altosui/AltosEepromList.java b/altosui/AltosEepromList.java
index 6a656215..a63d173d 100644
--- a/altosui/AltosEepromList.java
+++ b/altosui/AltosEepromList.java
@@ -17,19 +17,11 @@
package altosui;
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
import java.util.*;
import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
-
-import libaltosJNI.*;
+import org.altusmetrum.altoslib_1.*;
/*
* Temporary structure to hold the list of stored flights;
diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java
index 563c90b3..7a721196 100644
--- a/altosui/AltosEepromManage.java
+++ b/altosui/AltosEepromManage.java
@@ -17,19 +17,12 @@
package altosui;
-import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
-
-import libaltosJNI.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosEepromManage implements ActionListener {
@@ -52,6 +45,15 @@ public class AltosEepromManage implements ActionListener {
}
}
+ private int countDeletedFlights() {
+ int count = 0;
+ for (AltosEepromLog flight : flights) {
+ if (flight.selected)
+ count++;
+ }
+ return count;
+ }
+
private String showDeletedFlights() {
String result = "";
@@ -101,7 +103,8 @@ public class AltosEepromManage implements ActionListener {
} else if (cmd.equals("delete")) {
if (success) {
JOptionPane.showMessageDialog(frame,
- String.format("Flights erased: %s",
+ String.format("%d flights erased: %s",
+ countDeletedFlights(),
showDeletedFlights()),
serial_line.device.toShortString(),
JOptionPane.INFORMATION_MESSAGE);
@@ -161,7 +164,7 @@ public class AltosEepromManage implements ActionListener {
ee.getLocalizedMessage(),
JOptionPane.ERROR_MESSAGE);
} else if (e instanceof TimeoutException) {
- TimeoutException te = (TimeoutException) e;
+ //TimeoutException te = (TimeoutException) e;
JOptionPane.showMessageDialog(frame,
String.format("Communications failed with \"%s\"",
device.toShortString()),
@@ -202,10 +205,10 @@ public class AltosEepromManage implements ActionListener {
public AltosEepromManage(JFrame given_frame) {
- boolean running = false;
+ //boolean running = false;
frame = given_frame;
- device = AltosDeviceDialog.show(frame, Altos.product_any);
+ device = AltosDeviceUIDialog.show(frame, Altos.product_any);
remote = false;
diff --git a/altosui/AltosEepromMonitor.java b/altosui/AltosEepromMonitor.java
index 75643442..50921da1 100644
--- a/altosui/AltosEepromMonitor.java
+++ b/altosui/AltosEepromMonitor.java
@@ -20,16 +20,9 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib_1.*;
-public class AltosEepromMonitor extends AltosDialog {
+public class AltosEepromMonitor extends AltosUIDialog {
Container pane;
Box box;
@@ -108,7 +101,7 @@ public class AltosEepromMonitor extends AltosDialog {
max_state = in_max_state;
pbar = new JProgressBar();
pbar.setMinimum(0);
- pbar.setMaximum((max_state - min_state) * 100);
+ pbar.setMaximum(1000);
pbar.setValue(0);
pbar.setString("startup");
pbar.setStringPainted(true);
@@ -142,30 +135,28 @@ public class AltosEepromMonitor extends AltosDialog {
cancel.addActionListener(l);
}
- private void set_value_internal(String state_name, int in_state, int in_block) {
- int block = in_block;
- int state = in_state;
-
- if (block > 100)
- block = 100;
+ private void set_value_internal(String state_name, int state, int state_block, int block) {
+ if (state_block > 100)
+ state_block = 100;
if (state < min_state) state = min_state;
if (state >= max_state) state = max_state - 1;
state -= min_state;
- int pos = state * 100 + block;
+ int pos = state * 100 + state_block;
- pbar.setString(state_name);
+ pbar.setString(String.format("block %d state %s", block, state_name));
pbar.setValue(pos);
}
- public void set_value(String in_state_name, int in_state, int in_block) {
+ public void set_value(String in_state_name, int in_state, int in_state_block, int in_block) {
final String state_name = in_state_name;
final int state = in_state;
+ final int state_block = in_state_block;
final int block = in_block;
Runnable r = new Runnable() {
public void run() {
try {
- set_value_internal(state_name, state, block);
+ set_value_internal(state_name, state, state_block, block);
} catch (Exception ex) {
}
}
@@ -242,7 +233,7 @@ public class AltosEepromMonitor extends AltosDialog {
}
private void reset_internal() {
- set_value_internal("startup",min_state,0);
+ set_value_internal("startup",min_state,0, 0);
set_flight_internal(0);
set_file_internal("");
}
diff --git a/altosui/AltosEepromSelect.java b/altosui/AltosEepromSelect.java
index 4ad78896..a451aa3a 100644
--- a/altosui/AltosEepromSelect.java
+++ b/altosui/AltosEepromSelect.java
@@ -17,17 +17,12 @@
package altosui;
-import java.lang.*;
-import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
-import libaltosJNI.libaltos;
-import libaltosJNI.altos_device;
-import libaltosJNI.SWIGTYPE_p_altos_file;
-import libaltosJNI.SWIGTYPE_p_altos_list;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
class AltosEepromItem implements ActionListener {
AltosEepromLog log;
@@ -56,8 +51,8 @@ class AltosEepromItem implements ActionListener {
}
}
-public class AltosEepromSelect extends AltosDialog implements ActionListener {
- private JList list;
+public class AltosEepromSelect extends AltosUIDialog implements ActionListener {
+ //private JList list;
private JFrame frame;
JButton ok;
JButton cancel;
diff --git a/altosui/AltosFlash.java b/altosui/AltosFlash.java
deleted file mode 100644
index bd0c8a50..00000000
--- a/altosui/AltosFlash.java
+++ /dev/null
@@ -1,380 +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.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
-
-public class AltosFlash {
- File file;
- FileInputStream input;
- AltosHexfile image;
- JFrame frame;
- AltosDevice debug_dongle;
- AltosDebug debug;
- AltosRomconfig rom_config;
- ActionListener listener;
- boolean aborted;
-
- static final byte MOV_direct_data = (byte) 0x75;
- static final byte MOV_DPTR_data16 = (byte) 0x90;
- static final byte MOV_A_data = (byte) 0x74;
- static final byte MOVX_atDPTR_A = (byte) 0xf0;
- static final byte MOVX_A_atDPTR = (byte) 0xe0;
- static final byte INC_DPTR = (byte) 0xa3;
- static final byte TRAP = (byte) 0xa5;
-
- static final byte JB = (byte) 0x20;
-
- static final byte MOV_A_direct = (byte) 0xe5;
- static final byte MOV_direct1_direct2 = (byte) 0x85;
- static final byte MOV_direct_A = (byte) 0xf5;
- static final byte MOV_R0_data = (byte) (0x78 | 0);
- static final byte MOV_R1_data = (byte) (0x78 | 1);
- static final byte MOV_R2_data = (byte) (0x78 | 2);
- static final byte MOV_R3_data = (byte) (0x78 | 3);
- static final byte MOV_R4_data = (byte) (0x78 | 4);
- static final byte MOV_R5_data = (byte) (0x78 | 5);
- static final byte MOV_R6_data = (byte) (0x78 | 6);
- static final byte MOV_R7_data = (byte) (0x78 | 7);
- static final byte DJNZ_R0_rel = (byte) (0xd8 | 0);
- static final byte DJNZ_R1_rel = (byte) (0xd8 | 1);
- static final byte DJNZ_R2_rel = (byte) (0xd8 | 2);
- static final byte DJNZ_R3_rel = (byte) (0xd8 | 3);
- static final byte DJNZ_R4_rel = (byte) (0xd8 | 4);
- static final byte DJNZ_R5_rel = (byte) (0xd8 | 5);
- static final byte DJNZ_R6_rel = (byte) (0xd8 | 6);
- static final byte DJNZ_R7_rel = (byte) (0xd8 | 7);
-
- static final byte P1DIR = (byte) 0xFE;
- static final byte P1 = (byte) 0x90;
-
- /* flash controller */
- static final byte FWT = (byte) 0xAB;
- static final byte FADDRL = (byte) 0xAC;
- static final byte FADDRH = (byte) 0xAD;
- static final byte FCTL = (byte) 0xAE;
- static final byte FCTL_BUSY = (byte) 0x80;
- static final byte FCTL_BUSY_BIT = (byte) 7;
- static final byte FCTL_SWBSY = (byte) 0x40;
- static final byte FCTL_SWBSY_BIT = (byte) 6;
- static final byte FCTL_CONTRD = (byte) 0x10;
- static final byte FCTL_WRITE = (byte) 0x02;
- static final byte FCTL_ERASE = (byte) 0x01;
- static final byte FWDATA = (byte) 0xAF;
-
- static final byte ACC = (byte) 0xE0;
-
- /* offsets within the flash_page program */
- static final int FLASH_ADDR_HIGH = 8;
- static final int FLASH_ADDR_LOW = 11;
- static final int RAM_ADDR_HIGH = 13;
- static final int RAM_ADDR_LOW = 14;
- static final int FLASH_WORDS_HIGH = 16;
- static final int FLASH_WORDS_LOW = 18;
- static final int FLASH_TIMING = 21;
-
- /* sleep mode control */
- static final int SLEEP = (byte) 0xbe;
- static final int SLEEP_USB_EN = (byte) 0x80;
- static final int SLEEP_XOSC_STB = (byte) 0x40;
- static final int SLEEP_HFRC_STB = (byte) 0x20;
- static final int SLEEP_RST_MASK = (byte) 0x18;
- static final int SLEEP_RST_POWERON = (byte) 0x00;
- static final int SLEEP_RST_EXTERNAL = (byte) 0x10;
- static final int SLEEP_RST_WATCHDOG = (byte) 0x08;
- static final int SLEEP_OSC_PD = (byte) 0x04;
- static final int SLEEP_MODE_MASK = (byte) 0x03;
- static final int SLEEP_MODE_PM0 = (byte) 0x00;
- static final int SLEEP_MODE_PM1 = (byte) 0x01;
- static final int SLEEP_MODE_PM2 = (byte) 0x02;
- static final int SLEEP_MODE_PM3 = (byte) 0x03;
-
- /* clock controller */
- static final byte CLKCON = (byte) 0xC6;
- static final byte CLKCON_OSC32K = (byte) 0x80;
- static final byte CLKCON_OSC = (byte) 0x40;
- static final byte CLKCON_TICKSPD = (byte) 0x38;
- static final byte CLKCON_CLKSPD = (byte) 0x07;
-
- static final byte[] flash_page_proto = {
-
- MOV_direct_data, P1DIR, (byte) 0x02,
- MOV_direct_data, P1, (byte) 0xFF,
-
- MOV_direct_data, FADDRH, 0, /* FLASH_ADDR_HIGH */
-
- MOV_direct_data, FADDRL, 0, /* FLASH_ADDR_LOW */
-
- MOV_DPTR_data16, 0, 0, /* RAM_ADDR_HIGH, RAM_ADDR_LOW */
-
- MOV_R7_data, 0, /* FLASH_WORDS_HIGH */
-
- MOV_R6_data, 0, /* FLASH_WORDS_LOW */
-
-
- MOV_direct_data, FWT, 0x20, /* FLASH_TIMING */
-
- MOV_direct_data, FCTL, FCTL_ERASE,
-/* eraseWaitLoop: */
- MOV_A_direct, FCTL,
- JB, ACC|FCTL_BUSY_BIT, (byte) 0xfb,
-
- MOV_direct_data, P1, (byte) 0xfd,
-
- MOV_direct_data, FCTL, FCTL_WRITE,
-/* writeLoop: */
- MOV_R5_data, 2,
-/* writeWordLoop: */
- MOVX_A_atDPTR,
- INC_DPTR,
- MOV_direct_A, FWDATA,
- DJNZ_R5_rel, (byte) 0xfa, /* writeWordLoop */
-/* writeWaitLoop: */
- MOV_A_direct, FCTL,
- JB, ACC|FCTL_SWBSY_BIT, (byte) 0xfb, /* writeWaitLoop */
- DJNZ_R6_rel, (byte) 0xf1, /* writeLoop */
- DJNZ_R7_rel, (byte) 0xef, /* writeLoop */
-
- MOV_direct_data, P1DIR, (byte) 0x00,
- MOV_direct_data, P1, (byte) 0xFF,
- TRAP,
- };
-
- public byte[] make_flash_page(int flash_addr, int ram_addr, int byte_count) {
- int flash_word_addr = flash_addr >> 1;
- int flash_word_count = ((byte_count + 1) >> 1);
-
- byte[] flash_page = new byte[flash_page_proto.length];
- for (int i = 0; i < flash_page.length; i++)
- flash_page[i] = flash_page_proto[i];
-
- flash_page[FLASH_ADDR_HIGH] = (byte) (flash_word_addr >> 8);
- flash_page[FLASH_ADDR_LOW] = (byte) (flash_word_addr);
- flash_page[RAM_ADDR_HIGH] = (byte) (ram_addr >> 8);
- flash_page[RAM_ADDR_LOW] = (byte) (ram_addr);
-
- byte flash_words_low = (byte) (flash_word_count);
- byte flash_words_high = (byte) (flash_word_count >> 8);
- /* the flashing code has a minor 'bug' */
- if (flash_words_low != 0)
- flash_words_high++;
-
- flash_page[FLASH_WORDS_HIGH] = (byte) flash_words_high;
- flash_page[FLASH_WORDS_LOW] = (byte) flash_words_low;
- return flash_page;
- }
-
- static byte[] set_clkcon_fast = {
- MOV_direct_data, CLKCON, 0x00
- };
-
- static byte[] get_sleep = {
- MOV_A_direct, SLEEP
- };
-
- public void clock_init() throws IOException, InterruptedException {
- if (debug != null) {
- debug.debug_instr(set_clkcon_fast);
-
- byte status;
- for (int times = 0; times < 20; times++) {
- Thread.sleep(1);
- status = debug.debug_instr(get_sleep);
- if ((status & SLEEP_XOSC_STB) != 0)
- return;
- }
- throw new IOException("Failed to initialize target clock");
- }
- }
-
- void action(String in_s, int in_percent) {
- final String s = in_s;
- final int percent = in_percent;
- if (listener != null && !aborted) {
- Runnable r = new Runnable() {
- public void run() {
- try {
- listener.actionPerformed(new ActionEvent(this,
- percent,
- s));
- } catch (Exception ex) {
- }
- }
- };
- SwingUtilities.invokeLater(r);
- }
- }
-
- void action(int part, int total) {
- int percent = 100 * part / total;
- action(String.format("%d/%d (%d%%)",
- part, total, percent),
- percent);
- }
-
- void altos_run(int pc) throws IOException, InterruptedException {
- debug.set_pc(pc);
- int set_pc = debug.get_pc();
- if (pc != set_pc)
- throw new IOException("Failed to set target program counter");
- debug.resume();
-
- for (int times = 0; times < 20; times++) {
- byte status = debug.read_status();
- if ((status & AltosDebug.STATUS_CPU_HALTED) != 0)
- return;
- }
-
- throw new IOException("Failed to execute program on target");
- }
-
- public void flash() {
- try {
- if (!check_rom_config())
- throw new IOException("Invalid rom config settings");
- if (image.address + image.data.length > 0x8000)
- throw new IOException(String.format("Flash image too long %d",
- image.address +
- image.data.length));
- if ((image.address & 0x3ff) != 0)
- throw new IOException(String.format("Flash image must start on page boundary (is 0x%x)",
- image.address));
- int ram_address = 0xf000;
- int flash_prog = 0xf400;
-
- /*
- * Store desired config values into image
- */
- rom_config.write(image);
- /*
- * Bring up the clock
- */
- clock_init();
-
- int remain = image.data.length;
- int flash_addr = image.address;
- int image_start = 0;
-
- action("start", 0);
- action(0, image.data.length);
- while (remain > 0 && !aborted) {
- int this_time = remain;
- if (this_time > 0x400)
- this_time = 0x400;
-
- if (debug != null) {
- /* write the data */
- debug.write_memory(ram_address, image.data,
- image_start, this_time);
-
- /* write the flash program */
- byte[] flash_page = make_flash_page(flash_addr,
- ram_address,
- this_time);
- debug.write_memory(flash_prog, flash_page);
-
- altos_run(flash_prog);
- byte[] check = debug.read_memory(flash_addr, this_time);
- for (int i = 0; i < this_time; i++)
- if (check[i] != image.data[image_start + i])
- throw new IOException(String.format("Flash write failed at 0x%x (%02x != %02x)",
- image.address + image_start + i,
- check[i], image.data[image_start + i]));
- } else {
- Thread.sleep(100);
- }
-
- remain -= this_time;
- flash_addr += this_time;
- image_start += this_time;
-
- action(image.data.length - remain, image.data.length);
- }
- if (!aborted) {
- action("done", 100);
- if (debug != null) {
- debug.set_pc(image.address);
- debug.resume();
- }
- }
- if (debug != null)
- debug.close();
- } catch (IOException ie) {
- action(ie.getMessage(), -1);
- abort();
- } catch (InterruptedException ie) {
- abort();
- }
- }
-
- public void close() {
- if (debug != null)
- debug.close();
- }
-
- synchronized public void abort() {
- aborted = true;
- close();
- }
-
- public void addActionListener(ActionListener l) {
- listener = l;
- }
-
- public boolean check_rom_config() {
- if (debug == null)
- return true;
- if (rom_config == null)
- rom_config = debug.romconfig();
- return rom_config != null && rom_config.valid();
- }
-
- public void set_romconfig (AltosRomconfig romconfig) {
- rom_config = romconfig;
- }
-
- public AltosRomconfig romconfig() {
- if (!check_rom_config())
- return null;
- return rom_config;
- }
-
- public AltosFlash(File in_file, AltosDevice in_debug_dongle)
- throws IOException, FileNotFoundException, AltosSerialInUseException, InterruptedException {
- file = in_file;
- debug_dongle = in_debug_dongle;
- if (debug_dongle != null)
- debug = new AltosDebug(in_debug_dongle);
- input = new FileInputStream(file);
- image = new AltosHexfile(input);
- if (debug != null && !debug.check_connection()) {
- debug.close();
- throw new IOException("Debug port not connected");
- }
- }
-} \ No newline at end of file
diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java
index 66991d10..f4e52218 100644
--- a/altosui/AltosFlashUI.java
+++ b/altosui/AltosFlashUI.java
@@ -21,16 +21,13 @@ import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosFlashUI
- extends AltosDialog
+ extends AltosUIDialog
implements ActionListener
{
Container pane;
@@ -180,7 +177,7 @@ public class AltosFlashUI
}
boolean select_debug_dongle() {
- debug_dongle = AltosDeviceDialog.show(frame, Altos.product_any);
+ debug_dongle = AltosDeviceUIDialog.show(frame, Altos.product_any);
if (debug_dongle == null)
return false;
@@ -218,15 +215,30 @@ public class AltosFlashUI
}
}
- class flash_task implements Runnable {
+ class flash_task implements Runnable, AltosFlashListener {
AltosFlashUI ui;
Thread t;
AltosFlash flash;
+ public void position(String in_s, int in_percent) {
+ final String s = in_s;
+ final int percent = in_percent;
+ Runnable r = new Runnable() {
+ public void run() {
+ try {
+ ui.actionPerformed(new ActionEvent(this,
+ percent,
+ s));
+ } catch (Exception ex) {
+ }
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+
public void run () {
try {
- flash = new AltosFlash(ui.file, ui.debug_dongle);
- flash.addActionListener(ui);
+ flash = new AltosFlash(ui.file, new AltosSerial(ui.debug_dongle), this);
final AltosRomconfig current_config = flash.romconfig();
diff --git a/altosui/AltosFlightDisplay.java b/altosui/AltosFlightDisplay.java
index 826f9522..4f4c158e 100644
--- a/altosui/AltosFlightDisplay.java
+++ b/altosui/AltosFlightDisplay.java
@@ -17,12 +17,12 @@
package altosui;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public interface AltosFlightDisplay {
void reset();
- void show(AltosState state, int crc_errors);
+ void show(AltosState state, AltosListenerState listener_state);
void set_font();
}
diff --git a/altosui/AltosFlightInfoTableModel.java b/altosui/AltosFlightInfoTableModel.java
index 77969a89..249f6497 100644
--- a/altosui/AltosFlightInfoTableModel.java
+++ b/altosui/AltosFlightInfoTableModel.java
@@ -17,17 +17,7 @@
package altosui;
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.*;
-import java.io.*;
-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"};
diff --git a/altosui/AltosFlightStats.java b/altosui/AltosFlightStats.java
index ab094c80..dee31a8d 100644
--- a/altosui/AltosFlightStats.java
+++ b/altosui/AltosFlightStats.java
@@ -17,23 +17,14 @@
package altosui;
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosFlightStats {
double max_height;
double max_speed;
double max_acceleration;
- double[] state_speed = new double[Altos.ao_flight_invalid + 1];
+ double[] state_accel_speed = new double[Altos.ao_flight_invalid + 1];
double[] state_baro_speed = new double[Altos.ao_flight_invalid + 1];
double[] state_accel = new double[Altos.ao_flight_invalid + 1];
int[] state_count = new int[Altos.ao_flight_invalid + 1];
@@ -43,6 +34,11 @@ public class AltosFlightStats {
int flight;
int year, month, day;
int hour, minute, second;
+ double lat, lon;
+ double pad_lat, pad_lon;
+ boolean has_gps;
+ boolean has_other_adc;
+ boolean has_rssi;
double landed_time(AltosRecordIterable iterable) {
AltosState state = null;
@@ -107,11 +103,19 @@ public class AltosFlightStats {
year = month = day = -1;
hour = minute = second = -1;
serial = flight = -1;
+ lat = lon = -1;
+ has_gps = false;
+ has_other_adc = false;
+ has_rssi = false;
for (AltosRecord record : iterable) {
if (serial < 0)
serial = record.serial;
if ((record.seen & AltosRecord.seen_flight) != 0 && flight < 0)
flight = record.flight;
+ if ((record.seen & AltosRecord.seen_temp_volt) != 0)
+ has_other_adc = true;
+ if (record.rssi != 0)
+ has_rssi = true;
new_state = new AltosState(record, state);
end_time = new_state.time;
state = new_state;
@@ -132,7 +136,7 @@ public class AltosFlightStats {
}
}
state_accel[state.state] += state.acceleration;
- state_speed[state.state] += state.speed;
+ state_accel_speed[state.state] += state.accel_speed;
state_baro_speed[state.state] += state.baro_speed;
state_count[state.state]++;
if (state_start[state.state] == 0.0)
@@ -140,16 +144,25 @@ public class AltosFlightStats {
if (state_end[state.state] < state.time)
state_end[state.state] = state.time;
max_height = state.max_height;
- if (state.max_speed != 0)
- max_speed = state.max_speed;
+ if (state.max_accel_speed != 0)
+ max_speed = state.max_accel_speed;
else
max_speed = state.max_baro_speed;
max_acceleration = state.max_acceleration;
}
+ if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) {
+ if (state.state <= Altos.ao_flight_pad) {
+ pad_lat = state.gps.lat;
+ pad_lon = state.gps.lon;
+ }
+ lat = state.gps.lat;
+ lon = state.gps.lon;
+ has_gps = true;
+ }
}
for (int s = Altos.ao_flight_startup; s <= Altos.ao_flight_landed; s++) {
if (state_count[s] > 0) {
- state_speed[s] /= state_count[s];
+ state_accel_speed[s] /= state_count[s];
state_baro_speed[s] /= state_count[s];
state_accel[s] /= state_count[s];
}
diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java
index 87ba6aa8..a35b5f63 100644
--- a/altosui/AltosFlightStatsTable.java
+++ b/altosui/AltosFlightStatsTable.java
@@ -18,16 +18,8 @@
package altosui;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosFlightStatsTable extends JComponent {
GridBagLayout layout;
@@ -66,6 +58,17 @@ public class AltosFlightStatsTable extends JComponent {
}
+ static String pos(double p, String pos, String neg) {
+ String h = pos;
+ if (p < 0) {
+ h = neg;
+ p = -p;
+ }
+ int deg = (int) Math.floor(p);
+ double min = (p - Math.floor(p)) * 60.0;
+ return String.format("%s %4d° %9.6f'", h, deg, min);
+ }
+
public AltosFlightStatsTable(AltosFlightStats stats) {
layout = new GridBagLayout();
@@ -73,12 +76,18 @@ public class AltosFlightStatsTable extends JComponent {
int y = 0;
new FlightStat(layout, y++, "Serial", String.format("%d", stats.serial));
new FlightStat(layout, y++, "Flight", String.format("%d", stats.flight));
- if (stats.year > 0)
- new FlightStat(layout, y++, "Date",
- String.format("%04d-%02d-%02d", stats.year, stats.month, stats.day));
- if (stats.hour > 0)
- new FlightStat(layout, y++, "Time",
+ if (stats.year > 0 && stats.hour > 0)
+ new FlightStat(layout, y++, "Date/Time",
+ String.format("%04d-%02d-%02d", stats.year, stats.month, stats.day),
String.format("%02d:%02d:%02d UTC", stats.hour, stats.minute, stats.second));
+ else {
+ if (stats.year > 0)
+ new FlightStat(layout, y++, "Date",
+ String.format("%04d-%02d-%02d", stats.year, stats.month, stats.day));
+ if (stats.hour > 0)
+ new FlightStat(layout, y++, "Time",
+ String.format("%02d:%02d:%02d UTC", stats.hour, stats.minute, stats.second));
+ }
new FlightStat(layout, y++, "Maximum height",
String.format("%5.0f m", stats.max_height),
String.format("%5.0f ft", AltosConvert.meters_to_feet(stats.max_height)));
@@ -102,14 +111,29 @@ public class AltosFlightStatsTable extends JComponent {
new FlightStat(layout, y++, "Main descent rate",
String.format("%5.0f m/s", stats.state_baro_speed[Altos.ao_flight_main]),
String.format("%5.0f ft/s", AltosConvert.meters_to_feet(stats.state_baro_speed[Altos.ao_flight_main])));
- for (int s = Altos.ao_flight_boost; s <= Altos.ao_flight_main; s++) {
- new FlightStat(layout, y++, String.format("%s time", AltosLib.state_name_capital(s)),
- String.format("%6.0f s", stats.state_end[s] - stats.state_start[s]));
- }
- new FlightStat(layout, y++, "Flight Time",
- String.format("%6.0f s", stats.state_end[Altos.ao_flight_main] -
+ new FlightStat(layout, y++, "Ascent time",
+ String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_boost] - stats.state_start[AltosLib.ao_flight_boost],
+ AltosLib.state_name(Altos.ao_flight_boost)),
+ String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_fast] - stats.state_start[AltosLib.ao_flight_fast],
+ AltosLib.state_name(Altos.ao_flight_fast)),
+ String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_coast] - stats.state_start[AltosLib.ao_flight_coast],
+ AltosLib.state_name(Altos.ao_flight_coast)));
+ new FlightStat(layout, y++, "Descent time",
+ String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_drogue] - stats.state_start[AltosLib.ao_flight_drogue],
+ AltosLib.state_name(Altos.ao_flight_drogue)),
+ String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_main] - stats.state_start[AltosLib.ao_flight_main],
+ AltosLib.state_name(Altos.ao_flight_main)));
+ new FlightStat(layout, y++, "Flight time",
+ String.format("%6.1f s", stats.state_end[Altos.ao_flight_main] -
stats.state_start[Altos.ao_flight_boost]));
-
+ if (stats.has_gps) {
+ new FlightStat(layout, y++, "Pad location",
+ pos(stats.pad_lat,"N","S"),
+ pos(stats.pad_lon,"E","W"));
+ new FlightStat(layout, y++, "Last reported location",
+ pos(stats.lat,"N","S"),
+ pos(stats.lon,"E","W"));
+ }
}
} \ No newline at end of file
diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java
index 6a351004..d2910414 100644
--- a/altosui/AltosFlightStatus.java
+++ b/altosui/AltosFlightStatus.java
@@ -18,16 +18,8 @@
package altosui;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosFlightStatus extends JComponent implements AltosFlightDisplay {
GridBagLayout layout;
@@ -36,7 +28,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
JLabel label;
JTextField value;
- void show(AltosState state, int crc_errors) {}
+ void show(AltosState state, AltosListenerState listener_state) {}
void reset() {
value.setText("");
@@ -72,7 +64,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
}
class Call extends FlightValue {
- void show(AltosState state, int crc_errors) {
+ void show(AltosState state, AltosListenerState listener_state) {
value.setText(state.data.callsign);
}
public Call (GridBagLayout layout, int x) {
@@ -83,8 +75,11 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
Call call;
class Serial extends FlightValue {
- void show(AltosState state, int crc_errors) {
- value.setText(String.format("%d", state.data.serial));
+ void show(AltosState state, AltosListenerState listener_state) {
+ if (state.data.serial == AltosRecord.MISSING)
+ value.setText("none");
+ else
+ value.setText(String.format("%d", state.data.serial));
}
public Serial (GridBagLayout layout, int x) {
super (layout, x, "Serial");
@@ -94,8 +89,11 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
Serial serial;
class Flight extends FlightValue {
- void show(AltosState state, int crc_errors) {
- value.setText(String.format("%d", state.data.flight));
+ void show(AltosState state, AltosListenerState listener_state) {
+ if (state.data.flight == AltosRecord.MISSING)
+ value.setText("none");
+ else
+ value.setText(String.format("%d", state.data.flight));
}
public Flight (GridBagLayout layout, int x) {
super (layout, x, "Flight");
@@ -105,7 +103,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
Flight flight;
class FlightState extends FlightValue {
- void show(AltosState state, int crc_errors) {
+ void show(AltosState state, AltosListenerState listener_state) {
value.setText(state.data.state());
}
public FlightState (GridBagLayout layout, int x) {
@@ -116,7 +114,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
FlightState flight_state;
class RSSI extends FlightValue {
- void show(AltosState state, int crc_errors) {
+ void show(AltosState state, AltosListenerState listener_state) {
value.setText(String.format("%d", state.data.rssi));
}
public RSSI (GridBagLayout layout, int x) {
@@ -127,7 +125,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
RSSI rssi;
class LastPacket extends FlightValue {
- void show(AltosState state, int crc_errors) {
+ void show(AltosState state, AltosListenerState listener_state) {
long secs = (System.currentTimeMillis() - state.report_time + 500) / 1000;
value.setText(String.format("%d", secs));
}
@@ -156,13 +154,13 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
last_packet.set_font();
}
- public void show (AltosState state, int crc_errors) {
- call.show(state, crc_errors);
- serial.show(state, crc_errors);
- flight.show(state, crc_errors);
- flight_state.show(state, crc_errors);
- rssi.show(state, crc_errors);
- last_packet.show(state, crc_errors);
+ public void show (AltosState state, AltosListenerState listener_state) {
+ call.show(state, listener_state);
+ serial.show(state, listener_state);
+ flight.show(state, listener_state);
+ flight_state.show(state, listener_state);
+ rssi.show(state, listener_state);
+ last_packet.show(state, listener_state);
}
public int height() {
diff --git a/altosui/AltosFlightStatusTableModel.java b/altosui/AltosFlightStatusTableModel.java
index c2cf8cd1..6a327841 100644
--- a/altosui/AltosFlightStatusTableModel.java
+++ b/altosui/AltosFlightStatusTableModel.java
@@ -14,7 +14,7 @@
* 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.awt.*;
@@ -27,7 +27,7 @@ import java.util.*;
import java.text.*;
import java.util.prefs.*;
import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosFlightStatusTableModel extends AbstractTableModel {
private String[] columnNames = {
@@ -65,3 +65,4 @@ public class AltosFlightStatusTableModel extends AbstractTableModel {
setValueAt(String.format("%1.0f", AltosConvert.speed(speed)), 3);
}
}
+*/ \ No newline at end of file
diff --git a/altosui/AltosFlightStatusUpdate.java b/altosui/AltosFlightStatusUpdate.java
index d70fc7f8..962a08f7 100644
--- a/altosui/AltosFlightStatusUpdate.java
+++ b/altosui/AltosFlightStatusUpdate.java
@@ -17,26 +17,21 @@
package altosui;
-import java.awt.*;
import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosFlightStatusUpdate implements ActionListener {
- public AltosState saved_state;
- AltosFlightStatus flightStatus;
+ public AltosState saved_state;
+ public AltosListenerState saved_listener_state;
+ AltosFlightStatus flightStatus;
public void actionPerformed (ActionEvent e) {
- if (saved_state != null)
- flightStatus.show(saved_state, 0);
+ if (saved_state != null) {
+ if (saved_listener_state == null)
+ saved_listener_state = new AltosListenerState();
+ flightStatus.show(saved_state, saved_listener_state);
+ }
}
public AltosFlightStatusUpdate (AltosFlightStatus in_flightStatus) {
diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java
index 600d8acc..6d010d23 100644
--- a/altosui/AltosFlightUI.java
+++ b/altosui/AltosFlightUI.java
@@ -20,16 +20,11 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
-public class AltosFlightUI extends AltosFrame implements AltosFlightDisplay, AltosFontListener {
+public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener {
AltosVoice voice;
AltosFlightReader reader;
AltosDisplayThread thread;
@@ -44,6 +39,7 @@ public class AltosFlightUI extends AltosFrame implements AltosFlightDisplay, Alt
AltosSiteMap sitemap;
boolean has_map;
boolean has_companion;
+ boolean has_state;
private AltosFlightStatus flightStatus;
private AltosInfoTable flightInfo;
@@ -102,29 +98,44 @@ public class AltosFlightUI extends AltosFrame implements AltosFlightDisplay, Alt
AltosFlightStatusUpdate status_update;
- public void show(AltosState state, int crc_errors) {
+ public void show(AltosState state, AltosListenerState listener_state) {
status_update.saved_state = state;
+
+ if (state == null)
+ state = new AltosState(new AltosRecord());
+
+ pad.show(state, listener_state);
+
+ if (state.state != Altos.ao_flight_startup) {
+ if (!has_state) {
+ pane.setTitleAt(0, "Launch Pad");
+ pane.add(ascent, 1);
+ pane.add(descent, 2);
+ pane.add(landed, 3);
+ has_state = true;
+ }
+ }
+
+ ascent.show(state, listener_state);
+ descent.show(state, listener_state);
+ landed.show(state, listener_state);
+
JComponent tab = which_tab(state);
- try {
- pad.show(state, crc_errors);
- ascent.show(state, crc_errors);
- descent.show(state, crc_errors);
- landed.show(state, crc_errors);
if (tab != cur_tab) {
if (cur_tab == pane.getSelectedComponent()) {
pane.setSelectedComponent(tab);
}
cur_tab = tab;
}
- flightStatus.show(state, crc_errors);
- flightInfo.show(state, crc_errors);
+ flightStatus.show(state, listener_state);
+ flightInfo.show(state, listener_state);
if (state.data.companion != null) {
if (!has_companion) {
pane.add("Companion", companion);
has_companion= true;
}
- companion.show(state, crc_errors);
+ companion.show(state, listener_state);
} else {
if (has_companion) {
pane.remove(companion);
@@ -136,16 +147,13 @@ public class AltosFlightUI extends AltosFrame implements AltosFlightDisplay, Alt
pane.add("Site Map", sitemap);
has_map = true;
}
- sitemap.show(state, crc_errors);
+ sitemap.show(state, listener_state);
} else {
if (has_map) {
pane.remove(sitemap);
has_map = false;
}
}
- } catch (Exception e) {
- System.out.print("Show exception" + e);
- }
}
public void set_exit_on_close() {
@@ -264,22 +272,18 @@ public class AltosFlightUI extends AltosFrame implements AltosFlightDisplay, Alt
pane = new JTabbedPane();
pad = new AltosPad();
- pane.add("Launch Pad", pad);
+ pane.add("Status", pad);
ascent = new AltosAscent();
- pane.add("Ascent", ascent);
-
descent = new AltosDescent();
- pane.add("Descent", descent);
-
landed = new AltosLanded(reader);
- pane.add("Landed", landed);
flightInfo = new AltosInfoTable();
pane.add("Table", new JScrollPane(flightInfo));
companion = new AltosCompanionInfo();
has_companion = false;
+ has_state = false;
sitemap = new AltosSiteMap();
has_map = false;
diff --git a/altosui/AltosFontListener.java b/altosui/AltosFontListener.java
deleted file mode 100644
index 0dda0f29..00000000
--- a/altosui/AltosFontListener.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright © 2011 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;
-
-public interface AltosFontListener {
- void font_size_changed(int font_size);
-}
diff --git a/altosui/AltosFrame.java b/altosui/AltosFrame.java
deleted file mode 100644
index 338b363e..00000000
--- a/altosui/AltosFrame.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright © 2011 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.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
-
-import libaltosJNI.*;
-
-class AltosFrameListener extends WindowAdapter {
- public void windowClosing (WindowEvent e) {
- AltosUIPreferences.unregister_ui_listener((AltosFrame) e.getWindow());
- }
-}
-
-public class AltosFrame extends JFrame implements AltosUIListener {
-
- public void ui_changed(String look_and_feel) {
- SwingUtilities.updateComponentTreeUI(this);
- this.pack();
- }
-
- static final String[] icon_names = {
- "/altus-metrum-16.png",
- "/altus-metrum-32.png",
- "/altus-metrum-48.png",
- "/altus-metrum-64.png",
- "/altus-metrum-128.png",
- "/altus-metrum-256.png"
- };
-
- public void set_icon() {
- ArrayList<Image> icons = new ArrayList<Image>();
-
- for (int i = 0; i < icon_names.length; i++) {
- java.net.URL imgURL = AltosUI.class.getResource(icon_names[i]);
- if (imgURL != null)
- icons.add(new ImageIcon(imgURL).getImage());
- }
-
- setIconImages(icons);
- }
-
- public AltosFrame() {
- AltosUIPreferences.register_ui_listener(this);
- addWindowListener(new AltosFrameListener());
- set_icon();
- }
-
- public AltosFrame(String name) {
- super(name);
- AltosUIPreferences.register_ui_listener(this);
- addWindowListener(new AltosFrameListener());
- set_icon();
- }
-}
diff --git a/altosui/AltosFreqList.java b/altosui/AltosFreqList.java
index 1bbc97c6..7464ac3e 100644
--- a/altosui/AltosFreqList.java
+++ b/altosui/AltosFreqList.java
@@ -17,17 +17,9 @@
package altosui;
-import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosFreqList extends JComboBox {
diff --git a/altosui/AltosGraph.java b/altosui/AltosGraph.java
index 54d2bb0b..defe69a0 100644
--- a/altosui/AltosGraph.java
+++ b/altosui/AltosGraph.java
@@ -1,27 +1,221 @@
-
-// Copyright (c) 2010 Anthony Towns
-// GPL v2 or later
+/*
+ * Copyright © 2013 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.ArrayList;
+
+import java.awt.*;
+import javax.swing.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
+
+import org.jfree.ui.*;
+import org.jfree.chart.*;
+import org.jfree.chart.plot.*;
+import org.jfree.chart.axis.*;
+import org.jfree.chart.renderer.*;
+import org.jfree.chart.renderer.xy.*;
+import org.jfree.chart.labels.*;
+import org.jfree.data.xy.*;
+import org.jfree.data.*;
+
+class AltosVoltage extends AltosUnits {
+
+ public double value(double v) {
+ return v;
+ }
+
+ public String show_units() {
+ return "V";
+ }
+
+ public String say_units() {
+ return "volts";
+ }
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.ChartUtilities;
-import org.altusmetrum.AltosLib.*;
-
-abstract class AltosGraph {
- public String filename;
- public abstract void addData(AltosDataPoint d);
- public abstract JFreeChart createChart();
- public String title;
- public void toPNG() throws java.io.IOException { toPNG(300, 500); }
- public void toPNG(int width, int height)
- throws java.io.IOException
- {
- File pngout = new File(filename);
- JFreeChart chart = createChart();
- ChartUtilities.saveChartAsPNG(pngout, chart, width, height);
- System.out.println("Created " + filename);
- }
+ public int show_fraction(int width) {
+ return width / 2;
+ }
}
+
+class AltosNsat extends AltosUnits {
+
+ public double value(double v) {
+ return v;
+ }
+
+ public String show_units() {
+ return "Sats";
+ }
+
+ public String say_units() {
+ return "Satellites";
+ }
+
+ public int show_fraction(int width) {
+ return 0;
+ }
+}
+
+class AltosDbm extends AltosUnits {
+
+ public double value(double v) {
+ return v;
+ }
+
+ public String show_units() {
+ return "dBm";
+ }
+
+ public String say_units() {
+ return "d b m";
+ }
+
+ public int show_fraction(int width) {
+ return 0;
+ }
+}
+
+public class AltosGraph extends AltosUIGraph {
+
+ static final private Color height_color = new Color(194,31,31);
+ static final private Color gps_height_color = new Color(150,31,31);
+ static final private Color range_color = new Color(100, 31, 31);
+ static final private Color distance_color = new Color(100, 31, 194);
+ static final private Color speed_color = new Color(31,194,31);
+ static final private Color accel_color = new Color(31,31,194);
+ static final private Color voltage_color = new Color(194, 194, 31);
+ static final private Color battery_voltage_color = new Color(194, 194, 31);
+ static final private Color drogue_voltage_color = new Color(150, 150, 31);
+ static final private Color main_voltage_color = new Color(100, 100, 31);
+ static final private Color gps_nsat_color = new Color (194, 31, 194);
+ static final private Color gps_nsat_solution_color = new Color (194, 31, 194);
+ static final private Color gps_nsat_view_color = new Color (150, 31, 150);
+ static final private Color temperature_color = new Color (31, 194, 194);
+ static final private Color dbm_color = new Color(31, 100, 100);
+ static final private Color state_color = new Color(0,0,0);
+
+ static AltosVoltage voltage_units = new AltosVoltage();
+ static AltosNsat nsat_units = new AltosNsat();
+ static AltosDbm dbm_units = new AltosDbm();
+
+ AltosUIAxis height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis;
+ AltosUIAxis distance_axis;
+
+ public AltosGraph(AltosUIEnable enable, AltosFlightStats stats, AltosGraphDataSet dataSet) {
+ super(enable);
+
+ height_axis = newAxis("Height", AltosConvert.height, height_color);
+ speed_axis = newAxis("Speed", AltosConvert.speed, speed_color);
+ accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color);
+ voltage_axis = newAxis("Voltage", voltage_units, voltage_color);
+ temperature_axis = newAxis("Temperature", AltosConvert.temperature, temperature_color, 0);
+ nsat_axis = newAxis("Satellites", nsat_units, gps_nsat_color,
+ AltosUIAxis.axis_include_zero | AltosUIAxis.axis_integer);
+ dbm_axis = newAxis("Signal Strength", dbm_units, dbm_color, 0);
+ distance_axis = newAxis("Distance", AltosConvert.distance, range_color);
+
+ addMarker("State", AltosGraphDataPoint.data_state, state_color);
+ addSeries("Height",
+ AltosGraphDataPoint.data_height,
+ AltosConvert.height,
+ height_color,
+ true,
+ height_axis);
+ addSeries("Speed",
+ AltosGraphDataPoint.data_speed,
+ AltosConvert.speed,
+ speed_color,
+ true,
+ speed_axis);
+ addSeries("Acceleration",
+ AltosGraphDataPoint.data_accel,
+ AltosConvert.accel,
+ accel_color,
+ true,
+ accel_axis);
+ if (stats.has_gps) {
+ addSeries("Range",
+ AltosGraphDataPoint.data_range,
+ AltosConvert.distance,
+ range_color,
+ false,
+ distance_axis);
+ addSeries("Distance",
+ AltosGraphDataPoint.data_distance,
+ AltosConvert.distance,
+ distance_color,
+ false,
+ distance_axis);
+ addSeries("GPS Height",
+ AltosGraphDataPoint.data_gps_height,
+ AltosConvert.height,
+ gps_height_color,
+ false,
+ height_axis);
+ addSeries("GPS Satellites in Solution",
+ AltosGraphDataPoint.data_gps_nsat_solution,
+ nsat_units,
+ gps_nsat_solution_color,
+ false,
+ nsat_axis);
+ addSeries("GPS Satellites in View",
+ AltosGraphDataPoint.data_gps_nsat_view,
+ nsat_units,
+ gps_nsat_view_color,
+ false,
+ nsat_axis);
+ }
+ if (stats.has_rssi)
+ addSeries("Received Signal Strength",
+ AltosGraphDataPoint.data_rssi,
+ dbm_units,
+ dbm_color,
+ false,
+ dbm_axis);
+ if (stats.has_other_adc) {
+ addSeries("Temperature",
+ AltosGraphDataPoint.data_temperature,
+ AltosConvert.temperature,
+ temperature_color,
+ false,
+ temperature_axis);
+ addSeries("Battery Voltage",
+ AltosGraphDataPoint.data_battery_voltage,
+ voltage_units,
+ battery_voltage_color,
+ false,
+ voltage_axis);
+ addSeries("Drogue Voltage",
+ AltosGraphDataPoint.data_drogue_voltage,
+ voltage_units,
+ drogue_voltage_color,
+ false,
+ voltage_axis);
+ addSeries("Main Voltage",
+ AltosGraphDataPoint.data_main_voltage,
+ voltage_units,
+ main_voltage_color,
+ false,
+ voltage_axis);
+ }
+
+ setDataSet(dataSet);
+ }
+} \ No newline at end of file
diff --git a/altosui/AltosGraphDataPoint.java b/altosui/AltosGraphDataPoint.java
new file mode 100644
index 00000000..8e6d6923
--- /dev/null
+++ b/altosui/AltosGraphDataPoint.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright © 2013 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 org.altusmetrum.altosuilib_1.*;
+import org.altusmetrum.altoslib_1.*;
+
+public class AltosGraphDataPoint implements AltosUIDataPoint {
+
+ AltosState state;
+
+ public static final int data_height = 0;
+ public static final int data_speed = 1;
+ public static final int data_accel = 2;
+ public static final int data_temp = 3;
+ public static final int data_battery_voltage = 4;
+ public static final int data_drogue_voltage = 5;
+ public static final int data_main_voltage = 6;
+ public static final int data_rssi = 7;
+ public static final int data_state = 8;
+ public static final int data_gps_height = 9;
+ public static final int data_gps_nsat_solution = 10;
+ public static final int data_gps_nsat_view = 11;
+ public static final int data_temperature = 12;
+ public static final int data_range = 13;
+ public static final int data_distance = 14;
+
+ public double x() throws AltosUIDataMissing {
+ if (state.data.time < -2)
+ throw new AltosUIDataMissing(-1);
+ return state.data.time;
+ }
+
+ public double y(int index) throws AltosUIDataMissing {
+ double y = AltosRecord.MISSING;
+ switch (index) {
+ case data_height:
+ y = state.height;
+ break;
+ case data_speed:
+ y = state.speed();
+ break;
+ case data_accel:
+ y = state.acceleration;
+ break;
+ case data_temp:
+ y = state.temperature;
+ break;
+ case data_battery_voltage:
+ y = state.battery;
+ break;
+ case data_drogue_voltage:
+ y = state.drogue_sense;
+ break;
+ case data_main_voltage:
+ y = state.main_sense;
+ break;
+ case data_rssi:
+ y = state.data.rssi;
+ break;
+ case data_gps_height:
+ y = state.gps_height;
+ break;
+ case data_gps_nsat_solution:
+ if (state.gps != null)
+ y = state.gps.nsat;
+ break;
+ case data_gps_nsat_view:
+ if (state.gps != null && state.gps.cc_gps_sat != null)
+ y = state.gps.cc_gps_sat.length;
+ break;
+ case data_temperature:
+ y = state.temperature;
+ break;
+ case data_range:
+ y = state.range;
+ break;
+ case data_distance:
+ if (state.from_pad != null)
+ y = state.from_pad.distance;
+ break;
+ }
+ if (y == AltosRecord.MISSING)
+ throw new AltosUIDataMissing(index);
+ return y;
+ }
+
+ public int id(int index) {
+ if (index == data_state) {
+ int s = state.data.state;
+ if (s < Altos.ao_flight_boost || s > Altos.ao_flight_landed)
+ return -1;
+ return s;
+ }
+ return 0;
+ }
+
+ public String id_name(int index) {
+ if (index == data_state)
+ return state.data.state();
+ return "";
+ }
+
+ public AltosGraphDataPoint (AltosState state) {
+ this.state = state;
+ }
+} \ No newline at end of file
diff --git a/altosui/AltosGraphDataSet.java b/altosui/AltosGraphDataSet.java
new file mode 100644
index 00000000..dc047e9a
--- /dev/null
+++ b/altosui/AltosGraphDataSet.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright © 2013 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.io.*;
+import java.util.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
+
+class AltosGraphIterator implements Iterator<AltosUIDataPoint> {
+ AltosGraphDataSet dataSet;
+ Iterator<AltosRecord> iterator;
+
+ AltosState state;
+
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ public AltosUIDataPoint next() {
+ state = new AltosState(iterator.next(), state);
+
+ if ((state.data.seen & AltosRecord.seen_flight) != 0) {
+ if (dataSet.callsign == null && state.data.callsign != null)
+ dataSet.callsign = state.data.callsign;
+
+ if (dataSet.serial == 0 && state.data.serial != 0)
+ dataSet.serial = state.data.serial;
+
+ if (dataSet.flight == 0 && state.data.flight != 0)
+ dataSet.flight = state.data.flight;
+ }
+
+ return new AltosGraphDataPoint(state);
+ }
+
+ public AltosGraphIterator (Iterator<AltosRecord> iterator, AltosGraphDataSet dataSet) {
+ this.iterator = iterator;
+ this.state = null;
+ this.dataSet = dataSet;
+ }
+
+ public void remove() {
+ }
+}
+
+class AltosGraphIterable implements Iterable<AltosUIDataPoint> {
+ AltosGraphDataSet dataSet;
+
+ public Iterator<AltosUIDataPoint> iterator() {
+ return new AltosGraphIterator(dataSet.records.iterator(), dataSet);
+ }
+
+ public AltosGraphIterable(AltosGraphDataSet dataSet) {
+ this.dataSet = dataSet;
+ }
+}
+
+public class AltosGraphDataSet implements AltosUIDataSet {
+ String callsign;
+ int serial;
+ int flight;
+ AltosRecordIterable records;
+
+ public String name() {
+ if (callsign != null)
+ return String.format("%s - %d/%d", callsign, serial, flight);
+ else
+ return String.format("%d/%d", serial, flight);
+ }
+
+ public Iterable<AltosUIDataPoint> dataPoints() {
+ return new AltosGraphIterable(this);
+ }
+
+ public AltosGraphDataSet (AltosRecordIterable records) {
+ this.records = records;
+ this.callsign = null;
+ this.serial = 0;
+ this.flight = 0;
+ }
+}
diff --git a/altosui/AltosGraphTime.java b/altosui/AltosGraphTime.java
deleted file mode 100644
index 0955f6e6..00000000
--- a/altosui/AltosGraphTime.java
+++ /dev/null
@@ -1,236 +0,0 @@
-
-// Copyright (c) 2010 Anthony Towns
-// GPL v2 or later
-
-package altosui;
-
-import java.lang.*;
-import java.io.*;
-import java.util.concurrent.*;
-import java.util.*;
-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;
-import org.jfree.chart.axis.AxisLocation;
-import org.jfree.chart.axis.NumberAxis;
-import org.jfree.chart.labels.StandardXYToolTipGenerator;
-import org.jfree.chart.plot.PlotOrientation;
-import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.plot.ValueMarker;
-import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
-import org.jfree.chart.renderer.xy.XYItemRenderer;
-import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
-import org.jfree.data.xy.XYSeries;
-import org.jfree.data.xy.XYSeriesCollection;
-import org.jfree.ui.RectangleAnchor;
-import org.jfree.ui.TextAnchor;
-
-class AltosGraphTime extends AltosGraph {
- static interface Element {
- void attachGraph(AltosGraphTime g);
- void gotTimeData(double time, AltosDataPoint d);
- void addToPlot(AltosGraphTime g, XYPlot plot);
- }
-
- static class TimeAxis implements Element {
- private int axis;
- private Color color;
- private String label;
- private AxisLocation locn;
- private double min_y = Double.NaN;
-
- public TimeAxis(int axis, String label, Color color, AxisLocation locn)
- {
- this.axis = axis;
- this.color = color;
- this.label = label;
- this.locn = locn;
- }
-
- public void setLowerBound(double min_y) {
- this.min_y = min_y;
- }
-
- public void attachGraph(AltosGraphTime g) { return; }
- public void gotTimeData(double time, AltosDataPoint d) { return; }
-
- public void addToPlot(AltosGraphTime g, XYPlot plot) {
- NumberAxis numAxis = new NumberAxis(label);
- if (!Double.isNaN(min_y))
- numAxis.setLowerBound(min_y);
- plot.setRangeAxis(axis, numAxis);
- plot.setRangeAxisLocation(axis, locn);
- numAxis.setLabelPaint(color);
- numAxis.setTickLabelPaint(color);
- numAxis.setAutoRangeIncludesZero(false);
- }
- }
-
- abstract static class TimeSeries implements Element {
- protected XYSeries series;
- private String axisName;
- private Color color;
-
- public TimeSeries(String axisName, String label, Color color) {
- this.series = new XYSeries(label);
- this.axisName = axisName;
- this.color = color;
- }
-
- public void attachGraph(AltosGraphTime g) {
- g.setAxis(this, axisName, color);
- }
- abstract public void gotTimeData(double time, AltosDataPoint d);
-
- public void addToPlot(AltosGraphTime g, XYPlot plot) {
- XYSeriesCollection dataset = new XYSeriesCollection();
- dataset.addSeries(this.series);
-
- XYItemRenderer renderer = new StandardXYItemRenderer();
- renderer.setSeriesPaint(0, color);
-
- int dataNum = g.getDataNum(this);
- int axisNum = g.getAxisNum(this);
-
- plot.setDataset(dataNum, dataset);
- plot.mapDatasetToRangeAxis(dataNum, axisNum);
- plot.setRenderer(dataNum, renderer);
- }
- }
-
- static class StateMarker implements Element {
- private LinkedList<Double> times = new LinkedList<Double>();
- private String name;
- private int state;
- private int prev_state = Altos.ao_flight_startup;
-
- StateMarker(int state, String name) {
- this.state = state;
- this.name = name;
- }
-
- public void attachGraph(AltosGraphTime g) { return; }
- public void gotTimeData(double time, AltosDataPoint d) {
- if (prev_state != state && d.state() == state)
- times.add(time);
- prev_state = d.state();
- }
-
- public void addToPlot(AltosGraphTime g, XYPlot plot) {
- for (double time : times) {
- ValueMarker m = new ValueMarker(time);
- m.setLabel(name);
- m.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
- m.setLabelTextAnchor(TextAnchor.TOP_LEFT);
- plot.addDomainMarker(m);
- }
- }
- }
-
- private String callsign = null;
- private Integer serial = null;
- private Integer flight = null;
-
- private ArrayList<Element> elements;
- private HashMap<String,Integer> axes;
- private HashMap<Element,Integer> datasets;
- private ArrayList<Integer> datasetAxis;
-
- public AltosGraphTime(String title) {
- this.filename = title.toLowerCase().replaceAll("[^a-z0-9]","_")+".png";
- this.title = title;
- this.elements = new ArrayList<Element>();
- this.axes = new HashMap<String,Integer>();
- this.datasets = new HashMap<Element,Integer>();
- this.datasetAxis = new ArrayList<Integer>();
- }
-
- public AltosGraphTime addElement(Element e) {
- e.attachGraph(this);
- elements.add(e);
- return this;
- }
-
- public void setAxis(Element ds, String axisName, Color color) {
- Integer axisNum = axes.get(axisName);
- int dsNum = datasetAxis.size();
- if (axisNum == null) {
- axisNum = newAxis(axisName, color);
- }
- datasets.put(ds, dsNum);
- datasetAxis.add(axisNum);
- }
-
- public int getAxisNum(Element ds) {
- return datasetAxis.get( datasets.get(ds) ).intValue();
- }
- public int getDataNum(Element ds) {
- return datasets.get(ds).intValue();
- }
-
- private Integer newAxis(String name, Color color) {
- int cnt = axes.size();
- AxisLocation locn = AxisLocation.BOTTOM_OR_LEFT;
- if (cnt > 0) {
- locn = AxisLocation.TOP_OR_RIGHT;
- }
- Integer res = new Integer(cnt);
- axes.put(name, res);
- this.addElement(new TimeAxis(cnt, name, color, locn));
- return res;
- }
-
- public void addData(AltosDataPoint d) {
- double time = d.time();
- for (Element e : elements) {
- e.gotTimeData(time, d);
- }
- if (callsign == null) callsign = d.callsign();
- if (serial == null) serial = new Integer(d.serial());
- if (flight == null) flight = new Integer(d.flight());
- }
-
- public JFreeChart createChart() {
- NumberAxis xAxis = new NumberAxis("Time (s)");
- xAxis.setAutoRangeIncludesZero(false);
- XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
- XYPlot plot = new XYPlot();
- plot.setDomainAxis(xAxis);
- plot.setRenderer(renderer);
- plot.setOrientation(PlotOrientation.VERTICAL);
-
- if (serial != null && flight != null) {
- title = serial + "/" + flight + ": " + title;
- }
- if (callsign != null) {
- title = callsign + " - " + title;
- }
-
- renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
- JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
- plot, true);
- ChartUtilities.applyCurrentTheme(chart);
-
- plot.setDomainPannable(true);
- plot.setRangePannable(true);
-
- for (Element e : elements) {
- e.addToPlot(this, plot);
- }
-
- return chart;
- }
-
- public void toPNG() throws java.io.IOException {
- if (axes.size() > 1) {
- toPNG(800, 500);
- } else {
- toPNG(300, 500);
- }
- }
-}
diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java
index edde1307..d8b8f6dd 100644
--- a/altosui/AltosGraphUI.java
+++ b/altosui/AltosGraphUI.java
@@ -8,306 +8,70 @@ import java.io.*;
import java.util.ArrayList;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
import org.jfree.chart.ChartPanel;
-import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
-import org.jfree.chart.axis.AxisLocation;
-import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
-public class AltosGraphUI extends AltosFrame
+public class AltosGraphUI extends AltosUIFrame
{
- JTabbedPane pane;
-
- static final private Color red = new Color(194,31,31);
- static final private Color green = new Color(31,194,31);
- static final private Color blue = new Color(31,31,194);
- static final private Color black = new Color(31,31,31);
- static final private Color yellow = new Color(194,194,31);
- static final private Color cyan = new Color(31,194,194);
- static final private Color magenta = new Color(194,31,194);
-
- static private class OverallGraphs {
- AltosGraphTime.Element height =
- new AltosGraphTime.TimeSeries(String.format("Height (%s)", AltosConvert.height.show_units()), "Height (AGL)", red) {
- public void gotTimeData(double time, AltosDataPoint d) {
- double height = d.height();
- if (height != AltosRecord.MISSING)
- series.add(time, AltosConvert.height.value(height));
- }
- };
-
- AltosGraphTime.Element speed =
- new AltosGraphTime.TimeSeries(String.format("Speed (%s)", AltosConvert.speed.show_units()), "Vertical Speed", green) {
- public void gotTimeData(double time, AltosDataPoint d) {
- double speed;
- if (d.state() < Altos.ao_flight_drogue && d.has_accel()) {
- speed = d.accel_speed();
- } else {
- speed = d.baro_speed();
- }
- if (speed != AltosRecord.MISSING)
- series.add(time, AltosConvert.speed.value(speed));
- }
- };
-
- AltosGraphTime.Element acceleration =
- new AltosGraphTime.TimeSeries(String.format("Acceleration (%s)",
- AltosConvert.accel.show_units()),
- "Axial Acceleration", blue)
- {
- public void gotTimeData(double time, AltosDataPoint d) {
- double acceleration = d.acceleration();
- if (acceleration != AltosRecord.MISSING)
- series.add(time, AltosConvert.accel.value(acceleration));
- }
- };
-
- AltosGraphTime.Element temperature =
- new AltosGraphTime.TimeSeries("Temperature (\u00B0C)",
- "Board temperature", red)
- {
- public void gotTimeData(double time, AltosDataPoint d) {
- double temp = d.temperature();
- if (temp != AltosRecord.MISSING)
- series.add(time, d.temperature());
- }
- };
-
- AltosGraphTime.Element drogue_voltage =
- new AltosGraphTime.TimeSeries("Voltage (V)", "Drogue Continuity", yellow)
- {
- public void gotTimeData(double time, AltosDataPoint d) {
- double v = d.drogue_voltage();
- if (v != AltosRecord.MISSING)
- series.add(time, v);
- }
- };
-
- AltosGraphTime.Element main_voltage =
- new AltosGraphTime.TimeSeries("Voltage (V)", "Main Continuity", magenta)
- {
- public void gotTimeData(double time, AltosDataPoint d) {
- double v = d.main_voltage();
- if (v != AltosRecord.MISSING)
- series.add(time, v);
- }
- };
-
- AltosGraphTime.Element e_pad = new AltosGraphTime.StateMarker(Altos.ao_flight_pad, "Pad");
- AltosGraphTime.Element e_boost = new AltosGraphTime.StateMarker(Altos.ao_flight_boost, "Boost");
- AltosGraphTime.Element e_fast = new AltosGraphTime.StateMarker(Altos.ao_flight_fast, "Fast");
- AltosGraphTime.Element e_coast = new AltosGraphTime.StateMarker(Altos.ao_flight_coast, "Coast");
- AltosGraphTime.Element e_drogue = new AltosGraphTime.StateMarker(Altos.ao_flight_drogue, "Drogue");
- AltosGraphTime.Element e_main = new AltosGraphTime.StateMarker(Altos.ao_flight_main, "Main");
- AltosGraphTime.Element e_landed = new AltosGraphTime.StateMarker(Altos.ao_flight_landed, "Landed");
-
- protected AltosGraphTime myAltosGraphTime(String suffix) {
- return (new AltosGraphTime("Overall " + suffix))
- .addElement(e_boost)
- .addElement(e_fast)
- .addElement(e_coast)
- .addElement(e_drogue)
- .addElement(e_main)
- .addElement(e_landed);
- }
-
- public ArrayList<AltosGraph> graphs() {
- ArrayList<AltosGraph> graphs = new ArrayList<AltosGraph>();
-
- graphs.add( myAltosGraphTime("Summary")
- .addElement(height)
- .addElement(speed)
- .addElement(acceleration) );
-
- graphs.add( myAltosGraphTime("Summary")
- .addElement(height)
- .addElement(speed));
-
- graphs.add( myAltosGraphTime("Altitude")
- .addElement(height) );
-
- graphs.add( myAltosGraphTime("Speed")
- .addElement(speed) );
-
- graphs.add( myAltosGraphTime("Acceleration")
- .addElement(acceleration) );
-
- graphs.add( myAltosGraphTime("Temperature")
- .addElement(temperature) );
-
- graphs.add( myAltosGraphTime("Continuity")
- .addElement(drogue_voltage)
- .addElement(main_voltage) );
-
- return graphs;
- }
- }
-
- static private class AscentGraphs extends OverallGraphs {
- protected AltosGraphTime myAltosGraphTime(String suffix) {
- return (new AltosGraphTime("Ascent " + suffix) {
- public void addData(AltosDataPoint d) {
- int state = d.state();
- if (Altos.ao_flight_boost <= state && state <= Altos.ao_flight_coast) {
- super.addData(d);
- }
- }
- }).addElement(e_boost)
- .addElement(e_fast)
- .addElement(e_coast);
- }
- }
-
- static private class DescentGraphs extends OverallGraphs {
- protected AltosGraphTime myAltosGraphTime(String suffix) {
- return (new AltosGraphTime("Descent " + suffix) {
- public void addData(AltosDataPoint d) {
- int state = d.state();
- if (Altos.ao_flight_drogue <= state && state <= Altos.ao_flight_main) {
- super.addData(d);
- }
- }
- }).addElement(e_drogue)
- .addElement(e_main);
- // ((XYGraph)graph[8]).ymin = new Double(-50);
- }
- }
-
- public AltosGraphUI(AltosRecordIterable records, String name) throws InterruptedException, IOException {
- super(String.format("Altos Graph %s", name));
-
- AltosDataPointReader reader = new AltosDataPointReader (records);
- if (reader == null)
- return;
-
- if (reader.has_accel)
- init(reader, records, 0);
- else
- init(reader, records, 1);
+ JTabbedPane pane;
+ AltosGraph graph;
+ AltosUIEnable enable;
+ AltosSiteMap map;
+ AltosState state;
+ AltosGraphDataSet graphDataSet;
+ AltosFlightStats stats;
+ AltosFlightStatsTable statsTable;
+ boolean has_gps;
+
+ void fill_map(AltosRecordIterable records) {
+ boolean any_gps = false;
+ for (AltosRecord record : records) {
+ state = new AltosState(record, state);
+ if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) {
+ if (map == null)
+ map = new AltosSiteMap();
+ map.show(state, null);
+ has_gps = true;
+ }
+ }
}
-// public AltosGraphUI(AltosDataPointReader data, int which)
- // {
-// super("Altos Graph");
-// init(data, which);
-// }
-
- private void init(AltosDataPointReader data, AltosRecordIterable records, int which) throws InterruptedException, IOException {
- pane = new JTabbedPane();
+ AltosGraphUI(AltosRecordIterable records, File file) throws InterruptedException, IOException {
+ super(file.getName());
+ state = null;
- AltosGraph graph = createGraph(data, which);
+ pane = new JTabbedPane();
- JFreeChart chart = graph.createChart();
- ChartPanel chartPanel = new ChartPanel(chart);
- chartPanel.setMouseWheelEnabled(true);
- chartPanel.setPreferredSize(new java.awt.Dimension(800, 500));
- pane.add(graph.title, chartPanel);
+ enable = new AltosUIEnable();
- AltosFlightStatsTable stats = new AltosFlightStatsTable(new AltosFlightStats(records));
- pane.add("Flight Statistics", stats);
+ stats = new AltosFlightStats(records);
+ graphDataSet = new AltosGraphDataSet(records);
- setContentPane (pane);
+ graph = new AltosGraph(enable, stats, graphDataSet);
- pack();
+ statsTable = new AltosFlightStatsTable(stats);
- RefineryUtilities.centerFrameOnScreen(this);
+ pane.add("Flight Graph", graph.panel);
+ pane.add("Configure Graph", enable);
+ pane.add("Flight Statistics", statsTable);
- setDefaultCloseOperation(DISPOSE_ON_CLOSE);
- setVisible(true);
- }
+ has_gps = false;
+ fill_map(records);
+ if (has_gps)
+ pane.add("Map", map);
- private static AltosGraph createGraph(Iterable<AltosDataPoint> data,
- int which)
- {
- return createGraphsWhich(data, which).get(0);
- }
+ setContentPane (pane);
- private static ArrayList<AltosGraph> createGraphs(
- Iterable<AltosDataPoint> data)
- {
- return createGraphsWhich(data, -1);
- }
+ pack();
- private static ArrayList<AltosGraph> createGraphsWhich(
- Iterable<AltosDataPoint> data, int which)
- {
- ArrayList<AltosGraph> graph = new ArrayList<AltosGraph>();
- graph.addAll((new OverallGraphs()).graphs());
-// graph.addAll((new AscentGraphs()).graphs());
-// graph.addAll((new DescentGraphs()).graphs());
-
- if (which > 0) {
- if (which >= graph.size()) {
- which = 0;
- }
- AltosGraph g = graph.get(which);
- graph = new ArrayList<AltosGraph>();
- graph.add(g);
- }
-
- for (AltosDataPoint dp : data) {
- for (AltosGraph g : graph) {
- g.addData(dp);
- }
- }
-
- return graph;
- }
+ setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+ setVisible(true);
+ if (state != null && has_gps)
+ map.centre(state);
+ }
}
-
-/* gnuplot bits...
- *
-300x400
-
---------------------------------------------------------
-TOO HARD! :)
-
-"ascent-gps-accuracy.png" "Vertical error margin to apogee - GPS v Baro (m)"
- 5:($7 < 6 ? $24-$11 : 1/0)
-"descent-gps-accuracy.png" "Vertical error margin during descent - GPS v Baro (m)"
- 5:($7 < 6 ? 1/0 : $24-$11)
-
-set output "overall-gps-accuracy.png"
-set ylabel "distance above sea level (m)"
-plot "telemetry.csv" using 5:11 with lines ti "baro altitude" axis x1y1, \
- "telemetry.csv" using 5:24 with lines ti "gps altitude" axis x1y1
-
-set term png tiny size 700,700 enhanced
-set xlabel "m"
-set ylabel "m"
-set polar
-set grid polar
-set rrange[*:*]
-set angles degrees
-
-set output "overall-gps-path.png"
-#:30 with yerrorlines
-plot "telemetry.csv" using (90-$33):($7 == 2 ? $31 : 1/0) with lines ti "pad", \
- "telemetry.csv" using (90-$33):($7 == 3 ? $31 : 1/0) with lines ti "boost", \
- "telemetry.csv" using (90-$33):($7 == 4 ? $31 : 1/0) with lines ti "fast", \
- "telemetry.csv" using (90-$33):($7 == 5 ? $31 : 1/0) with lines ti "coast", \
- "telemetry.csv" using (90-$33):($7 == 6 ? $31 : 1/0) with lines ti "drogue", \
- "telemetry.csv" using (90-$33):($7 == 7 ? $31 : 1/0) with lines ti "main", \
- "telemetry.csv" using (90-$33):($7 == 8 ? $31 : 1/0) with lines ti "landed"
-
-set output "ascent-gps-path.png"
-plot "telemetry.csv" using (90-$33):($7 == 2 ? $31 : 1/0):30 with lines ti "pad", \
- "telemetry.csv" using (90-$33):($7 == 3 ? $31 : 1/0):20 with lines ti "boost", \
- "telemetry.csv" using (90-$33):($7 == 4 ? $31 : 1/0):10 with lines ti "fast", \
- "telemetry.csv" using (90-$33):($7 == 5 ? $31 : 1/0):5 with lines ti "coast"
-
-set output "descent-gps-path.png"
-plot "telemetry.csv" using (90-$33):($7 == 6 ? $31 : 1/0) with lines ti "drogue", \
- "telemetry.csv" using (90-$33):($7 == 7 ? $31 : 1/0) with lines ti "main", \
- "telemetry.csv" using (90-$33):($7 == 8 ? $31 : 1/0) with lines ti "landed"
-
- */
-
-
diff --git a/altosui/AltosHexfile.java b/altosui/AltosHexfile.java
deleted file mode 100644
index d52b46c3..00000000
--- a/altosui/AltosHexfile.java
+++ /dev/null
@@ -1,253 +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.lang.*;
-import java.io.*;
-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;
-
- public HexFileInputStream(FileInputStream o) {
- super(new BufferedInputStream(o));
- line = 1;
- }
-
- public int read() throws IOException {
- int c = super.read();
- if (c == '\n')
- line++;
- return c;
- }
-
- public void unread(int c) throws IOException {
- if (c == '\n')
- line--;
- if (c != -1)
- super.unread(c);
- }
-}
-
-class HexRecord implements Comparable {
- public int address;
- public int type;
- public byte checksum;
- public byte[] data;
-
- static final int NORMAL = 0;
- static final int EOF = 1;
- static final int EXTENDED_ADDRESS = 2;
-
- enum read_state {
- marker,
- length,
- address,
- type,
- data,
- checksum,
- newline,
- white,
- done,
- }
-
- boolean ishex(int c) {
- if ('0' <= c && c <= '9')
- return true;
- if ('a' <= c && c <= 'f')
- return true;
- if ('A' <= c && c <= 'F')
- return true;
- return false;
- }
-
- boolean isspace(int c) {
- switch (c) {
- case ' ':
- case '\t':
- return true;
- }
- return false;
- }
-
- int fromhex(int c) {
- if ('0' <= c && c <= '9')
- return c - '0';
- if ('a' <= c && c <= 'f')
- return c - 'a' + 10;
- if ('A' <= c && c <= 'F')
- return c - 'A' + 10;
- return -1;
- }
-
- public byte checksum() {
- byte got = 0;
-
- got += data.length;
- got += (address >> 8) & 0xff;
- got += (address ) & 0xff;
- got += type;
- for (int i = 0; i < data.length; i++)
- got += data[i];
- return (byte) (-got);
- }
-
- public int compareTo(Object other) {
- HexRecord o = (HexRecord) other;
- return address - o.address;
- }
-
- public String toString() {
- return String.format("%04x: %02x (%d)", address, type, data.length);
- }
-
- public HexRecord(HexFileInputStream input) throws IOException {
- read_state state = read_state.marker;
- int nhexbytes = 0;
- int hex = 0;
- int ndata = 0;
- byte got_checksum;
-
- while (state != read_state.done) {
- int c = input.read();
- if (c < 0 && state != read_state.white)
- throw new IOException(String.format("%d: Unexpected EOF", input.line));
- if (c == ' ')
- continue;
- switch (state) {
- case marker:
- if (c != ':')
- throw new IOException("Missing ':'");
- state = read_state.length;
- nhexbytes = 2;
- hex = 0;
- break;
- case length:
- case address:
- case type:
- case data:
- case checksum:
- if(!ishex(c))
- throw new IOException(String.format("Non-hex char '%c'", c));
- hex = hex << 4 | fromhex(c);
- --nhexbytes;
- if (nhexbytes != 0)
- break;
-
- switch (state) {
- case length:
- data = new byte[hex];
- state = read_state.address;
- nhexbytes = 4;
- break;
- case address:
- address = hex;
- state = read_state.type;
- nhexbytes = 2;
- break;
- case type:
- type = hex;
- if (data.length > 0)
- state = read_state.data;
- else
- state = read_state.checksum;
- nhexbytes = 2;
- ndata = 0;
- break;
- case data:
- data[ndata] = (byte) hex;
- ndata++;
- nhexbytes = 2;
- if (ndata == data.length)
- state = read_state.checksum;
- break;
- case checksum:
- checksum = (byte) hex;
- state = read_state.newline;
- break;
- default:
- break;
- }
- hex = 0;
- break;
- case newline:
- if (c != '\n' && c != '\r')
- throw new IOException("Missing newline");
- state = read_state.white;
- break;
- case white:
- if (!isspace(c)) {
- input.unread(c);
- state = read_state.done;
- }
- break;
- case done:
- break;
- }
- }
- got_checksum = checksum();
- if (got_checksum != checksum)
- throw new IOException(String.format("Invalid checksum (read 0x%02x computed 0x%02x)\n",
- checksum, got_checksum));
- }
-}
-
-public class AltosHexfile {
- public int address;
- public byte[] data;
-
- public byte get_byte(int a) {
- return data[a - address];
- }
-
- public AltosHexfile(FileInputStream file) throws IOException {
- HexFileInputStream input = new HexFileInputStream(file);
- LinkedList<HexRecord> record_list = new LinkedList<HexRecord>();
- boolean done = false;
-
- while (!done) {
- HexRecord record = new HexRecord(input);
-
- if (record.type == HexRecord.EOF)
- done = true;
- else
- record_list.add(record);
- }
- HexRecord[] records = record_list.toArray(new HexRecord[0]);
- Arrays.sort(records);
- if (records.length > 0) {
- int base = records[0].address;
- int bound = records[records.length-1].address +
- records[records.length-1].data.length;
-
- data = new byte[bound - base];
- address = base;
- Arrays.fill(data, (byte) 0xff);
-
- /* Paint the records into the new array */
- for (int i = 0; i < records.length; i++) {
- for (int j = 0; j < records[i].data.length; j++)
- data[records[i].address - base + j] = records[i].data[j];
- }
- }
- }
-} \ No newline at end of file
diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java
index 510579c5..bbab017f 100644
--- a/altosui/AltosIdleMonitorUI.java
+++ b/altosui/AltosIdleMonitorUI.java
@@ -20,16 +20,13 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
+import javax.swing.event.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
-public class AltosIdleMonitorUI extends AltosFrame implements AltosFlightDisplay, AltosFontListener, AltosIdleMonitorListener {
+public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener, AltosIdleMonitorListener, DocumentListener {
AltosDevice device;
JTabbedPane pane;
AltosPad pad;
@@ -40,11 +37,8 @@ public class AltosIdleMonitorUI extends AltosFrame implements AltosFlightDisplay
boolean remote;
void stop_display() {
- if (thread != null && thread.isAlive()) {
- thread.interrupt();
- try {
- thread.join();
- } catch (InterruptedException ie) {}
+ if (thread != null) {
+ thread.abort();
}
thread = null;
}
@@ -69,21 +63,21 @@ public class AltosIdleMonitorUI extends AltosFrame implements AltosFlightDisplay
AltosFlightStatusUpdate status_update;
- public void show(AltosState state, int crc_errors) {
+ public void show(AltosState state, AltosListenerState listener_state) {
status_update.saved_state = state;
try {
- pad.show(state, crc_errors);
- flightStatus.show(state, crc_errors);
- flightInfo.show(state, crc_errors);
+ pad.show(state, listener_state);
+ flightStatus.show(state, listener_state);
+ flightInfo.show(state, listener_state);
} catch (Exception e) {
System.out.print("Show exception" + e);
}
}
- public void update(final AltosState state) {
+ public void update(final AltosState state, final AltosListenerState listener_state) {
Runnable r = new Runnable() {
public void run() {
- show(state, 0);
+ show(state, listener_state);
}
};
SwingUtilities.invokeLater(r);
@@ -91,11 +85,53 @@ public class AltosIdleMonitorUI extends AltosFrame implements AltosFlightDisplay
Container bag;
AltosFreqList frequencies;
+ JTextField callsign_value;
+
+ /* DocumentListener interface methods */
+ public void changedUpdate(DocumentEvent e) {
+ if (callsign_value != null) {
+ String callsign = callsign_value.getText();
+ thread.set_callsign(callsign);
+ AltosUIPreferences.set_callsign(callsign);
+ }
+ }
+
+ public void insertUpdate(DocumentEvent e) {
+ changedUpdate(e);
+ }
+
+ public void removeUpdate(DocumentEvent e) {
+ changedUpdate(e);
+ }
+
+ int row = 0;
+
+ public GridBagConstraints constraints (int x, int width, int fill) {
+ GridBagConstraints c = new GridBagConstraints();
+ Insets insets = new Insets(4, 4, 4, 4);
+
+ c.insets = insets;
+ c.fill = fill;
+ if (width == 3)
+ c.anchor = GridBagConstraints.CENTER;
+ else if (x == 2)
+ c.anchor = GridBagConstraints.EAST;
+ else
+ c.anchor = GridBagConstraints.WEST;
+ c.gridx = x;
+ c.gridwidth = width;
+ c.gridy = row;
+ return c;
+ }
+
+ public GridBagConstraints constraints(int x, int width) {
+ return constraints(x, width, GridBagConstraints.NONE);
+ }
public AltosIdleMonitorUI(JFrame in_owner)
throws FileNotFoundException, AltosSerialInUseException, TimeoutException, InterruptedException {
- device = AltosDeviceDialog.show(in_owner, Altos.product_any);
+ device = AltosDeviceUIDialog.show(in_owner, Altos.product_any);
remote = false;
if (!device.matchProduct(Altos.product_altimeter))
remote = true;
@@ -104,8 +140,6 @@ public class AltosIdleMonitorUI extends AltosFrame implements AltosFlightDisplay
bag = getContentPane();
bag.setLayout(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
-
setTitle(String.format("AltOS %s", device.toShortString()));
/* Stick frequency selector at top of table for telemetry monitoring */
@@ -120,23 +154,21 @@ public class AltosIdleMonitorUI extends AltosFrame implements AltosFlightDisplay
frequency);
}
});
- c.gridx = 0;
- c.gridy = 0;
- c.insets = new Insets(3, 3, 3, 3);
- c.anchor = GridBagConstraints.WEST;
- bag.add (frequencies, c);
+ bag.add (frequencies, constraints(0, 1));
+ bag.add (new JLabel("Callsign:"), constraints(1, 1));
+ /* Add callsign configuration */
+ callsign_value = new JTextField(AltosUIPreferences.callsign());
+ callsign_value.getDocument().addDocumentListener(this);
+ callsign_value.setToolTipText("Callsign sent in packet mode");
+ bag.add(callsign_value, constraints(2, 1, GridBagConstraints.BOTH));
+ row++;
}
/* Flight status is always visible */
flightStatus = new AltosFlightStatus();
- c.gridx = 0;
- c.gridy = 1;
- c.fill = GridBagConstraints.HORIZONTAL;
- c.weightx = 1;
- c.gridwidth = 2;
- bag.add(flightStatus, c);
- c.gridwidth = 1;
+ bag.add(flightStatus, constraints(0, 3, GridBagConstraints.HORIZONTAL));
+ row++;
/* The rest of the window uses a tabbed pane to
* show one of the alternate data views
@@ -150,13 +182,7 @@ public class AltosIdleMonitorUI extends AltosFrame implements AltosFlightDisplay
pane.add("Table", new JScrollPane(flightInfo));
/* Make the tabbed pane use the rest of the window space */
- c.gridx = 0;
- c.gridy = 2;
- c.fill = GridBagConstraints.BOTH;
- c.weightx = 1;
- c.weighty = 1;
- c.gridwidth = 2;
- bag.add(pane, c);
+ bag.add(pane, constraints(0, 3, GridBagConstraints.BOTH));
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java
index 78eba8e6..14d4eebc 100644
--- a/altosui/AltosIgniteUI.java
+++ b/altosui/AltosIgniteUI.java
@@ -20,18 +20,14 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import javax.swing.event.*;
import java.io.*;
-import java.util.*;
import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosIgniteUI
- extends AltosDialog
+ extends AltosUIDialog
implements ActionListener
{
AltosDevice device;
@@ -309,7 +305,7 @@ public class AltosIgniteUI
private boolean open() {
command_queue = new LinkedBlockingQueue<String>();
- device = AltosDeviceDialog.show(owner, Altos.product_any);
+ device = AltosDeviceUIDialog.show(owner, Altos.product_any);
if (device != null) {
IgniteHandler handler = new IgniteHandler(owner);
Thread t = new Thread(handler);
diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java
index c1400976..3d16faf2 100644
--- a/altosui/AltosInfoTable.java
+++ b/altosui/AltosInfoTable.java
@@ -18,16 +18,9 @@
package altosui;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosInfoTable extends JTable {
private AltosFlightInfoTableModel model;
@@ -100,7 +93,7 @@ public class AltosInfoTable extends JTable {
double deg = Math.floor(v);
double min = (v - deg) * 60;
- info_add_row(col, name, String.format("%3.0f°%08.5f'", deg, min));
+ info_add_row(col, name, String.format("%c %3.0f°%08.5f'", c, deg, min));
}
void info_finish() {
@@ -111,98 +104,118 @@ public class AltosInfoTable extends JTable {
model.clear();
}
- public void show(AltosState state, int crc_errors) {
- if (state == null)
- return;
+ public void show(AltosState state, AltosListenerState listener_state) {
info_reset();
- info_add_row(0, "Altitude", "%6.0f m", state.altitude);
- info_add_row(0, "Pad altitude", "%6.0f m", state.ground_altitude);
- info_add_row(0, "Height", "%6.0f m", state.height);
- info_add_row(0, "Max height", "%6.0f m", state.max_height);
- info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration);
- info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration);
- info_add_row(0, "Speed", "%8.1f m/s", state.ascent ? state.speed : state.baro_speed);
- info_add_row(0, "Max Speed", "%8.1f m/s", state.max_speed);
- info_add_row(0, "Temperature", "%9.2f °C", state.temperature);
- info_add_row(0, "Battery", "%9.2f V", state.battery);
- if (state.drogue_sense != AltosRecord.MISSING)
- info_add_row(0, "Drogue", "%9.2f V", state.drogue_sense);
- if (state.main_sense != AltosRecord.MISSING)
- info_add_row(0, "Main", "%9.2f V", state.main_sense);
- info_add_row(0, "CRC Errors", "%6d", crc_errors);
-
- if (state.gps == null || !state.gps.connected) {
- info_add_row(1, "GPS", "not available");
- } else {
- if (state.gps_ready)
- info_add_row(1, "GPS state", "%s", "ready");
- else
- info_add_row(1, "GPS state", "wait (%d)",
- state.gps_waiting);
- if (state.data.gps.locked)
- info_add_row(1, "GPS", " locked");
- else if (state.data.gps.connected)
- info_add_row(1, "GPS", " unlocked");
- else
- info_add_row(1, "GPS", " missing");
- info_add_row(1, "Satellites", "%6d", state.data.gps.nsat);
- info_add_deg(1, "Latitude", state.gps.lat, 'N', 'S');
- info_add_deg(1, "Longitude", state.gps.lon, 'E', 'W');
- info_add_row(1, "GPS altitude", "%6d", state.gps.alt);
- info_add_row(1, "GPS height", "%6.0f", state.gps_height);
-
- /* The SkyTraq GPS doesn't report these values */
- if (false) {
- info_add_row(1, "GPS ground speed", "%8.1f m/s %3d°",
- state.gps.ground_speed,
- state.gps.course);
- info_add_row(1, "GPS climb rate", "%8.1f m/s",
- state.gps.climb_rate);
- info_add_row(1, "GPS error", "%6d m(h)%3d m(v)",
- state.gps.h_error, state.gps.v_error);
- }
- info_add_row(1, "GPS hdop", "%8.1f", state.gps.hdop);
-
- if (state.npad > 0) {
- if (state.from_pad != null) {
- info_add_row(1, "Distance from pad", "%6d m",
- (int) (state.from_pad.distance + 0.5));
- info_add_row(1, "Direction from pad", "%6d°",
- (int) (state.from_pad.bearing + 0.5));
- info_add_row(1, "Elevation from pad", "%6d°",
- (int) (state.elevation + 0.5));
- info_add_row(1, "Range from pad", "%6d m",
- (int) (state.range + 0.5));
- } else {
- info_add_row(1, "Distance from pad", "unknown");
- info_add_row(1, "Direction from pad", "unknown");
- info_add_row(1, "Elevation from pad", "unknown");
- info_add_row(1, "Range from pad", "unknown");
+ if (state != null) {
+ if (state.altitude != AltosRecord.MISSING)
+ info_add_row(0, "Altitude", "%6.0f m", state.altitude);
+ if (state.ground_altitude != AltosRecord.MISSING)
+ info_add_row(0, "Pad altitude", "%6.0f m", state.ground_altitude);
+ if (state.height != AltosRecord.MISSING)
+ info_add_row(0, "Height", "%6.0f m", state.height);
+ if (state.height != AltosRecord.MISSING)
+ info_add_row(0, "Max height", "%6.0f m", state.max_height);
+ if (state.acceleration != AltosRecord.MISSING)
+ info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration);
+ if (state.acceleration != AltosRecord.MISSING)
+ info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration);
+ if (state.speed() != AltosRecord.MISSING)
+ info_add_row(0, "Speed", "%8.1f m/s", state.speed());
+ if (state.speed() != AltosRecord.MISSING)
+ info_add_row(0, "Max Speed", "%8.1f m/s", state.max_accel_speed);
+ if (state.temperature != AltosRecord.MISSING)
+ info_add_row(0, "Temperature", "%9.2f °C", state.temperature);
+ if (state.battery != AltosRecord.MISSING)
+ info_add_row(0, "Battery", "%9.2f V", state.battery);
+ if (state.drogue_sense != AltosRecord.MISSING)
+ info_add_row(0, "Drogue", "%9.2f V", state.drogue_sense);
+ if (state.main_sense != AltosRecord.MISSING)
+ info_add_row(0, "Main", "%9.2f V", state.main_sense);
+ }
+ if (listener_state != null) {
+ info_add_row(0, "CRC Errors", "%6d", listener_state.crc_errors);
+
+ if (listener_state.battery != AltosRecord.MISSING)
+ info_add_row(0, "Receiver Battery", "%9.2f", listener_state.battery);
+ }
+
+ if (state != null) {
+ if (state.gps == null || !state.gps.connected) {
+ info_add_row(1, "GPS", "not available");
+ } else {
+ if (state.gps_ready)
+ info_add_row(1, "GPS state", "%s", "ready");
+ else
+ info_add_row(1, "GPS state", "wait (%d)",
+ state.gps_waiting);
+ if (state.data.gps.locked)
+ info_add_row(1, "GPS", " locked");
+ else if (state.data.gps.connected)
+ info_add_row(1, "GPS", " unlocked");
+ else
+ info_add_row(1, "GPS", " missing");
+ info_add_row(1, "Satellites", "%6d", state.data.gps.nsat);
+ info_add_deg(1, "Latitude", state.gps.lat, 'N', 'S');
+ info_add_deg(1, "Longitude", state.gps.lon, 'E', 'W');
+ info_add_row(1, "GPS altitude", "%6d", state.gps.alt);
+ info_add_row(1, "GPS height", "%6.0f", state.gps_height);
+
+ /* The SkyTraq GPS doesn't report these values */
+ /*
+ if (false) {
+ info_add_row(1, "GPS ground speed", "%8.1f m/s %3d°",
+ state.gps.ground_speed,
+ state.gps.course);
+ info_add_row(1, "GPS climb rate", "%8.1f m/s",
+ state.gps.climb_rate);
+ info_add_row(1, "GPS error", "%6d m(h)%3d m(v)",
+ state.gps.h_error, state.gps.v_error);
+ }
+ */
+
+ info_add_row(1, "GPS hdop", "%8.1f", state.gps.hdop);
+
+ if (state.npad > 0) {
+ if (state.from_pad != null) {
+ info_add_row(1, "Distance from pad", "%6d m",
+ (int) (state.from_pad.distance + 0.5));
+ info_add_row(1, "Direction from pad", "%6d°",
+ (int) (state.from_pad.bearing + 0.5));
+ info_add_row(1, "Elevation from pad", "%6d°",
+ (int) (state.elevation + 0.5));
+ info_add_row(1, "Range from pad", "%6d m",
+ (int) (state.range + 0.5));
+ } else {
+ info_add_row(1, "Distance from pad", "unknown");
+ info_add_row(1, "Direction from pad", "unknown");
+ info_add_row(1, "Elevation from pad", "unknown");
+ info_add_row(1, "Range from pad", "unknown");
+ }
+ info_add_deg(1, "Pad latitude", state.pad_lat, 'N', 'S');
+ info_add_deg(1, "Pad longitude", state.pad_lon, 'E', 'W');
+ info_add_row(1, "Pad GPS alt", "%6.0f m", state.pad_alt);
}
- info_add_deg(1, "Pad latitude", state.pad_lat, 'N', 'S');
- info_add_deg(1, "Pad longitude", state.pad_lon, 'E', 'W');
- info_add_row(1, "Pad GPS alt", "%6.0f m", state.pad_alt);
- }
- info_add_row(1, "GPS date", "%04d-%02d-%02d",
- state.gps.year,
- state.gps.month,
- state.gps.day);
- info_add_row(1, "GPS time", " %02d:%02d:%02d",
- state.gps.hour,
- state.gps.minute,
- state.gps.second);
- int nsat_vis = 0;
- int c;
-
- if (state.gps.cc_gps_sat == null)
- info_add_row(2, "Satellites Visible", "%4d", 0);
- else {
- info_add_row(2, "Satellites Visible", "%4d", state.gps.cc_gps_sat.length);
- for (c = 0; c < state.gps.cc_gps_sat.length; c++) {
- info_add_row(2, "Satellite id,C/N0",
- "%4d, %4d",
- state.gps.cc_gps_sat[c].svid,
- state.gps.cc_gps_sat[c].c_n0);
+ info_add_row(1, "GPS date", "%04d-%02d-%02d",
+ state.gps.year,
+ state.gps.month,
+ state.gps.day);
+ info_add_row(1, "GPS time", " %02d:%02d:%02d",
+ state.gps.hour,
+ state.gps.minute,
+ state.gps.second);
+ //int nsat_vis = 0;
+ int c;
+
+ if (state.gps.cc_gps_sat == null)
+ info_add_row(2, "Satellites Visible", "%4d", 0);
+ else {
+ info_add_row(2, "Satellites Visible", "%4d", state.gps.cc_gps_sat.length);
+ for (c = 0; c < state.gps.cc_gps_sat.length; c++) {
+ info_add_row(2, "Satellite id,C/N0",
+ "%4d, %4d",
+ state.gps.cc_gps_sat[c].svid,
+ state.gps.cc_gps_sat[c].c_n0);
+ }
}
}
}
diff --git a/altosui/AltosKML.java b/altosui/AltosKML.java
index 73a5ae53..140f3f07 100644
--- a/altosui/AltosKML.java
+++ b/altosui/AltosKML.java
@@ -17,11 +17,8 @@
package altosui;
-import java.lang.*;
import java.io.*;
-import java.text.*;
-import java.util.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosKML implements AltosWriter {
@@ -29,6 +26,7 @@ public class AltosKML implements AltosWriter {
PrintStream out;
int state = -1;
AltosRecord prev = null;
+ double gps_start_altitude;
static final String[] kml_state_colors = {
"FF000000",
@@ -110,9 +108,15 @@ public class AltosKML implements AltosWriter {
void coord(AltosRecord record) {
AltosGPS gps = record.gps;
+ double altitude;
+
+ if (record.height() != AltosRecord.MISSING)
+ altitude = record.height() + gps_start_altitude;
+ else
+ altitude = gps.alt;
out.printf(kml_coord_fmt,
gps.lon, gps.lat,
- record.filtered_altitude(), (double) gps.alt,
+ altitude, (double) gps.alt,
record.time, gps.nsat);
}
@@ -134,8 +138,6 @@ public class AltosKML implements AltosWriter {
if (gps == null)
return;
- if ((record.seen & (AltosRecord.seen_flight)) == 0)
- return;
if ((record.seen & (AltosRecord.seen_gps_lat)) == 0)
return;
if ((record.seen & (AltosRecord.seen_gps_lon)) == 0)
@@ -143,11 +145,9 @@ public class AltosKML implements AltosWriter {
if (!started) {
start(record);
started = true;
+ gps_start_altitude = gps.alt;
}
- if (prev != null &&
- prev.gps.second == record.gps.second &&
- prev.gps.minute == record.gps.minute &&
- prev.gps.hour == record.gps.hour)
+ if (prev != null && prev.gps_sequence == record.gps_sequence)
return;
if (record.state != state) {
state = record.state;
diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java
index 68efae8d..1d209bda 100644
--- a/altosui/AltosLanded.java
+++ b/altosui/AltosLanded.java
@@ -20,14 +20,8 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener {
GridBagLayout layout;
@@ -35,7 +29,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
public class LandedValue {
JLabel label;
JTextField value;
- void show(AltosState state, int crc_errors) {}
+ void show(AltosState state, AltosListenerState listener_state) {}
void reset() {
value.setText("");
@@ -108,7 +102,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
}
class Lat extends LandedValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
if (state.gps != null && state.gps.connected)
show(pos(state.gps.lat,"N", "S"));
else
@@ -122,7 +116,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
Lat lat;
class Lon extends LandedValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show();
if (state.gps != null && state.gps.connected)
show(pos(state.gps.lon,"E", "W"));
@@ -137,7 +131,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
Lon lon;
class Bearing extends LandedValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show();
if (state.from_pad != null)
show("%3.0f°", state.from_pad.bearing);
@@ -152,7 +146,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
Bearing bearing;
class Distance extends LandedValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show();
if (state.from_pad != null)
show(AltosConvert.distance, state.from_pad.distance);
@@ -167,7 +161,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
Distance distance;
class Height extends LandedValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show(AltosConvert.height, state.max_height);
}
public Height (GridBagLayout layout, int y) {
@@ -178,8 +172,8 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
Height height;
class Speed extends LandedValue {
- void show (AltosState state, int crc_errors) {
- show(AltosConvert.speed, state.max_speed);
+ void show (AltosState state, AltosListenerState listener_state) {
+ show(AltosConvert.speed, state.max_speed());
}
public Speed (GridBagLayout layout, int y) {
super (layout, y, "Maximum Speed");
@@ -189,7 +183,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
Speed speed;
class Accel extends LandedValue {
- void show (AltosState state, int crc_errors) {
+ void show (AltosState state, AltosListenerState listener_state) {
show(AltosConvert.accel, state.max_acceleration);
}
public Accel (GridBagLayout layout, int y) {
@@ -219,21 +213,21 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
accel.set_font();
}
- public void show(AltosState state, int crc_errors) {
+ public void show(AltosState state, AltosListenerState listener_state) {
if (state.gps != null && state.gps.connected) {
- bearing.show(state, crc_errors);
- distance.show(state, crc_errors);
- lat.show(state, crc_errors);
- lon.show(state, crc_errors);
+ bearing.show(state, listener_state);
+ distance.show(state, listener_state);
+ lat.show(state, listener_state);
+ lon.show(state, listener_state);
} else {
bearing.hide();
distance.hide();
lat.hide();
lon.hide();
}
- height.show(state, crc_errors);
- speed.show(state, crc_errors);
- accel.show(state, crc_errors);
+ height.show(state, listener_state);
+ speed.show(state, listener_state);
+ accel.show(state, listener_state);
if (reader.backing_file() != null)
graph.setEnabled(true);
}
@@ -256,11 +250,14 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
} else if (filename.endsWith("telem")) {
FileInputStream in = new FileInputStream(file);
records = new AltosTelemetryIterable(in);
+ } else if (filename.endsWith("mega")) {
+ FileInputStream in = new FileInputStream(file);
+ records = new AltosEepromMegaIterable(in);
} else {
throw new FileNotFoundException(filename);
}
try {
- new AltosGraphUI(records, filename);
+ new AltosGraphUI(records, file);
} catch (InterruptedException ie) {
} catch (IOException ie) {
}
@@ -274,6 +271,10 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
}
}
+ public String getName() {
+ return "Landed";
+ }
+
public AltosLanded(AltosFlightReader in_reader) {
layout = new GridBagLayout();
diff --git a/altosui/AltosLaunch.java b/altosui/AltosLaunch.java
index 0e493b91..04948ee6 100644
--- a/altosui/AltosLaunch.java
+++ b/altosui/AltosLaunch.java
@@ -20,12 +20,7 @@ package altosui;
import java.io.*;
import java.util.concurrent.*;
import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import javax.swing.event.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosLaunch {
AltosDevice device;
diff --git a/altosui/AltosLaunchUI.java b/altosui/AltosLaunchUI.java
index 44481544..4d9fbda5 100644
--- a/altosui/AltosLaunchUI.java
+++ b/altosui/AltosLaunchUI.java
@@ -20,15 +20,10 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import javax.swing.event.*;
import java.io.*;
-import java.util.*;
import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib_1.*;
class FireButton extends JButton {
protected void processMouseEvent(MouseEvent e) {
@@ -51,7 +46,7 @@ class FireButton extends JButton {
}
public class AltosLaunchUI
- extends AltosDialog
+ extends AltosUIDialog
implements ActionListener
{
AltosDevice device;
@@ -376,7 +371,7 @@ public class AltosLaunchUI
private boolean open() {
command_queue = new LinkedBlockingQueue<String>();
- device = AltosDeviceDialog.show(owner, Altos.product_any);
+ device = AltosDeviceUIDialog.show(owner, Altos.product_any);
if (device != null) {
LaunchHandler handler = new LaunchHandler(owner);
Thread t = new Thread(handler);
diff --git a/altosui/AltosLed.java b/altosui/AltosLed.java
index 1358cd48..93064f1e 100644
--- a/altosui/AltosLed.java
+++ b/altosui/AltosLed.java
@@ -17,17 +17,7 @@
package altosui;
-import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-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;
diff --git a/altosui/AltosLights.java b/altosui/AltosLights.java
index 8bd9e7de..7ad22f3e 100644
--- a/altosui/AltosLights.java
+++ b/altosui/AltosLights.java
@@ -18,16 +18,7 @@
package altosui;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
public class AltosLights extends JComponent {
diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java
index 947c7540..e2316a13 100644
--- a/altosui/AltosPad.java
+++ b/altosui/AltosPad.java
@@ -18,16 +18,8 @@
package altosui;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosPad extends JComponent implements AltosFlightDisplay {
GridBagLayout layout;
@@ -37,7 +29,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
JTextField value;
AltosLights lights;
- void show(AltosState state, int crc_errors) {}
+ void show(AltosState state, AltosListenerState listener_state) {}
void reset() {
value.setText("");
@@ -74,6 +66,10 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
value.setFont(Altos.value_font);
}
+ public void set_label(String text) {
+ label.setText(text);
+ }
+
public LaunchStatus (GridBagLayout layout, int y, String text) {
GridBagConstraints c = new GridBagConstraints();
c.weighty = 1;
@@ -113,7 +109,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
public class LaunchValue {
JLabel label;
JTextField value;
- void show(AltosState state, int crc_errors) {}
+ void show(AltosState state, AltosListenerState listener_state) {}
void show() {
label.setVisible(true);
@@ -143,6 +139,10 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
show(String.format(format, v));
}
+ public void set_label(String text) {
+ label.setText(text);
+ }
+
void reset() {
value.setText("");
}
@@ -175,9 +175,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
}
class Battery extends LaunchStatus {
- void show (AltosState state, int crc_errors) {
- show("%4.2f V", state.battery);
- lights.set(state.battery > 3.7);
+ void show (AltosState state, AltosListenerState listener_state) {
+ if (state == null || state.battery == AltosRecord.MISSING)
+ hide();
+ else {
+ show("%4.2f V", state.battery);
+ lights.set(state.battery > 3.7);
+ }
}
public Battery (GridBagLayout layout, int y) {
super(layout, y, "Battery Voltage");
@@ -187,9 +191,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
Battery battery;
class Apogee extends LaunchStatus {
- void show (AltosState state, int crc_errors) {
- show("%4.2f V", state.drogue_sense);
- lights.set(state.drogue_sense > 3.2);
+ void show (AltosState state, AltosListenerState listener_state) {
+ if (state == null || state.drogue_sense == AltosRecord.MISSING)
+ hide();
+ else {
+ show("%4.2f V", state.drogue_sense);
+ lights.set(state.drogue_sense > 3.2);
+ }
}
public Apogee (GridBagLayout layout, int y) {
super(layout, y, "Apogee Igniter Voltage");
@@ -199,9 +207,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
Apogee apogee;
class Main extends LaunchStatus {
- void show (AltosState state, int crc_errors) {
- show("%4.2f V", state.main_sense);
- lights.set(state.main_sense > 3.2);
+ void show (AltosState state, AltosListenerState listener_state) {
+ if (state == null || state.main_sense == AltosRecord.MISSING)
+ hide();
+ else {
+ show("%4.2f V", state.main_sense);
+ lights.set(state.main_sense > 3.2);
+ }
}
public Main (GridBagLayout layout, int y) {
super(layout, y, "Main Igniter Voltage");
@@ -211,18 +223,21 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
Main main;
class LoggingReady extends LaunchStatus {
- void show (AltosState state, int crc_errors) {
- if (state.data.flight != 0) {
- if (state.data.state <= Altos.ao_flight_pad)
- show("Ready to record");
- else if (state.data.state < Altos.ao_flight_landed)
- show("Recording data");
- else
- show("Recorded data");
+ void show (AltosState state, AltosListenerState listener_state) {
+ if (state == null || state.data.flight == AltosRecord.MISSING) {
+ hide();
+ } else {
+ if (state.data.flight != 0) {
+ if (state.data.state <= Altos.ao_flight_pad)
+ show("Ready to record");
+ else if (state.data.state < Altos.ao_flight_landed)
+ show("Recording data");
+ else
+ show("Recorded data");
+ } else
+ show("Storage full");
+ lights.set(state.data.flight != 0);
}
- else
- show("Storage full");
- lights.set(state.data.flight != 0);
}
public LoggingReady (GridBagLayout layout, int y) {
super(layout, y, "On-board Data Logging");
@@ -232,9 +247,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
LoggingReady logging_ready;
class GPSLocked extends LaunchStatus {
- void show (AltosState state, int crc_errors) {
- show("%4d sats", state.gps.nsat);
- lights.set(state.gps.locked && state.gps.nsat >= 4);
+ void show (AltosState state, AltosListenerState listener_state) {
+ if (state == null || state.gps == null)
+ hide();
+ else {
+ show("%4d sats", state.gps.nsat);
+ lights.set(state.gps.locked && state.gps.nsat >= 4);
+ }
}
public GPSLocked (GridBagLayout layout, int y) {
super (layout, y, "GPS Locked");
@@ -244,12 +263,16 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
GPSLocked gps_locked;
class GPSReady extends LaunchStatus {
- void show (AltosState state, int crc_errors) {
- if (state.gps_ready)
- show("Ready");
- else
- show("Waiting %d", state.gps_waiting);
- lights.set(state.gps_ready);
+ void show (AltosState state, AltosListenerState listener_state) {
+ if (state == null || state.gps == null)
+ hide();
+ else {
+ if (state.gps_ready)
+ show("Ready");
+ else
+ show("Waiting %d", state.gps_waiting);
+ lights.set(state.gps_ready);
+ }
}
public GPSReady (GridBagLayout layout, int y) {
super (layout, y, "GPS Ready");
@@ -258,6 +281,22 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
GPSReady gps_ready;
+ class ReceiverBattery extends LaunchStatus {
+ void show (AltosState state, AltosListenerState listener_state) {
+ if (listener_state == null || listener_state.battery == AltosRecord.MISSING)
+ hide();
+ else {
+ show("%4.2f V", listener_state.battery);
+ lights.set(listener_state.battery > 3.7);
+ }
+ }
+ public ReceiverBattery (GridBagLayout layout, int y) {
+ super(layout, y, "Receiver Battery");
+ }
+ }
+
+ ReceiverBattery receiver_battery;
+
String pos(double p, String pos, String neg) {
String h = pos;
if (p < 0) {
@@ -270,8 +309,18 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
}
class PadLat extends LaunchValue {
- void show (AltosState state, int crc_errors) {
- show(pos(state.pad_lat,"N", "S"));
+ void show (AltosState state, AltosListenerState listener_state) {
+ if (state == null || state.gps == null) {
+ hide();
+ } else {
+ if (state.state < AltosLib.ao_flight_pad) {
+ show(pos(state.gps.lat,"N", "S"));
+ set_label("Latitude");
+ } else {
+ show(pos(state.pad_lat,"N", "S"));
+ set_label("Pad Latitude");
+ }
+ }
}
public PadLat (GridBagLayout layout, int y) {
super (layout, y, "Pad Latitude");
@@ -281,8 +330,18 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
PadLat pad_lat;
class PadLon extends LaunchValue {
- void show (AltosState state, int crc_errors) {
- show(pos(state.pad_lon,"E", "W"));
+ void show (AltosState state, AltosListenerState listener_state) {
+ if (state == null || state.gps == null) {
+ hide();
+ } else {
+ if (state.state < AltosLib.ao_flight_pad) {
+ show(pos(state.gps.lon,"E", "W"));
+ set_label("Longitude");
+ } else {
+ show(pos(state.pad_lon,"E", "W"));
+ set_label("Pad Longitude");
+ }
+ }
}
public PadLon (GridBagLayout layout, int y) {
super (layout, y, "Pad Longitude");
@@ -292,8 +351,22 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
PadLon pad_lon;
class PadAlt extends LaunchValue {
- void show (AltosState state, int crc_errors) {
- show("%4.0f m", state.pad_alt);
+ void show (AltosState state, AltosListenerState listener_state) {
+ if (state == null)
+ hide();
+ else {
+ if (state.state < AltosLib.ao_flight_pad && state.gps != null) {
+ show("%4.0f m", state.gps.alt);
+ set_label("Altitude");
+ } else {
+ if (state.pad_alt == AltosRecord.MISSING)
+ hide();
+ else {
+ show("%4.0f m", state.pad_alt);
+ set_label("Pad Altitude");
+ }
+ }
+ }
}
public PadAlt (GridBagLayout layout, int y) {
super (layout, y, "Pad Altitude");
@@ -309,6 +382,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
logging_ready.reset();
gps_locked.reset();
gps_ready.reset();
+ receiver_battery.reset();
pad_lat.reset();
pad_lon.reset();
pad_alt.reset();
@@ -321,34 +395,23 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
logging_ready.set_font();
gps_locked.set_font();
gps_ready.set_font();
+ receiver_battery.set_font();
pad_lat.set_font();
pad_lon.set_font();
pad_alt.set_font();
}
- public void show(AltosState state, int crc_errors) {
- battery.show(state, crc_errors);
- if (state.drogue_sense == AltosRecord.MISSING)
- apogee.hide();
- else
- apogee.show(state, crc_errors);
- if (state.main_sense == AltosRecord.MISSING)
- main.hide();
- else
- main.show(state, crc_errors);
- logging_ready.show(state, crc_errors);
- pad_alt.show(state, crc_errors);
- if (state.gps != null && state.gps.connected) {
- gps_locked.show(state, crc_errors);
- gps_ready.show(state, crc_errors);
- pad_lat.show(state, crc_errors);
- pad_lon.show(state, crc_errors);
- } else {
- gps_locked.hide();
- gps_ready.hide();
- pad_lat.hide();
- pad_lon.hide();
- }
+ public void show(AltosState state, AltosListenerState listener_state) {
+ battery.show(state, listener_state);
+ apogee.show(state, listener_state);
+ main.show(state, listener_state);
+ logging_ready.show(state, listener_state);
+ pad_alt.show(state, listener_state);
+ receiver_battery.show(state, listener_state);
+ gps_locked.show(state, listener_state);
+ gps_ready.show(state, listener_state);
+ pad_lat.show(state, listener_state);
+ pad_lon.show(state, listener_state);
}
public AltosPad() {
@@ -372,8 +435,10 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
logging_ready = new LoggingReady(layout, 3);
gps_locked = new GPSLocked(layout, 4);
gps_ready = new GPSReady(layout, 5);
- pad_lat = new PadLat(layout, 6);
- pad_lon = new PadLon(layout, 7);
- pad_alt = new PadAlt(layout, 8);
+ receiver_battery = new ReceiverBattery(layout, 6);
+ pad_lat = new PadLat(layout, 7);
+ pad_lon = new PadLon(layout, 8);
+ pad_alt = new PadAlt(layout, 9);
+ show(null, null);
}
}
diff --git a/altosui/AltosRomconfig.java b/altosui/AltosRomconfig.java
deleted file mode 100644
index 0a283e51..00000000
--- a/altosui/AltosRomconfig.java
+++ /dev/null
@@ -1,148 +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 org.altusmetrum.AltosLib.*;
-
-public class AltosRomconfig {
- public boolean valid;
- public int version;
- public int check;
- public int serial_number;
- public int radio_calibration;
-
- static int get_int(byte[] bytes, int start, int len) {
- int v = 0;
- int o = 0;
- while (len > 0) {
- v = v | ((((int) bytes[start]) & 0xff) << o);
- start++;
- len--;
- o += 8;
- }
- return v;
- }
-
- static void put_int(int value, byte[] bytes, int start, int len) {
- while (len > 0) {
- bytes[start] = (byte) (value & 0xff);
- start++;
- len--;
- value >>= 8;
- }
- }
-
- static void put_string(String value, byte[] bytes, int start) {
- for (int i = 0; i < value.length(); i++)
- bytes[start + i] = (byte) value.charAt(i);
- }
-
- static final int AO_USB_DESC_STRING = 3;
-
- static void put_usb_serial(int value, byte[] bytes, int start) {
- int offset = start + 0xa;
- int string_num = 0;
-
- while (offset < bytes.length && bytes[offset] != 0) {
- if (bytes[offset + 1] == AO_USB_DESC_STRING) {
- ++string_num;
- if (string_num == 4)
- break;
- }
- offset += ((int) bytes[offset]) & 0xff;
- }
- if (offset >= bytes.length || bytes[offset] == 0)
- return;
- int len = ((((int) bytes[offset]) & 0xff) - 2) / 2;
- String fmt = String.format("%%0%dd", len);
-
- String s = String.format(fmt, value);
- if (s.length() != len) {
- System.out.printf("weird usb length issue %s isn't %d\n",
- s, len);
- return;
- }
- for (int i = 0; i < len; i++) {
- bytes[offset + 2 + i*2] = (byte) s.charAt(i);
- bytes[offset + 2 + i*2+1] = 0;
- }
- }
-
- public AltosRomconfig(byte[] bytes, int offset) {
- version = get_int(bytes, offset + 0, 2);
- check = get_int(bytes, offset + 2, 2);
- if (check == (~version & 0xffff)) {
- switch (version) {
- case 2:
- case 1:
- serial_number = get_int(bytes, offset + 4, 2);
- radio_calibration = get_int(bytes, offset + 6, 4);
- valid = true;
- break;
- }
- }
- }
-
- public AltosRomconfig(AltosHexfile hexfile) {
- this(hexfile.data, 0xa0 - hexfile.address);
- }
-
- public void write(byte[] bytes, int offset) throws IOException {
- if (!valid)
- throw new IOException("rom configuration invalid");
-
- if (offset < 0 || bytes.length < offset + 10)
- throw new IOException("image cannot contain rom config");
-
- AltosRomconfig existing = new AltosRomconfig(bytes, offset);
- if (!existing.valid)
- throw new IOException("image does not contain existing rom config");
-
- switch (existing.version) {
- case 2:
- put_usb_serial(serial_number, bytes, offset);
- case 1:
- put_int(serial_number, bytes, offset + 4, 2);
- put_int(radio_calibration, bytes, offset + 6, 4);
- break;
- }
- }
-
- public void write (AltosHexfile hexfile) throws IOException {
- write(hexfile.data, 0xa0 - hexfile.address);
- AltosRomconfig check = new AltosRomconfig(hexfile);
- if (!check.valid())
- throw new IOException("writing new rom config failed\n");
- }
-
- public AltosRomconfig(int in_serial_number, int in_radio_calibration) {
- valid = true;
- version = 1;
- check = (~version & 0xffff);
- serial_number = in_serial_number;
- radio_calibration = in_radio_calibration;
- }
-
- public boolean valid() {
- return valid && serial_number != 0;
- }
-
- public AltosRomconfig() {
- valid = false;
- }
-}
diff --git a/altosui/AltosRomconfigUI.java b/altosui/AltosRomconfigUI.java
index 306b8623..909e72a0 100644
--- a/altosui/AltosRomconfigUI.java
+++ b/altosui/AltosRomconfigUI.java
@@ -20,17 +20,11 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import javax.swing.event.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosRomconfigUI
- extends AltosDialog
+ extends AltosUIDialog
implements ActionListener
{
Container pane;
diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java
index 9da1290f..0c903873 100644
--- a/altosui/AltosScanUI.java
+++ b/altosui/AltosScanUI.java
@@ -20,15 +20,13 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import javax.swing.event.*;
import java.io.*;
import java.util.*;
import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
class AltosScanResult {
String callsign;
@@ -124,7 +122,7 @@ class AltosScanResults extends LinkedList<AltosScanResult> implements ListModel
}
public class AltosScanUI
- extends AltosDialog
+ extends AltosUIDialog
implements ActionListener
{
AltosUI owner;
@@ -330,7 +328,7 @@ public class AltosScanUI
}
private boolean open() {
- device = AltosDeviceDialog.show(owner, Altos.product_basestation);
+ device = AltosDeviceUIDialog.show(owner, Altos.product_basestation);
if (device == null)
return false;
try {
diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java
index 6cee1609..e869f1ab 100644
--- a/altosui/AltosSerial.java
+++ b/altosui/AltosSerial.java
@@ -21,17 +21,12 @@
package altosui;
-import java.lang.*;
import java.io.*;
-import java.util.concurrent.*;
import java.util.*;
-import java.text.*;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
import libaltosJNI.*;
@@ -77,7 +72,7 @@ public class AltosSerial extends AltosLink {
Object[] options = { "Cancel" };
JOptionPane pane = new JOptionPane();
- pane.setMessage(String.format("Connecting to %s, %7.3f MHz", device.toShortString(), frequency));
+ pane.setMessage(String.format("Connecting to %s, %7.3f MHz as %s", device.toShortString(), frequency, callsign));
pane.setOptions(options);
pane.setInitialValue(null);
diff --git a/altosui/AltosSerialInUseException.java b/altosui/AltosSerialInUseException.java
index 7380f331..b45d9157 100644
--- a/altosui/AltosSerialInUseException.java
+++ b/altosui/AltosSerialInUseException.java
@@ -16,6 +16,7 @@
*/
package altosui;
+import org.altusmetrum.altosuilib_1.*;
public class AltosSerialInUseException extends Exception {
public AltosDevice device;
diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java
index b57edcab..23085f3e 100644
--- a/altosui/AltosSiteMap.java
+++ b/altosui/AltosSiteMap.java
@@ -18,21 +18,13 @@
package altosui;
import java.awt.*;
-import java.awt.image.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.event.MouseInputAdapter;
-import javax.imageio.ImageIO;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
import java.lang.Math;
import java.awt.geom.Point2D;
-import java.awt.geom.Line2D;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
// preferred vertical step in a tile in naut. miles
@@ -61,11 +53,13 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
// based on google js
// http://maps.gstatic.com/intl/en_us/mapfiles/api-3/2/10/main.js
// search for fromLatLngToPoint and fromPointToLatLng
+ /*
private static Point2D.Double pt(LatLng latlng, int zoom) {
double scale_x = 256/360.0 * Math.pow(2, zoom);
double scale_y = 256/(2.0*Math.PI) * Math.pow(2, zoom);
return pt(latlng, scale_x, scale_y);
}
+ */
private static Point2D.Double pt(LatLng latlng,
double scale_x, double scale_y)
@@ -108,9 +102,11 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
private LatLng latlng(double x, double y) {
return latlng(new Point2D.Double(x,y), scale_x, scale_y);
}
+ /*
private LatLng latlng(Point2D.Double pt) {
return latlng(pt, scale_x, scale_y);
}
+ */
ConcurrentHashMap<Point,AltosSiteMapTile> mapTiles = new ConcurrentHashMap<Point,AltosSiteMapTile>();
Point2D.Double centre;
@@ -190,8 +186,8 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
AltosSiteMap asm = new AltosSiteMap(true);
asm.centre = asm.getBaseLocation(lat, lng);
- Point2D.Double p = new Point2D.Double();
- Point2D.Double p2;
+ //Point2D.Double p = new Point2D.Double();
+ //Point2D.Double p2;
int dx = -w/2, dy = -h/2;
for (int y = dy; y < h+dy; y++) {
for (int x = dx; x < w+dx; x++) {
@@ -224,6 +220,16 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
return pngfile.toString();
}
+ public void initAndFinishMapAsync (final AltosSiteMapTile tile, final Point offset) {
+ Thread thread = new Thread() {
+ public void run() {
+ initMap(offset);
+ finishTileLater(tile, offset);
+ }
+ };
+ thread.start();
+ }
+
public void setBaseLocation(double lat, double lng) {
for (Point k : mapTiles.keySet()) {
AltosSiteMapTile tile = mapTiles.get(k);
@@ -268,7 +274,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
initMaps(lat, lon);
scrollRocketToVisible(pt(lat, lon));
}
- public void show(final AltosState state, final int crc_errors) {
+ public void show(final AltosState state, final AltosListenerState listener_state) {
// if insufficient gps data, nothing to update
if (!state.gps.locked && state.gps.nsat < 4)
return;
@@ -298,7 +304,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
Point2D.Double ref, lref;
ref = translatePoint(pt, tileCoordOffset(offset));
lref = translatePoint(last_pt, tileCoordOffset(offset));
- tile.show(state, crc_errors, lref, ref);
+ tile.show(state, listener_state, lref, ref);
if (0 <= ref.x && ref.x < px_size)
if (0 <= ref.y && ref.y < px_size)
in_any = true;
@@ -311,9 +317,8 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
lref = translatePoint(last_pt, tileCoordOffset(offset));
AltosSiteMapTile tile = createTile(offset);
- tile.show(state, crc_errors, lref, ref);
- initMap(offset);
- finishTileLater(tile, offset);
+ tile.show(state, listener_state, lref, ref);
+ initAndFinishMapAsync(tile, offset);
}
scrollRocketToVisible(pt);
@@ -326,6 +331,22 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
last_state = state.state;
}
+ public void centre(Point2D.Double pt) {
+ Rectangle r = comp.getVisibleRect();
+ Point2D.Double copt = translatePoint(pt, tileCoordOffset(topleft));
+ int dx = (int)copt.x - r.width/2 - r.x;
+ int dy = (int)copt.y - r.height/2 - r.y;
+ r.x += dx;
+ r.y += dy;
+ comp.scrollRectToVisible(r);
+ }
+
+ public void centre(AltosState state) {
+ if (!state.gps.locked && state.gps.nsat < 4)
+ return;
+ centre(pt(state.gps.lat, state.gps.lon));
+ }
+
public void draw_circle(double lat, double lon) {
final Point2D.Double pt = pt(lat, lon);
@@ -358,8 +379,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
if (mapTiles.containsKey(offset))
continue;
AltosSiteMapTile tile = createTile(offset);
- initMap(offset);
- finishTileLater(tile, offset);
+ initAndFinishMapAsync(tile, offset);
}
}
}
diff --git a/altosui/AltosSiteMapCache.java b/altosui/AltosSiteMapCache.java
index f729a298..40c8ff6b 100644
--- a/altosui/AltosSiteMapCache.java
+++ b/altosui/AltosSiteMapCache.java
@@ -17,19 +17,12 @@
package altosui;
-import java.awt.*;
-import java.awt.image.*;
-import java.awt.event.*;
import javax.swing.*;
import javax.imageio.ImageIO;
-import javax.swing.table.*;
+import java.awt.image.*;
import java.io.*;
-import java.util.*;
-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) {
@@ -95,7 +88,14 @@ public class AltosSiteMapCache extends JLabel {
}
try {
- return new ImageIcon(ImageIO.read(pngfile));
+ BufferedImage img;
+
+ img = ImageIO.read(pngfile);
+ if (img == null) {
+ System.out.printf("# Can't read pngfile %s\n", pngfile);
+ return null;
+ }
+ return new ImageIcon(img);
} catch (IOException e) {
System.out.printf("# IO error trying to load %s\n", pngfile);
return null;
diff --git a/altosui/AltosSiteMapPreload.java b/altosui/AltosSiteMapPreload.java
index 676b0790..fd648abc 100644
--- a/altosui/AltosSiteMapPreload.java
+++ b/altosui/AltosSiteMapPreload.java
@@ -18,22 +18,15 @@
package altosui;
import java.awt.*;
-import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.event.MouseInputAdapter;
-import javax.imageio.ImageIO;
-import javax.swing.table.*;
import java.io.*;
import java.util.*;
import java.text.*;
-import java.util.prefs.*;
import java.lang.Math;
-import java.awt.geom.Point2D;
-import java.awt.geom.Line2D;
import java.net.URL;
import java.net.URLConnection;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altosuilib_1.*;
class AltosMapPos extends Box {
AltosUI owner;
@@ -184,7 +177,7 @@ class AltosSites extends Thread {
public void run() {
try {
URLConnection uc = url.openConnection();
- int length = uc.getContentLength();
+ //int length = uc.getContentLength();
InputStreamReader in_stream = new InputStreamReader(uc.getInputStream(), Altos.unicode_set);
BufferedReader in = new BufferedReader(in_stream);
@@ -213,7 +206,7 @@ class AltosSites extends Thread {
}
}
-public class AltosSiteMapPreload extends AltosDialog implements ActionListener, ItemListener {
+public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener, ItemListener {
AltosUI owner;
AltosSiteMap map;
diff --git a/altosui/AltosSiteMapTile.java b/altosui/AltosSiteMapTile.java
index 34550219..365e4b6c 100644
--- a/altosui/AltosSiteMapTile.java
+++ b/altosui/AltosSiteMapTile.java
@@ -19,18 +19,10 @@ package altosui;
import java.awt.*;
import java.awt.image.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.imageio.ImageIO;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.lang.Math;
import java.awt.geom.Point2D;
import java.awt.geom.Line2D;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public class AltosSiteMapTile extends JLayeredPane {
JLabel mapLabel;
@@ -64,7 +56,7 @@ public class AltosSiteMapTile extends JLayeredPane {
private boolean drawn_landed_circle = false;
private boolean drawn_boost_circle = false;
- public synchronized void show(AltosState state, int crc_errors,
+ public synchronized void show(AltosState state, AltosListenerState listener_state,
Point2D.Double last_pt, Point2D.Double pt)
{
if (0 <= state.state && state.state < stateColors.length) {
diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java
index c1a66b83..9f8f6dda 100644
--- a/altosui/AltosUI.java
+++ b/altosui/AltosUI.java
@@ -20,18 +20,12 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altosuilib_1.*;
-import libaltosJNI.*;
-
-public class AltosUI extends AltosFrame {
+public class AltosUI extends AltosUIFrame {
public AltosVoice voice = new AltosVoice();
public static boolean load_library(Frame frame) {
@@ -54,7 +48,7 @@ public class AltosUI extends AltosFrame {
} catch (FileNotFoundException ee) {
JOptionPane.showMessageDialog(AltosUI.this,
ee.getMessage(),
- "Cannot open target device",
+ String.format ("Cannot open %s", device.toShortString()),
JOptionPane.ERROR_MESSAGE);
} catch (AltosSerialInUseException si) {
JOptionPane.showMessageDialog(AltosUI.this,
@@ -64,17 +58,17 @@ public class AltosUI extends AltosFrame {
JOptionPane.ERROR_MESSAGE);
} catch (IOException ee) {
JOptionPane.showMessageDialog(AltosUI.this,
- device.toShortString(),
- "Unkonwn I/O error",
+ String.format ("Unknown I/O error on %s", device.toShortString()),
+ "Unknown I/O error",
JOptionPane.ERROR_MESSAGE);
} catch (TimeoutException te) {
JOptionPane.showMessageDialog(this,
- device.toShortString(),
+ String.format ("Timeout on %s", device.toShortString()),
"Timeout error",
JOptionPane.ERROR_MESSAGE);
} catch (InterruptedException ie) {
JOptionPane.showMessageDialog(this,
- device.toShortString(),
+ String.format("Interrupted %s", device.toShortString()),
"Interrupted exception",
JOptionPane.ERROR_MESSAGE);
}
@@ -94,7 +88,7 @@ public class AltosUI extends AltosFrame {
c.weighty = 1;
b = new JButton(label);
- Dimension ps = b.getPreferredSize();
+ //Dimension ps = b.getPreferredSize();
gridbag.setConstraints(b, c);
add(b, c);
@@ -230,14 +224,6 @@ public class AltosUI extends AltosFrame {
doLayout();
validate();
- setVisible(true);
-
- Insets i = getInsets();
- Dimension ps = rootPane.getPreferredSize();
- ps.width += i.left + i.right;
- ps.height += i.top + i.bottom;
- setPreferredSize(ps);
- setSize(ps);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
@@ -245,10 +231,15 @@ public class AltosUI extends AltosFrame {
System.exit(0);
}
});
+
+ setLocationByPlatform(false);
+
+ /* Insets aren't set before the window is visible */
+ setVisible(true);
}
private void ConnectToDevice() {
- AltosDevice device = AltosDeviceDialog.show(AltosUI.this,
+ AltosDevice device = AltosDeviceUIDialog.show(AltosUI.this,
Altos.product_basestation);
if (device != null)
@@ -337,7 +328,7 @@ public class AltosUI extends AltosFrame {
if (record_reader == null)
return;
try {
- new AltosGraphUI(record_reader, chooser.filename());
+ new AltosGraphUI(record_reader, chooser.file());
} catch (InterruptedException ie) {
} catch (IOException ie) {
}
@@ -354,15 +345,14 @@ public class AltosUI extends AltosFrame {
}
}
- static AltosRecordIterable open_logfile(String filename) {
- File file = new File (filename);
+ static AltosRecordIterable open_logfile(File file) {
try {
FileInputStream in;
in = new FileInputStream(file);
- if (filename.endsWith("eeprom"))
+ if (file.getName().endsWith("eeprom"))
return new AltosEepromIterable(in);
- else if (filename.endsWith("mega"))
+ else if (file.getName().endsWith("mega"))
return new AltosEepromMegaIterable(in);
else
return new AltosTelemetryIterable(in);
@@ -372,8 +362,7 @@ public class AltosUI extends AltosFrame {
}
}
- static AltosWriter open_csv(String filename) {
- File file = new File (filename);
+ static AltosWriter open_csv(File file) {
try {
return new AltosCSV(file);
} catch (FileNotFoundException fe) {
@@ -382,8 +371,7 @@ public class AltosUI extends AltosFrame {
}
}
- static AltosWriter open_kml(String filename) {
- File file = new File (filename);
+ static AltosWriter open_kml(File file) {
try {
return new AltosKML(file);
} catch (FileNotFoundException fe) {
@@ -399,12 +387,12 @@ public class AltosUI extends AltosFrame {
static final int process_replay = 4;
static final int process_summary = 5;
- static boolean process_csv(String input) {
+ static boolean process_csv(File input) {
AltosRecordIterable iterable = open_logfile(input);
if (iterable == null)
return false;
- String output = Altos.replace_extension(input,".csv");
+ File output = Altos.replace_extension(input,".csv");
System.out.printf("Processing \"%s\" to \"%s\"\n", input, output);
if (input.equals(output)) {
System.out.printf("Not processing '%s'\n", input);
@@ -419,12 +407,12 @@ public class AltosUI extends AltosFrame {
return true;
}
- static boolean process_kml(String input) {
+ static boolean process_kml(File input) {
AltosRecordIterable iterable = open_logfile(input);
if (iterable == null)
return false;
- String output = Altos.replace_extension(input,".kml");
+ File output = Altos.replace_extension(input,".kml");
System.out.printf("Processing \"%s\" to \"%s\"\n", input, output);
if (input.equals(output)) {
System.out.printf("Not processing '%s'\n", input);
@@ -448,28 +436,26 @@ public class AltosUI extends AltosFrame {
return null;
}
AltosRecordIterable recs;
- AltosReplayReader reader;
+ //AltosReplayReader reader;
if (file.getName().endsWith("eeprom")) {
recs = new AltosEepromIterable(in);
+ } else if (file.getName().endsWith("mega")) {
+ recs = new AltosEepromMegaIterable(in);
} else {
recs = new AltosTelemetryIterable(in);
}
return recs;
}
- static AltosRecordIterable record_iterable_file(String filename) {
- return record_iterable (new File(filename));
- }
-
- static AltosReplayReader replay_file(String filename) {
- AltosRecordIterable recs = record_iterable_file(filename);
+ static AltosReplayReader replay_file(File file) {
+ AltosRecordIterable recs = record_iterable(file);
if (recs == null)
return null;
- return new AltosReplayReader(recs.iterator(), new File(filename));
+ return new AltosReplayReader(recs.iterator(), file);
}
- static boolean process_replay(String filename) {
- AltosReplayReader reader = replay_file(filename);
+ static boolean process_replay(File file) {
+ AltosReplayReader reader = replay_file(file);
if (reader == null)
return false;
AltosFlightUI flight_ui = new AltosFlightUI(new AltosVoice(), reader);
@@ -477,12 +463,12 @@ public class AltosUI extends AltosFrame {
return true;
}
- static boolean process_graph(String filename) {
- AltosRecordIterable recs = record_iterable_file(filename);
+ static boolean process_graph(File file) {
+ AltosRecordIterable recs = record_iterable(file);
if (recs == null)
return false;
try {
- new AltosGraphUI(recs, filename);
+ new AltosGraphUI(recs, file);
return true;
} catch (InterruptedException ie) {
} catch (IOException ie) {
@@ -490,8 +476,8 @@ public class AltosUI extends AltosFrame {
return false;
}
- static boolean process_summary(String filename) {
- AltosRecordIterable iterable = record_iterable_file(filename);
+ static boolean process_summary(File file) {
+ AltosRecordIterable iterable = record_iterable(file);
if (iterable == null)
return false;
try {
@@ -556,7 +542,6 @@ public class AltosUI extends AltosFrame {
/* Handle batch-mode */
if (args.length == 0) {
AltosUI altosui = new AltosUI();
- altosui.setVisible(true);
java.util.List<AltosDevice> devices = AltosUSBDevice.list(Altos.product_basestation);
for (AltosDevice device : devices)
@@ -588,26 +573,27 @@ public class AltosUI extends AltosFrame {
else if (args[i].startsWith("--"))
help(1);
else {
+ File file = new File(args[i]);
switch (process) {
case process_none:
case process_graph:
- if (!process_graph(args[i]))
+ if (!process_graph(file))
++errors;
break;
case process_replay:
- if (!process_replay(args[i]))
+ if (!process_replay(file))
++errors;
break;
case process_kml:
- if (!process_kml(args[i]))
+ if (!process_kml(file))
++errors;
break;
case process_csv:
- if (!process_csv(args[i]))
+ if (!process_csv(file))
++errors;
break;
case process_summary:
- if (!process_summary(args[i]))
+ if (!process_summary(file))
++errors;
break;
}
diff --git a/altosui/AltosUIListener.java b/altosui/AltosUIListener.java
deleted file mode 100644
index 7ee62afc..00000000
--- a/altosui/AltosUIListener.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright © 2011 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;
-
-public interface AltosUIListener {
- public void ui_changed(String look_and_feel);
-}
diff --git a/altosui/AltosUIPreferences.java b/altosui/AltosUIPreferences.java
deleted file mode 100644
index 8f1e45d9..00000000
--- a/altosui/AltosUIPreferences.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright © 2011 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;
-import org.altusmetrum.AltosLib.*;
-
-public class AltosUIPreferences extends AltosPreferences {
-
- /* font size preferences name */
- final static String fontSizePreference = "FONT-SIZE";
-
- /* Look&Feel preference name */
- final static String lookAndFeelPreference = "LOOK-AND-FEEL";
-
- /* UI Component to pop dialogs up */
- static Component component;
-
- static LinkedList<AltosFontListener> font_listeners;
-
- static int font_size = Altos.font_size_medium;
-
- static LinkedList<AltosUIListener> ui_listeners;
-
- static String look_and_feel = null;
-
- /* Serial debug */
- static boolean serial_debug;
-
- public static void init() {
- font_listeners = new LinkedList<AltosFontListener>();
-
- font_size = preferences.getInt(fontSizePreference, Altos.font_size_medium);
- Altos.set_fonts(font_size);
- look_and_feel = preferences.get(lookAndFeelPreference, UIManager.getSystemLookAndFeelClassName());
-
- ui_listeners = new LinkedList<AltosUIListener>();
- serial_debug = preferences.getBoolean(serialDebugPreference, false);
- AltosLink.set_debug(serial_debug);
- }
-
- static { init(); }
-
- static void set_component(Component in_component) {
- component = in_component;
- }
-
- private static boolean check_dir(File dir) {
- if (!dir.exists()) {
- if (!dir.mkdirs()) {
- JOptionPane.showMessageDialog(component,
- dir.getName(),
- "Cannot create directory",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
- } else if (!dir.isDirectory()) {
- JOptionPane.showMessageDialog(component,
- dir.getName(),
- "Is not a directory",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
- return true;
- }
-
- /* Configure the log directory. This is where all telemetry and eeprom files
- * will be written to, and where replay will look for telemetry files
- */
- public static void ConfigureLog() {
- JFileChooser logdir_chooser = new JFileChooser(logdir.getParentFile());
-
- logdir_chooser.setDialogTitle("Configure Data Logging Directory");
- logdir_chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
-
- if (logdir_chooser.showDialog(component, "Select Directory") == JFileChooser.APPROVE_OPTION) {
- File dir = logdir_chooser.getSelectedFile();
- if (check_dir(dir))
- set_logdir(dir);
- }
- }
- public static int font_size() {
- synchronized (preferences) {
- return font_size;
- }
- }
-
- static void set_fonts() {
- }
-
- public static void set_font_size(int new_font_size) {
- synchronized (preferences) {
- font_size = new_font_size;
- preferences.putInt(fontSizePreference, font_size);
- flush_preferences();
- Altos.set_fonts(font_size);
- for (AltosFontListener l : font_listeners)
- l.font_size_changed(font_size);
- }
- }
-
- public static void register_font_listener(AltosFontListener l) {
- synchronized (preferences) {
- font_listeners.add(l);
- }
- }
-
- public static void unregister_font_listener(AltosFontListener l) {
- synchronized (preferences) {
- font_listeners.remove(l);
- }
- }
-
- public static void set_look_and_feel(String new_look_and_feel) {
- try {
- UIManager.setLookAndFeel(new_look_and_feel);
- } catch (Exception e) {
- }
- synchronized(preferences) {
- look_and_feel = new_look_and_feel;
- preferences.put(lookAndFeelPreference, look_and_feel);
- flush_preferences();
- for (AltosUIListener l : ui_listeners)
- l.ui_changed(look_and_feel);
- }
- }
-
- public static String look_and_feel() {
- synchronized (preferences) {
- return look_and_feel;
- }
- }
-
- public static void register_ui_listener(AltosUIListener l) {
- synchronized(preferences) {
- ui_listeners.add(l);
- }
- }
-
- public static void unregister_ui_listener(AltosUIListener l) {
- synchronized (preferences) {
- ui_listeners.remove(l);
- }
- }
- public static void set_serial_debug(boolean new_serial_debug) {
- AltosLink.set_debug(new_serial_debug);
- synchronized (preferences) {
- serial_debug = new_serial_debug;
- preferences.putBoolean(serialDebugPreference, serial_debug);
- flush_preferences();
- }
- }
-
- public static boolean serial_debug() {
- synchronized (preferences) {
- return serial_debug;
- }
- }
-
-} \ No newline at end of file
diff --git a/altosui/AltosUIPreferencesBackend.java b/altosui/AltosUIPreferencesBackend.java
new file mode 100644
index 00000000..0dac9fc7
--- /dev/null
+++ b/altosui/AltosUIPreferencesBackend.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright © 2012 Mike Beattie <mike@ethernal.org>
+ *
+ * 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.File;
+import java.util.prefs.*;
+import org.altusmetrum.altoslib_1.*;
+import javax.swing.filechooser.FileSystemView;
+
+public class AltosUIPreferencesBackend implements AltosPreferencesBackend {
+
+ private Preferences _preferences = null;
+
+ public AltosUIPreferencesBackend() {
+ _preferences = Preferences.userRoot().node("/org/altusmetrum/altosui");
+ }
+
+ public AltosUIPreferencesBackend(Preferences in_preferences) {
+ _preferences = in_preferences;
+ }
+
+ public String getString(String key, String def) {
+ return _preferences.get(key, def);
+ }
+ public void putString(String key, String value) {
+ _preferences.put(key, value);
+ }
+
+ public int getInt(String key, int def) {
+ return _preferences.getInt(key, def);
+ }
+ public void putInt(String key, int value) {
+ _preferences.putInt(key, value);
+ }
+
+ public double getDouble(String key, double def) {
+ return _preferences.getDouble(key, def);
+ }
+ public void putDouble(String key, double value) {
+ _preferences.putDouble(key, value);
+ }
+
+ public boolean getBoolean(String key, boolean def) {
+ return _preferences.getBoolean(key, def);
+ }
+ public void putBoolean(String key, boolean value) {
+ _preferences.putBoolean(key, value);
+ }
+
+ public boolean nodeExists(String key) {
+ try {
+ return _preferences.nodeExists(key);
+ } catch (BackingStoreException be) {
+ return false;
+ }
+ }
+
+ public AltosPreferencesBackend node(String key) {
+ return new AltosUIPreferencesBackend(_preferences.node(key));
+ }
+
+ public String[] keys() {
+ try {
+ return _preferences.keys();
+ } catch (BackingStoreException be) {
+ return null;
+ }
+ }
+
+ public void remove(String key) {
+ _preferences.remove(key);
+ }
+
+ public void flush() {
+ try {
+ _preferences.flush();
+ } catch (BackingStoreException ee) {
+ System.err.printf("Cannot save preferences\n");
+ }
+ }
+
+ public File homeDirectory() {
+ /* Use the file system view default directory */
+ return FileSystemView.getFileSystemView().getDefaultDirectory();
+ }
+}
diff --git a/altosui/AltosUSBDevice.java b/altosui/AltosUSBDevice.java
deleted file mode 100644
index ed5f8307..00000000
--- a/altosui/AltosUSBDevice.java
+++ /dev/null
@@ -1,112 +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.lang.*;
-import java.util.*;
-import libaltosJNI.*;
-
-public class AltosUSBDevice extends altos_device implements AltosDevice {
-
- public String toString() {
- String name = getName();
- if (name == null)
- name = "Altus Metrum";
- return String.format("%-20.20s %4d %s",
- name, getSerial(), getPath());
- }
-
- public String toShortString() {
- String name = getName();
- if (name == null)
- name = "Altus Metrum";
- return String.format("%s %d %s",
- name, getSerial(), getPath());
-
- }
-
- public String getErrorString() {
- altos_error error = new altos_error();
-
- libaltos.altos_get_last_error(error);
- return String.format("%s (%d)", error.getString(), error.getCode());
- }
-
- public SWIGTYPE_p_altos_file open() {
- return libaltos.altos_open(this);
- }
-
- private boolean isAltusMetrum() {
- if (getVendor() != Altos.vendor_altusmetrum)
- return false;
- if (getProduct() < Altos.product_altusmetrum_min)
- return false;
- if (getProduct() > Altos.product_altusmetrum_max)
- return false;
- return true;
- }
-
- public boolean matchProduct(int want_product) {
-
- if (!isAltusMetrum())
- return false;
-
- if (want_product == Altos.product_any)
- return true;
-
- if (want_product == Altos.product_basestation)
- return matchProduct(Altos.product_teledongle) ||
- matchProduct(Altos.product_teleterra) ||
- matchProduct(Altos.product_telebt) ||
- matchProduct(Altos.product_megadongle);
-
- if (want_product == Altos.product_altimeter)
- return matchProduct(Altos.product_telemetrum) ||
- matchProduct(Altos.product_megametrum);
-
- int have_product = getProduct();
-
- if (have_product == Altos.product_altusmetrum) /* old devices match any request */
- return true;
-
- if (want_product == have_product)
- return true;
-
- return false;
- }
-
- static java.util.List<AltosDevice> list(int product) {
- if (!Altos.load_library())
- return null;
-
- SWIGTYPE_p_altos_list list = libaltos.altos_list_start();
-
- ArrayList<AltosDevice> device_list = new ArrayList<AltosDevice>();
- if (list != null) {
- for (;;) {
- AltosUSBDevice device = new AltosUSBDevice();
- if (libaltos.altos_list_next(list, device) == 0)
- break;
- if (device.matchProduct(product))
- device_list.add(device);
- }
- libaltos.altos_list_finish(list);
- }
-
- return device_list;
- }
-} \ No newline at end of file
diff --git a/altosui/AltosVersion.java.in b/altosui/AltosVersion.java.in
deleted file mode 100644
index b0b3c0cf..00000000
--- a/altosui/AltosVersion.java.in
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright © 2011 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;
-
-public class AltosVersion {
- public final static String version = "@VERSION@";
-}
diff --git a/altosui/AltosVoice.java b/altosui/AltosVoice.java
index ab74e0b3..2ed6a8c2 100644
--- a/altosui/AltosVoice.java
+++ b/altosui/AltosVoice.java
@@ -19,8 +19,8 @@ package altosui;
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
-import com.sun.speech.freetts.audio.JavaClipAudioPlayer;
import java.util.concurrent.LinkedBlockingQueue;
+import org.altusmetrum.altosuilib_1.*;
public class AltosVoice implements Runnable {
VoiceManager voice_manager;
diff --git a/altosui/AltosWriter.java b/altosui/AltosWriter.java
index b7375204..2f70b472 100644
--- a/altosui/AltosWriter.java
+++ b/altosui/AltosWriter.java
@@ -17,11 +17,7 @@
package altosui;
-import java.lang.*;
-import java.io.*;
-import java.text.*;
-import java.util.*;
-import org.altusmetrum.AltosLib.*;
+import org.altusmetrum.altoslib_1.*;
public interface AltosWriter {
diff --git a/altosui/GrabNDrag.java b/altosui/GrabNDrag.java
index c350efec..2fd6c4da 100644
--- a/altosui/GrabNDrag.java
+++ b/altosui/GrabNDrag.java
@@ -18,16 +18,9 @@
package altosui;
import java.awt.*;
-import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.MouseInputAdapter;
-import javax.imageio.ImageIO;
-import javax.swing.table.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import org.altusmetrum.AltosLib.*;
class GrabNDrag extends MouseInputAdapter {
private JComponent scroll;
diff --git a/altosui/Makefile.am b/altosui/Makefile.am
index 6010df58..d59e3082 100644
--- a/altosui/Makefile.am
+++ b/altosui/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS=libaltos
+
JAVAROOT=classes
AM_JAVACFLAGS=-encoding UTF-8 -Xlint:deprecation
@@ -6,7 +6,7 @@ man_MANS=altosui.1
altoslibdir=$(libdir)/altos
-CLASSPATH_ENV=mkdir -p $(JAVAROOT); CLASSPATH=".:classes:../altoslib/*:libaltos:$(JCOMMON)/jcommon.jar:$(JFREECHART)/jfreechart.jar:$(FREETTS)/freetts.jar"
+CLASSPATH_ENV=mkdir -p $(JAVAROOT); CLASSPATH="$(JAVAROOT):../altoslib/*:../altosuilib/*:../libaltos:$(JCOMMON)/jcommon.jar:$(JFREECHART)/jfreechart.jar:$(FREETTS)/freetts.jar"
bin_SCRIPTS=altosui
@@ -24,16 +24,14 @@ altosui_JAVA = \
AltosConfig.java \
AltosConfigFreqUI.java \
AltosConfigUI.java \
+ AltosConfigPyroUI.java \
AltosConfigureUI.java \
AltosConfigTD.java \
AltosConfigTDUI.java \
AltosCSV.java \
AltosCSVUI.java \
- AltosDebug.java \
AltosDescent.java \
- AltosDeviceDialog.java \
- AltosDevice.java \
- AltosUSBDevice.java \
+ AltosDeviceUIDialog.java \
AltosDisplayThread.java \
AltosEepromDelete.java \
AltosEepromDownload.java \
@@ -41,7 +39,6 @@ altosui_JAVA = \
AltosEepromManage.java \
AltosEepromMonitor.java \
AltosEepromSelect.java \
- AltosFlash.java \
AltosFlashUI.java \
AltosFlightDisplay.java \
AltosFlightInfoTableModel.java \
@@ -50,9 +47,7 @@ altosui_JAVA = \
AltosFlightStatus.java \
AltosFlightStatusUpdate.java \
AltosFlightUI.java \
- AltosFontListener.java \
AltosFreqList.java \
- AltosHexfile.java \
Altos.java \
AltosIdleMonitorUI.java \
AltosIgniteUI.java \
@@ -64,8 +59,7 @@ altosui_JAVA = \
AltosLed.java \
AltosLights.java \
AltosPad.java \
- AltosUIPreferences.java \
- AltosRomconfig.java \
+ AltosUIPreferencesBackend.java \
AltosRomconfigUI.java \
AltosScanUI.java \
AltosSerial.java \
@@ -75,17 +69,12 @@ altosui_JAVA = \
AltosSiteMapCache.java \
AltosSiteMapTile.java \
AltosUI.java \
- AltosUIListener.java \
- AltosFrame.java \
- AltosDialog.java \
AltosWriter.java \
- AltosDataPointReader.java \
- AltosDataPoint.java \
AltosGraph.java \
- AltosGraphTime.java \
+ AltosGraphDataPoint.java \
+ AltosGraphDataSet.java \
AltosGraphUI.java \
AltosDataChooser.java \
- AltosVersion.java \
AltosVoice.java \
$(altosui_BT)
@@ -105,7 +94,10 @@ FREETTS_CLASS= \
freetts.jar
ALTOSLIB_CLASS=\
- AltosLib.jar
+ altoslib_$(ALTOSLIB_VERSION).jar
+
+ALTOSUILIB_CLASS=\
+ altosuilib_$(ALTOSUILIB_VERSION).jar
LIBALTOS= \
libaltos.so \
@@ -161,22 +153,22 @@ FIRMWARE=$(FIRMWARE_TM) $(FIRMWARE_TELEMINI) $(FIRMWARE_TD)
ALTUSMETRUM_DOC=$(top_srcdir)/doc/altusmetrum.pdf
ALTOS_DOC=$(top_srcdir)/doc/altos.pdf
TELEMETRY_DOC=$(top_srcdir)/doc/telemetry.pdf
-TEMPLATE_DOC=$(top_srcdir)/doc/telemetrum-outline.pdf $(top_srcdir)/doc/megametrum-outline.pdf
+TEMPLATE_DOC=$(top_srcdir)/doc/telemetrum-outline.pdf $(top_srcdir)/doc/telemega-outline.pdf
DOC=$(ALTUSMETRUM_DOC) $(ALTOS_DOC) $(TELEMETRY_DOC) $(TEMPLATE_DOC)
# Distribution targets
LINUX_DIST=Altos-Linux-$(VERSION).tar.bz2
-MACOSX_DIST=Altos-Mac-$(VERSION).zip
+MACOSX_DIST=Altos-Mac-$(VERSION).dmg
WINDOWS_DIST=Altos-Windows-$(VERSION_DASH).exe
-FAT_FILES=$(FATJAR) $(ALTOSLIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS)
+FAT_FILES=$(FATJAR) $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS)
LINUX_FILES=$(FAT_FILES) libaltos.so $(FIRMWARE) $(DOC)
LINUX_EXTRA=altosui-fat
MACOSX_INFO_PLIST=Info.plist
-MACOSX_FILES=$(FAT_FILES) libaltos.dylib $(MACOSX_INFO_PLIST)
+MACOSX_FILES=$(FAT_FILES) libaltos.dylib $(MACOSX_INFO_PLIST) ReadMe-Mac.rtf
MACOSX_EXTRA=$(FIRMWARE)
WINDOWS_FILES=$(FAT_FILES) altos.dll altos64.dll $(top_srcdir)/telemetrum.inf $(WINDOWS_ICON)
@@ -185,8 +177,8 @@ all-local: classes/altosui $(JAR) altosui altosui-test altosui-jdb
clean-local:
-rm -rf classes $(JAR) $(FATJAR) \
- $(LINUX_DIST) $(MACOSX_DIST) windows $(WINDOWS_DIST) $(ALTOSLIB_CLASS) $(FREETTS_CLASS) \
- $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) Manifest.txt Manifest-fat.txt altos-windows.log \
+ $(LINUX_DIST) $(MACOSX_DIST) windows $(WINDOWS_DIST) $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(FREETTS_CLASS) \
+ $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) Manifest.txt Manifest-fat.txt altos-windows.log altos-windows.nsi \
altosui altosui-test altosui-jdb macosx linux
if FATINSTALL
@@ -227,75 +219,79 @@ install-altosuiJAVA: altosui.jar
classes/altosui:
mkdir -p classes/altosui
-$(JAR): classaltosui.stamp Manifest.txt $(JAVA_ICONS) $(ALTOSLIB_CLASS)
+$(JAR): classaltosui.stamp Manifest.txt $(JAVA_ICONS) $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS)
jar cfm $@ Manifest.txt \
$(ICONJAR) \
-C classes altosui \
- -C libaltos libaltosJNI
+ -C ../libaltos libaltosJNI
-$(FATJAR): classaltosui.stamp Manifest-fat.txt $(ALTOSLIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) $(JAVA_ICONS)
+$(FATJAR): classaltosui.stamp Manifest-fat.txt $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) $(JAVA_ICONS)
jar cfm $@ Manifest-fat.txt \
$(ICONJAR) \
-C classes altosui \
- -C libaltos libaltosJNI
+ -C ../libaltos libaltosJNI
Manifest.txt: Makefile
echo 'Main-Class: altosui.AltosUI' > $@
- echo "Class-Path: AltosLib.jar $(FREETTS)/freetts.jar $(JCOMMON)/jcommon.jar $(JFREECHART)/jfreechart.jar" >> $@
+ echo "Class-Path: $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(FREETTS)/freetts.jar $(JCOMMON)/jcommon.jar $(JFREECHART)/jfreechart.jar" >> $@
Manifest-fat.txt:
echo 'Main-Class: altosui.AltosUI' > $@
- echo "Class-Path: AltosLib.jar freetts.jar jcommon.jar jfreechart.jar" >> $@
+ echo "Class-Path: $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) freetts.jar jcommon.jar jfreechart.jar" >> $@
altosui: Makefile
echo "#!/bin/sh" > $@
- echo 'exec java -cp "$(FREETTS)/freetts.jar:$(JCOMMON)/jcommon.jar:$(JFREECHART)/jfreechart.jar" -Djava.library.path="$(altoslibdir)" -jar "$(altosuidir)/altosui.jar" "$$@"' >> $@
+ echo 'exec java -Djava.library.path="$(altoslibdir)" -jar "$(altosuidir)/altosui.jar" "$$@"' >> $@
chmod +x $@
altosui-test: Makefile
echo "#!/bin/sh" > $@
- echo 'exec java -cp "./*:$(FREETTS)/freetts.jar:$(JCOMMON)/jcommon.jar:$(JFREECHART)/jfreechart.jar" -Djava.library.path="libaltos/.libs" -jar altosui.jar "$$@"' >> $@
+ echo 'exec java -Djava.library.path="../libaltos/.libs" -jar altosui.jar "$$@"' >> $@
chmod +x $@
altosui-jdb: Makefile
echo "#!/bin/sh" > $@
- echo 'exec jdb -classpath "classes:libaltos:$(FREETTS)/freetts.jar:$(JCOMMON)/jcommon.jar:$(JFREECHART)/jfreechart.jar" -Djava.library.path="libaltos/.libs" altosui/AltosUI "$$@"' >> $@
+ echo 'exec jdb -classpath "classes:./*:../libaltos:$(FREETTS)/freetts.jar:$(JCOMMON)/jcommon.jar:$(JFREECHART)/jfreechart.jar" -Djava.library.path="../libaltos/.libs" altosui/AltosUI "$$@"' >> $@
chmod +x $@
libaltos.so: build-libaltos
-rm -f "$@"
- $(LN_S) libaltos/.libs/"$@" .
+ $(LN_S) ../libaltos/.libs/"$@" .
libaltos.dylib:
-rm -f "$@"
- $(LN_S) libaltos/"$@" .
+ $(LN_S) ../libaltos/"$@" .
-altos.dll: libaltos/altos.dll
+altos.dll: ../libaltos/altos.dll
-rm -f "$@"
- $(LN_S) libaltos/"$@" .
+ $(LN_S) ../libaltos/"$@" .
-altos64.dll: libaltos/altos64.dll
+altos64.dll: ../libaltos/altos64.dll
-rm -f "$@"
- $(LN_S) libaltos/"$@" .
+ $(LN_S) ../libaltos/"$@" .
-libaltos/.libs/libaltos.so: build-libaltos
+../libaltos/.libs/libaltos.so: build-libaltos
-libaltos/altos.dll: build-altos-dll
+../libaltos/altos.dll: build-altos-dll
-libaltos/altos64.dll: build-altos64-dll
+../libaltos/altos64.dll: build-altos64-dll
build-libaltos:
- +cd libaltos && make libaltos.la
+ +cd ../libaltos && make libaltos.la
build-altos-dll:
- +cd libaltos && make altos.dll
+ +cd ../libaltos && make altos.dll
build-altos64-dll:
- +cd libaltos && make altos64.dll
+ +cd ../libaltos && make altos64.dll
$(ALTOSLIB_CLASS):
-rm -f "$@"
$(LN_S) ../altoslib/"$@" .
+$(ALTOSUILIB_CLASS):
+ -rm -f "$@"
+ $(LN_S) ../altosuilib/"$@" .
+
$(FREETTS_CLASS):
-rm -f "$@"
$(LN_S) "$(FREETTS)"/"$@" .
@@ -317,25 +313,25 @@ $(LINUX_DIST): $(LINUX_FILES) $(LINUX_EXTRA)
chmod +x linux/AltOS/altosui
tar cjf $@ -C linux AltOS
-$(MACOSX_DIST): $(MACOSX_FILES) $(MACOSX_EXTRA)
+$(MACOSX_DIST): $(MACOSX_FILES) $(MACOSX_EXTRA) Makefile
-rm -f $@
-rm -rf macosx
mkdir macosx
cp -a AltosUI.app macosx/
+ cp -a ReadMe-Mac.rtf macosx/ReadMe.rtf
cp -p Info.plist macosx/AltosUI.app/Contents
- mkdir -p macosx/AltOS macosx/AltosUI.app/Contents/Resources/Java
+ mkdir -p macosx/AltOS-$(VERSION) macosx/AltosUI.app/Contents/Resources/Java
cp -p $(FATJAR) macosx/AltosUI.app/Contents/Resources/Java/altosui.jar
cp -p libaltos.dylib macosx/AltosUI.app/Contents/Resources/Java
cp -p $(ALTOSLIB_CLASS) macosx/AltosUI.app/Contents/Resources/Java
+ cp -p $(ALTOSUILIB_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
+ cp -p $(MACOSX_EXTRA) macosx/AltOS-$(VERSION)
+ genisoimage -D -V AltOS-$(VERSION) -no-pad -r -apple -o $@ macosx
$(WINDOWS_DIST): $(WINDOWS_FILES) altos-windows.nsi
-rm -f $@
makensis -Oaltos-windows.log "-XOutFile $@" "-DVERSION=$(VERSION)" altos-windows.nsi
-publish:
- scp launch-sites.txt gag.com:public_html \ No newline at end of file
diff --git a/altosui/ReadMe-Mac.rtf b/altosui/ReadMe-Mac.rtf
new file mode 100644
index 00000000..8a95262c
--- /dev/null
+++ b/altosui/ReadMe-Mac.rtf
@@ -0,0 +1,56 @@
+{\rtf1\ansi\deff3\adeflang1025
+{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset128 Liberation Serif{\*\falt Times New Roman};}{\f4\fswiss\fprq2\fcharset128 Arial;}{\f5\fnil\fprq2\fcharset128 SimSun;}{\f6\fnil\fprq2\fcharset128 Raghindi;}{\f7\fnil\fprq0\fcharset128 Raghindi;}}
+{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
+{\stylesheet{\s0\snext0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033 Normal;}
+{\*\cs15\snext15 Numbering Symbols;}
+{\s16\sbasedon0\snext17\sb240\sa120\keepn\hich\af5\dbch\af6\afs28\loch\f4\fs28 Heading;}
+{\s17\sbasedon0\snext17\sb0\sa120 Text body;}
+{\s18\sbasedon17\snext18\sb0\sa120\dbch\af7 List;}
+{\s19\sbasedon0\snext19\sb120\sa120\noline\i\dbch\af7\afs24\ai\fs24 Caption;}
+{\s20\sbasedon0\snext20\noline\dbch\af7 Index;}
+}{\*\listtable{\list\listtemplateid1
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'00);}{\levelnumbers\'01;}\fi-360\li720}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'01.;}{\levelnumbers\'01;}\fi-360\li1080}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'02.;}{\levelnumbers\'01;}\fi-360\li1440}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'03.;}{\levelnumbers\'01;}\fi-360\li1800}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'04.;}{\levelnumbers\'01;}\fi-360\li2160}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'05.;}{\levelnumbers\'01;}\fi-360\li2520}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'06.;}{\levelnumbers\'01;}\fi-360\li2880}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'07.;}{\levelnumbers\'01;}\fi-360\li3240}
+{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'08.;}{\levelnumbers\'01;}\fi-360\li3600}\listid1}
+{\list\listtemplateid2
+{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow0{\leveltext \'00;}{\levelnumbers;}\fi-432\li432}
+{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow0{\leveltext \'00;}{\levelnumbers;}\fi-576\li576}
+{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow0{\leveltext \'00;}{\levelnumbers;}\fi-720\li720}
+{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow0{\leveltext \'00;}{\levelnumbers;}\fi-864\li864}
+{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow0{\leveltext \'00;}{\levelnumbers;}\fi-1008\li1008}
+{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow0{\leveltext \'00;}{\levelnumbers;}\fi-1152\li1152}
+{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow0{\leveltext \'00;}{\levelnumbers;}\fi-1296\li1296}
+{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow0{\leveltext \'00;}{\levelnumbers;}\fi-1440\li1440}
+{\listlevel\levelnfc255\leveljc0\levelstartat1\levelfollow0{\leveltext \'00;}{\levelnumbers;}\fi-1584\li1584}\listid2}
+}{\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}}{\info{\creatim\yr2013\mo1\dy6\hr13\min7}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment LibreOffice}{\vern3500}}\deftab709
+
+{\*\pgdsctbl
+{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Default;}}
+\formshade\paperh15840\paperw12240\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\sectunlocked1\pgndec\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
+\pgndec\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033{\rtlch \ltrch\loch
+Installing AltOS software for Mac OS X Computers}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033{\rtlch \ltrch\loch
+}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033{\rtlch \ltrch\loch
+The AltOS distribution for Mac OS X consists of:}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033{\rtlch \ltrch\loch
+}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033{\listtext\pard\plain 1)\tab}\ilvl0\ls1 \li720\ri0\lin720\rin0\fi-360{\rtlch \ltrch\loch
+The AltosUI application}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033{\listtext\pard\plain 2)\tab}\ilvl0\ls1 \li720\ri0\lin720\rin0\fi-360{\rtlch \ltrch\loch
+Current AltOS firmware for Altus Metrum products}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033{\rtlch \ltrch\loch
+}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033{\rtlch \ltrch\loch
+Install the AltosUI application by dragging it to your Applications folder (or wherever else you want to install it).}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033{\rtlch \ltrch\loch
+}
+\par \pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\hich\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1033{\rtlch \ltrch\loch
+The AltOS firmware can be used to update your Altus Metrum products to the latest firmware version, you can copy it to your disk if you like, or simply use it directly from the installation disk image.}
+\par } \ No newline at end of file
diff --git a/altosui/altos-windows.nsi b/altosui/altos-windows.nsi.in
index 20dd65f0..9886e4a2 100644
--- a/altosui/altos-windows.nsi
+++ b/altosui/altos-windows.nsi.in
@@ -88,7 +88,8 @@ Section "AltosUI Application"
SetOutPath $INSTDIR
File "altosui-fat.jar"
- File "AltosLib.jar"
+ File "altoslib_@ALTOSLIB_VERSION@.jar"
+ File "altosuilib_@ALTOSUILIB_VERSION@.jar"
File "cmudict04.jar"
File "cmulex.jar"
File "cmu_time_awb.jar"
@@ -130,7 +131,7 @@ Section "Documentation"
File "../doc/altos.pdf"
File "../doc/telemetry.pdf"
File "../doc/telemetrum-outline.pdf"
- File "../doc/megametrum-outline.pdf"
+ File "../doc/telemega-outline.pdf"
SectionEnd
Section "Uninstaller"
diff --git a/altosui/launch-sites.txt b/altosui/launch-sites.txt
deleted file mode 100644
index de7955e0..00000000
--- a/altosui/launch-sites.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-AHPRA BALLS:40.808333333333333:-119.15
-ARS Rio Rancho:35.33475:-106.75361
-HARA Bragg Farms:34.895875:-86.616211
-KLOUDBusters Rocket Pasture:37.167833333:-97.73975
-METRA Pine Island:41.31939:-74.47077
-NCR Pawnee:40.885955:-104.63793
-OPROC Discovery Bay:47.97808,-122.896383
-OROC Brothers:43.79949786336483:-120.6485810681392
-OROC Sheridan:45.044176:-123.314323
-QRS Cedar Grove:-27.8512283:152.9624000
-SCORE Hudson Ranch:38.155602777777778:-104.809119444444444
-Tripoli Colorado Hartsel:39.009247:-105.702338
-WAC Sportsman Club:47.815327777777778:-119.427186111111111
diff --git a/altosui/libaltos/.gitignore b/altosui/libaltos/.gitignore
deleted file mode 100644
index c490e6f8..00000000
--- a/altosui/libaltos/.gitignore
+++ /dev/null
@@ -1,12 +0,0 @@
-*.so
-*.lo
-*.la
-*.java
-*.class
-.libs/
-classlibaltos.stamp
-libaltos_wrap.c
-libaltosJNI
-cjnitest
-libaltos.swig
-swig_bindings/
diff --git a/altosui/libaltos/Makefile-standalone b/altosui/libaltos/Makefile-standalone
deleted file mode 100644
index 4e438050..00000000
--- a/altosui/libaltos/Makefile-standalone
+++ /dev/null
@@ -1,126 +0,0 @@
-OS:=$(shell uname)
-
-#
-# Linux
-#
-ifeq ($(OS),Linux)
-
-JAVA_CFLAGS=-I/usr/lib/jvm/java-6-openjdk/include
-
-OS_LIB_CFLAGS=-DLINUX -DPOSIX_TTY $(JAVA_CFLAGS)
-
-OS_APP_CFLAGS=$(OS_LIB_CFLAGS)
-
-OS_LDFLAGS=
-
-LIBNAME=libaltos.so
-EXEEXT=
-endif
-
-#
-# Darwin (Mac OS X)
-#
-ifeq ($(OS),Darwin)
-
-OS_LIB_CFLAGS=\
- -DDARWIN -DPOSIX_TTY -arch i386 -arch x86_64 \
- --sysroot=/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 \
- -iwithsysroot /System/Library/Frameworks/JavaVM.framework/Headers \
- -iwithsysroot /System/Library/Frameworks/IOKit.framework/Headers \
- -iwithsysroot /System/Library/Frameworks/CoreFoundation.framework/Headers
-OS_APP_CFLAGS=$(OS_LIB_CFLAGS)
-
-OS_LDFLAGS =\
- -framework IOKit -framework CoreFoundation
-
-LIBNAME=libaltos.dylib
-EXEEXT=
-
-endif
-
-#
-# Windows
-#
-ifneq (,$(findstring MINGW,$(OS)))
-
-CC=gcc
-
-OS_LIB_CFLAGS = -DWINDOWS -mconsole -DBUILD_DLL
-OS_APP_CFLAGS = -DWINDOWS -mconsole
-
-OS_LDFLAGS = -lgdi32 -luser32 -lcfgmgr32 -lsetupapi -lole32 \
- -ladvapi32 -lcomctl32 -mconsole -Wl,--add-stdcall-alias
-
-LIBNAME=altos.dll
-
-EXEEXT=.exe
-
-endif
-
-.SUFFIXES: .java .class
-
-CLASSPATH=".:jnitest/*:libaltosJNI:/usr/share/java/*"
-
-SWIG_DIR=swig_bindings/java
-SWIG_FILE=$(SWIG_DIR)/libaltos.swig
-SWIG_WRAP=$(SWIG_DIR)/libaltos_wrap.c
-
-JNI_DIR=libaltosJNI
-JNI_FILE=$(JNI_DIR)/libaltosJNI.java
-JNI_SRCS=$(JNI_FILE) \
- $(JNI_DIR)/SWIGTYPE_p_altos_file.java \
- $(JNI_DIR)/SWIGTYPE_p_altos_list.java \
- $(JNI_DIR)/altos_device.java \
- $(JNI_DIR)/libaltos.java
-
-JAVAFILES=\
- $(JNI_SRCS)
-
-CLASSFILES = $(JAVAFILES:%.java=%.class)
-
-JAVAFLAGS=-Xlint:unchecked
-
-CJNITEST=cjnitest$(EXEEXT)
-
-all: $(LIBNAME) $(CJNITEST) $(CLASSFILES)
-
-.java.class:
- javac -encoding UTF8 -classpath "$(CLASSPATH)" $(JAVAFLAGS) $*.java
-
-CFLAGS=$(OS_LIB_CFLAGS) -O -I.
-
-LDFLAGS=$(OS_LDFLAGS)
-
-HEADERS=libaltos.h
-SRCS = libaltos.c $(SWIG_WRAP)
-OBJS = $(SRCS:%.c=%.o)
-LIBS = $(DARWIN_LIBS)
-
-$(CJNITEST): cjnitest.c $(LIBNAME)
- $(CC) -o $@ $(OS_APP_CFLAGS) cjnitest.c $(LIBNAME) $(LIBS) $(LDFLAGS)
-
-$(LIBNAME): $(OBJS)
- $(CC) -shared $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
-
-clean:
- rm -f $(CLASSFILES) $(OBJS) $(LIBNAME) $(CJNITEST) cjnitest.o
- rm -rf swig_bindings libaltosJNI
-
-distclean: clean
-
-$(JNI_FILE): libaltos.i0 $(HEADERS)
- mkdir -p $(SWIG_DIR)
- mkdir -p libaltosJNI
- sed 's;//%;%;' libaltos.i0 $(HEADERS) > $(SWIG_FILE)
- swig -java -package libaltosJNI $(SWIG_FILE)
- cp swig_bindings/java/*.java libaltosJNI
-
-$(SWIG_WRAP): $(JNI_FILE)
-
-ifeq ($(OS),Linux)
-install: $(LIBNAME)
- install -c $(LIBNAME) $(DESTDIR)/usr/lib/altos/$(LIBNAME)
-
-endif
-
-.NOTPARALLEL:
diff --git a/altosui/libaltos/Makefile.am b/altosui/libaltos/Makefile.am
deleted file mode 100644
index b5ab1ddb..00000000
--- a/altosui/libaltos/Makefile.am
+++ /dev/null
@@ -1,54 +0,0 @@
-JAVAC=javac
-AM_CFLAGS=-DLINUX -DPOSIX_TTY -I$(JVM_INCLUDE)
-AM_JAVACFLAGS=-encoding UTF-8
-
-altoslibdir=$(libdir)/altos
-
-altoslib_LTLIBRARIES=libaltos.la
-
-libaltos_la_LDFLAGS = -version-info 1:0:1
-
-libaltos_la_SOURCES=\
- libaltos.c \
- libaltos_wrap.c
-
-noinst_PROGRAMS=cjnitest
-
-cjnitest_LDADD=libaltos.la
-
-LIBS=-lbluetooth
-
-HFILES=libaltos.h
-
-SWIG_FILE=libaltos.swig
-
-CLASSDIR=libaltosJNI
-
-$(SWIG_FILE): libaltos.i0 $(HFILES)
- sed 's;//%;%;' libaltos.i0 $(HFILES) > $(SWIG_FILE)
-
-all-local: classlibaltos.stamp
-
-libaltos_wrap.c: classlibaltos.stamp
-
-classlibaltos.stamp: $(SWIG_FILE)
- swig -java -package libaltosJNI $(SWIG_FILE)
- mkdir -p libaltosJNI
- $(JAVAC) -d . $(AM_JAVACFLAGS) $(JAVACFLAGS) *.java && \
- touch classlibaltos.stamp
-
-MINGCC32=i686-w64-mingw32-gcc
-MINGCC64=x86_64-w64-mingw32-gcc
-MINGFLAGS=-Wall -DWINDOWS -DBUILD_DLL -I$(JVM_INCLUDE)
-MINGLIBS=-lsetupapi
-
-fat: altos.dll altos64.dll
-
-altos.dll: $(libaltos_la_SOURCES)
- $(MINGCC32) -o $@ $(MINGFLAGS) -shared $(libaltos_la_SOURCES) $(MINGLIBS)
-
-altos64.dll: $(libaltos_la_SOURCES)
- $(MINGCC64) -o $@ $(MINGFLAGS) -shared $(libaltos_la_SOURCES) $(MINGLIBS)
-
-clean-local:
- -rm -rf libaltosJNI *.class *.java classlibaltos.stamp $(SWIG_FILE) libaltos_wrap.c altos.dll altos64.dll
diff --git a/altosui/libaltos/cjnitest.c b/altosui/libaltos/cjnitest.c
deleted file mode 100644
index f0fe78f7..00000000
--- a/altosui/libaltos/cjnitest.c
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <stdio.h>
-#include "libaltos.h"
-
-static void
-altos_puts(struct altos_file *file, char *string)
-{
- char c;
-
- while ((c = *string++))
- altos_putchar(file, c);
-}
-
-main ()
-{
- struct altos_device device;
- struct altos_list *list;
- struct altos_bt_device bt_device;
- struct altos_bt_list *bt_list;
-
- altos_init();
- list = altos_list_start();
- while (altos_list_next(list, &device)) {
- struct altos_file *file;
- int c;
-
- printf ("%04x:%04x %-20s %4d %s\n", device.vendor, device.product,
- device.name, device.serial, device.path);
-
- file = altos_open(&device);
- if (!file) {
- printf("altos_open failed\n");
- continue;
- }
- altos_puts(file,"v\nc s\n");
- altos_flush(file);
- while ((c = altos_getchar(file, 100)) >= 0) {
- putchar (c);
- }
- if (c != LIBALTOS_TIMEOUT)
- printf ("getchar returns %d\n", c);
- altos_close(file);
- }
- altos_list_finish(list);
-#if HAS_BLUETOOTH
- bt_list = altos_bt_list_start(8);
- while (altos_bt_list_next(bt_list, &bt_device)) {
- printf ("%s %s\n", bt_device.name, bt_device.addr);
- if (strncmp(bt_device.name, "TeleBT", 6) == 0) {
- struct altos_file *file;
-
- int c;
- file = altos_bt_open(&bt_device);
- if (!file) {
- printf("altos_bt_open failed\n");
- continue;
- }
- altos_puts(file,"v\nc s\n");
- altos_flush(file);
- while ((c = altos_getchar(file, 100)) >= 0) {
- putchar(c);
- }
- if (c != LIBALTOS_TIMEOUT)
- printf("getchar returns %d\n", c);
- altos_close(file);
- }
- }
- altos_bt_list_finish(bt_list);
-#endif
- altos_fini();
- return 0;
-}
diff --git a/altosui/libaltos/libaltos.c b/altosui/libaltos/libaltos.c
deleted file mode 100644
index ab6ca878..00000000
--- a/altosui/libaltos/libaltos.c
+++ /dev/null
@@ -1,1311 +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.
- */
-
-#include "libaltos.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define USB_VENDOR_FSF 0xfffe
-#define USB_VENDOR_ALTUSMETRUM USB_VENDOR_FSF
-#define USB_PRODUCT_ALTUSMETRUM 0x000a
-#define USB_PRODUCT_ALTUSMETRUM_MIN 0x000a
-#define USB_PRODUCT_ALTUSMETRUM_MAX 0x00ff
-
-#define USB_IS_ALTUSMETRUM(v,p) ((v) == USB_VENDOR_ALTUSMETRUM && \
- (USB_PRODUCT_ALTUSMETRUM_MIN <= (p) && \
- (p) <= USB_PRODUCT_ALTUSMETRUM_MAX))
-
-#define BLUETOOTH_PRODUCT_TELEBT "TeleBT"
-
-#define USE_POLL
-
-PUBLIC int
-altos_init(void)
-{
- return LIBALTOS_SUCCESS;
-}
-
-PUBLIC void
-altos_fini(void)
-{
-}
-
-static struct altos_error last_error;
-
-static void
-altos_set_last_error(int code, char *string)
-{
- last_error.code = code;
- strncpy(last_error.string, string, sizeof (last_error.string) -1);
- last_error.string[sizeof(last_error.string)-1] = '\0';
-}
-
-PUBLIC void
-altos_get_last_error(struct altos_error *error)
-{
- *error = last_error;
-}
-
-#ifdef DARWIN
-
-#undef USE_POLL
-
-/* Mac OS X don't have strndup even if _GNU_SOURCE is defined */
-static char *
-altos_strndup (const char *s, size_t n)
-{
- size_t len = strlen (s);
- char *ret;
-
- if (len <= n)
- return strdup (s);
- ret = malloc(n + 1);
- strncpy(ret, s, n);
- ret[n] = '\0';
- return ret;
-}
-
-#else
-#define altos_strndup strndup
-#endif
-
-#ifdef POSIX_TTY
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <errno.h>
-
-#define USB_BUF_SIZE 64
-
-struct altos_file {
- int fd;
-#ifdef USE_POLL
- int pipe[2];
-#else
- int out_fd;
-#endif
- unsigned char out_data[USB_BUF_SIZE];
- int out_used;
- unsigned char in_data[USB_BUF_SIZE];
- int in_used;
- int in_read;
-};
-
-static void
-altos_set_last_posix_error(void)
-{
- altos_set_last_error(errno, strerror(errno));
-}
-
-PUBLIC struct altos_file *
-altos_open(struct altos_device *device)
-{
- struct altos_file *file = calloc (sizeof (struct altos_file), 1);
- int ret;
- struct termios term;
-
- if (!file) {
- altos_set_last_posix_error();
- return NULL;
- }
-
-// altos_set_last_error(12, "yeah yeah, failed again");
-// free(file);
-// return NULL;
-
- file->fd = open(device->path, O_RDWR | O_NOCTTY);
- if (file->fd < 0) {
- altos_set_last_posix_error();
- free(file);
- return NULL;
- }
-#ifdef USE_POLL
- pipe(file->pipe);
-#else
- file->out_fd = open(device->path, O_RDWR | O_NOCTTY);
- if (file->out_fd < 0) {
- altos_set_last_posix_error();
- close(file->fd);
- free(file);
- return NULL;
- }
-#endif
- ret = tcgetattr(file->fd, &term);
- if (ret < 0) {
- altos_set_last_posix_error();
- close(file->fd);
-#ifndef USE_POLL
- close(file->out_fd);
-#endif
- free(file);
- return NULL;
- }
- cfmakeraw(&term);
-#ifdef USE_POLL
- term.c_cc[VMIN] = 1;
- term.c_cc[VTIME] = 0;
-#else
- term.c_cc[VMIN] = 0;
- term.c_cc[VTIME] = 1;
-#endif
- ret = tcsetattr(file->fd, TCSAFLUSH, &term);
- if (ret < 0) {
- altos_set_last_posix_error();
- close(file->fd);
-#ifndef USE_POLL
- close(file->out_fd);
-#endif
- free(file);
- return NULL;
- }
- return file;
-}
-
-PUBLIC void
-altos_close(struct altos_file *file)
-{
- if (file->fd != -1) {
- int fd = file->fd;
- file->fd = -1;
-#ifdef USE_POLL
- write(file->pipe[1], "\r", 1);
-#else
- close(file->out_fd);
- file->out_fd = -1;
-#endif
- close(fd);
- }
-}
-
-PUBLIC void
-altos_free(struct altos_file *file)
-{
- altos_close(file);
- free(file);
-}
-
-PUBLIC int
-altos_flush(struct altos_file *file)
-{
- if (file->out_used && 0) {
- printf ("flush \"");
- fwrite(file->out_data, 1, file->out_used, stdout);
- printf ("\"\n");
- }
- while (file->out_used) {
- int ret;
-
- if (file->fd < 0)
- return -EBADF;
-#ifdef USE_POLL
- ret = write (file->fd, file->out_data, file->out_used);
-#else
- ret = write (file->out_fd, file->out_data, file->out_used);
-#endif
- if (ret < 0) {
- altos_set_last_posix_error();
- return -last_error.code;
- }
- if (ret) {
- memmove(file->out_data, file->out_data + ret,
- file->out_used - ret);
- file->out_used -= ret;
- }
- }
- return 0;
-}
-
-PUBLIC int
-altos_putchar(struct altos_file *file, char c)
-{
- int ret;
-
- if (file->out_used == USB_BUF_SIZE) {
- ret = altos_flush(file);
- if (ret) {
- return ret;
- }
- }
- file->out_data[file->out_used++] = c;
- ret = 0;
- if (file->out_used == USB_BUF_SIZE)
- ret = altos_flush(file);
- return ret;
-}
-
-#ifdef USE_POLL
-#include <poll.h>
-#endif
-
-static int
-altos_fill(struct altos_file *file, int timeout)
-{
- int ret;
-#ifdef USE_POLL
- struct pollfd fd[2];
-#endif
-
- if (timeout == 0)
- timeout = -1;
- while (file->in_read == file->in_used) {
- if (file->fd < 0)
- return LIBALTOS_ERROR;
-#ifdef USE_POLL
- fd[0].fd = file->fd;
- fd[0].events = POLLIN|POLLERR|POLLHUP|POLLNVAL;
- fd[1].fd = file->pipe[0];
- fd[1].events = POLLIN;
- ret = poll(fd, 2, timeout);
- if (ret < 0) {
- altos_set_last_posix_error();
- return LIBALTOS_ERROR;
- }
- if (ret == 0)
- return LIBALTOS_TIMEOUT;
-
- if (fd[0].revents & (POLLHUP|POLLERR|POLLNVAL))
- return LIBALTOS_ERROR;
- if (fd[0].revents & POLLIN)
-#endif
- {
- ret = read(file->fd, file->in_data, USB_BUF_SIZE);
- if (ret < 0) {
- altos_set_last_posix_error();
- return LIBALTOS_ERROR;
- }
- file->in_read = 0;
- file->in_used = ret;
-#ifndef USE_POLL
- if (ret == 0 && timeout > 0)
- return LIBALTOS_TIMEOUT;
-#endif
- }
- }
- if (file->in_used && 0) {
- printf ("fill \"");
- fwrite(file->in_data, 1, file->in_used, stdout);
- printf ("\"\n");
- }
- return 0;
-}
-
-PUBLIC int
-altos_getchar(struct altos_file *file, int timeout)
-{
- int ret;
- while (file->in_read == file->in_used) {
- if (file->fd < 0)
- return LIBALTOS_ERROR;
- ret = altos_fill(file, timeout);
- if (ret)
- return ret;
- }
- return file->in_data[file->in_read++];
-}
-
-#endif /* POSIX_TTY */
-
-/*
- * Scan for Altus Metrum devices by looking through /sys
- */
-
-#ifdef LINUX
-
-#define _GNU_SOURCE
-#include <ctype.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <bluetooth/bluetooth.h>
-#include <bluetooth/hci.h>
-#include <bluetooth/hci_lib.h>
-#include <bluetooth/rfcomm.h>
-
-static char *
-cc_fullname (char *dir, char *file)
-{
- char *new;
- int dlen = strlen (dir);
- int flen = strlen (file);
- int slen = 0;
-
- if (dir[dlen-1] != '/')
- slen = 1;
- new = malloc (dlen + slen + flen + 1);
- if (!new)
- return 0;
- strcpy(new, dir);
- if (slen)
- strcat (new, "/");
- strcat(new, file);
- return new;
-}
-
-static char *
-cc_basename(char *file)
-{
- char *b;
-
- b = strrchr(file, '/');
- if (!b)
- return file;
- return b + 1;
-}
-
-static char *
-load_string(char *dir, char *file)
-{
- char *full = cc_fullname(dir, file);
- char line[4096];
- char *r;
- FILE *f;
- int rlen;
-
- f = fopen(full, "r");
- free(full);
- if (!f)
- return NULL;
- r = fgets(line, sizeof (line), f);
- fclose(f);
- if (!r)
- return NULL;
- rlen = strlen(r);
- if (r[rlen-1] == '\n')
- r[rlen-1] = '\0';
- return strdup(r);
-}
-
-static int
-load_hex(char *dir, char *file)
-{
- char *line;
- char *end;
- long i;
-
- line = load_string(dir, file);
- if (!line)
- return -1;
- i = strtol(line, &end, 16);
- free(line);
- if (end == line)
- return -1;
- return i;
-}
-
-static int
-load_dec(char *dir, char *file)
-{
- char *line;
- char *end;
- long i;
-
- line = load_string(dir, file);
- if (!line)
- return -1;
- i = strtol(line, &end, 10);
- free(line);
- if (end == line)
- return -1;
- return i;
-}
-
-static int
-dir_filter_tty_colon(const struct dirent *d)
-{
- return strncmp(d->d_name, "tty:", 4) == 0;
-}
-
-static int
-dir_filter_tty(const struct dirent *d)
-{
- return strncmp(d->d_name, "tty", 3) == 0;
-}
-
-struct altos_usbdev {
- char *sys;
- char *tty;
- char *manufacturer;
- char *product_name;
- int serial; /* AltOS always uses simple integer serial numbers */
- int idProduct;
- int idVendor;
-};
-
-static char *
-usb_tty(char *sys)
-{
- char *base;
- int num_configs;
- int config;
- struct dirent **namelist;
- int interface;
- int num_interfaces;
- char endpoint_base[20];
- char *endpoint_full;
- char *tty_dir;
- int ntty;
- char *tty;
-
- base = cc_basename(sys);
- num_configs = load_hex(sys, "bNumConfigurations");
- num_interfaces = load_hex(sys, "bNumInterfaces");
- for (config = 1; config <= num_configs; config++) {
- for (interface = 0; interface < num_interfaces; interface++) {
- sprintf(endpoint_base, "%s:%d.%d",
- base, config, interface);
- endpoint_full = cc_fullname(sys, endpoint_base);
-
- /* Check for tty:ttyACMx style names
- */
- ntty = scandir(endpoint_full, &namelist,
- dir_filter_tty_colon,
- alphasort);
- if (ntty > 0) {
- free(endpoint_full);
- tty = cc_fullname("/dev", namelist[0]->d_name + 4);
- free(namelist);
- return tty;
- }
-
- /* Check for tty/ttyACMx style names
- */
- tty_dir = cc_fullname(endpoint_full, "tty");
- free(endpoint_full);
- ntty = scandir(tty_dir, &namelist,
- dir_filter_tty,
- alphasort);
- free (tty_dir);
- if (ntty > 0) {
- tty = cc_fullname("/dev", namelist[0]->d_name);
- free(namelist);
- return tty;
- }
- }
- }
- return NULL;
-}
-
-static struct altos_usbdev *
-usb_scan_device(char *sys)
-{
- struct altos_usbdev *usbdev;
-
- usbdev = calloc(1, sizeof (struct altos_usbdev));
- if (!usbdev)
- return NULL;
- usbdev->sys = strdup(sys);
- usbdev->manufacturer = load_string(sys, "manufacturer");
- usbdev->product_name = load_string(sys, "product");
- usbdev->serial = load_dec(sys, "serial");
- usbdev->idProduct = load_hex(sys, "idProduct");
- usbdev->idVendor = load_hex(sys, "idVendor");
- usbdev->tty = usb_tty(sys);
- return usbdev;
-}
-
-static void
-usbdev_free(struct altos_usbdev *usbdev)
-{
- free(usbdev->sys);
- free(usbdev->manufacturer);
- free(usbdev->product_name);
- /* this can get used as a return value */
- if (usbdev->tty)
- free(usbdev->tty);
- free(usbdev);
-}
-
-#define USB_DEVICES "/sys/bus/usb/devices"
-
-static int
-dir_filter_dev(const struct dirent *d)
-{
- const char *n = d->d_name;
- char c;
-
- while ((c = *n++)) {
- if (isdigit(c))
- continue;
- if (c == '-')
- continue;
- if (c == '.' && n != d->d_name + 1)
- continue;
- return 0;
- }
- return 1;
-}
-
-struct altos_list {
- struct altos_usbdev **dev;
- int current;
- int ndev;
-};
-
-struct altos_list *
-altos_list_start(void)
-{
- int e;
- struct dirent **ents;
- char *dir;
- struct altos_usbdev *dev;
- struct altos_list *devs;
- int n;
-
- devs = calloc(1, sizeof (struct altos_list));
- if (!devs)
- return NULL;
-
- n = scandir (USB_DEVICES, &ents,
- dir_filter_dev,
- alphasort);
- if (!n)
- return 0;
- for (e = 0; e < n; e++) {
- dir = cc_fullname(USB_DEVICES, ents[e]->d_name);
- dev = usb_scan_device(dir);
- free(dir);
- if (USB_IS_ALTUSMETRUM(dev->idVendor, dev->idProduct)) {
- if (devs->dev)
- devs->dev = realloc(devs->dev,
- (devs->ndev + 1) * sizeof (struct usbdev *));
- else
- devs->dev = malloc (sizeof (struct usbdev *));
- devs->dev[devs->ndev++] = dev;
- }
- }
- free(ents);
- devs->current = 0;
- return devs;
-}
-
-int
-altos_list_next(struct altos_list *list, struct altos_device *device)
-{
- struct altos_usbdev *dev;
- if (list->current >= list->ndev)
- return 0;
- dev = list->dev[list->current];
- strcpy(device->name, dev->product_name);
- device->vendor = dev->idVendor;
- device->product = dev->idProduct;
- strcpy(device->path, dev->tty);
- device->serial = dev->serial;
- list->current++;
- return 1;
-}
-
-void
-altos_list_finish(struct altos_list *usbdevs)
-{
- int i;
-
- if (!usbdevs)
- return;
- for (i = 0; i < usbdevs->ndev; i++)
- usbdev_free(usbdevs->dev[i]);
- free(usbdevs);
-}
-
-struct altos_bt_list {
- inquiry_info *ii;
- int sock;
- int dev_id;
- int rsp;
- int num_rsp;
-};
-
-#define INQUIRY_MAX_RSP 255
-
-struct altos_bt_list *
-altos_bt_list_start(int inquiry_time)
-{
- struct altos_bt_list *bt_list;
-
- bt_list = calloc(1, sizeof (struct altos_bt_list));
- if (!bt_list)
- goto no_bt_list;
-
- bt_list->ii = calloc(INQUIRY_MAX_RSP, sizeof (inquiry_info));
- if (!bt_list->ii)
- goto no_ii;
- bt_list->dev_id = hci_get_route(NULL);
- if (bt_list->dev_id < 0)
- goto no_dev_id;
-
- bt_list->sock = hci_open_dev(bt_list->dev_id);
- if (bt_list->sock < 0)
- goto no_sock;
-
- bt_list->num_rsp = hci_inquiry(bt_list->dev_id,
- inquiry_time,
- INQUIRY_MAX_RSP,
- NULL,
- &bt_list->ii,
- IREQ_CACHE_FLUSH);
- if (bt_list->num_rsp < 0)
- goto no_rsp;
-
- bt_list->rsp = 0;
- return bt_list;
-
-no_rsp:
- close(bt_list->sock);
-no_sock:
-no_dev_id:
- free(bt_list->ii);
-no_ii:
- free(bt_list);
-no_bt_list:
- return NULL;
-}
-
-int
-altos_bt_list_next(struct altos_bt_list *bt_list,
- struct altos_bt_device *device)
-{
- inquiry_info *ii;
-
- if (bt_list->rsp >= bt_list->num_rsp)
- return 0;
-
- ii = &bt_list->ii[bt_list->rsp];
- ba2str(&ii->bdaddr, device->addr);
- memset(&device->name, '\0', sizeof (device->name));
- if (hci_read_remote_name(bt_list->sock, &ii->bdaddr,
- sizeof (device->name),
- device->name, 0) < 0) {
- strcpy(device->name, "[unknown]");
- }
- bt_list->rsp++;
- return 1;
-}
-
-void
-altos_bt_list_finish(struct altos_bt_list *bt_list)
-{
- close(bt_list->sock);
- free(bt_list->ii);
- free(bt_list);
-}
-
-void
-altos_bt_fill_in(char *name, char *addr, struct altos_bt_device *device)
-{
- strncpy(device->name, name, sizeof (device->name));
- device->name[sizeof(device->name)-1] = '\0';
- strncpy(device->addr, addr, sizeof (device->addr));
- device->addr[sizeof(device->addr)-1] = '\0';
-}
-
-struct altos_file *
-altos_bt_open(struct altos_bt_device *device)
-{
- struct sockaddr_rc addr = { 0 };
- int s, status;
- struct altos_file *file;
-
- file = calloc(1, sizeof (struct altos_file));
- if (!file)
- goto no_file;
- file->fd = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
- if (file->fd < 0) {
- altos_set_last_posix_error();
- goto no_sock;
- }
-
- addr.rc_family = AF_BLUETOOTH;
- addr.rc_channel = 1;
- str2ba(device->addr, &addr.rc_bdaddr);
-
- status = connect(file->fd,
- (struct sockaddr *)&addr,
- sizeof(addr));
- if (status < 0) {
- altos_set_last_posix_error();
- goto no_link;
- }
- sleep(1);
-
-#ifdef USE_POLL
- pipe(file->pipe);
-#else
- file->out_fd = dup(file->fd);
-#endif
- return file;
-no_link:
- close(s);
-no_sock:
- free(file);
-no_file:
- return NULL;
-}
-
-#endif
-
-#ifdef DARWIN
-
-#include <IOKitLib.h>
-#include <IOKit/usb/USBspec.h>
-#include <sys/param.h>
-#include <paths.h>
-#include <CFNumber.h>
-#include <IOBSD.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-struct altos_list {
- io_iterator_t iterator;
-};
-
-static int
-get_string(io_object_t object, CFStringRef entry, char *result, int result_len)
-{
- CFTypeRef entry_as_string;
- Boolean got_string;
-
- entry_as_string = IORegistryEntrySearchCFProperty (object,
- kIOServicePlane,
- entry,
- kCFAllocatorDefault,
- kIORegistryIterateRecursively);
- if (entry_as_string) {
- got_string = CFStringGetCString(entry_as_string,
- result, result_len,
- kCFStringEncodingASCII);
-
- CFRelease(entry_as_string);
- if (got_string)
- return 1;
- }
- return 0;
-}
-
-static int
-get_number(io_object_t object, CFStringRef entry, int *result)
-{
- CFTypeRef entry_as_number;
- Boolean got_number;
-
- entry_as_number = IORegistryEntrySearchCFProperty (object,
- kIOServicePlane,
- entry,
- kCFAllocatorDefault,
- kIORegistryIterateRecursively);
- if (entry_as_number) {
- got_number = CFNumberGetValue(entry_as_number,
- kCFNumberIntType,
- result);
- if (got_number)
- return 1;
- }
- return 0;
-}
-
-PUBLIC struct altos_list *
-altos_list_start(void)
-{
- struct altos_list *list = calloc (sizeof (struct altos_list), 1);
- CFMutableDictionaryRef matching_dictionary = IOServiceMatching("IOUSBDevice");
- io_iterator_t tdIterator;
- io_object_t tdObject;
- kern_return_t ret;
- int i;
-
- ret = IOServiceGetMatchingServices(kIOMasterPortDefault, matching_dictionary, &list->iterator);
- if (ret != kIOReturnSuccess)
- return NULL;
- return list;
-}
-
-PUBLIC int
-altos_list_next(struct altos_list *list, struct altos_device *device)
-{
- io_object_t object;
- char serial_string[128];
-
- for (;;) {
- object = IOIteratorNext(list->iterator);
- if (!object)
- return 0;
-
- if (!get_number (object, CFSTR(kUSBVendorID), &device->vendor) ||
- !get_number (object, CFSTR(kUSBProductID), &device->product))
- continue;
- if (device->vendor != 0xfffe)
- continue;
- if (device->product < 0x000a || 0x0013 < device->product)
- continue;
- if (get_string (object, CFSTR("IOCalloutDevice"), device->path, sizeof (device->path)) &&
- get_string (object, CFSTR("USB Product Name"), device->name, sizeof (device->name)) &&
- get_string (object, CFSTR("USB Serial Number"), serial_string, sizeof (serial_string))) {
- device->serial = atoi(serial_string);
- return 1;
- }
- }
-}
-
-PUBLIC void
-altos_list_finish(struct altos_list *list)
-{
- IOObjectRelease (list->iterator);
- free(list);
-}
-
-struct altos_bt_list {
- int sock;
- int dev_id;
- int rsp;
- int num_rsp;
-};
-
-#define INQUIRY_MAX_RSP 255
-
-struct altos_bt_list *
-altos_bt_list_start(int inquiry_time)
-{
- return NULL;
-}
-
-int
-altos_bt_list_next(struct altos_bt_list *bt_list,
- struct altos_bt_device *device)
-{
- return 0;
-}
-
-void
-altos_bt_list_finish(struct altos_bt_list *bt_list)
-{
-}
-
-void
-altos_bt_fill_in(char *name, char *addr, struct altos_bt_device *device)
-{
- strncpy(device->name, name, sizeof (device->name));
- device->name[sizeof(device->name)-1] = '\0';
- strncpy(device->addr, addr, sizeof (device->addr));
- device->addr[sizeof(device->addr)-1] = '\0';
-}
-
-struct altos_file *
-altos_bt_open(struct altos_bt_device *device)
-{
- return NULL;
-}
-
-#endif
-
-
-#ifdef WINDOWS
-
-#include <stdlib.h>
-#include <windows.h>
-#include <setupapi.h>
-
-struct altos_list {
- HDEVINFO dev_info;
- int index;
-};
-
-#define USB_BUF_SIZE 64
-
-struct altos_file {
- HANDLE handle;
- unsigned char out_data[USB_BUF_SIZE];
- int out_used;
- unsigned char in_data[USB_BUF_SIZE];
- int in_used;
- int in_read;
- OVERLAPPED ov_read;
- BOOL pend_read;
- OVERLAPPED ov_write;
-};
-
-static void
-_altos_set_last_windows_error(char *file, int line)
-{
- DWORD error = GetLastError();
- TCHAR message[1024];
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
- 0,
- error,
- 0,
- message,
- sizeof (message) / sizeof (TCHAR),
- NULL);
- if (error != ERROR_SUCCESS)
- printf ("%s:%d %s\n", file, line, message);
- altos_set_last_error(error, message);
-}
-
-#define altos_set_last_windows_error() _altos_set_last_windows_error(__FILE__, __LINE__)
-
-PUBLIC struct altos_list *
-altos_list_start(void)
-{
- struct altos_list *list = calloc(1, sizeof (struct altos_list));
-
- if (!list)
- return NULL;
- list->dev_info = SetupDiGetClassDevs(NULL, "USB", NULL,
- DIGCF_ALLCLASSES|DIGCF_PRESENT);
- if (list->dev_info == INVALID_HANDLE_VALUE) {
- altos_set_last_windows_error();
- free(list);
- return NULL;
- }
- list->index = 0;
- return list;
-}
-
-PUBLIC int
-altos_list_next(struct altos_list *list, struct altos_device *device)
-{
- SP_DEVINFO_DATA dev_info_data;
- BYTE port[128];
- DWORD port_len;
- char friendlyname[256];
- BYTE symbolic[256];
- DWORD symbolic_len;
- HKEY dev_key;
- unsigned int vid, pid;
- int serial;
- HRESULT result;
- DWORD friendlyname_type;
- DWORD friendlyname_len;
-
- dev_info_data.cbSize = sizeof (SP_DEVINFO_DATA);
- while(SetupDiEnumDeviceInfo(list->dev_info, list->index,
- &dev_info_data))
- {
- list->index++;
-
- dev_key = SetupDiOpenDevRegKey(list->dev_info, &dev_info_data,
- DICS_FLAG_GLOBAL, 0, DIREG_DEV,
- KEY_READ);
- if (dev_key == INVALID_HANDLE_VALUE) {
- altos_set_last_windows_error();
- printf("cannot open device registry key\n");
- continue;
- }
-
- /* Fetch symbolic name for this device and parse out
- * the vid/pid/serial info */
- symbolic_len = sizeof(symbolic);
- result = RegQueryValueEx(dev_key, "SymbolicName", NULL, NULL,
- symbolic, &symbolic_len);
- if (result != 0) {
- altos_set_last_windows_error();
- printf("cannot find SymbolicName value\n");
- RegCloseKey(dev_key);
- continue;
- }
- vid = pid = serial = 0;
- sscanf((char *) symbolic + sizeof("\\??\\USB#VID_") - 1,
- "%04X", &vid);
- sscanf((char *) symbolic + sizeof("\\??\\USB#VID_XXXX&PID_") - 1,
- "%04X", &pid);
- sscanf((char *) symbolic + sizeof("\\??\\USB#VID_XXXX&PID_XXXX#") - 1,
- "%d", &serial);
- if (!USB_IS_ALTUSMETRUM(vid, pid)) {
- RegCloseKey(dev_key);
- continue;
- }
-
- /* Fetch the com port name */
- port_len = sizeof (port);
- result = RegQueryValueEx(dev_key, "PortName", NULL, NULL,
- port, &port_len);
- RegCloseKey(dev_key);
- if (result != 0) {
- altos_set_last_windows_error();
- printf("failed to get PortName\n");
- continue;
- }
-
- /* Fetch the device description which is the device name,
- * with firmware that has unique USB ids */
- friendlyname_len = sizeof (friendlyname);
- if(!SetupDiGetDeviceRegistryProperty(list->dev_info,
- &dev_info_data,
- SPDRP_FRIENDLYNAME,
- &friendlyname_type,
- (BYTE *)friendlyname,
- sizeof(friendlyname),
- &friendlyname_len))
- {
- altos_set_last_windows_error();
- printf("Failed to get friendlyname\n");
- continue;
- }
- device->vendor = vid;
- device->product = pid;
- device->serial = serial;
- strcpy(device->name, friendlyname);
-
- strcpy(device->path, (char *) port);
- return 1;
- }
- result = GetLastError();
- if (result != ERROR_NO_MORE_ITEMS) {
- altos_set_last_windows_error();
- printf ("SetupDiEnumDeviceInfo failed error %d\n", (int) result);
- }
- return 0;
-}
-
-PUBLIC void
-altos_list_finish(struct altos_list *list)
-{
- SetupDiDestroyDeviceInfoList(list->dev_info);
- free(list);
-}
-
-static int
-altos_queue_read(struct altos_file *file)
-{
- DWORD got;
- if (file->pend_read)
- return LIBALTOS_SUCCESS;
-
- if (!ReadFile(file->handle, file->in_data, USB_BUF_SIZE, &got, &file->ov_read)) {
- if (GetLastError() != ERROR_IO_PENDING) {
- altos_set_last_windows_error();
- return LIBALTOS_ERROR;
- }
- file->pend_read = TRUE;
- } else {
- file->pend_read = FALSE;
- file->in_read = 0;
- file->in_used = got;
- }
- return LIBALTOS_SUCCESS;
-}
-
-static int
-altos_wait_read(struct altos_file *file, int timeout)
-{
- DWORD ret;
- DWORD got;
-
- if (!file->pend_read)
- return LIBALTOS_SUCCESS;
-
- if (!timeout)
- timeout = INFINITE;
-
- ret = WaitForSingleObject(file->ov_read.hEvent, timeout);
- switch (ret) {
- case WAIT_OBJECT_0:
- if (!GetOverlappedResult(file->handle, &file->ov_read, &got, FALSE)) {
- altos_set_last_windows_error();
- return LIBALTOS_ERROR;
- }
- file->pend_read = FALSE;
- file->in_read = 0;
- file->in_used = got;
- break;
- case WAIT_TIMEOUT:
- return LIBALTOS_TIMEOUT;
- break;
- default:
- return LIBALTOS_ERROR;
- }
- return LIBALTOS_SUCCESS;
-}
-
-static int
-altos_fill(struct altos_file *file, int timeout)
-{
- int ret;
-
- if (file->in_read < file->in_used)
- return LIBALTOS_SUCCESS;
-
- file->in_read = file->in_used = 0;
-
- ret = altos_queue_read(file);
- if (ret)
- return ret;
- ret = altos_wait_read(file, timeout);
- if (ret)
- return ret;
-
- return LIBALTOS_SUCCESS;
-}
-
-PUBLIC int
-altos_flush(struct altos_file *file)
-{
- DWORD put;
- unsigned char *data = file->out_data;
- int used = file->out_used;
- DWORD ret;
-
- while (used) {
- if (!WriteFile(file->handle, data, used, &put, &file->ov_write)) {
- if (GetLastError() != ERROR_IO_PENDING) {
- altos_set_last_windows_error();
- printf ("\tflush write error\n");
- return LIBALTOS_ERROR;
- }
- ret = WaitForSingleObject(file->ov_write.hEvent, INFINITE);
- switch (ret) {
- case WAIT_OBJECT_0:
- if (!GetOverlappedResult(file->handle, &file->ov_write, &put, FALSE)) {
- altos_set_last_windows_error();
- printf ("\tflush result error\n");
- return LIBALTOS_ERROR;
- }
- break;
- default:
- altos_set_last_windows_error();
- printf ("\tflush wait error\n");
- return LIBALTOS_ERROR;
- }
- }
- data += put;
- used -= put;
- }
- file->out_used = 0;
- return LIBALTOS_SUCCESS;
-}
-
-PUBLIC struct altos_file *
-altos_open(struct altos_device *device)
-{
- struct altos_file *file = calloc (1, sizeof (struct altos_file));
- char full_name[64];
- COMMTIMEOUTS timeouts;
-
- if (!file)
- return NULL;
-
- strcpy(full_name, "\\\\.\\");
- strcat(full_name, device->path);
- file->handle = CreateFile(full_name, GENERIC_READ|GENERIC_WRITE,
- 0, NULL, OPEN_EXISTING,
- FILE_FLAG_OVERLAPPED, NULL);
- if (file->handle == INVALID_HANDLE_VALUE) {
- altos_set_last_windows_error();
- printf ("cannot open %s\n", full_name);
- free(file);
- return NULL;
- }
- file->ov_read.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- file->ov_write.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
-
- timeouts.ReadIntervalTimeout = MAXDWORD;
- timeouts.ReadTotalTimeoutMultiplier = MAXDWORD;
- timeouts.ReadTotalTimeoutConstant = 1 << 30; /* almost forever */
- timeouts.WriteTotalTimeoutMultiplier = 0;
- timeouts.WriteTotalTimeoutConstant = 0;
- SetCommTimeouts(file->handle, &timeouts);
-
- return file;
-}
-
-PUBLIC void
-altos_close(struct altos_file *file)
-{
- if (file->handle != INVALID_HANDLE_VALUE) {
- CloseHandle(file->handle);
- file->handle = INVALID_HANDLE_VALUE;
- SetEvent(file->ov_read.hEvent);
- SetEvent(file->ov_write.hEvent);
- CloseHandle(file->ov_read.hEvent);
- CloseHandle(file->ov_write.hEvent);
- }
-}
-
-PUBLIC void
-altos_free(struct altos_file *file)
-{
- altos_close(file);
- free(file);
-}
-
-PUBLIC int
-altos_putchar(struct altos_file *file, char c)
-{
- int ret;
-
- if (file->out_used == USB_BUF_SIZE) {
- ret = altos_flush(file);
- if (ret)
- return ret;
- }
- file->out_data[file->out_used++] = c;
- if (file->out_used == USB_BUF_SIZE)
- return altos_flush(file);
- return LIBALTOS_SUCCESS;
-}
-
-PUBLIC int
-altos_getchar(struct altos_file *file, int timeout)
-{
- int ret;
- while (file->in_read == file->in_used) {
- if (file->handle == INVALID_HANDLE_VALUE)
- return LIBALTOS_ERROR;
- ret = altos_fill(file, timeout);
- if (ret)
- return ret;
- }
- return file->in_data[file->in_read++];
-}
-
-struct altos_bt_list *
-altos_bt_list_start(int inquiry_time)
-{
- return NULL;
-}
-
-int
-altos_bt_list_next(struct altos_bt_list *bt_list,
- struct altos_bt_device *device)
-{
- return 0;
-}
-
-void
-altos_bt_list_finish(struct altos_bt_list *bt_list)
-{
- free(bt_list);
-}
-
-void
-altos_bt_fill_in(char *name, char *addr, struct altos_bt_device *device)
-{
- strncpy(device->name, name, sizeof (device->name));
- device->name[sizeof(device->name)-1] = '\0';
- strncpy(device->addr, addr, sizeof (device->addr));
- device->addr[sizeof(device->addr)-1] = '\0';
-}
-
-struct altos_file *
-altos_bt_open(struct altos_bt_device *device)
-{
- return NULL;
-}
-
-#endif
diff --git a/altosui/libaltos/libaltos.dylib b/altosui/libaltos/libaltos.dylib
deleted file mode 100755
index 1038817d..00000000
--- a/altosui/libaltos/libaltos.dylib
+++ /dev/null
Binary files differ
diff --git a/altosui/libaltos/libaltos.h b/altosui/libaltos/libaltos.h
deleted file mode 100644
index f90fbb87..00000000
--- a/altosui/libaltos/libaltos.h
+++ /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.
- */
-
-#ifndef _LIBALTOS_H_
-#define _LIBALTOS_H_
-
-#include <stdlib.h>
-
-#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# ifndef BUILD_STATIC
-# ifdef BUILD_DLL
-# define PUBLIC __declspec(dllexport)
-# else
-# define PUBLIC __declspec(dllimport)
-# endif
-# endif /* BUILD_STATIC */
-#endif
-
-#ifndef PUBLIC
-# define PUBLIC
-#endif
-
-struct altos_device {
- //%immutable;
- int vendor;
- int product;
- int serial;
- char name[256];
- char path[256];
- //%mutable;
-};
-
-struct altos_bt_device {
- //%immutable;
- char name[256];
- char addr[20];
- //%mutable;
-};
-
-struct altos_error {
- int code;
- char string[1024];
-};
-
-#define LIBALTOS_SUCCESS 0
-#define LIBALTOS_ERROR -1
-#define LIBALTOS_TIMEOUT -2
-
-/* Returns 0 for success, < 0 on error */
-PUBLIC int
-altos_init(void);
-
-PUBLIC void
-altos_fini(void);
-
-PUBLIC void
-altos_get_last_error(struct altos_error *error);
-
-PUBLIC struct altos_list *
-altos_list_start(void);
-
-/* Returns 1 for success, zero on end of list */
-PUBLIC int
-altos_list_next(struct altos_list *list, struct altos_device *device);
-
-PUBLIC void
-altos_list_finish(struct altos_list *list);
-
-PUBLIC struct altos_file *
-altos_open(struct altos_device *device);
-
-PUBLIC void
-altos_close(struct altos_file *file);
-
-PUBLIC void
-altos_free(struct altos_file *file);
-
-/* Returns < 0 for error */
-PUBLIC int
-altos_putchar(struct altos_file *file, char c);
-
-/* Returns < 0 for error */
-PUBLIC int
-altos_flush(struct altos_file *file);
-
-/* Returns < 0 for error or timeout. timeout of 0 == wait forever */
-PUBLIC int
-altos_getchar(struct altos_file *file, int timeout);
-
-PUBLIC struct altos_bt_list *
-altos_bt_list_start(int inquiry_time);
-
-PUBLIC int
-altos_bt_list_next(struct altos_bt_list *list, struct altos_bt_device *device);
-
-PUBLIC void
-altos_bt_list_finish(struct altos_bt_list *list);
-
-PUBLIC void
-altos_bt_fill_in(char *name, char *addr, struct altos_bt_device *device);
-
-PUBLIC struct altos_file *
-altos_bt_open(struct altos_bt_device *device);
-
-#endif /* _LIBALTOS_H_ */
diff --git a/altosui/libaltos/libaltos.i0 b/altosui/libaltos/libaltos.i0
deleted file mode 100644
index d06468f5..00000000
--- a/altosui/libaltos/libaltos.i0
+++ /dev/null
@@ -1,5 +0,0 @@
-%module libaltos
-%{
-#include "libaltos.h"
-%}
-