summaryrefslogtreecommitdiff
path: root/altosui
diff options
context:
space:
mode:
Diffstat (limited to 'altosui')
-rw-r--r--altosui/.gitignore1
-rw-r--r--altosui/Altos.java2
-rw-r--r--altosui/AltosAscent.java33
-rw-r--r--altosui/AltosBTKnown.java2
-rw-r--r--altosui/AltosBTManage.java20
-rw-r--r--altosui/AltosCSV.java117
-rw-r--r--altosui/AltosCSVUI.java10
-rw-r--r--altosui/AltosCompanionInfo.java10
-rw-r--r--altosui/AltosConfig.java4
-rw-r--r--altosui/AltosConfigFreqUI.java2
-rw-r--r--altosui/AltosConfigPyroUI.java104
-rw-r--r--altosui/AltosConfigTD.java2
-rw-r--r--altosui/AltosConfigTDUI.java2
-rw-r--r--altosui/AltosConfigUI.java102
-rw-r--r--altosui/AltosDataChooser.java15
-rw-r--r--altosui/AltosDescent.java25
-rw-r--r--altosui/AltosDisplayThread.java23
-rw-r--r--altosui/AltosEepromDelete.java2
-rw-r--r--altosui/AltosEepromDownload.java490
-rw-r--r--altosui/AltosEepromList.java118
-rw-r--r--altosui/AltosEepromManage.java8
-rw-r--r--altosui/AltosEepromMonitorUI.java311
-rw-r--r--altosui/AltosEepromSelect.java2
-rw-r--r--altosui/AltosFlashUI.java164
-rw-r--r--altosui/AltosFlightDisplay.java2
-rw-r--r--altosui/AltosFlightStats.java143
-rw-r--r--altosui/AltosFlightStatsTable.java18
-rw-r--r--altosui/AltosFlightStatus.java18
-rw-r--r--altosui/AltosFlightStatusTableModel.java2
-rw-r--r--altosui/AltosFlightStatusUpdate.java2
-rw-r--r--altosui/AltosFlightUI.java6
-rw-r--r--altosui/AltosFreqList.java8
-rw-r--r--altosui/AltosGraph.java76
-rw-r--r--altosui/AltosGraphDataPoint.java31
-rw-r--r--altosui/AltosGraphDataSet.java33
-rw-r--r--altosui/AltosGraphUI.java15
-rw-r--r--altosui/AltosIdleMonitorUI.java22
-rw-r--r--altosui/AltosIgniteUI.java2
-rw-r--r--altosui/AltosInfoTable.java86
-rw-r--r--altosui/AltosKML.java58
-rw-r--r--altosui/AltosLanded.java22
-rw-r--r--altosui/AltosPad.java108
-rw-r--r--altosui/AltosRomconfigUI.java4
-rw-r--r--altosui/AltosScanUI.java14
-rw-r--r--altosui/AltosSerial.java50
-rw-r--r--altosui/AltosSiteMap.java23
-rw-r--r--altosui/AltosSiteMapTile.java2
-rw-r--r--altosui/AltosUI.java115
-rw-r--r--altosui/AltosUIPreferencesBackend.java2
-rw-r--r--altosui/AltosWriter.java6
-rw-r--r--altosui/Makefile.am35
-rw-r--r--altosui/altos-windows.nsi.in3
52 files changed, 1260 insertions, 1215 deletions
diff --git a/altosui/.gitignore b/altosui/.gitignore
index f8554c6a..4ee3f4ad 100644
--- a/altosui/.gitignore
+++ b/altosui/.gitignore
@@ -21,3 +21,4 @@ Altos-Windows-*.exe
*.so
*.jar
*.class
+*.dmg
diff --git a/altosui/Altos.java b/altosui/Altos.java
index d25736bf..07280b4a 100644
--- a/altosui/Altos.java
+++ b/altosui/Altos.java
@@ -20,7 +20,7 @@ package altosui;
import java.awt.*;
import libaltosJNI.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class Altos extends AltosUILib {
diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java
index 4da4d591..ba4fc614 100644
--- a/altosui/AltosAscent.java
+++ b/altosui/AltosAscent.java
@@ -19,7 +19,7 @@ package altosui;
import java.awt.*;
import javax.swing.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosAscent extends JComponent implements AltosFlightDisplay {
GridBagLayout layout;
@@ -179,7 +179,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
void reset() {
value.setText("");
max_value.setText("");
- max = AltosRecord.MISSING;
+ max = AltosLib.MISSING;
}
void set_font() {
@@ -189,12 +189,12 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
}
void show(AltosUnits units, double v) {
- if (v == AltosRecord.MISSING) {
+ if (v == AltosLib.MISSING) {
value.setText("Missing");
max_value.setText("Missing");
} else {
value.setText(units.show(8, v));
- if (v > max || max == AltosRecord.MISSING) {
+ if (v > max || max == AltosLib.MISSING) {
max_value.setText(units.show(8, v));
max = v;
}
@@ -240,7 +240,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Height extends AscentValueHold {
void show (AltosState state, AltosListenerState listener_state) {
- show(AltosConvert.height, state.height);
+ show(AltosConvert.height, state.height());
}
public Height (GridBagLayout layout, int y) {
super (layout, y, "Height");
@@ -251,10 +251,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Speed extends AscentValueHold {
void show (AltosState state, AltosListenerState listener_state) {
- double speed = state.accel_speed;
- if (!state.ascent)
- speed = state.baro_speed;
- show(AltosConvert.speed, speed);
+ show(AltosConvert.speed, state.speed());
}
public Speed (GridBagLayout layout, int y) {
super (layout, y, "Speed");
@@ -265,7 +262,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Accel extends AscentValueHold {
void show (AltosState state, AltosListenerState listener_state) {
- show(AltosConvert.accel, state.acceleration);
+ show(AltosConvert.accel, state.acceleration());
}
public Accel (GridBagLayout layout, int y) {
super (layout, y, "Acceleration");
@@ -287,8 +284,8 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Apogee extends AscentStatus {
void show (AltosState state, AltosListenerState listener_state) {
- show("%4.2f V", state.drogue_sense);
- lights.set(state.drogue_sense > 3.2);
+ show("%4.2f V", state.apogee_voltage);
+ lights.set(state.apogee_voltage >= AltosLib.ao_igniter_good);
}
public Apogee (GridBagLayout layout, int y) {
super(layout, y, "Apogee Igniter Voltage");
@@ -299,8 +296,8 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Main extends AscentStatus {
void show (AltosState state, AltosListenerState listener_state) {
- show("%4.2f V", state.main_sense);
- lights.set(state.main_sense > 3.2);
+ show("%4.2f V", state.main_voltage);
+ lights.set(state.main_voltage >= AltosLib.ao_igniter_good);
}
public Main (GridBagLayout layout, int y) {
super(layout, y, "Main Igniter Voltage");
@@ -311,7 +308,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Lat extends AscentValue {
void show (AltosState state, AltosListenerState listener_state) {
- if (state.gps != null)
+ if (state.gps != null && state.gps.connected && state.gps.lat != AltosLib.MISSING)
show(pos(state.gps.lat,"N", "S"));
else
show("???");
@@ -325,7 +322,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Lon extends AscentValue {
void show (AltosState state, AltosListenerState listener_state) {
- if (state.gps != null)
+ if (state.gps != null && state.gps.connected && state.gps.lon != AltosLib.MISSING)
show(pos(state.gps.lon,"E", "W"));
else
show("???");
@@ -368,11 +365,11 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
lon.hide();
}
height.show(state, listener_state);
- if (state.main_sense != AltosRecord.MISSING)
+ if (state.main_voltage != AltosLib.MISSING)
main.show(state, listener_state);
else
main.hide();
- if (state.drogue_sense != AltosRecord.MISSING)
+ if (state.apogee_voltage != AltosLib.MISSING)
apogee.show(state, listener_state);
else
apogee.hide();
diff --git a/altosui/AltosBTKnown.java b/altosui/AltosBTKnown.java
index 1d42365b..a1652ec4 100644
--- a/altosui/AltosBTKnown.java
+++ b/altosui/AltosBTKnown.java
@@ -17,7 +17,7 @@
package altosui;
import java.util.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosBTKnown implements Iterable<AltosBTDevice> {
diff --git a/altosui/AltosBTManage.java b/altosui/AltosBTManage.java
index 4c9b7a6c..1015f7c3 100644
--- a/altosui/AltosBTManage.java
+++ b/altosui/AltosBTManage.java
@@ -85,7 +85,7 @@ public class AltosBTManage extends AltosUIDialog implements ActionListener, Iter
return devices.iterator();
}
- public java.util.List<AltosBTDevice> selected_list() {
+ public java.util.List<AltosBTDevice> selected_list() throws InterruptedException {
java.util.LinkedList<AltosBTDevice> l = new java.util.LinkedList<AltosBTDevice>();
Object[] a = getSelectedValues();
for (int i = 0; i < a.length; i++)
@@ -117,16 +117,22 @@ public class AltosBTManage extends AltosUIDialog implements ActionListener, Iter
}
public void add_known() {
- for (AltosBTDevice device : visible_devices.selected_list()) {
- known_devices.add(device);
- visible_devices.remove(device);
+ try {
+ for (AltosBTDevice device : visible_devices.selected_list()) {
+ known_devices.add(device);
+ visible_devices.remove(device);
+ }
+ } catch (InterruptedException ie) {
}
}
public void remove_known() {
- for (AltosBTDevice device : known_devices.selected_list()) {
- known_devices.remove(device);
- visible_devices.add(device);
+ try {
+ for (AltosBTDevice device : known_devices.selected_list()) {
+ known_devices.remove(device);
+ visible_devices.add(device);
+ }
+ } catch (InterruptedException ie) {
}
}
diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java
index 0676f99d..7598eca0 100644
--- a/altosui/AltosCSV.java
+++ b/altosui/AltosCSV.java
@@ -19,7 +19,7 @@ package altosui;
import java.io.*;
import java.util.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosCSV implements AltosWriter {
File name;
@@ -27,7 +27,7 @@ public class AltosCSV implements AltosWriter {
boolean header_written;
boolean seen_boost;
int boost_tick;
- LinkedList<AltosRecord> pad_records;
+ LinkedList<AltosState> pad_states;
AltosState state;
static final int ALTOS_CSV_VERSION = 5;
@@ -105,47 +105,47 @@ public class AltosCSV implements AltosWriter {
out.printf("version,serial,flight,call,time,clock,rssi,lqi");
}
- void write_general(AltosRecord record) {
+ void write_general(AltosState state) {
out.printf("%s, %d, %d, %s, %8.2f, %8.2f, %4d, %3d",
- ALTOS_CSV_VERSION, record.serial, record.flight, record.callsign,
- (double) record.time, (double) record.tick / 100.0,
- record.rssi,
- record.status & 0x7f);
+ ALTOS_CSV_VERSION, state.serial, state.flight, state.callsign,
+ (double) state.time, (double) state.tick / 100.0,
+ state.rssi,
+ state.status & 0x7f);
}
void write_flight_header() {
out.printf("state,state_name");
}
- void write_flight(AltosRecord record) {
- out.printf("%d,%8s", record.state, record.state());
+ void write_flight(AltosState state) {
+ out.printf("%d,%8s", state.state, state.state_name());
}
void write_basic_header() {
out.printf("acceleration,pressure,altitude,height,accel_speed,baro_speed,temperature,battery_voltage,drogue_voltage,main_voltage");
}
- void write_basic(AltosRecord record) {
+ void write_basic(AltosState state) {
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.pressure(),
- record.altitude(),
- record.height(),
- state.accel_speed,
- state.baro_speed,
- record.temperature(),
- record.battery_voltage(),
- record.drogue_voltage(),
- record.main_voltage());
+ state.acceleration(),
+ state.pressure(),
+ state.altitude(),
+ state.height(),
+ state.speed(),
+ state.speed(),
+ state.temperature,
+ state.battery_voltage,
+ state.apogee_voltage,
+ state.main_voltage);
}
void write_advanced_header() {
out.printf("accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z");
}
- void write_advanced(AltosRecord record) {
- AltosIMU imu = record.imu();
- AltosMag mag = record.mag();
+ void write_advanced(AltosState state) {
+ AltosIMU imu = state.imu;
+ AltosMag mag = state.mag;
if (imu == null)
imu = new AltosIMU();
@@ -161,8 +161,8 @@ public class AltosCSV implements AltosWriter {
out.printf("connected,locked,nsat,latitude,longitude,altitude,year,month,day,hour,minute,second,pad_dist,pad_range,pad_az,pad_el,hdop");
}
- void write_gps(AltosRecord record) {
- AltosGPS gps = record.gps;
+ void write_gps(AltosState state) {
+ AltosGPS gps = state.gps;
if (gps == null)
gps = new AltosGPS();
@@ -170,7 +170,7 @@ public class AltosCSV implements AltosWriter {
if (from_pad == null)
from_pad = new AltosGreatCircle();
- out.printf("%2d,%2d,%3d,%12.7f,%12.7f,%6d,%5d,%3d,%3d,%3d,%3d,%3d,%9.0f,%9.0f,%4.0f,%4.0f,%6.1f",
+ out.printf("%2d,%2d,%3d,%12.7f,%12.7f,%8.1f,%5d,%3d,%3d,%3d,%3d,%3d,%9.0f,%9.0f,%4.0f,%4.0f,%6.1f",
gps.connected?1:0,
gps.locked?1:0,
gps.nsat,
@@ -198,8 +198,8 @@ public class AltosCSV implements AltosWriter {
}
}
- void write_gps_sat(AltosRecord record) {
- AltosGPS gps = record.gps;
+ void write_gps_sat(AltosState state) {
+ AltosGPS gps = state.gps;
for(int i = 1; i <= 32; i++) {
int c_n0 = 0;
if (gps != null && gps.cc_gps_sat != null) {
@@ -221,8 +221,8 @@ public class AltosCSV implements AltosWriter {
out.printf(",companion_%02d", i);
}
- void write_companion(AltosRecord record) {
- AltosRecordCompanion companion = record.companion;
+ void write_companion(AltosState state) {
+ AltosCompanion companion = state.companion;
int channels_written = 0;
if (companion == null) {
@@ -256,50 +256,49 @@ public class AltosCSV implements AltosWriter {
out.printf ("\n");
}
- void write_one(AltosRecord record) {
- state = new AltosState(record, state);
- write_general(record); out.printf(",");
- write_flight(record); out.printf(",");
- write_basic(record); out.printf(",");
- if (record.imu() != null || record.mag() != null)
- write_advanced(record);
- if (record.gps != null) {
+ void write_one(AltosState state) {
+ write_general(state); out.printf(",");
+ write_flight(state); out.printf(",");
+ write_basic(state); out.printf(",");
+ if (state.imu != null || state.mag != null)
+ write_advanced(state);
+ if (state.gps != null) {
out.printf(",");
- write_gps(record); out.printf(",");
- write_gps_sat(record);
+ write_gps(state); out.printf(",");
+ write_gps_sat(state);
}
- if (record.companion != null) {
+ if (state.companion != null) {
out.printf(",");
- write_companion(record);
+ write_companion(state);
}
out.printf ("\n");
}
void flush_pad() {
- while (!pad_records.isEmpty()) {
- write_one (pad_records.remove());
+ while (!pad_states.isEmpty()) {
+ write_one (pad_states.remove());
}
}
- public void write(AltosRecord record) {
- if (record.state == Altos.ao_flight_startup)
+ public void write(AltosState state) {
+ if (state.state == Altos.ao_flight_startup)
return;
if (!header_written) {
- write_header(record.imu() != null || record.mag() != null,
- record.gps != null, record.companion != null);
+ write_header(state.imu != null || state.mag != null,
+ state.gps != null, state.companion != null);
header_written = true;
}
if (!seen_boost) {
- if (record.state >= Altos.ao_flight_boost) {
+ if (state.state >= Altos.ao_flight_boost) {
seen_boost = true;
- boost_tick = record.tick;
+ boost_tick = state.tick;
flush_pad();
}
}
if (seen_boost)
- write_one(record);
+ write_one(state);
else
- pad_records.add(record);
+ pad_states.add(state);
}
public PrintStream out() {
@@ -307,23 +306,23 @@ public class AltosCSV implements AltosWriter {
}
public void close() {
- if (!pad_records.isEmpty()) {
- boost_tick = pad_records.element().tick;
+ if (!pad_states.isEmpty()) {
+ boost_tick = pad_states.element().tick;
flush_pad();
}
out.close();
}
- public void write(AltosRecordIterable iterable) {
- iterable.write_comments(out());
- for (AltosRecord r : iterable)
- write(r);
+ public void write(AltosStateIterable states) {
+ states.write_comments(out());
+ for (AltosState state : states)
+ write(state);
}
public AltosCSV(PrintStream in_out, File in_name) {
name = in_name;
out = in_out;
- pad_records = new LinkedList<AltosRecord>();
+ pad_states = new LinkedList<AltosState>();
}
public AltosCSV(File in_name) throws FileNotFoundException {
diff --git a/altosui/AltosCSVUI.java b/altosui/AltosCSVUI.java
index 42508346..c41ea74b 100644
--- a/altosui/AltosCSVUI.java
+++ b/altosui/AltosCSVUI.java
@@ -21,7 +21,7 @@ import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosCSVUI
@@ -31,7 +31,7 @@ public class AltosCSVUI
JFileChooser csv_chooser;
JPanel accessory;
JComboBox combo_box;
- AltosRecordIterable iterable;
+ Iterable<AltosState> states;
AltosWriter writer;
static String[] combo_box_items = { "Comma Separated Values (.CSV)", "Googleearth Data (.KML)" };
@@ -55,8 +55,8 @@ public class AltosCSVUI
set_default_file();
}
- public AltosCSVUI(JFrame frame, AltosRecordIterable in_iterable, File source_file) {
- iterable = in_iterable;
+ public AltosCSVUI(JFrame frame, AltosStateIterable states, File source_file) {
+ this.states = states;
csv_chooser = new JFileChooser(source_file);
accessory = new JPanel();
@@ -91,7 +91,7 @@ public class AltosCSVUI
writer = new AltosCSV(file);
else
writer = new AltosKML(file);
- writer.write(iterable);
+ writer.write(states);
writer.close();
} catch (FileNotFoundException ee) {
JOptionPane.showMessageDialog(frame,
diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java
index ebe1d1f9..1f446700 100644
--- a/altosui/AltosCompanionInfo.java
+++ b/altosui/AltosCompanionInfo.java
@@ -19,7 +19,7 @@ package altosui;
import java.awt.*;
import javax.swing.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosCompanionInfo extends JTable {
private AltosFlightInfoTableModel model;
@@ -70,13 +70,13 @@ public class AltosCompanionInfo extends JTable {
model.clear();
}
- AltosRecordCompanion companion;
+ AltosCompanion companion;
public String board_name() {
if (companion == null)
return "None";
switch (companion.board_id) {
- case AltosRecordCompanion.board_id_telescience:
+ case AltosCompanion.board_id_telescience:
return "TeleScience";
default:
return String.format("%02x\n", companion.board_id);
@@ -86,8 +86,8 @@ public class AltosCompanionInfo extends JTable {
public void show(AltosState state, AltosListenerState listener_state) {
if (state == null)
return;
- if (state.data.companion != null)
- companion = state.data.companion;
+ if (state.companion != null)
+ companion = state.companion;
info_reset();
info_add_row(0, "Companion board", "%s", board_name());
if (companion != null) {
diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java
index 4927d3f8..206cbee3 100644
--- a/altosui/AltosConfig.java
+++ b/altosui/AltosConfig.java
@@ -22,7 +22,7 @@ import javax.swing.*;
import java.io.*;
import java.util.concurrent.*;
import java.text.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosConfig implements ActionListener {
@@ -161,9 +161,9 @@ public class AltosConfig implements ActionListener {
} finally {
try {
stop_serial();
+ serial_line.close();
} catch (InterruptedException ie) {
}
- serial_line.close();
}
}
diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java
index c90b168f..555af3b6 100644
--- a/altosui/AltosConfigFreqUI.java
+++ b/altosui/AltosConfigFreqUI.java
@@ -21,7 +21,7 @@ import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
class AltosEditFreqUI extends AltosUIDialog implements ActionListener {
diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java
index 3cac56c3..81d12111 100644
--- a/altosui/AltosConfigPyroUI.java
+++ b/altosui/AltosConfigPyroUI.java
@@ -21,12 +21,12 @@ import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosConfigPyroUI
extends AltosUIDialog
- implements ItemListener, DocumentListener
+ implements ItemListener, DocumentListener, AltosUnitsListener
{
AltosConfigUI owner;
Container pane;
@@ -45,13 +45,14 @@ public class AltosConfigPyroUI
}
}
- class PyroItem implements ItemListener, DocumentListener
+ class PyroItem implements ItemListener, DocumentListener, AltosUnitsListener
{
public int flag;
public JRadioButton enable;
public JTextField value;
public JComboBox combo;
AltosConfigPyroUI ui;
+ boolean setting;
public void set_enable(boolean enable) {
if (value != null)
@@ -62,36 +63,59 @@ public class AltosConfigPyroUI
public void itemStateChanged(ItemEvent e) {
set_enable(enable.isSelected());
- ui.set_dirty();
+ if (!setting)
+ ui.set_dirty();
}
public void changedUpdate(DocumentEvent e) {
- ui.set_dirty();
+ if (!setting)
+ ui.set_dirty();
}
public void insertUpdate(DocumentEvent e) {
- ui.set_dirty();
+ if (!setting)
+ ui.set_dirty();
}
public void removeUpdate(DocumentEvent e) {
- ui.set_dirty();
+ if (!setting)
+ ui.set_dirty();
+ }
+
+ public void units_changed(boolean imperial_units) {
+ AltosUnits units = AltosPyro.pyro_to_units(flag);
+
+ if (units != null) {
+ try {
+ double v = units.parse(value.getText(), !imperial_units);
+ set(enabled(), v);
+ } catch (NumberFormatException ne) {
+ set(enabled(), 0.0);
+ }
+ }
}
public void set(boolean new_enable, double new_value) {
+ setting = true;
enable.setSelected(new_enable);
set_enable(new_enable);
if (value != null) {
double scale = AltosPyro.pyro_to_scale(flag);
+ double unit_value = new_value;
+ AltosUnits units = AltosPyro.pyro_to_units(flag);
+ if (units != null)
+ unit_value = units.value(new_value);
String format = "%6.0f";
if (scale >= 10)
format = "%6.1f";
else if (scale >= 100)
format = "%6.2f";
- value.setText(String.format(format, new_value));
+ value.setText(String.format(format, unit_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);
+ setting = false;
}
public boolean enabled() {
@@ -99,8 +123,12 @@ public class AltosConfigPyroUI
}
public double value() {
- if (value != null)
+ if (value != null) {
+ AltosUnits units = AltosPyro.pyro_to_units(flag);
+ if (units != null)
+ return units.parse(value.getText());
return Double.parseDouble(value.getText());
+ }
if (combo != null)
return combo.getSelectedIndex() + AltosLib.ao_flight_boost;
return 0;
@@ -143,7 +171,7 @@ public class AltosConfigPyroUI
}
}
- class PyroColumn {
+ class PyroColumn implements AltosUnitsListener {
public PyroItem[] items;
public JLabel label;
int channel;
@@ -166,17 +194,25 @@ public class AltosConfigPyroUI
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 void units_changed(boolean imperial_units) {
+ int row = 0;
+ for (int flag = 1; flag < AltosPyro.pyro_all; flag <<= 1) {
+ if ((AltosPyro.pyro_all & flag) != 0) {
+ items[row].units_changed(imperial_units);
+ row++;
+ }
+ }
+ }
+
public PyroColumn(AltosConfigPyroUI ui, int x, int y, int in_channel) {
channel = in_channel;
@@ -209,6 +245,7 @@ public class AltosConfigPyroUI
}
PyroColumn[] columns;
+ JLabel[] labels;
public void set_pyros(AltosPyro[] pyros) {
for (int i = 0; i < pyros.length; i++) {
@@ -244,6 +281,34 @@ public class AltosConfigPyroUI
owner.set_dirty();
}
+ public void units_changed(boolean imperial_units) {
+ for (int c = 0; c < columns.length; c++)
+ columns[c].units_changed(imperial_units);
+ int r = 0;
+ for (int flag = 1; flag <= AltosPyro.pyro_all; flag <<= 1) {
+ String n = AltosPyro.pyro_to_name(flag);
+ if (n != null) {
+ labels[r].setText(n);
+ r++;
+ }
+ }
+ }
+
+ /* A window listener to catch closing events and tell the config code */
+ class ConfigListener extends WindowAdapter {
+ AltosConfigPyroUI ui;
+ AltosConfigUI owner;
+
+ public ConfigListener(AltosConfigPyroUI this_ui, AltosConfigUI this_owner) {
+ ui = this_ui;
+ owner = this_owner;
+ }
+
+ public void windowClosing(WindowEvent e) {
+ ui.setVisible(false);
+ }
+ }
+
public AltosConfigPyroUI(AltosConfigUI in_owner, AltosPyro[] pyros) {
super(in_owner, "Configure Pyro Channels", false);
@@ -255,6 +320,13 @@ public class AltosConfigPyroUI
pane = getContentPane();
pane.setLayout(new GridBagLayout());
+ int nrow = 0;
+ for (int flag = 1; flag < AltosPyro.pyro_all; flag <<= 1)
+ if ((flag & AltosPyro.pyro_all) != 0)
+ nrow++;
+
+ labels = new JLabel[nrow];
+
int row = 1;
for (int flag = 1; flag <= AltosPyro.pyro_all; flag <<= 1) {
@@ -270,6 +342,7 @@ public class AltosConfigPyroUI
c.insets = il;
JLabel label = new JLabel(n);
pane.add(label, c);
+ labels[row-1] = label;
row++;
}
}
@@ -280,6 +353,13 @@ public class AltosConfigPyroUI
columns[i] = new PyroColumn(this, i*2 + 1, 0, i);
columns[i].set(pyros[i]);
}
+ addWindowListener(new ConfigListener(this, owner));
+ AltosPreferences.register_units_listener(this);
+ }
+
+ public void dispose() {
+ AltosPreferences.unregister_units_listener(this);
+ super.dispose();
}
public void make_visible() {
diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java
index 16c9e357..f879ff88 100644
--- a/altosui/AltosConfigTD.java
+++ b/altosui/AltosConfigTD.java
@@ -21,7 +21,7 @@ import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosConfigTD implements ActionListener {
diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java
index 125780a9..b5a6cd7c 100644
--- a/altosui/AltosConfigTDUI.java
+++ b/altosui/AltosConfigTDUI.java
@@ -21,7 +21,7 @@ import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosConfigTDUI
diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java
index 11f40593..a7d95903 100644
--- a/altosui/AltosConfigUI.java
+++ b/altosui/AltosConfigUI.java
@@ -21,12 +21,12 @@ import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosConfigUI
extends AltosUIDialog
- implements ActionListener, ItemListener, DocumentListener, AltosConfigValues
+ implements ActionListener, ItemListener, DocumentListener, AltosConfigValues, AltosUnitsListener
{
Container pane;
@@ -75,11 +75,16 @@ public class AltosConfigUI
ActionListener listener;
- static String[] main_deploy_values = {
+ static String[] main_deploy_values_m = {
"100", "150", "200", "250", "300", "350",
"400", "450", "500"
};
+ static String[] main_deploy_values_ft = {
+ "250", "500", "750", "1000", "1250", "1500",
+ "1750", "2000"
+ };
+
static String[] apogee_delay_values = {
"0", "1", "2", "3", "4", "5"
};
@@ -180,7 +185,7 @@ public class AltosConfigUI
void set_pad_orientation_tool_tip() {
if (pad_orientation_value.isEnabled())
- pad_orientation_value.setToolTipText("How will TeleMetrum be mounted in the airframe");
+ pad_orientation_value.setToolTipText("How will the computer be mounted in the airframe");
else {
if (is_telemetrum())
pad_orientation_value.setToolTipText("Older TeleMetrum firmware must fly antenna forward");
@@ -193,7 +198,7 @@ public class AltosConfigUI
/* Build the UI using a grid bag */
public AltosConfigUI(JFrame in_owner, boolean remote) {
- super (in_owner, "Configure TeleMetrum", false);
+ super (in_owner, "Configure Flight Computer", false);
owner = in_owner;
GridBagConstraints c;
@@ -280,7 +285,7 @@ public class AltosConfigUI
c.anchor = GridBagConstraints.LINE_START;
c.insets = il;
c.ipady = 5;
- main_deploy_label = new JLabel("Main Deploy Altitude(m):");
+ main_deploy_label = new JLabel(get_main_deploy_label());
pane.add(main_deploy_label, c);
c = new GridBagConstraints();
@@ -291,7 +296,7 @@ public class AltosConfigUI
c.anchor = GridBagConstraints.LINE_START;
c.insets = ir;
c.ipady = 5;
- main_deploy_value = new JComboBox(main_deploy_values);
+ main_deploy_value = new JComboBox(main_deploy_values());
main_deploy_value.setEditable(true);
main_deploy_value.addItemListener(this);
pane.add(main_deploy_value, c);
@@ -616,6 +621,7 @@ public class AltosConfigUI
close.setActionCommand("Close");
addWindowListener(new ConfigListener(this));
+ AltosPreferences.register_units_listener(this);
}
/* Once the initial values are set, the config code will show the dialog */
@@ -654,15 +660,22 @@ public class AltosConfigUI
AltosConfigPyroUI pyro_ui;
+ public void dispose() {
+ if (pyro_ui != null)
+ pyro_ui.dispose();
+ AltosPreferences.unregister_units_listener(this);
+ super.dispose();
+ }
+
/* 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) {
+ if (pyro_ui == null && pyros != null)
pyro_ui = new AltosConfigPyroUI(this, pyros);
+ if (pyro_ui != null)
pyro_ui.make_visible();
- }
return;
}
@@ -718,12 +731,40 @@ public class AltosConfigUI
}
public void set_main_deploy(int new_main_deploy) {
- main_deploy_value.setSelectedItem(Integer.toString(new_main_deploy));
+ main_deploy_value.setSelectedItem(AltosConvert.height.say(new_main_deploy));
main_deploy_value.setEnabled(new_main_deploy >= 0);
}
public int main_deploy() {
- return Integer.parseInt(main_deploy_value.getSelectedItem().toString());
+ return (int) (AltosConvert.height.parse(main_deploy_value.getSelectedItem().toString()) + 0.5);
+ }
+
+ String get_main_deploy_label() {
+ return String.format("Main Deploy Altitude(%s):", AltosConvert.height.show_units());
+ }
+
+ String[] main_deploy_values() {
+ if (AltosConvert.imperial_units)
+ return main_deploy_values_ft;
+ else
+ return main_deploy_values_m;
+ }
+
+ void set_main_deploy_values() {
+ String[] v = main_deploy_values();
+ while (main_deploy_value.getItemCount() > 0)
+ main_deploy_value.removeItemAt(0);
+ for (int i = 0; i < v.length; i++)
+ main_deploy_value.addItem(v[i]);
+ main_deploy_value.setMaximumRowCount(v.length);
+ }
+
+ public void units_changed(boolean imperial_units) {
+ String v = main_deploy_value.getSelectedItem().toString();
+ main_deploy_label.setText(get_main_deploy_label());
+ set_main_deploy_values();
+ int m = (int) (AltosConvert.height.parse(v, !imperial_units) + 0.5);
+ set_main_deploy(m);
}
public void set_apogee_delay(int new_apogee_delay) {
@@ -745,28 +786,7 @@ public class AltosConfigUI
}
public void set_radio_frequency(double new_radio_frequency) {
- int i;
- for (i = 0; i < radio_frequency_value.getItemCount(); i++) {
- AltosFrequency f = (AltosFrequency) radio_frequency_value.getItemAt(i);
-
- if (f.close(new_radio_frequency)) {
- radio_frequency_value.setSelectedIndex(i);
- return;
- }
- }
- for (i = 0; i < radio_frequency_value.getItemCount(); i++) {
- AltosFrequency f = (AltosFrequency) radio_frequency_value.getItemAt(i);
-
- if (new_radio_frequency < f.frequency)
- break;
- }
- String description = String.format("%s serial %s",
- product_value.getText(),
- serial_value.getText());
- AltosFrequency new_frequency = new AltosFrequency(new_radio_frequency, description);
- AltosUIPreferences.add_common_frequency(new_frequency);
- radio_frequency_value.insertItemAt(new_frequency, i);
- radio_frequency_value.setSelectedIndex(i);
+ radio_frequency_value.set_frequency(new_radio_frequency);
}
public double radio_frequency() {
@@ -774,7 +794,11 @@ public class AltosConfigUI
}
public void set_radio_calibration(int new_radio_calibration) {
- radio_calibration_value.setText(String.format("%d", new_radio_calibration));
+ radio_calibration_value.setVisible(new_radio_calibration >= 0);
+ if (new_radio_calibration < 0)
+ radio_calibration_value.setText("Disabled");
+ else
+ radio_calibration_value.setText(String.format("%d", new_radio_calibration));
}
public int radio_calibration() {
@@ -787,6 +811,7 @@ public class AltosConfigUI
radio_enable_value.setEnabled(true);
} else {
radio_enable_value.setSelected(true);
+ radio_enable_value.setVisible(radio_frequency() > 0);
radio_enable_value.setEnabled(false);
}
set_radio_enable_tool_tip();
@@ -800,6 +825,7 @@ public class AltosConfigUI
}
public void set_callsign(String new_callsign) {
+ callsign_value.setVisible(new_callsign != null);
callsign_value.setText(new_callsign);
}
@@ -859,10 +885,10 @@ public class AltosConfigUI
if (new_pad_orientation >= pad_orientation_values.length)
new_pad_orientation = 0;
if (new_pad_orientation < 0) {
- pad_orientation_value.setEnabled(false);
+ pad_orientation_value.setVisible(false);
new_pad_orientation = 0;
} else {
- pad_orientation_value.setEnabled(true);
+ pad_orientation_value.setVisible(true);
}
pad_orientation_value.setSelectedIndex(new_pad_orientation);
set_pad_orientation_tool_tip();
@@ -877,7 +903,7 @@ public class AltosConfigUI
public void set_pyros(AltosPyro[] new_pyros) {
pyros = new_pyros;
- pyro.setEnabled(pyros != null);
+ pyro.setVisible(pyros != null);
if (pyros != null && pyro_ui != null)
pyro_ui.set_pyros(pyros);
}
@@ -896,7 +922,7 @@ public class AltosConfigUI
else
s = Integer.toString(new_aprs_interval);
aprs_interval_value.setSelectedItem(s);
- aprs_interval_value.setEnabled(new_aprs_interval >= 0);
+ aprs_interval_value.setVisible(new_aprs_interval >= 0);
set_aprs_interval_tool_tip();
}
diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java
index f914f138..c0d66682 100644
--- a/altosui/AltosDataChooser.java
+++ b/altosui/AltosDataChooser.java
@@ -20,7 +20,7 @@ package altosui;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.io.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosDataChooser extends JFileChooser {
@@ -36,7 +36,7 @@ public class AltosDataChooser extends JFileChooser {
return file;
}
- public AltosRecordIterable runDialog() {
+ public AltosStateIterable runDialog() {
int ret;
ret = showOpenDialog(frame);
@@ -48,13 +48,10 @@ public class AltosDataChooser extends JFileChooser {
try {
if (filename.endsWith("eeprom")) {
FileInputStream in = new FileInputStream(file);
- return new AltosEepromIterable(in);
+ return new AltosEepromFile(in);
} else if (filename.endsWith("telem")) {
FileInputStream in = new FileInputStream(file);
- return new AltosTelemetryIterable(in);
- } else if (filename.endsWith("mega")) {
- FileInputStream in = new FileInputStream(file);
- return new AltosEepromMegaIterable(in);
+ return new AltosTelemetryFile(in);
} else {
throw new FileNotFoundException();
}
@@ -77,8 +74,10 @@ public class AltosDataChooser extends JFileChooser {
"telem"));
setFileFilter(new FileNameExtensionFilter("TeleMega eeprom file",
"mega"));
+ setFileFilter(new FileNameExtensionFilter("EasyMini eeprom file",
+ "mini"));
setFileFilter(new FileNameExtensionFilter("Flight data file",
- "telem", "eeprom", "mega"));
+ "telem", "eeprom", "mega", "mini"));
setCurrentDirectory(AltosUIPreferences.logdir());
}
}
diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java
index 29d33ddc..e73d990c 100644
--- a/altosui/AltosDescent.java
+++ b/altosui/AltosDescent.java
@@ -19,7 +19,7 @@ package altosui;
import java.awt.*;
import javax.swing.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosDescent extends JComponent implements AltosFlightDisplay {
GridBagLayout layout;
@@ -245,7 +245,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
class Height extends DescentValue {
void show (AltosState state, AltosListenerState listener_state) {
- show(AltosConvert.height, state.height);
+ show(AltosConvert.height, state.height());
}
public Height (GridBagLayout layout, int x, int y) {
super (layout, x, y, "Height");
@@ -256,10 +256,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
class Speed extends DescentValue {
void show (AltosState state, AltosListenerState listener_state) {
- double speed = state.accel_speed;
- if (!state.ascent)
- speed = state.baro_speed;
- show(AltosConvert.speed, speed);
+ show(AltosConvert.speed, state.speed());
}
public Speed (GridBagLayout layout, int x, int y) {
super (layout, x, y, "Speed");
@@ -281,7 +278,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
class Lat extends DescentValue {
void show (AltosState state, AltosListenerState listener_state) {
- if (state.gps != null && state.gps.connected)
+ if (state.gps != null && state.gps.connected && state.gps.lat != AltosLib.MISSING)
show(pos(state.gps.lat,"N", "S"));
else
show("???");
@@ -295,7 +292,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
class Lon extends DescentValue {
void show (AltosState state, AltosListenerState listener_state) {
- if (state.gps != null && state.gps.connected)
+ if (state.gps != null && state.gps.connected && state.gps.lon != AltosLib.MISSING)
show(pos(state.gps.lon,"W", "E"));
else
show("???");
@@ -325,8 +322,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
class Apogee extends DescentStatus {
void show (AltosState state, AltosListenerState listener_state) {
- show("%4.2f V", state.drogue_sense);
- lights.set(state.drogue_sense > 3.2);
+ show("%4.2f V", state.apogee_voltage);
+ lights.set(state.apogee_voltage >= AltosLib.ao_igniter_good);
}
public Apogee (GridBagLayout layout, int y) {
super(layout, y, "Apogee Igniter Voltage");
@@ -337,8 +334,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
class Main extends DescentStatus {
void show (AltosState state, AltosListenerState listener_state) {
- show("%4.2f V", state.main_sense);
- lights.set(state.main_sense > 3.2);
+ show("%4.2f V", state.main_voltage);
+ lights.set(state.main_voltage >= AltosLib.ao_igniter_good);
}
public Main (GridBagLayout layout, int y) {
super(layout, y, "Main Igniter Voltage");
@@ -430,11 +427,11 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
lat.hide();
lon.hide();
}
- if (state.main_sense != AltosRecord.MISSING)
+ if (state.main_voltage != AltosLib.MISSING)
main.show(state, listener_state);
else
main.hide();
- if (state.drogue_sense != AltosRecord.MISSING)
+ if (state.apogee_voltage != AltosLib.MISSING)
apogee.show(state, listener_state);
else
apogee.hide();
diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java
index 095bed99..4b4cc3b9 100644
--- a/altosui/AltosDisplayThread.java
+++ b/altosui/AltosDisplayThread.java
@@ -21,7 +21,7 @@ import java.awt.*;
import javax.swing.*;
import java.io.*;
import java.text.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosDisplayThread extends Thread {
@@ -89,17 +89,18 @@ public class AltosDisplayThread extends Thread {
/* If the rocket isn't on the pad, then report height */
if (Altos.ao_flight_drogue <= state.state &&
state.state < Altos.ao_flight_landed &&
+ state.from_pad != null &&
state.range >= 0)
{
voice.speak("Height %s, bearing %s %d, elevation %d, range %s.\n",
- AltosConvert.height.say(state.height),
+ AltosConvert.height.say(state.height()),
state.from_pad.bearing_words(
AltosGreatCircle.BEARING_VOICE),
(int) (state.from_pad.bearing + 0.5),
(int) (state.elevation + 0.5),
AltosConvert.distance.say(state.range));
} else if (state.state > Altos.ao_flight_pad) {
- voice.speak(AltosConvert.height.say_units(state.height));
+ voice.speak(AltosConvert.height.say_units(state.height()));
} else {
reported_landing = 0;
}
@@ -110,10 +111,10 @@ public class AltosDisplayThread extends Thread {
*/
if (state.state >= Altos.ao_flight_drogue &&
(last ||
- System.currentTimeMillis() - state.report_time >= 15000 ||
+ System.currentTimeMillis() - state.received_time >= 15000 ||
state.state == Altos.ao_flight_landed))
{
- if (Math.abs(state.baro_speed) < 20 && state.height < 100)
+ if (Math.abs(state.speed()) < 20 && state.height() < 100)
voice.speak("rocket landed safely");
else
voice.speak("rocket may have crashed");
@@ -181,16 +182,16 @@ public class AltosDisplayThread extends Thread {
synchronized boolean tell() {
boolean ret = false;
if (old_state == null || old_state.state != state.state) {
- voice.speak(state.data.state());
+ voice.speak(state.state_name());
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_accel_speed + 0.5));
+ AltosConvert.speed.say_units(state.max_speed() + 0.5));
ret = true;
} else if ((old_state == null || old_state.state < Altos.ao_flight_drogue) &&
state.state >= Altos.ao_flight_drogue) {
voice.speak("max height: %s.",
- AltosConvert.height.say_units(state.max_height + 0.5));
+ AltosConvert.height.say_units(state.max_height() + 0.5));
ret = true;
}
}
@@ -218,11 +219,9 @@ public class AltosDisplayThread extends Thread {
try {
for (;;) {
try {
- AltosRecord record = reader.read();
- if (record == null)
+ state = reader.read();
+ if (state == null)
break;
- old_state = state;
- state = new AltosState(record, state);
reader.update(state);
show_safely();
told = tell();
diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java
index e81a35d1..9984d1a2 100644
--- a/altosui/AltosEepromDelete.java
+++ b/altosui/AltosEepromDelete.java
@@ -21,7 +21,7 @@ import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosEepromDelete implements Runnable {
AltosEepromList flights;
diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java
deleted file mode 100644
index a0523b58..00000000
--- a/altosui/AltosEepromDownload.java
+++ /dev/null
@@ -1,490 +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.event.*;
-import javax.swing.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
-
-public class AltosEepromDownload implements Runnable {
-
- JFrame frame;
- AltosSerial serial_line;
- boolean remote;
- Thread eeprom_thread;
- AltosEepromMonitor monitor;
-
- int flight;
- int serial;
- int year, month, day;
- boolean want_file;
- FileWriter eeprom_file;
- LinkedList<String> eeprom_pending;
-
- AltosEepromList flights;
- ActionListener listener;
- boolean success;
- ParseException parse_exception;
- String extension;
-
- private void FlushPending() throws IOException {
- for (String s : flights.config_data) {
- eeprom_file.write(s);
- eeprom_file.write('\n');
- }
-
- for (String s : eeprom_pending)
- eeprom_file.write(s);
- }
-
- private void CheckFile(boolean force) throws IOException {
- if (eeprom_file != null)
- return;
- if (force || (flight != 0 && want_file)) {
- AltosFile eeprom_name;
-
- if (extension == null)
- extension = "data";
- if (year != 0 && month != 0 && day != 0)
- eeprom_name = new AltosFile(year, month, day, serial, flight, extension);
- else
- eeprom_name = new AltosFile(serial, flight, extension);
-
- eeprom_file = new FileWriter(eeprom_name);
- if (eeprom_file != null) {
- monitor.set_file(eeprom_name.getName());
- FlushPending();
- eeprom_pending = null;
- }
- }
- }
-
- void Log(AltosEepromRecord r) throws IOException {
- if (r.cmd != Altos.AO_LOG_INVALID) {
- String log_line = String.format("%c %4x %4x %4x\n",
- r.cmd, r.tick, r.a, r.b);
- if (eeprom_file != null)
- eeprom_file.write(log_line);
- else
- eeprom_pending.add(log_line);
- }
- }
-
- void set_serial(int in_serial) {
- serial = in_serial;
- monitor.set_serial(serial);
- }
-
- void set_flight(int in_flight) {
- flight = in_flight;
- monitor.set_flight(flight);
- }
-
- boolean done;
- int state;
-
- void CaptureFull(AltosEepromChunk eechunk) throws IOException {
- boolean any_valid = false;
-
- extension = "eeprom";
- set_serial(flights.config_data.serial);
- 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)
- set_flight(r.b);
-
- /* Monitor state transitions to update display */
- if (r.cmd == Altos.AO_LOG_STATE && r.a <= Altos.ao_flight_landed) {
- state = r.a;
- if (state > Altos.ao_flight_pad)
- want_file = true;
- }
-
- if (r.cmd == Altos.AO_LOG_GPS_DATE) {
- year = 2000 + (r.a & 0xff);
- month = (r.a >> 8) & 0xff;
- day = (r.b & 0xff);
- want_file = true;
- }
- if (r.cmd == Altos.AO_LOG_STATE && r.a == Altos.ao_flight_landed)
- done = true;
- if (r.cmd != AltosLib.AO_LOG_INVALID)
- any_valid = true;
- Log(r);
- } catch (ParseException pe) {
- if (parse_exception == null)
- parse_exception = pe;
- }
- }
-
- if (!any_valid)
- done = true;
-
- CheckFile(false);
- }
-
- boolean start;
- int tiny_tick;
-
- void CaptureTiny (AltosEepromChunk eechunk) throws IOException {
- boolean any_valid = false;
-
- extension = "eeprom";
- set_serial(flights.config_data.serial);
- for (int i = 0; i < eechunk.data.length && !done; i += 2) {
- int v = eechunk.data16(i);
- AltosEepromRecord r;
-
- if (i == 0 && start) {
- tiny_tick = 0;
- start = false;
- set_flight(v);
- r = new AltosEepromRecord(Altos.AO_LOG_FLIGHT, tiny_tick, 0, v);
- any_valid = true;
- } else {
- int s = v ^ 0x8000;
-
- if (Altos.ao_flight_startup <= s && s <= Altos.ao_flight_invalid) {
- state = s;
- r = new AltosEepromRecord(Altos.AO_LOG_STATE, tiny_tick, state, 0);
- if (state == Altos.ao_flight_landed)
- done = true;
- state = s;
- any_valid = true;
- } else {
- if (v != 0xffff)
- any_valid = true;
-
- r = new AltosEepromRecord(Altos.AO_LOG_PRESSURE, tiny_tick, 0, v);
-
- /*
- * The flight software records ascent data every 100ms, and descent
- * data every 1s.
- */
- if (state < Altos.ao_flight_drogue)
- tiny_tick += 10;
- else
- tiny_tick += 100;
- }
- }
- Log(r);
- }
- CheckFile(false);
- if (!any_valid)
- done = true;
- }
-
- void LogTeleScience(AltosEepromTeleScience r) throws IOException {
- if (r.type != Altos.AO_LOG_INVALID) {
- String log_line = String.format("%c %4x %4x %d %5d %5d %5d %5d %5d %5d %5d %5d %5d %5d %5d %5d\n",
- r.type, r.tick, r.tm_tick, r.tm_state,
- r.data[0], r.data[1], r.data[2], r.data[3],
- r.data[4], r.data[5], r.data[6], r.data[7],
- r.data[8], r.data[9], r.data[10], r.data[11]);
- if (eeprom_file != null)
- eeprom_file.write(log_line);
- else
- eeprom_pending.add(log_line);
- }
- }
-
- boolean telescience_start;
-
- void CaptureTeleScience (AltosEepromChunk eechunk) throws IOException {
- boolean any_valid = false;
-
- extension = "science";
- 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) {
- if (telescience_start) {
- done = true;
- break;
- }
- set_serial(r.data[0]);
- set_flight(r.data[1]);
- telescience_start = true;
- } else {
- if (!telescience_start)
- break;
- }
- state = r.tm_state;
- want_file =true;
- any_valid = true;
- LogTeleScience(r);
- } catch (ParseException pe) {
- if (parse_exception == null)
- parse_exception = pe;
- }
- }
-
- CheckFile(false);
- if (!any_valid)
- done = true;
- }
-
- void LogMega(AltosEepromMega r) throws IOException {
- if (r.cmd != Altos.AO_LOG_INVALID) {
- String log_line = String.format("%c %4x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x\n",
- r.cmd, r.tick,
- r.data8[0], r.data8[1], r.data8[2], r.data8[3],
- r.data8[4], r.data8[5], r.data8[6], r.data8[7],
- r.data8[8], r.data8[9], r.data8[10], r.data8[11],
- r.data8[12], r.data8[13], r.data8[14], r.data8[15],
- r.data8[16], r.data8[17], r.data8[18], r.data8[19],
- r.data8[20], r.data8[21], r.data8[22], r.data8[23],
- r.data8[24], r.data8[25], r.data8[26], r.data8[27]);
- if (eeprom_file != null)
- eeprom_file.write(log_line);
- else
- eeprom_pending.add(log_line);
- }
- }
-
- void CaptureMega(AltosEepromChunk eechunk) throws IOException {
- boolean any_valid = false;
-
- extension = "mega";
- set_serial(flights.config_data.serial);
- 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)
- set_flight(r.data16(0));
-
- /* Monitor state transitions to update display */
- if (r.cmd == Altos.AO_LOG_STATE && r.data16(0) <= Altos.ao_flight_landed) {
- state = r.data16(0);
- if (state > Altos.ao_flight_pad)
- want_file = true;
- }
-
- if (r.cmd == Altos.AO_LOG_GPS_TIME) {
- year = 2000 + r.data8(14);
- month = r.data8(15);
- day = r.data8(16);
- want_file = true;
- }
-
- if (r.cmd == Altos.AO_LOG_STATE && r.data16(0) == Altos.ao_flight_landed)
- done = true;
- any_valid = true;
- LogMega(r);
- } catch (ParseException pe) {
- if (parse_exception == null)
- parse_exception = pe;
- }
- }
- if (!any_valid)
- done = true;
-
- CheckFile(false);
- }
-
- void CaptureTelemetry(AltosEepromChunk eechunk) throws IOException {
-
- }
-
- void CaptureLog(AltosEepromLog log) throws IOException, InterruptedException, TimeoutException {
- int block, state_block = 0;
- int log_format = flights.config_data.log_format;
-
- state = 0;
- done = false;
- start = true;
-
- if (flights.config_data.serial < 0)
- throw new IOException("no serial number found");
-
- /* Reset per-capture variables */
- flight = 0;
- year = 0;
- month = 0;
- day = 0;
- want_file = false;
- eeprom_file = null;
- eeprom_pending = new LinkedList<String>();
-
- /* Set serial number in the monitor dialog window */
- /* Now scan the eeprom, reading blocks of data and converting to .eeprom file form */
-
- 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, block - log.start_block);
-
- AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block, block == log.start_block);
-
- /*
- * Guess what kind of data is there if the device
- * didn't tell us
- */
-
- if (log_format == Altos.AO_LOG_FORMAT_UNKNOWN) {
- if (block == log.start_block) {
- if (eechunk.data(0) == Altos.AO_LOG_FLIGHT)
- log_format = Altos.AO_LOG_FORMAT_FULL;
- else
- log_format = Altos.AO_LOG_FORMAT_TINY;
- }
- }
-
- switch (log_format) {
- case AltosLib.AO_LOG_FORMAT_FULL:
- extension = "eeprom";
- CaptureFull(eechunk);
- break;
- case AltosLib.AO_LOG_FORMAT_TINY:
- extension = "eeprom";
- CaptureTiny(eechunk);
- break;
- case AltosLib.AO_LOG_FORMAT_TELEMETRY:
- extension = "telem";
- CaptureTelemetry(eechunk);
- break;
- case AltosLib.AO_LOG_FORMAT_TELESCIENCE:
- extension = "science";
- CaptureTeleScience(eechunk);
- break;
- case AltosLib.AO_LOG_FORMAT_TELEMEGA:
- extension = "mega";
- CaptureMega(eechunk);
- }
- }
- CheckFile(true);
- if (eeprom_file != null) {
- eeprom_file.flush();
- eeprom_file.close();
- }
- }
-
- private void show_message_internal(String message, String title, int message_type) {
- JOptionPane.showMessageDialog(frame,
- message,
- title,
- message_type);
- }
-
- private void show_message(String in_message, String in_title, int in_message_type) {
- final String message = in_message;
- final String title = in_title;
- final int message_type = in_message_type;
- Runnable r = new Runnable() {
- public void run() {
- try {
- show_message_internal(message, title, message_type);
- } catch (Exception ex) {
- }
- }
- };
- SwingUtilities.invokeLater(r);
- }
-
- public void run () {
- try {
- boolean failed = false;
- if (remote)
- serial_line.start_remote();
-
- for (AltosEepromLog log : flights) {
- parse_exception = null;
- if (log.selected) {
- monitor.reset();
- CaptureLog(log);
- }
- if (parse_exception != null) {
- failed = true;
- show_message(String.format("Flight %d download error\n%s\nValid log data saved",
- log.flight,
- parse_exception.getMessage()),
- serial_line.device.toShortString(),
- JOptionPane.WARNING_MESSAGE);
- }
- }
- success = !failed;
- } catch (IOException ee) {
- show_message(ee.getLocalizedMessage(),
- serial_line.device.toShortString(),
- JOptionPane.ERROR_MESSAGE);
- } catch (InterruptedException ie) {
- System.out.printf("download interrupted\n");
- } catch (TimeoutException te) {
- show_message(String.format("Connection to \"%s\" failed",
- serial_line.device.toShortString()),
- "Connection Failed",
- JOptionPane.ERROR_MESSAGE);
- } finally {
- if (remote) {
- try {
- serial_line.stop_remote();
- } catch (InterruptedException ie) {
- }
- }
- serial_line.flush_output();
- }
- monitor.done();
- if (listener != null) {
- Runnable r = new Runnable() {
- public void run() {
- try {
- listener.actionPerformed(new ActionEvent(this,
- success ? 1 : 0,
- "download"));
- } catch (Exception ex) {
- }
- }
- };
- SwingUtilities.invokeLater(r);
- }
- }
-
- public void start() {
- eeprom_thread = new Thread(this);
- eeprom_thread.start();
- }
-
- public void addActionListener(ActionListener l) {
- listener = l;
- }
-
- public AltosEepromDownload(JFrame given_frame,
- AltosSerial given_serial_line,
- boolean given_remote,
- AltosEepromList given_flights) {
-
- frame = given_frame;
- serial_line = given_serial_line;
- serial_line.set_frame(frame);
- remote = given_remote;
- flights = given_flights;
- success = false;
-
- monitor = new AltosEepromMonitor(frame, Altos.ao_flight_boost, Altos.ao_flight_landed);
- monitor.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (eeprom_thread != null)
- eeprom_thread.interrupt();
- }
- });
- }
-}
diff --git a/altosui/AltosEepromList.java b/altosui/AltosEepromList.java
deleted file mode 100644
index a63d173d..00000000
--- a/altosui/AltosEepromList.java
+++ /dev/null
@@ -1,118 +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.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
-
-/*
- * Temporary structure to hold the list of stored flights;
- * each of these will be queried in turn to generate more
- * complete information
- */
-
-class AltosEepromFlight {
- int flight;
- int start;
- int end;
-
- public AltosEepromFlight(int in_flight, int in_start, int in_end) {
- flight = in_flight;
- start = in_start;
- end = in_end;
- }
-}
-
-/*
- * Construct a list of flights available in a connected device
- */
-
-public class AltosEepromList extends ArrayList<AltosEepromLog> {
- AltosConfigData config_data;
-
- public AltosEepromList (AltosSerial serial_line, boolean remote)
- throws IOException, InterruptedException, TimeoutException
- {
- try {
- if (remote)
- serial_line.start_remote();
- config_data = new AltosConfigData (serial_line);
-// if (config_data.serial == 0)
-// throw new IOException("no serial number found");
-
- ArrayList<AltosEepromFlight> flights = new ArrayList<AltosEepromFlight>();
-
- if (config_data.flight_log_max != 0 || config_data.log_format != 0) {
-
- /* Devices with newer firmware will support the 'l'
- * command which will list the region of storage
- * occupied by each available flight
- */
- serial_line.printf("l\n");
- for (;;) {
- String line = serial_line.get_reply(5000);
- if (line == null)
- throw new TimeoutException();
- if (line.contains("done"))
- break;
- if (line.contains("Syntax"))
- continue;
- String[] tokens = line.split("\\s+");
- if (tokens.length < 6)
- break;
-
- int flight = -1, start = -1, end = -1;
- try {
- if (tokens[0].equals("flight"))
- flight = AltosParse.parse_int(tokens[1]);
- if (tokens[2].equals("start"))
- start = AltosParse.parse_hex(tokens[3]);
- if (tokens[4].equals("end"))
- end = AltosParse.parse_hex(tokens[5]);
- if (flight > 0 && start >= 0 && end > 0)
- flights.add(new AltosEepromFlight(flight, start, end));
- } catch (ParseException pe) { System.out.printf("Parse error %s\n", pe.toString()); }
- }
- } else {
-
- /* Older devices will hold only a single
- * flight. This also assumes that any older
- * device will have a 1MB flash device
- */
- flights.add(new AltosEepromFlight(0, 0, 0xfff));
- }
-
- /* With the list of flights collected, collect more complete
- * information on them by reading the first block or two of
- * data. This will add GPS coordinates and a date. For older
- * firmware, this will also extract the flight number.
- */
- for (AltosEepromFlight flight : flights) {
- add(new AltosEepromLog(config_data, serial_line,
- flight.flight, flight.start, flight.end));
- }
- } finally {
- if (remote)
- serial_line.stop_remote();
- serial_line.flush_output();
- }
- }
-} \ No newline at end of file
diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java
index 7a721196..da0a9777 100644
--- a/altosui/AltosEepromManage.java
+++ b/altosui/AltosEepromManage.java
@@ -21,7 +21,7 @@ import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosEepromManage implements ActionListener {
@@ -133,11 +133,13 @@ public class AltosEepromManage implements ActionListener {
for (AltosEepromLog flight : flights)
any_selected = any_selected || flight.selected;
if (any_selected) {
- download = new AltosEepromDownload(frame,
+ AltosEepromMonitorUI monitor = new AltosEepromMonitorUI(frame);
+ monitor.addActionListener(this);
+ serial_line.set_frame(frame);
+ download = new AltosEepromDownload(monitor,
serial_line,
remote,
flights);
- download.addActionListener(this);
/*
* Start flight log download
*/
diff --git a/altosui/AltosEepromMonitorUI.java b/altosui/AltosEepromMonitorUI.java
new file mode 100644
index 00000000..6ad4ca5c
--- /dev/null
+++ b/altosui/AltosEepromMonitorUI.java
@@ -0,0 +1,311 @@
+/*
+ * 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 org.altusmetrum.altosuilib_1.*;
+import org.altusmetrum.altoslib_2.*;
+
+public class AltosEepromMonitorUI extends AltosUIDialog implements AltosEepromMonitor {
+ JFrame owner;
+ Container pane;
+ Box box;
+ JLabel serial_label;
+ JLabel flight_label;
+ JLabel file_label;
+ JLabel serial_value;
+ JLabel flight_value;
+ JLabel file_value;
+ JButton cancel;
+ JProgressBar pbar;
+ int min_state, max_state;
+ ActionListener listener;
+
+ public AltosEepromMonitorUI(JFrame owner) {
+ super (owner, "Download Flight Data", false);
+
+ this.owner = owner;
+
+ GridBagConstraints c;
+ Insets il = new Insets(4,4,4,4);
+ Insets ir = new Insets(4,4,4,4);
+
+ pane = getContentPane();
+ pane.setLayout(new GridBagLayout());
+
+ c = new GridBagConstraints();
+ c.gridx = 0; c.gridy = 0;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ serial_label = new JLabel("Serial:");
+ pane.add(serial_label, c);
+
+ c = new GridBagConstraints();
+ c.gridx = 1; c.gridy = 0;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = ir;
+ serial_value = new JLabel("");
+ pane.add(serial_value, c);
+
+ c = new GridBagConstraints();
+ c.fill = GridBagConstraints.NONE;
+ c.gridx = 0; c.gridy = 1;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ flight_label = new JLabel("Flight:");
+ pane.add(flight_label, c);
+
+ c = new GridBagConstraints();
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+ c.gridx = 1; c.gridy = 1;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = ir;
+ flight_value = new JLabel("");
+ pane.add(flight_value, c);
+
+ c = new GridBagConstraints();
+ c.fill = GridBagConstraints.NONE;
+ c.gridx = 0; c.gridy = 2;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ file_label = new JLabel("File:");
+ pane.add(file_label, c);
+
+ c = new GridBagConstraints();
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+ c.gridx = 1; c.gridy = 2;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = ir;
+ file_value = new JLabel("");
+ pane.add(file_value, c);
+
+ pbar = new JProgressBar();
+ pbar.setMinimum(0);
+ pbar.setMaximum(1000);
+ pbar.setValue(0);
+ pbar.setString("startup");
+ pbar.setStringPainted(true);
+ pbar.setPreferredSize(new Dimension(600, 20));
+ c = new GridBagConstraints();
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.anchor = GridBagConstraints.CENTER;
+ c.gridx = 0; c.gridy = 3;
+ c.gridwidth = GridBagConstraints.REMAINDER;
+ Insets ib = new Insets(4,4,4,4);
+ c.insets = ib;
+ pane.add(pbar, c);
+
+
+ cancel = new JButton("Cancel");
+ c = new GridBagConstraints();
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.CENTER;
+ c.gridx = 0; c.gridy = 4;
+ c.gridwidth = GridBagConstraints.REMAINDER;
+ Insets ic = new Insets(4,4,4,4);
+ c.insets = ic;
+ pane.add(cancel, c);
+
+ pack();
+ setLocationRelativeTo(owner);
+ }
+
+ public void addActionListener(ActionListener l) {
+ listener = l;
+ }
+
+ public void set_states(int min_state, int max_state) {
+ this.min_state = min_state;
+ this.max_state = max_state;
+ }
+
+ public void set_thread(Thread in_eeprom_thread) {
+ final Thread eeprom_thread = in_eeprom_thread;
+ cancel.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ if (eeprom_thread != null)
+ eeprom_thread.interrupt();
+ }
+ });
+ }
+
+ public void start() {
+ setVisible(true);
+ }
+
+ 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 + state_block;
+
+ 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_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, state_block, block);
+ } catch (Exception ex) {
+ }
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+
+ private void set_serial_internal(int serial) {
+ serial_value.setText(String.format("%d", serial));
+ }
+
+ public void set_serial(int in_serial) {
+ final int serial = in_serial;
+ Runnable r = new Runnable() {
+ public void run() {
+ try {
+ set_serial_internal(serial);
+ } catch (Exception ex) {
+ }
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+
+ private void set_flight_internal(int flight) {
+ flight_value.setText(String.format("%d", flight));
+ }
+
+ public void set_flight(int in_flight) {
+ final int flight = in_flight;
+ Runnable r = new Runnable() {
+ public void run() {
+ try {
+ set_flight_internal(flight);
+ } catch (Exception ex) {
+ }
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+
+ private void set_filename_internal(String filename) {
+ file_value.setText(String.format("%s", filename));
+ }
+
+ public void set_filename(String in_filename) {
+ final String filename = in_filename;
+ Runnable r = new Runnable() {
+ public void run() {
+ try {
+ set_filename_internal(filename);
+ } catch (Exception ex) {
+ }
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+
+ private void done_internal(boolean success) {
+ listener.actionPerformed(new ActionEvent(this,
+ success ? 1 : 0,
+ "download"));
+ setVisible(false);
+ dispose();
+ }
+
+ public void done(boolean in_success) {
+ final boolean success = in_success;
+ Runnable r = new Runnable() {
+ public void run() {
+ try {
+ done_internal(success);
+ } catch (Exception ex) {
+ }
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+
+ private void reset_internal() {
+ set_value_internal("startup",min_state,0, 0);
+ set_flight_internal(0);
+ set_filename_internal("");
+ }
+
+ public void reset() {
+ Runnable r = new Runnable() {
+ public void run() {
+ try {
+ reset_internal();
+ } catch (Exception ex) {
+ }
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+
+ private void show_message_internal(String message, String title, int message_type) {
+ int joption_message_type = JOptionPane.ERROR_MESSAGE;
+
+ switch (message_type) {
+ case INFO_MESSAGE:
+ joption_message_type = JOptionPane.INFORMATION_MESSAGE;
+ break;
+ case WARNING_MESSAGE:
+ joption_message_type = JOptionPane.WARNING_MESSAGE;
+ break;
+ case ERROR_MESSAGE:
+ joption_message_type = JOptionPane.ERROR_MESSAGE;
+ break;
+ }
+ JOptionPane.showMessageDialog(owner,
+ message,
+ title,
+ joption_message_type);
+ }
+
+ public void show_message(String in_message, String in_title, int in_message_type) {
+ final String message = in_message;
+ final String title = in_title;
+ final int message_type = in_message_type;
+ Runnable r = new Runnable() {
+ public void run() {
+ try {
+ show_message_internal(message, title, message_type);
+ } catch (Exception ex) {
+ }
+ }
+ };
+ SwingUtilities.invokeLater(r);
+ }
+}
diff --git a/altosui/AltosEepromSelect.java b/altosui/AltosEepromSelect.java
index a451aa3a..8f86eebf 100644
--- a/altosui/AltosEepromSelect.java
+++ b/altosui/AltosEepromSelect.java
@@ -21,7 +21,7 @@ import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
class AltosEepromItem implements ActionListener {
diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java
index f4e52218..296ad8ef 100644
--- a/altosui/AltosFlashUI.java
+++ b/altosui/AltosFlashUI.java
@@ -23,7 +23,7 @@ import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.io.*;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosFlashUI
@@ -45,18 +45,51 @@ public class AltosFlashUI
File file;
// Debug connection
- AltosDevice debug_dongle;
+ AltosDevice device;
+
+ AltosLink link;
// Desired Rom configuration
AltosRomconfig rom_config;
// Flash controller
- AltosFlash flash;
+ AltosProgrammer programmer;
+
+ private static String[] pair_programmed = {
+ "teleballoon",
+ "telebt",
+ "teledongle",
+ "telefire",
+ "telemetrum-v0",
+ "telemetrum-v1",
+ "telemini",
+ "telenano",
+ "teleshield",
+ "teleterra"
+ };
+
+ private boolean is_pair_programmed() {
+
+ if (file != null) {
+ String name = file.getName();
+ for (int i = 0; i < pair_programmed.length; i++) {
+ if (name.startsWith(pair_programmed[i]))
+ return true;
+ }
+ }
+ if (device != null) {
+ if (!device.matchProduct(AltosLib.product_altusmetrum) &&
+ (device.matchProduct(AltosLib.product_teledongle) ||
+ device.matchProduct(AltosLib.product_telebt)))
+ return true;
+ }
+ return false;
+ }
public void actionPerformed(ActionEvent e) {
if (e.getSource() == cancel) {
- if (flash != null)
- flash.abort();
+ if (programmer != null)
+ programmer.abort();
setVisible(false);
dispose();
} else {
@@ -156,6 +189,33 @@ public class AltosFlashUI
serial_value.setText(String.format("%d", serial_number));
}
+ static class AltosHexfileFilter extends javax.swing.filechooser.FileFilter {
+ int product;
+ String head;
+ String description;
+
+ public AltosHexfileFilter(int product, String head, String description) {
+ this.product = product;
+ this.head = head;
+ this.description = description;
+ }
+
+ public boolean accept(File file) {
+ return !file.isFile() || (file.getName().startsWith(head) && file.getName().endsWith(".ihx"));
+ }
+
+ public String getDescription() {
+ return description;
+ }
+ }
+
+ static AltosHexfileFilter[] filters = {
+ new AltosHexfileFilter(AltosLib.product_telemetrum, "telemetrum", "TeleMetrum Image"),
+ new AltosHexfileFilter(AltosLib.product_teledongle, "teledongle", "TeleDongle Image"),
+ new AltosHexfileFilter(AltosLib.product_telemega, "telemega", "TeleMega Image"),
+ new AltosHexfileFilter(AltosLib.product_easymini, "easymini", "EasyMini Image"),
+ };
+
boolean select_source_file() {
JFileChooser hexfile_chooser = new JFileChooser();
@@ -164,7 +224,21 @@ public class AltosFlashUI
hexfile_chooser.setCurrentDirectory(firmwaredir);
hexfile_chooser.setDialogTitle("Select Flash Image");
- hexfile_chooser.setFileFilter(new FileNameExtensionFilter("Flash Image", "ihx"));
+
+ for (int i = 0; i < filters.length; i++) {
+ hexfile_chooser.addChoosableFileFilter(filters[i]);
+ }
+ javax.swing.filechooser.FileFilter ihx_filter = new FileNameExtensionFilter("Flash Image", "ihx");
+ hexfile_chooser.addChoosableFileFilter(ihx_filter);
+ hexfile_chooser.setFileFilter(ihx_filter);
+
+ if (!is_pair_programmed() && !device.matchProduct(AltosLib.product_altusmetrum)) {
+ for (int i = 0; i < filters.length; i++) {
+ if (device != null && device.matchProduct(filters[i].product))
+ hexfile_chooser.setFileFilter(filters[i]);
+ }
+ }
+
int returnVal = hexfile_chooser.showOpenDialog(frame);
if (returnVal != JFileChooser.APPROVE_OPTION)
@@ -173,13 +247,16 @@ public class AltosFlashUI
if (file == null)
return false;
AltosUIPreferences.set_firmwaredir(file.getParentFile());
+
return true;
}
- boolean select_debug_dongle() {
- debug_dongle = AltosDeviceUIDialog.show(frame, Altos.product_any);
+ boolean select_device() {
+ int product = Altos.product_any;
- if (debug_dongle == null)
+ device = AltosDeviceUIDialog.show(frame, Altos.product_any);
+
+ if (device == null)
return false;
return true;
}
@@ -204,7 +281,7 @@ public class AltosFlashUI
} else if (e instanceof AltosSerialInUseException) {
JOptionPane.showMessageDialog(frame,
String.format("Device \"%s\" already in use",
- debug_dongle.toShortString()),
+ device.toShortString()),
"Device in use",
JOptionPane.ERROR_MESSAGE);
} else if (e instanceof IOException) {
@@ -218,7 +295,7 @@ public class AltosFlashUI
class flash_task implements Runnable, AltosFlashListener {
AltosFlashUI ui;
Thread t;
- AltosFlash flash;
+ AltosProgrammer programmer;
public void position(String in_s, int in_percent) {
final String s = in_s;
@@ -238,14 +315,17 @@ public class AltosFlashUI
public void run () {
try {
- flash = new AltosFlash(ui.file, new AltosSerial(ui.debug_dongle), this);
+ if (ui.is_pair_programmed())
+ programmer = new AltosFlash(ui.file, link, this);
+ else
+ programmer = new AltosSelfFlash(ui.file, link, this);
- final AltosRomconfig current_config = flash.romconfig();
+ final AltosRomconfig current_config = programmer.romconfig();
final Semaphore await_rom_config = new Semaphore(0);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
- ui.flash = flash;
+ ui.programmer = programmer;
ui.update_rom_config_info(current_config);
await_rom_config.release();
}
@@ -253,8 +333,8 @@ public class AltosFlashUI
await_rom_config.acquire();
if (ui.rom_config != null) {
- flash.set_romconfig(ui.rom_config);
- flash.flash();
+ programmer.set_romconfig(ui.rom_config);
+ programmer.flash();
}
} catch (InterruptedException ee) {
final Exception e = ee;
@@ -270,16 +350,9 @@ public class AltosFlashUI
ui.exception(e);
}
});
- } catch (AltosSerialInUseException ee) {
- final Exception e = ee;
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- ui.exception(e);
- }
- });
} finally {
- if (flash != null)
- flash.close();
+ if (programmer != null)
+ programmer.close();
}
}
@@ -292,16 +365,55 @@ public class AltosFlashUI
flash_task flasher;
+ private boolean open_device() throws InterruptedException {
+ try {
+ link = new AltosSerial(device);
+ if (is_pair_programmed())
+ return true;
+
+ if (link == null)
+ throw new IOException(String.format("%s: open failed", device.toShortString()));
+
+ while (!link.is_loader()) {
+ link.to_loader();
+
+ java.util.List<AltosDevice> devices = AltosUSBDevice.list(AltosLib.product_altusmetrum);
+ if (devices.size() == 1)
+ device = devices.get(0);
+ else {
+ device = AltosDeviceUIDialog.show(frame, AltosLib.product_altusmetrum);
+ if (device == null)
+ return false;
+ }
+ link = new AltosSerial(device);
+ }
+ return true;
+ } catch (AltosSerialInUseException ee) {
+ exception(ee);
+ } catch (FileNotFoundException fe) {
+ exception(fe);
+ } catch (IOException ie) {
+ exception (ie);
+ }
+ return false;
+ }
+
/*
* Execute the steps for flashing
* a device. Note that this returns immediately;
* this dialog is not modal
*/
void showDialog() {
- if (!select_debug_dongle())
+ if (!select_device())
return;
if (!select_source_file())
return;
+ try {
+ if (!open_device())
+ return;
+ } catch (InterruptedException ie) {
+ return;
+ }
build_dialog();
flash_task f = new flash_task(this);
}
diff --git a/altosui/AltosFlightDisplay.java b/altosui/AltosFlightDisplay.java
index 4f4c158e..289ddd01 100644
--- a/altosui/AltosFlightDisplay.java
+++ b/altosui/AltosFlightDisplay.java
@@ -17,7 +17,7 @@
package altosui;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public interface AltosFlightDisplay {
void reset();
diff --git a/altosui/AltosFlightStats.java b/altosui/AltosFlightStats.java
index dee31a8d..552210c3 100644
--- a/altosui/AltosFlightStats.java
+++ b/altosui/AltosFlightStats.java
@@ -18,14 +18,13 @@
package altosui;
import java.io.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosFlightStats {
double max_height;
double max_speed;
double max_acceleration;
- double[] state_accel_speed = new double[Altos.ao_flight_invalid + 1];
- double[] state_baro_speed = new double[Altos.ao_flight_invalid + 1];
+ double[] state_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];
double[] state_start = new double[Altos.ao_flight_invalid + 1];
@@ -40,16 +39,19 @@ public class AltosFlightStats {
boolean has_other_adc;
boolean has_rssi;
- double landed_time(AltosRecordIterable iterable) {
- AltosState state = null;
- for (AltosRecord record : iterable) {
- state = new AltosState(record, state);
+ double landed_time(AltosStateIterable states) {
+ AltosState state = null;
+ for (AltosState s : states) {
+ state = s;
if (state.state == Altos.ao_flight_landed)
break;
}
- double landed_height = state.height;
+ if (state == null)
+ return 0;
+
+ double landed_height = state.height();
state = null;
@@ -57,13 +59,13 @@ public class AltosFlightStats {
double landed_time = -1000;
- for (AltosRecord record : iterable) {
- state = new AltosState(record, state);
+ for (AltosState s : states) {
+ state = s;
- if (state.height > landed_height + 10) {
+ if (state.height() > landed_height + 10) {
above = true;
} else {
- if (above && state.height < landed_height + 2) {
+ if (above && state.height() < landed_height + 2) {
above = false;
landed_time = state.time;
}
@@ -74,84 +76,80 @@ public class AltosFlightStats {
return landed_time;
}
- double boost_time(AltosRecordIterable iterable) {
- double boost_time = -1000;
-
- AltosState state = null;
+ double boost_time(AltosStateIterable states) {
+ double boost_time = AltosLib.MISSING;
+ AltosState state = null;
- for (AltosRecord record : iterable) {
- state = new AltosState(record, state);
-
- if (state.acceleration < 1)
+ for (AltosState s : states) {
+ state = s;
+ if (state.acceleration() < 1)
boost_time = state.time;
- if (state.state >= Altos.ao_flight_boost)
+ if (state.state >= AltosLib.ao_flight_boost && state.state <= AltosLib.ao_flight_landed)
break;
}
- if (boost_time == -1000)
+ if (state == null)
+ return 0;
+
+ if (boost_time == AltosLib.MISSING)
boost_time = state.time;
return boost_time;
}
- public AltosFlightStats(AltosRecordIterable iterable) throws InterruptedException, IOException {
- AltosState state = null;
- AltosState new_state = null;
- double boost_time = boost_time(iterable);
+ public AltosFlightStats(AltosStateIterable states) throws InterruptedException, IOException {
+ double boost_time = boost_time(states);
double end_time = 0;
- double landed_time = landed_time(iterable);
+ double landed_time = landed_time(states);
- year = month = day = -1;
- hour = minute = second = -1;
- serial = flight = -1;
- lat = lon = -1;
+ year = month = day = AltosLib.MISSING;
+ hour = minute = second = AltosLib.MISSING;
+ serial = flight = AltosLib.MISSING;
+ lat = lon = AltosLib.MISSING;
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)
+ for (AltosState state : states) {
+ if (serial == AltosLib.MISSING && state.serial != AltosLib.MISSING)
+ serial = state.serial;
+ if (flight == AltosLib.MISSING && state.flight != AltosLib.MISSING)
+ flight = state.flight;
+ if (state.battery_voltage != AltosLib.MISSING)
has_other_adc = true;
- if (record.rssi != 0)
+ if (state.rssi != AltosLib.MISSING)
has_rssi = true;
- new_state = new AltosState(record, state);
- end_time = new_state.time;
- state = new_state;
- if (state.time >= boost_time && state.state < Altos.ao_flight_boost)
- state.state = Altos.ao_flight_boost;
- if (state.time >= landed_time && state.state < Altos.ao_flight_landed)
- state.state = Altos.ao_flight_landed;
- if (0 <= state.state && state.state < Altos.ao_flight_invalid) {
- if (state.state >= Altos.ao_flight_boost) {
- if (state.gps != null && state.gps.locked &&
- year < 0) {
- year = state.gps.year;
- month = state.gps.month;
- day = state.gps.day;
- hour = state.gps.hour;
- minute = state.gps.minute;
- second = state.gps.second;
- }
+ end_time = state.time;
+
+ int state_id = state.state;
+ if (state.time >= boost_time && state_id < Altos.ao_flight_boost)
+ state_id = Altos.ao_flight_boost;
+ if (state.time >= landed_time && state_id < Altos.ao_flight_landed)
+ state_id = Altos.ao_flight_landed;
+ if (state.gps != null && state.gps.locked) {
+ year = state.gps.year;
+ month = state.gps.month;
+ day = state.gps.day;
+ hour = state.gps.hour;
+ minute = state.gps.minute;
+ second = state.gps.second;
+ }
+ if (0 <= state_id && state_id < Altos.ao_flight_invalid) {
+ double acceleration = state.acceleration();
+ double speed = state.speed();
+ if (acceleration != AltosLib.MISSING && speed != AltosLib.MISSING) {
+ state_accel[state_id] += acceleration;
+ state_speed[state_id] += speed;
+ state_count[state_id]++;
}
- state_accel[state.state] += state.acceleration;
- 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)
- state_start[state.state] = state.time;
- if (state_end[state.state] < state.time)
- state_end[state.state] = state.time;
- max_height = state.max_height;
- 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_start[state_id] == 0.0)
+ state_start[state_id] = state.time;
+ if (state_end[state_id] < state.time)
+ state_end[state_id] = state.time;
+ max_height = state.max_height();
+ max_speed = state.max_speed();
+ max_acceleration = state.max_acceleration();
}
if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) {
- if (state.state <= Altos.ao_flight_pad) {
+ if (state_id <= Altos.ao_flight_pad) {
pad_lat = state.gps.lat;
pad_lon = state.gps.lon;
}
@@ -162,8 +160,7 @@ public class AltosFlightStats {
}
for (int s = Altos.ao_flight_startup; s <= Altos.ao_flight_landed; s++) {
if (state_count[s] > 0) {
- state_accel_speed[s] /= state_count[s];
- state_baro_speed[s] /= state_count[s];
+ state_speed[s] /= state_count[s];
state_accel[s] /= state_count[s];
}
if (state_start[s] == 0)
diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java
index a35b5f63..db875b3b 100644
--- a/altosui/AltosFlightStatsTable.java
+++ b/altosui/AltosFlightStatsTable.java
@@ -19,7 +19,7 @@ package altosui;
import java.awt.*;
import javax.swing.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosFlightStatsTable extends JComponent {
GridBagLayout layout;
@@ -76,15 +76,15 @@ 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 && stats.hour > 0)
+ if (stats.year != AltosLib.MISSING && stats.hour != AltosLib.MISSING)
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)
+ if (stats.year != AltosLib.MISSING)
new FlightStat(layout, y++, "Date",
String.format("%04d-%02d-%02d", stats.year, stats.month, stats.day));
- if (stats.hour > 0)
+ if (stats.hour != AltosLib.MISSING)
new FlightStat(layout, y++, "Time",
String.format("%02d:%02d:%02d UTC", stats.hour, stats.minute, stats.second));
}
@@ -95,7 +95,7 @@ public class AltosFlightStatsTable extends JComponent {
String.format("%5.0f m/s", stats.max_speed),
String.format("%5.0f mph", AltosConvert.meters_to_mph(stats.max_speed)),
String.format("Mach %4.1f", AltosConvert.meters_to_mach(stats.max_speed)));
- if (stats.max_acceleration != AltosRecord.MISSING) {
+ if (stats.max_acceleration != AltosLib.MISSING) {
new FlightStat(layout, y++, "Maximum boost acceleration",
String.format("%5.0f m/s²", stats.max_acceleration),
String.format("%5.0f ft/s²", AltosConvert.meters_to_feet(stats.max_acceleration)),
@@ -106,11 +106,11 @@ public class AltosFlightStatsTable extends JComponent {
String.format("%5.0f G", AltosConvert.meters_to_g(stats.state_accel[Altos.ao_flight_boost])));
}
new FlightStat(layout, y++, "Drogue descent rate",
- String.format("%5.0f m/s", stats.state_baro_speed[Altos.ao_flight_drogue]),
- String.format("%5.0f ft/s", AltosConvert.meters_to_feet(stats.state_baro_speed[Altos.ao_flight_drogue])));
+ String.format("%5.0f m/s", stats.state_speed[Altos.ao_flight_drogue]),
+ String.format("%5.0f ft/s", AltosConvert.meters_to_feet(stats.state_speed[Altos.ao_flight_drogue])));
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])));
+ String.format("%5.0f m/s", stats.state_speed[Altos.ao_flight_main]),
+ String.format("%5.0f ft/s", AltosConvert.meters_to_feet(stats.state_speed[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)),
diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java
index d2910414..9d575e4c 100644
--- a/altosui/AltosFlightStatus.java
+++ b/altosui/AltosFlightStatus.java
@@ -19,7 +19,7 @@ package altosui;
import java.awt.*;
import javax.swing.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosFlightStatus extends JComponent implements AltosFlightDisplay {
GridBagLayout layout;
@@ -65,7 +65,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
class Call extends FlightValue {
void show(AltosState state, AltosListenerState listener_state) {
- value.setText(state.data.callsign);
+ value.setText(state.callsign);
}
public Call (GridBagLayout layout, int x) {
super (layout, x, "Callsign");
@@ -76,10 +76,10 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
class Serial extends FlightValue {
void show(AltosState state, AltosListenerState listener_state) {
- if (state.data.serial == AltosRecord.MISSING)
+ if (state.serial == AltosLib.MISSING)
value.setText("none");
else
- value.setText(String.format("%d", state.data.serial));
+ value.setText(String.format("%d", state.serial));
}
public Serial (GridBagLayout layout, int x) {
super (layout, x, "Serial");
@@ -90,10 +90,10 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
class Flight extends FlightValue {
void show(AltosState state, AltosListenerState listener_state) {
- if (state.data.flight == AltosRecord.MISSING)
+ if (state.flight == AltosLib.MISSING)
value.setText("none");
else
- value.setText(String.format("%d", state.data.flight));
+ value.setText(String.format("%d", state.flight));
}
public Flight (GridBagLayout layout, int x) {
super (layout, x, "Flight");
@@ -104,7 +104,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
class FlightState extends FlightValue {
void show(AltosState state, AltosListenerState listener_state) {
- value.setText(state.data.state());
+ value.setText(state.state_name());
}
public FlightState (GridBagLayout layout, int x) {
super (layout, x, "State");
@@ -115,7 +115,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
class RSSI extends FlightValue {
void show(AltosState state, AltosListenerState listener_state) {
- value.setText(String.format("%d", state.data.rssi));
+ value.setText(String.format("%d", state.rssi()));
}
public RSSI (GridBagLayout layout, int x) {
super (layout, x, "RSSI");
@@ -126,7 +126,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
class LastPacket extends FlightValue {
void show(AltosState state, AltosListenerState listener_state) {
- long secs = (System.currentTimeMillis() - state.report_time + 500) / 1000;
+ long secs = (System.currentTimeMillis() - state.received_time + 500) / 1000;
value.setText(String.format("%d", secs));
}
public LastPacket(GridBagLayout layout, int x) {
diff --git a/altosui/AltosFlightStatusTableModel.java b/altosui/AltosFlightStatusTableModel.java
index 6a327841..08154fda 100644
--- a/altosui/AltosFlightStatusTableModel.java
+++ b/altosui/AltosFlightStatusTableModel.java
@@ -27,7 +27,7 @@ import java.util.*;
import java.text.*;
import java.util.prefs.*;
import java.util.concurrent.LinkedBlockingQueue;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosFlightStatusTableModel extends AbstractTableModel {
private String[] columnNames = {
diff --git a/altosui/AltosFlightStatusUpdate.java b/altosui/AltosFlightStatusUpdate.java
index 962a08f7..7821a777 100644
--- a/altosui/AltosFlightStatusUpdate.java
+++ b/altosui/AltosFlightStatusUpdate.java
@@ -18,7 +18,7 @@
package altosui;
import java.awt.event.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosFlightStatusUpdate implements ActionListener {
diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java
index 6d010d23..c151177e 100644
--- a/altosui/AltosFlightUI.java
+++ b/altosui/AltosFlightUI.java
@@ -21,7 +21,7 @@ import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener {
@@ -102,7 +102,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A
status_update.saved_state = state;
if (state == null)
- state = new AltosState(new AltosRecord());
+ state = new AltosState();
pad.show(state, listener_state);
@@ -130,7 +130,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A
flightStatus.show(state, listener_state);
flightInfo.show(state, listener_state);
- if (state.data.companion != null) {
+ if (state.companion != null) {
if (!has_companion) {
pane.add("Companion", companion);
has_companion= true;
diff --git a/altosui/AltosFreqList.java b/altosui/AltosFreqList.java
index 7464ac3e..17a995d4 100644
--- a/altosui/AltosFreqList.java
+++ b/altosui/AltosFreqList.java
@@ -18,7 +18,7 @@
package altosui;
import javax.swing.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosFreqList extends JComboBox {
@@ -29,6 +29,12 @@ public class AltosFreqList extends JComboBox {
public void set_frequency(double new_frequency) {
int i;
+
+ if (new_frequency < 0) {
+ setVisible(false);
+ return;
+ }
+
for (i = 0; i < getItemCount(); i++) {
AltosFrequency f = (AltosFrequency) getItemAt(i);
diff --git a/altosui/AltosGraph.java b/altosui/AltosGraph.java
index defe69a0..c505d2d8 100644
--- a/altosui/AltosGraph.java
+++ b/altosui/AltosGraph.java
@@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.awt.*;
import javax.swing.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
import org.jfree.ui.*;
@@ -37,57 +37,92 @@ import org.jfree.data.*;
class AltosVoltage extends AltosUnits {
- public double value(double v) {
+ public double value(double v, boolean imperial_units) {
return v;
}
- public String show_units() {
+ public double inverse(double v, boolean imperial_units) {
+ return v;
+ }
+
+ public String show_units(boolean imperial_units) {
return "V";
}
- public String say_units() {
+ public String say_units(boolean imperial_units) {
return "volts";
}
- public int show_fraction(int width) {
+ public int show_fraction(int width, boolean imperial_units) {
return width / 2;
}
}
class AltosNsat extends AltosUnits {
- public double value(double v) {
+ public double value(double v, boolean imperial_units) {
+ return v;
+ }
+
+ public double inverse(double v, boolean imperial_units) {
return v;
}
- public String show_units() {
+ public String show_units(boolean imperial_units) {
return "Sats";
}
- public String say_units() {
+ public String say_units(boolean imperial_units) {
return "Satellites";
}
- public int show_fraction(int width) {
+ public int show_fraction(int width, boolean imperial_units) {
+ return 0;
+ }
+}
+
+class AltosPressure extends AltosUnits {
+
+ public double value(double p, boolean imperial_units) {
+ return p;
+ }
+
+ public double inverse(double p, boolean imperial_units) {
+ return p;
+ }
+
+ public String show_units(boolean imperial_units) {
+ return "Pa";
+ }
+
+ public String say_units(boolean imperial_units) {
+ return "pascals";
+ }
+
+ public int show_fraction(int width, boolean imperial_units) {
return 0;
}
}
class AltosDbm extends AltosUnits {
- public double value(double v) {
- return v;
+ public double value(double d, boolean imperial_units) {
+ return d;
+ }
+
+ public double inverse(double d, boolean imperial_units) {
+ return d;
}
- public String show_units() {
+ public String show_units(boolean imperial_units) {
return "dBm";
}
- public String say_units() {
- return "d b m";
+ public String say_units(boolean imperial_units) {
+ return "D B M";
}
- public int show_fraction(int width) {
+ public int show_fraction(int width, boolean imperial_units) {
return 0;
}
}
@@ -96,6 +131,7 @@ 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 pressure_color = new Color (225,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);
@@ -112,16 +148,18 @@ public class AltosGraph extends AltosUIGraph {
static final private Color state_color = new Color(0,0,0);
static AltosVoltage voltage_units = new AltosVoltage();
+ static AltosPressure pressure_units = new AltosPressure();
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;
+ AltosUIAxis distance_axis, pressure_axis;
public AltosGraph(AltosUIEnable enable, AltosFlightStats stats, AltosGraphDataSet dataSet) {
super(enable);
height_axis = newAxis("Height", AltosConvert.height, height_color);
+ pressure_axis = newAxis("Pressure", pressure_units, pressure_color, 0);
speed_axis = newAxis("Speed", AltosConvert.speed, speed_color);
accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color);
voltage_axis = newAxis("Voltage", voltage_units, voltage_color);
@@ -138,6 +176,12 @@ public class AltosGraph extends AltosUIGraph {
height_color,
true,
height_axis);
+ addSeries("Pressure",
+ AltosGraphDataPoint.data_pressure,
+ pressure_units,
+ pressure_color,
+ false,
+ pressure_axis);
addSeries("Speed",
AltosGraphDataPoint.data_speed,
AltosConvert.speed,
diff --git a/altosui/AltosGraphDataPoint.java b/altosui/AltosGraphDataPoint.java
index 8e6d6923..d8191f5d 100644
--- a/altosui/AltosGraphDataPoint.java
+++ b/altosui/AltosGraphDataPoint.java
@@ -18,7 +18,7 @@
package altosui;
import org.altusmetrum.altosuilib_1.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosGraphDataPoint implements AltosUIDataPoint {
@@ -39,39 +39,41 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
public static final int data_temperature = 12;
public static final int data_range = 13;
public static final int data_distance = 14;
+ public static final int data_pressure = 15;
public double x() throws AltosUIDataMissing {
- if (state.data.time < -2)
+ double time = state.time_since_boost();
+ if (time < -2)
throw new AltosUIDataMissing(-1);
- return state.data.time;
+ return time;
}
public double y(int index) throws AltosUIDataMissing {
- double y = AltosRecord.MISSING;
+ double y = AltosLib.MISSING;
switch (index) {
case data_height:
- y = state.height;
+ y = state.height();
break;
case data_speed:
y = state.speed();
break;
case data_accel:
- y = state.acceleration;
+ y = state.acceleration();
break;
case data_temp:
y = state.temperature;
break;
case data_battery_voltage:
- y = state.battery;
+ y = state.battery_voltage;
break;
case data_drogue_voltage:
- y = state.drogue_sense;
+ y = state.apogee_voltage;
break;
case data_main_voltage:
- y = state.main_sense;
+ y = state.main_voltage;
break;
case data_rssi:
- y = state.data.rssi;
+ y = state.rssi;
break;
case data_gps_height:
y = state.gps_height;
@@ -94,15 +96,18 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
if (state.from_pad != null)
y = state.from_pad.distance;
break;
+ case data_pressure:
+ y = state.pressure();
+ break;
}
- if (y == AltosRecord.MISSING)
+ if (y == AltosLib.MISSING)
throw new AltosUIDataMissing(index);
return y;
}
public int id(int index) {
if (index == data_state) {
- int s = state.data.state;
+ int s = state.state;
if (s < Altos.ao_flight_boost || s > Altos.ao_flight_landed)
return -1;
return s;
@@ -112,7 +117,7 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
public String id_name(int index) {
if (index == data_state)
- return state.data.state();
+ return state.state_name();
return "";
}
diff --git a/altosui/AltosGraphDataSet.java b/altosui/AltosGraphDataSet.java
index dc047e9a..4e6c46d1 100644
--- a/altosui/AltosGraphDataSet.java
+++ b/altosui/AltosGraphDataSet.java
@@ -20,39 +20,36 @@ package altosui;
import java.lang.*;
import java.io.*;
import java.util.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
class AltosGraphIterator implements Iterator<AltosUIDataPoint> {
AltosGraphDataSet dataSet;
- Iterator<AltosRecord> iterator;
-
- AltosState state;
+ Iterator<AltosState> iterator;
public boolean hasNext() {
return iterator.hasNext();
}
public AltosUIDataPoint next() {
- state = new AltosState(iterator.next(), state);
+ AltosState state = iterator.next();
- if ((state.data.seen & AltosRecord.seen_flight) != 0) {
- if (dataSet.callsign == null && state.data.callsign != null)
- dataSet.callsign = state.data.callsign;
+ if (state.flight != AltosLib.MISSING) {
+ if (dataSet.callsign == null && state.callsign != null)
+ dataSet.callsign = state.callsign;
- if (dataSet.serial == 0 && state.data.serial != 0)
- dataSet.serial = state.data.serial;
+ if (dataSet.serial == 0 && state.serial != 0)
+ dataSet.serial = state.serial;
- if (dataSet.flight == 0 && state.data.flight != 0)
- dataSet.flight = state.data.flight;
+ if (dataSet.flight == 0 && state.flight != 0)
+ dataSet.flight = state.flight;
}
return new AltosGraphDataPoint(state);
}
- public AltosGraphIterator (Iterator<AltosRecord> iterator, AltosGraphDataSet dataSet) {
+ public AltosGraphIterator (Iterator<AltosState> iterator, AltosGraphDataSet dataSet) {
this.iterator = iterator;
- this.state = null;
this.dataSet = dataSet;
}
@@ -64,7 +61,7 @@ class AltosGraphIterable implements Iterable<AltosUIDataPoint> {
AltosGraphDataSet dataSet;
public Iterator<AltosUIDataPoint> iterator() {
- return new AltosGraphIterator(dataSet.records.iterator(), dataSet);
+ return new AltosGraphIterator(dataSet.states.iterator(), dataSet);
}
public AltosGraphIterable(AltosGraphDataSet dataSet) {
@@ -76,7 +73,7 @@ public class AltosGraphDataSet implements AltosUIDataSet {
String callsign;
int serial;
int flight;
- AltosRecordIterable records;
+ AltosStateIterable states;
public String name() {
if (callsign != null)
@@ -89,8 +86,8 @@ public class AltosGraphDataSet implements AltosUIDataSet {
return new AltosGraphIterable(this);
}
- public AltosGraphDataSet (AltosRecordIterable records) {
- this.records = records;
+ public AltosGraphDataSet (AltosStateIterable states) {
+ this.states = states;
this.callsign = null;
this.serial = 0;
this.flight = 0;
diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java
index d8b8f6dd..c42f7b5f 100644
--- a/altosui/AltosGraphUI.java
+++ b/altosui/AltosGraphUI.java
@@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.awt.*;
import javax.swing.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
import org.jfree.chart.ChartPanel;
@@ -28,10 +28,9 @@ public class AltosGraphUI extends AltosUIFrame
AltosFlightStatsTable statsTable;
boolean has_gps;
- void fill_map(AltosRecordIterable records) {
+ void fill_map(AltosStateIterable states) {
boolean any_gps = false;
- for (AltosRecord record : records) {
- state = new AltosState(record, state);
+ for (AltosState state : states) {
if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) {
if (map == null)
map = new AltosSiteMap();
@@ -41,7 +40,7 @@ public class AltosGraphUI extends AltosUIFrame
}
}
- AltosGraphUI(AltosRecordIterable records, File file) throws InterruptedException, IOException {
+ AltosGraphUI(AltosStateIterable states, File file) throws InterruptedException, IOException {
super(file.getName());
state = null;
@@ -49,8 +48,8 @@ public class AltosGraphUI extends AltosUIFrame
enable = new AltosUIEnable();
- stats = new AltosFlightStats(records);
- graphDataSet = new AltosGraphDataSet(records);
+ stats = new AltosFlightStats(states);
+ graphDataSet = new AltosGraphDataSet(states);
graph = new AltosGraph(enable, stats, graphDataSet);
@@ -61,7 +60,7 @@ public class AltosGraphUI extends AltosUIFrame
pane.add("Flight Statistics", statsTable);
has_gps = false;
- fill_map(records);
+ fill_map(states);
if (has_gps)
pane.add("Map", map);
diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java
index bbab017f..6a79604e 100644
--- a/altosui/AltosIdleMonitorUI.java
+++ b/altosui/AltosIdleMonitorUI.java
@@ -23,7 +23,8 @@ import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
+import java.util.Arrays;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener, AltosIdleMonitorListener, DocumentListener {
@@ -38,7 +39,10 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl
void stop_display() {
if (thread != null) {
- thread.abort();
+ try {
+ thread.abort();
+ } catch (InterruptedException ie) {
+ }
}
thread = null;
}
@@ -65,13 +69,13 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl
public void show(AltosState state, AltosListenerState listener_state) {
status_update.saved_state = state;
- try {
+// try {
pad.show(state, listener_state);
flightStatus.show(state, listener_state);
flightInfo.show(state, listener_state);
- } catch (Exception e) {
- System.out.print("Show exception" + e);
- }
+// } catch (Exception e) {
+// System.out.print("Show exception " + e);
+// }
}
public void update(final AltosState state, final AltosListenerState listener_state) {
@@ -191,7 +195,11 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
- disconnect();
+ try {
+ disconnect();
+ } catch (Exception ex) {
+ System.out.println(Arrays.toString(ex.getStackTrace()));
+ }
setVisible(false);
dispose();
AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this);
diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java
index 14d4eebc..c8024aae 100644
--- a/altosui/AltosIgniteUI.java
+++ b/altosui/AltosIgniteUI.java
@@ -23,7 +23,7 @@ import javax.swing.*;
import java.io.*;
import java.text.*;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosIgniteUI
diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java
index 3d16faf2..feafed21 100644
--- a/altosui/AltosInfoTable.java
+++ b/altosui/AltosInfoTable.java
@@ -20,7 +20,7 @@ package altosui;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosInfoTable extends JTable {
private AltosFlightInfoTableModel model;
@@ -107,35 +107,37 @@ public class AltosInfoTable extends JTable {
public void show(AltosState state, AltosListenerState listener_state) {
info_reset();
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)
+ if (state.device_type != AltosLib.MISSING)
+ info_add_row(0, "Device", "%s", AltosLib.product_name(state.device_type));
+ if (state.altitude() != AltosLib.MISSING)
+ info_add_row(0, "Altitude", "%6.0f m", state.altitude());
+ if (state.ground_altitude() != AltosLib.MISSING)
+ info_add_row(0, "Pad altitude", "%6.0f m", state.ground_altitude());
+ if (state.height() != AltosLib.MISSING)
+ info_add_row(0, "Height", "%6.0f m", state.height());
+ if (state.max_height() != AltosLib.MISSING)
+ info_add_row(0, "Max height", "%6.0f m", state.max_height());
+ if (state.acceleration() != AltosLib.MISSING)
+ info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration());
+ if (state.max_acceleration() != AltosLib.MISSING)
+ info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration());
+ if (state.speed() != AltosLib.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)
+ if (state.max_speed() != AltosLib.MISSING)
+ info_add_row(0, "Max Speed", "%8.1f m/s", state.max_speed());
+ if (state.temperature != AltosLib.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 (state.battery_voltage != AltosLib.MISSING)
+ info_add_row(0, "Battery", "%9.2f V", state.battery_voltage);
+ if (state.apogee_voltage != AltosLib.MISSING)
+ info_add_row(0, "Drogue", "%9.2f V", state.apogee_voltage);
+ if (state.main_voltage != AltosLib.MISSING)
+ info_add_row(0, "Main", "%9.2f V", state.main_voltage);
}
if (listener_state != null) {
info_add_row(0, "CRC Errors", "%6d", listener_state.crc_errors);
- if (listener_state.battery != AltosRecord.MISSING)
+ if (listener_state.battery != AltosLib.MISSING)
info_add_row(0, "Receiver Battery", "%9.2f", listener_state.battery);
}
@@ -148,17 +150,21 @@ public class AltosInfoTable extends JTable {
else
info_add_row(1, "GPS state", "wait (%d)",
state.gps_waiting);
- if (state.data.gps.locked)
+ if (state.gps.locked)
info_add_row(1, "GPS", " locked");
- else if (state.data.gps.connected)
+ else if (state.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);
+ info_add_row(1, "Satellites", "%6d", state.gps.nsat);
+ if (state.gps.lat != AltosLib.MISSING)
+ info_add_deg(1, "Latitude", state.gps.lat, 'N', 'S');
+ if (state.gps.lon != AltosLib.MISSING)
+ info_add_deg(1, "Longitude", state.gps.lon, 'E', 'W');
+ if (state.gps.alt != AltosLib.MISSING)
+ info_add_row(1, "GPS altitude", "%8.1f", state.gps.alt);
+ if (state.gps_height != AltosLib.MISSING)
+ info_add_row(1, "GPS height", "%8.1f", state.gps_height);
/* The SkyTraq GPS doesn't report these values */
/*
@@ -195,14 +201,16 @@ public class AltosInfoTable extends JTable {
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);
+ if (state.gps.year != AltosLib.MISSING)
+ info_add_row(1, "GPS date", "%04d-%02d-%02d",
+ state.gps.year,
+ state.gps.month,
+ state.gps.day);
+ if (state.gps.hour != AltosLib.MISSING)
+ info_add_row(1, "GPS time", " %02d:%02d:%02d",
+ state.gps.hour,
+ state.gps.minute,
+ state.gps.second);
//int nsat_vis = 0;
int c;
diff --git a/altosui/AltosKML.java b/altosui/AltosKML.java
index 140f3f07..fbb0ece4 100644
--- a/altosui/AltosKML.java
+++ b/altosui/AltosKML.java
@@ -18,14 +18,14 @@
package altosui;
import java.io.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosKML implements AltosWriter {
File name;
PrintStream out;
- int state = -1;
- AltosRecord prev = null;
+ int flight_state = -1;
+ AltosState prev = null;
double gps_start_altitude;
static final String[] kml_state_colors = {
@@ -83,7 +83,7 @@ public class AltosKML implements AltosWriter {
"</Document>\n" +
"</kml>\n";
- void start (AltosRecord record) {
+ void start (AltosState record) {
out.printf(kml_header_start, record.flight, record.serial);
out.printf("Date: %04d-%02d-%02d\n",
record.gps.year, record.gps.month, record.gps.day);
@@ -94,30 +94,30 @@ public class AltosKML implements AltosWriter {
boolean started = false;
- void state_start(AltosRecord record) {
- String state_name = Altos.state_name(record.state);
- out.printf(kml_style_start, state_name, kml_state_colors[record.state]);
+ void state_start(AltosState state) {
+ String state_name = Altos.state_name(state.state);
+ out.printf(kml_style_start, state_name, kml_state_colors[state.state]);
out.printf("\tState: %s\n", state_name);
out.printf("%s", kml_style_end);
out.printf(kml_placemark_start, state_name, state_name);
}
- void state_end(AltosRecord record) {
+ void state_end(AltosState state) {
out.printf("%s", kml_placemark_end);
}
- void coord(AltosRecord record) {
- AltosGPS gps = record.gps;
+ void coord(AltosState state) {
+ AltosGPS gps = state.gps;
double altitude;
- if (record.height() != AltosRecord.MISSING)
- altitude = record.height() + gps_start_altitude;
+ if (state.height() != AltosLib.MISSING)
+ altitude = state.height() + gps_start_altitude;
else
altitude = gps.alt;
out.printf(kml_coord_fmt,
gps.lon, gps.lat,
altitude, (double) gps.alt,
- record.time, gps.nsat);
+ state.time, gps.nsat);
}
void end() {
@@ -132,38 +132,40 @@ public class AltosKML implements AltosWriter {
}
}
- public void write(AltosRecord record) {
- AltosGPS gps = record.gps;
+ public void write(AltosState state) {
+ AltosGPS gps = state.gps;
if (gps == null)
return;
- if ((record.seen & (AltosRecord.seen_gps_lat)) == 0)
+ if (gps.lat == AltosLib.MISSING)
return;
- if ((record.seen & (AltosRecord.seen_gps_lon)) == 0)
+ if (gps.lon == AltosLib.MISSING)
return;
if (!started) {
- start(record);
+ start(state);
started = true;
gps_start_altitude = gps.alt;
}
- if (prev != null && prev.gps_sequence == record.gps_sequence)
+ if (prev != null && prev.gps_sequence == state.gps_sequence)
return;
- if (record.state != state) {
- state = record.state;
+ if (state.state != flight_state) {
+ flight_state = state.state;
if (prev != null) {
- coord(record);
+ coord(state);
state_end(prev);
}
- state_start(record);
+ state_start(state);
}
- coord(record);
- prev = record;
+ coord(state);
+ prev = state;
}
- public void write(AltosRecordIterable iterable) {
- for (AltosRecord record : iterable)
- write(record);
+ public void write(AltosStateIterable states) {
+ for (AltosState state : states) {
+ if ((state.set & AltosState.set_gps) != 0)
+ write(state);
+ }
}
public AltosKML(File in_name) throws FileNotFoundException {
diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java
index 1d209bda..cc2053e0 100644
--- a/altosui/AltosLanded.java
+++ b/altosui/AltosLanded.java
@@ -21,7 +21,7 @@ import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener {
GridBagLayout layout;
@@ -103,7 +103,8 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
class Lat extends LandedValue {
void show (AltosState state, AltosListenerState listener_state) {
- if (state.gps != null && state.gps.connected)
+ show();
+ if (state.gps != null && state.gps.connected && state.gps.lat != AltosLib.MISSING)
show(pos(state.gps.lat,"N", "S"));
else
show("???");
@@ -118,7 +119,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
class Lon extends LandedValue {
void show (AltosState state, AltosListenerState listener_state) {
show();
- if (state.gps != null && state.gps.connected)
+ if (state.gps != null && state.gps.connected && state.gps.lon != AltosLib.MISSING)
show(pos(state.gps.lon,"E", "W"));
else
show("???");
@@ -162,7 +163,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
class Height extends LandedValue {
void show (AltosState state, AltosListenerState listener_state) {
- show(AltosConvert.height, state.max_height);
+ show(AltosConvert.height, state.max_height());
}
public Height (GridBagLayout layout, int y) {
super (layout, y, "Maximum Height");
@@ -184,7 +185,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
class Accel extends LandedValue {
void show (AltosState state, AltosListenerState listener_state) {
- show(AltosConvert.accel, state.max_acceleration);
+ show(AltosConvert.accel, state.max_acceleration());
}
public Accel (GridBagLayout layout, int y) {
super (layout, y, "Maximum Acceleration");
@@ -243,21 +244,18 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
if (file != null) {
String filename = file.getName();
try {
- AltosRecordIterable records = null;
+ AltosStateIterable states = null;
if (filename.endsWith("eeprom")) {
FileInputStream in = new FileInputStream(file);
- records = new AltosEepromIterable(in);
+ states = new AltosEepromFile(in);
} 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);
+ states = new AltosTelemetryFile(in);
} else {
throw new FileNotFoundException(filename);
}
try {
- new AltosGraphUI(records, file);
+ new AltosGraphUI(states, file);
} catch (InterruptedException ie) {
} catch (IOException ie) {
}
diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java
index e2316a13..06a0f1ef 100644
--- a/altosui/AltosPad.java
+++ b/altosui/AltosPad.java
@@ -19,7 +19,7 @@ package altosui;
import java.awt.*;
import javax.swing.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosPad extends JComponent implements AltosFlightDisplay {
GridBagLayout layout;
@@ -176,11 +176,11 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
class Battery extends LaunchStatus {
void show (AltosState state, AltosListenerState listener_state) {
- if (state == null || state.battery == AltosRecord.MISSING)
+ if (state == null || state.battery_voltage == AltosLib.MISSING)
hide();
else {
- show("%4.2f V", state.battery);
- lights.set(state.battery > 3.7);
+ show("%4.2f V", state.battery_voltage);
+ lights.set(state.battery_voltage >= AltosLib.ao_battery_good);
}
}
public Battery (GridBagLayout layout, int y) {
@@ -192,11 +192,11 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
class Apogee extends LaunchStatus {
void show (AltosState state, AltosListenerState listener_state) {
- if (state == null || state.drogue_sense == AltosRecord.MISSING)
+ if (state == null || state.apogee_voltage == AltosLib.MISSING)
hide();
else {
- show("%4.2f V", state.drogue_sense);
- lights.set(state.drogue_sense > 3.2);
+ show("%4.2f V", state.apogee_voltage);
+ lights.set(state.apogee_voltage >= AltosLib.ao_igniter_good);
}
}
public Apogee (GridBagLayout layout, int y) {
@@ -208,11 +208,11 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
class Main extends LaunchStatus {
void show (AltosState state, AltosListenerState listener_state) {
- if (state == null || state.main_sense == AltosRecord.MISSING)
+ if (state == null || state.main_voltage == AltosLib.MISSING)
hide();
else {
- show("%4.2f V", state.main_sense);
- lights.set(state.main_sense > 3.2);
+ show("%4.2f V", state.main_voltage);
+ lights.set(state.main_voltage >= AltosLib.ao_igniter_good);
}
}
public Main (GridBagLayout layout, int y) {
@@ -224,19 +224,19 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
class LoggingReady extends LaunchStatus {
void show (AltosState state, AltosListenerState listener_state) {
- if (state == null || state.data.flight == AltosRecord.MISSING) {
+ if (state == null || state.flight == AltosLib.MISSING) {
hide();
} else {
- if (state.data.flight != 0) {
- if (state.data.state <= Altos.ao_flight_pad)
+ if (state.flight != 0) {
+ if (state.state <= Altos.ao_flight_pad)
show("Ready to record");
- else if (state.data.state < Altos.ao_flight_landed)
+ else if (state.state < Altos.ao_flight_landed)
show("Recording data");
else
show("Recorded data");
} else
show("Storage full");
- lights.set(state.data.flight != 0);
+ lights.set(state.flight != 0);
}
}
public LoggingReady (GridBagLayout layout, int y) {
@@ -283,11 +283,11 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
class ReceiverBattery extends LaunchStatus {
void show (AltosState state, AltosListenerState listener_state) {
- if (listener_state == null || listener_state.battery == AltosRecord.MISSING)
+ if (listener_state == null || listener_state.battery == AltosLib.MISSING)
hide();
else {
show("%4.2f V", listener_state.battery);
- lights.set(listener_state.battery > 3.7);
+ lights.set(listener_state.battery > AltosLib.ao_battery_good);
}
}
public ReceiverBattery (GridBagLayout layout, int y) {
@@ -310,17 +310,23 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
class PadLat extends LaunchValue {
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");
+ double lat = AltosLib.MISSING;
+ String label = null;
+
+ if (state != null) {
+ if (state.state < AltosLib.ao_flight_pad && state.gps != null && state.gps.lat != AltosLib.MISSING) {
+ lat = state.gps.lat;
+ label = "Latitude";
+ } else {
+ lat = state.pad_lat;
+ label = "Pad Latitude";
}
}
+ if (lat != AltosLib.MISSING) {
+ show(pos(lat,"N", "S"));
+ set_label(label);
+ } else
+ hide();
}
public PadLat (GridBagLayout layout, int y) {
super (layout, y, "Pad Latitude");
@@ -331,17 +337,23 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
class PadLon extends LaunchValue {
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");
+ double lon = AltosLib.MISSING;
+ String label = null;
+
+ if (state != null) {
+ if (state.state < AltosLib.ao_flight_pad && state.gps != null && state.gps.lon != AltosLib.MISSING) {
+ lon = state.gps.lon;
+ label = "Longitude";
+ } else {
+ lon = state.pad_lon;
+ label = "Pad Longitude";
}
}
+ if (lon != AltosLib.MISSING) {
+ show(pos(lon,"E", "W"));
+ set_label(label);
+ } else
+ hide();
}
public PadLon (GridBagLayout layout, int y) {
super (layout, y, "Pad Longitude");
@@ -352,21 +364,23 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
class PadAlt extends LaunchValue {
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");
+ double alt = AltosLib.MISSING;
+ String label = null;
+
+ if (state != null) {
+ if (state.state < AltosLib.ao_flight_pad && state.gps != null && state.gps.alt != AltosLib.MISSING) {
+ alt = state.gps.alt;
+ label = "Altitude";
} else {
- if (state.pad_alt == AltosRecord.MISSING)
- hide();
- else {
- show("%4.0f m", state.pad_alt);
- set_label("Pad Altitude");
- }
+ alt = state.pad_alt;
+ label = "Pad Altitude";
}
}
+ if (alt != AltosLib.MISSING) {
+ show("%4.0f m", state.gps.alt);
+ set_label(label);
+ } else
+ hide();
}
public PadAlt (GridBagLayout layout, int y) {
super (layout, y, "Pad Altitude");
diff --git a/altosui/AltosRomconfigUI.java b/altosui/AltosRomconfigUI.java
index 909e72a0..fa780125 100644
--- a/altosui/AltosRomconfigUI.java
+++ b/altosui/AltosRomconfigUI.java
@@ -20,7 +20,7 @@ package altosui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosRomconfigUI
@@ -91,7 +91,7 @@ public class AltosRomconfigUI
c.anchor = GridBagConstraints.LINE_START;
c.insets = ir;
c.ipady = 5;
- radio_calibration_value = new JTextField("1186611");
+ radio_calibration_value = new JTextField("0");
pane.add(radio_calibration_value, c);
/* Buttons */
diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java
index 0c903873..a5ccb15a 100644
--- a/altosui/AltosScanUI.java
+++ b/altosui/AltosScanUI.java
@@ -25,7 +25,7 @@ import java.io.*;
import java.util.*;
import java.text.*;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
class AltosScanResult {
@@ -184,13 +184,13 @@ public class AltosScanUI
try {
for (;;) {
try {
- AltosRecord record = reader.read();
- if (record == null)
+ AltosState state = reader.read();
+ if (state == null)
continue;
- if ((record.seen & AltosRecord.seen_flight) != 0) {
- final AltosScanResult result = new AltosScanResult(record.callsign,
- record.serial,
- record.flight,
+ if (state.flight != AltosLib.MISSING) {
+ final AltosScanResult result = new AltosScanResult(state.callsign,
+ state.serial,
+ state.flight,
frequencies[frequency_index],
telemetry);
Runnable r = new Runnable() {
diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java
index e869f1ab..5e9322e5 100644
--- a/altosui/AltosSerial.java
+++ b/altosui/AltosSerial.java
@@ -25,7 +25,7 @@ import java.io.*;
import java.util.*;
import java.awt.*;
import javax.swing.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
import libaltosJNI.*;
@@ -57,11 +57,8 @@ public class AltosSerial extends AltosLink {
public void flush_output() {
super.flush_output();
if (altos != null) {
- if (libaltos.altos_flush(altos) != 0) {
- libaltos.altos_close(altos);
- altos = null;
- abort_reply();
- }
+ if (libaltos.altos_flush(altos) != 0)
+ close_serial();
}
}
@@ -122,6 +119,17 @@ public class AltosSerial extends AltosLink {
SwingUtilities.invokeLater(r);
}
+ private void close_serial() {
+ synchronized (devices_opened) {
+ devices_opened.remove(device.getPath());
+ }
+ if (altos != null) {
+ libaltos.altos_free(altos);
+ altos = null;
+ }
+ abort_reply();
+ }
+
public void close() {
if (remote) {
try {
@@ -132,35 +140,33 @@ public class AltosSerial extends AltosLink {
if (in_reply != 0)
System.out.printf("Uh-oh. Closing active serial device\n");
- if (altos != null) {
- libaltos.altos_close(altos);
- }
+ close_serial();
+
if (input_thread != null) {
try {
input_thread.interrupt();
input_thread.join();
- } catch (InterruptedException e) {
+ } catch (InterruptedException ie) {
}
input_thread = null;
}
- if (altos != null) {
- libaltos.altos_free(altos);
- altos = null;
- }
- synchronized (devices_opened) {
- devices_opened.remove(device.getPath());
- }
if (debug)
System.out.printf("Closing %s\n", device.getPath());
}
private void putc(char c) {
if (altos != null)
- if (libaltos.altos_putchar(altos, c) != 0) {
- libaltos.altos_close(altos);
- altos = null;
- abort_reply();
- }
+ if (libaltos.altos_putchar(altos, c) != 0)
+ close_serial();
+ }
+
+ public void putchar(byte c) {
+ if (altos != null) {
+ if (debug)
+ System.out.printf(" %02x", (int) c & 0xff);
+ if (libaltos.altos_putchar(altos, (char) c) != 0)
+ close_serial();
+ }
}
public void print(String data) {
diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java
index 23085f3e..9491ce2b 100644
--- a/altosui/AltosSiteMap.java
+++ b/altosui/AltosSiteMap.java
@@ -23,7 +23,7 @@ import java.io.*;
import java.lang.Math;
import java.awt.geom.Point2D;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
@@ -271,27 +271,34 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
int last_state = -1;
public void show(double lat, double lon) {
- initMaps(lat, lon);
- scrollRocketToVisible(pt(lat, lon));
+ System.out.printf ("show %g %g\n", lat, lon);
+ return;
+// initMaps(lat, lon);
+// scrollRocketToVisible(pt(lat, lon));
}
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)
+ AltosGPS gps = state.gps;
+
+ if (gps == null)
+ return;
+
+ if (!gps.locked && gps.nsat < 4)
return;
if (!initialised) {
- if (state.pad_lat != 0 || state.pad_lon != 0) {
+ if (state.pad_lat != AltosLib.MISSING && state.pad_lon != AltosLib.MISSING) {
initMaps(state.pad_lat, state.pad_lon);
initialised = true;
- } else if (state.gps.lat != 0 || state.gps.lon != 0) {
- initMaps(state.gps.lat, state.gps.lon);
+ } else if (gps.lat != AltosLib.MISSING && gps.lon != AltosLib.MISSING) {
+ initMaps(gps.lat, gps.lon);
initialised = true;
} else {
return;
}
}
- final Point2D.Double pt = pt(state.gps.lat, state.gps.lon);
+ final Point2D.Double pt = pt(gps.lat, gps.lon);
if (last_pt == pt && last_state == state.state)
return;
diff --git a/altosui/AltosSiteMapTile.java b/altosui/AltosSiteMapTile.java
index 365e4b6c..172e6397 100644
--- a/altosui/AltosSiteMapTile.java
+++ b/altosui/AltosSiteMapTile.java
@@ -22,7 +22,7 @@ import java.awt.image.*;
import javax.swing.*;
import java.awt.geom.Point2D;
import java.awt.geom.Line2D;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosSiteMapTile extends JLayeredPane {
JLabel mapLabel;
diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java
index 9f8f6dda..9dad8718 100644
--- a/altosui/AltosUI.java
+++ b/altosui/AltosUI.java
@@ -22,7 +22,7 @@ import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import org.altusmetrum.altosuilib_1.*;
public class AltosUI extends AltosUIFrame {
@@ -290,9 +290,9 @@ public class AltosUI extends AltosUIFrame {
AltosDataChooser chooser = new AltosDataChooser(
AltosUI.this);
- AltosRecordIterable iterable = chooser.runDialog();
- if (iterable != null) {
- AltosFlightReader reader = new AltosReplayReader(iterable.iterator(),
+ Iterable<AltosState> states = chooser.runDialog();
+ if (states != null) {
+ AltosFlightReader reader = new AltosReplayReader(states.iterator(),
chooser.file());
new AltosFlightUI(voice, reader);
}
@@ -312,10 +312,10 @@ public class AltosUI extends AltosUIFrame {
private void ExportData() {
AltosDataChooser chooser;
chooser = new AltosDataChooser(this);
- AltosRecordIterable record_reader = chooser.runDialog();
- if (record_reader == null)
+ AltosStateIterable states = chooser.runDialog();
+ if (states == null)
return;
- new AltosCSVUI(AltosUI.this, record_reader, chooser.file());
+ new AltosCSVUI(AltosUI.this, states, chooser.file());
}
/* Load a flight log CSV file and display a pretty graph.
@@ -324,11 +324,11 @@ public class AltosUI extends AltosUIFrame {
private void GraphData() {
AltosDataChooser chooser;
chooser = new AltosDataChooser(this);
- AltosRecordIterable record_reader = chooser.runDialog();
- if (record_reader == null)
+ AltosStateIterable states = chooser.runDialog();
+ if (states == null)
return;
try {
- new AltosGraphUI(record_reader, chooser.file());
+ new AltosGraphUI(states, chooser.file());
} catch (InterruptedException ie) {
} catch (IOException ie) {
}
@@ -345,17 +345,15 @@ public class AltosUI extends AltosUIFrame {
}
}
- static AltosRecordIterable open_logfile(File file) {
+ static AltosStateIterable open_logfile(File file) {
try {
FileInputStream in;
in = new FileInputStream(file);
- if (file.getName().endsWith("eeprom"))
- return new AltosEepromIterable(in);
- else if (file.getName().endsWith("mega"))
- return new AltosEepromMegaIterable(in);
+ if (file.getName().endsWith("telem"))
+ return new AltosTelemetryFile(in);
else
- return new AltosTelemetryIterable(in);
+ return new AltosEepromFile(in);
} catch (FileNotFoundException fe) {
System.out.printf("%s\n", fe.getMessage());
return null;
@@ -386,10 +384,11 @@ public class AltosUI extends AltosUIFrame {
static final int process_graph = 3;
static final int process_replay = 4;
static final int process_summary = 5;
+ static final int process_cat = 6;
static boolean process_csv(File input) {
- AltosRecordIterable iterable = open_logfile(input);
- if (iterable == null)
+ AltosStateIterable states = open_logfile(input);
+ if (states == null)
return false;
File output = Altos.replace_extension(input,".csv");
@@ -401,15 +400,15 @@ public class AltosUI extends AltosUIFrame {
AltosWriter writer = open_csv(output);
if (writer == null)
return false;
- writer.write(iterable);
+ writer.write(states);
writer.close();
}
return true;
}
static boolean process_kml(File input) {
- AltosRecordIterable iterable = open_logfile(input);
- if (iterable == null)
+ AltosStateIterable states = open_logfile(input);
+ if (states == null)
return false;
File output = Altos.replace_extension(input,".kml");
@@ -421,13 +420,13 @@ public class AltosUI extends AltosUIFrame {
AltosWriter writer = open_kml(output);
if (writer == null)
return false;
- writer.write(iterable);
+ writer.write(states);
writer.close();
return true;
}
}
- static AltosRecordIterable record_iterable(File file) {
+ static AltosStateIterable record_iterable(File file) {
FileInputStream in;
try {
in = new FileInputStream(file);
@@ -435,23 +434,17 @@ public class AltosUI extends AltosUIFrame {
System.out.printf("Failed to open file '%s'\n", file);
return null;
}
- AltosRecordIterable recs;
- //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;
+ if (file.getName().endsWith("telem"))
+ return new AltosTelemetryFile(in);
+ else
+ return new AltosEepromFile(in);
}
static AltosReplayReader replay_file(File file) {
- AltosRecordIterable recs = record_iterable(file);
- if (recs == null)
+ AltosStateIterable states = record_iterable(file);
+ if (states == null)
return null;
- return new AltosReplayReader(recs.iterator(), file);
+ return new AltosReplayReader(states.iterator(), file);
}
static boolean process_replay(File file) {
@@ -464,11 +457,11 @@ public class AltosUI extends AltosUIFrame {
}
static boolean process_graph(File file) {
- AltosRecordIterable recs = record_iterable(file);
- if (recs == null)
+ AltosStateIterable states = record_iterable(file);
+ if (states == null)
return false;
try {
- new AltosGraphUI(recs, file);
+ new AltosGraphUI(states, file);
return true;
} catch (InterruptedException ie) {
} catch (IOException ie) {
@@ -477,11 +470,11 @@ public class AltosUI extends AltosUIFrame {
}
static boolean process_summary(File file) {
- AltosRecordIterable iterable = record_iterable(file);
- if (iterable == null)
+ AltosStateIterable states = record_iterable(file);
+ if (states == null)
return false;
try {
- AltosFlightStats stats = new AltosFlightStats(iterable);
+ AltosFlightStats stats = new AltosFlightStats(states);
if (stats.serial > 0)
System.out.printf("Serial: %5d\n", stats.serial);
if (stats.flight > 0)
@@ -499,18 +492,18 @@ public class AltosUI extends AltosUIFrame {
stats.max_speed,
AltosConvert.meters_to_feet(stats.max_speed),
AltosConvert.meters_to_mach(stats.max_speed));
- if (stats.max_acceleration != AltosRecord.MISSING) {
+ if (stats.max_acceleration != AltosLib.MISSING) {
System.out.printf("Max accel: %6.0f m/s² %6.0f ft/s² %6.2f g\n",
stats.max_acceleration,
AltosConvert.meters_to_feet(stats.max_acceleration),
AltosConvert.meters_to_g(stats.max_acceleration));
}
System.out.printf("Drogue rate: %6.0f m/s %6.0f ft/s\n",
- stats.state_baro_speed[Altos.ao_flight_drogue],
- AltosConvert.meters_to_feet(stats.state_baro_speed[Altos.ao_flight_drogue]));
+ stats.state_speed[Altos.ao_flight_drogue],
+ AltosConvert.meters_to_feet(stats.state_speed[Altos.ao_flight_drogue]));
System.out.printf("Main rate: %6.0f m/s %6.0f ft/s\n",
- stats.state_baro_speed[Altos.ao_flight_main],
- AltosConvert.meters_to_feet(stats.state_baro_speed[Altos.ao_flight_main]));
+ stats.state_speed[Altos.ao_flight_main],
+ AltosConvert.meters_to_feet(stats.state_speed[Altos.ao_flight_main]));
System.out.printf("Flight time: %6.0f s\n",
stats.state_end[Altos.ao_flight_main] -
stats.state_start[Altos.ao_flight_boost]);
@@ -521,6 +514,29 @@ public class AltosUI extends AltosUIFrame {
return false;
}
+ static boolean process_cat(File file) {
+ try {
+ AltosStateIterable eef = record_iterable(file);
+
+ System.out.printf ("process cat\n");
+ for (AltosState state : eef) {
+ System.out.printf ("tick %d state %d height %g\n",
+ state.tick, state.state, state.height());
+ if ((state.set & AltosState.set_gps) != 0)
+ System.out.printf ("time %g lat %g lon %g alt %g\n",
+ state.time_since_boost(),
+ state.gps.lat,
+ state.gps.lon,
+ state.gps.alt);
+ }
+
+ } catch (Exception e) {
+ System.out.printf("Failed to open file '%s'\n", file);
+ return false;
+ }
+ return true;
+ }
+
public static void help(int code) {
System.out.printf("Usage: altosui [OPTION]... [FILE]...\n");
System.out.printf(" Options:\n");
@@ -570,6 +586,8 @@ public class AltosUI extends AltosUIFrame {
process = process_graph;
else if (args[i].equals("--summary"))
process = process_summary;
+ else if (args[i].equals("--cat"))
+ process = process_cat;
else if (args[i].startsWith("--"))
help(1);
else {
@@ -596,6 +614,9 @@ public class AltosUI extends AltosUIFrame {
if (!process_summary(file))
++errors;
break;
+ case process_cat:
+ if (!process_cat(file))
+ ++errors;
}
}
}
diff --git a/altosui/AltosUIPreferencesBackend.java b/altosui/AltosUIPreferencesBackend.java
index 0dac9fc7..fb5f8520 100644
--- a/altosui/AltosUIPreferencesBackend.java
+++ b/altosui/AltosUIPreferencesBackend.java
@@ -19,7 +19,7 @@ package altosui;
import java.io.File;
import java.util.prefs.*;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import javax.swing.filechooser.FileSystemView;
public class AltosUIPreferencesBackend implements AltosPreferencesBackend {
diff --git a/altosui/AltosWriter.java b/altosui/AltosWriter.java
index 2f70b472..d664d6e8 100644
--- a/altosui/AltosWriter.java
+++ b/altosui/AltosWriter.java
@@ -17,14 +17,14 @@
package altosui;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public interface AltosWriter {
- public void write(AltosRecord record);
+ public void write(AltosState state);
- public void write(AltosRecordIterable iterable);
+ public void write(AltosStateIterable states);
public void close();
}
diff --git a/altosui/Makefile.am b/altosui/Makefile.am
index 78e29cd8..824ec9e1 100644
--- a/altosui/Makefile.am
+++ b/altosui/Makefile.am
@@ -1,6 +1,6 @@
JAVAROOT=classes
-AM_JAVACFLAGS=-encoding UTF-8 -Xlint:deprecation
+AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -source 6
man_MANS=altosui.1
@@ -34,10 +34,8 @@ altosui_JAVA = \
AltosDeviceUIDialog.java \
AltosDisplayThread.java \
AltosEepromDelete.java \
- AltosEepromDownload.java \
- AltosEepromList.java \
AltosEepromManage.java \
- AltosEepromMonitor.java \
+ AltosEepromMonitorUI.java \
AltosEepromSelect.java \
AltosFlashUI.java \
AltosFlightDisplay.java \
@@ -137,26 +135,35 @@ ICONJAR= -C $(ICONDIR) altus-metrum-16.png \
WINDOWS_ICON=$(ICONDIR)/altus-metrum.ico
# Firmware
-FIRMWARE_TD_0_2=$(top_srcdir)/src/teledongle-v0.2-$(VERSION).ihx
+FIRMWARE_TD_0_2=$(top_srcdir)/src/teledongle-v0.2/teledongle-v0.2-$(VERSION).ihx
FIRMWARE_TD=$(FIRMWARE_TD_0_2)
-FIRMWARE_TM_1_0=$(top_srcdir)/src/telemetrum-v1.0-$(VERSION).ihx
-FIRMWARE_TM_1_1=$(top_srcdir)/src/telemetrum-v1.1-$(VERSION).ihx
-FIRMWARE_TM_1_2=$(top_srcdir)/src/telemetrum-v1.2-$(VERSION).ihx
+FIRMWARE_TM_1_0=$(top_srcdir)/src/telemetrum-v1.0/telemetrum-v1.0-$(VERSION).ihx
+FIRMWARE_TM_1_1=$(top_srcdir)/src/telemetrum-v1.1/telemetrum-v1.1-$(VERSION).ihx
+FIRMWARE_TM_1_2=$(top_srcdir)/src/telemetrum-v1.2/telemetrum-v1.2-$(VERSION).ihx
FIRMWARE_TM=$(FIRMWARE_TM_1_0) $(FIRMWARE_TM_1_1) $(FIRMWARE_TM_1_2)
-FIRMWARE_TELEMINI_1_0=$(top_srcdir)/src/telemini-v1.0-$(VERSION).ihx
+FIRMWARE_TELEMINI_1_0=$(top_srcdir)/src/telemini-v1.0/telemini-v1.0-$(VERSION).ihx
FIRMWARE_TELEMINI=$(FIRMWARE_TELEMINI_1_0)
-FIRMWARE_TBT_1_0=$(top_srcdir)/src/telebt-v1.0-$(VERSION).ihx
+FIRMWARE_TBT_1_0=$(top_srcdir)/src/telebt-v1.0/telebt-v1.0-$(VERSION).ihx
FIRMWARE_TBT=$(FIRMWARE_TBT_1_0)
-FIRMWARE=$(FIRMWARE_TM) $(FIRMWARE_TELEMINI) $(FIRMWARE_TD) $(FIRMWARE_TBT)
+FIRMWARE_TMEGA_1_0=$(top_srcdir)/src/telemega-v1.0/telemega-v1.0-$(VERSION).ihx
+FIRMWARE_TMEGA=$(FIRMWARE_TMEGA_1_0)
+
+FIRMWARE_EMINI_1_0=$(top_srcdir)/src/easymini-v1.0/easymini-v1.0-$(VERSION).ihx
+
+FIRMWARE=$(FIRMWARE_TM) $(FIRMWARE_TELEMINI) $(FIRMWARE_TD) $(FIRMWARE_TBT) $(FIRMWARE_TMEGA) $(FIRMWARE_EMINI)
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/telemega-outline.pdf
+TEMPLATE_DOC=\
+ $(top_srcdir)/doc/telemetrum-outline.pdf \
+ $(top_srcdir)/doc/easymini-outline.pdf \
+ $(top_srcdir)/doc/telemega-outline.pdf \
+ $(top_srcdir)/doc/easymini-outline.pdf
DOC=$(ALTUSMETRUM_DOC) $(ALTOS_DOC) $(TELEMETRY_DOC) $(TEMPLATE_DOC)
@@ -171,7 +178,7 @@ 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) ReadMe-Mac.rtf
+MACOSX_FILES=$(FAT_FILES) libaltos.dylib $(MACOSX_INFO_PLIST) $(DOC) ReadMe-Mac.rtf
MACOSX_EXTRA=$(FIRMWARE)
WINDOWS_FILES=$(FAT_FILES) altos.dll altos64.dll $(top_srcdir)/telemetrum.inf $(WINDOWS_ICON)
@@ -322,6 +329,8 @@ $(MACOSX_DIST): $(MACOSX_FILES) $(MACOSX_EXTRA) Makefile
mkdir macosx
cp -a AltosUI.app macosx/
cp -a ReadMe-Mac.rtf macosx/ReadMe.rtf
+ mkdir -p macosx/Doc
+ cp -a $(DOC) macosx/Doc
cp -p Info.plist macosx/AltosUI.app/Contents
mkdir -p macosx/AltOS-$(VERSION) macosx/AltosUI.app/Contents/Resources/Java
cp -p $(FATJAR) macosx/AltosUI.app/Contents/Resources/Java/altosui.jar
diff --git a/altosui/altos-windows.nsi.in b/altosui/altos-windows.nsi.in
index 81506bb0..779b0c12 100644
--- a/altosui/altos-windows.nsi.in
+++ b/altosui/altos-windows.nsi.in
@@ -121,6 +121,8 @@ Section "TeleMetrum, TeleDongle and TeleBT Firmware"
File "../src/telemini-v1.0/telemini-v1.0-${VERSION}.ihx"
File "../src/teledongle-v0.2/teledongle-v0.2-${VERSION}.ihx"
File "../src/telebt-v1.0/telebt-v1.0-${VERSION}.ihx"
+ File "../src/telemega-v1.0/telemega-v1.0-${VERSION}.ihx"
+ File "../src/easymini-v1.0/easymini-v1.0-${VERSION}.ihx"
SectionEnd
@@ -133,6 +135,7 @@ Section "Documentation"
File "../doc/telemetry.pdf"
File "../doc/telemetrum-outline.pdf"
File "../doc/telemega-outline.pdf"
+ File "../doc/easymini-outline.pdf"
SectionEnd
Section "Uninstaller"