summaryrefslogtreecommitdiff
path: root/altosui
diff options
context:
space:
mode:
Diffstat (limited to 'altosui')
-rw-r--r--altosui/AltosAscent.java17
-rw-r--r--altosui/AltosCSV.java115
-rw-r--r--altosui/AltosCSVUI.java8
-rw-r--r--altosui/AltosCompanionInfo.java4
-rw-r--r--altosui/AltosDataChooser.java12
-rw-r--r--altosui/AltosDescent.java17
-rw-r--r--altosui/AltosDisplayThread.java12
-rw-r--r--altosui/AltosEepromDownload.java5
-rw-r--r--altosui/AltosFlightStats.java99
-rw-r--r--altosui/AltosFlightStatsTable.java8
-rw-r--r--altosui/AltosFlightStatus.java14
-rw-r--r--altosui/AltosFlightUI.java2
-rw-r--r--altosui/AltosGraphDataPoint.java17
-rw-r--r--altosui/AltosGraphDataSet.java31
-rw-r--r--altosui/AltosGraphUI.java13
-rw-r--r--altosui/AltosInfoTable.java20
-rw-r--r--altosui/AltosKML.java56
-rw-r--r--altosui/AltosLanded.java14
-rw-r--r--altosui/AltosPad.java28
-rw-r--r--altosui/AltosScanUI.java12
-rw-r--r--altosui/AltosSiteMap.java21
-rw-r--r--altosui/AltosUI.java106
-rw-r--r--altosui/AltosWriter.java4
23 files changed, 314 insertions, 321 deletions
diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java
index 4da4d591..f8435037 100644
--- a/altosui/AltosAscent.java
+++ b/altosui/AltosAscent.java
@@ -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");
@@ -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 > 3.7);
}
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 > 3.7);
}
public Main (GridBagLayout layout, int y) {
super(layout, y, "Main Igniter Voltage");
@@ -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 != AltosRecord.MISSING)
main.show(state, listener_state);
else
main.hide();
- if (state.drogue_sense != AltosRecord.MISSING)
+ if (state.apogee_voltage != AltosRecord.MISSING)
apogee.show(state, listener_state);
else
apogee.hide();
diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java
index 0676f99d..c96c815e 100644
--- a/altosui/AltosCSV.java
+++ b/altosui/AltosCSV.java
@@ -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) {
+ AltosRecordCompanion 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..4b48bdf6 100644
--- a/altosui/AltosCSVUI.java
+++ b/altosui/AltosCSVUI.java
@@ -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..1ed2c425 100644
--- a/altosui/AltosCompanionInfo.java
+++ b/altosui/AltosCompanionInfo.java
@@ -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/AltosDataChooser.java b/altosui/AltosDataChooser.java
index c7b561d5..af6c245b 100644
--- a/altosui/AltosDataChooser.java
+++ b/altosui/AltosDataChooser.java
@@ -36,7 +36,7 @@ public class AltosDataChooser extends JFileChooser {
return file;
}
- public AltosRecordIterable runDialog() {
+ public AltosStateIterable runDialog() {
int ret;
ret = showOpenDialog(frame);
@@ -48,16 +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);
- } else if (filename.endsWith("mini")) {
- FileInputStream in = new FileInputStream(file);
- return new AltosEepromMiniIterable(in);
+ return null; // new AltosTelemetryIterable(in);
} else {
throw new FileNotFoundException();
}
diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java
index 29d33ddc..2b6575cb 100644
--- a/altosui/AltosDescent.java
+++ b/altosui/AltosDescent.java
@@ -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");
@@ -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 > 3.7);
}
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 > 3.7);
}
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 != AltosRecord.MISSING)
main.show(state, listener_state);
else
main.hide();
- if (state.drogue_sense != AltosRecord.MISSING)
+ if (state.apogee_voltage != AltosRecord.MISSING)
apogee.show(state, listener_state);
else
apogee.hide();
diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java
index 095bed99..70144fb2 100644
--- a/altosui/AltosDisplayThread.java
+++ b/altosui/AltosDisplayThread.java
@@ -113,7 +113,7 @@ public class AltosDisplayThread extends Thread {
System.currentTimeMillis() - state.report_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,11 +181,11 @@ 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) {
@@ -218,11 +218,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/AltosEepromDownload.java b/altosui/AltosEepromDownload.java
index 46715db6..95b17e2a 100644
--- a/altosui/AltosEepromDownload.java
+++ b/altosui/AltosEepromDownload.java
@@ -418,8 +418,9 @@ public class AltosEepromDownload implements Runnable {
extension = "mega";
CaptureMega(eechunk);
break;
- case AltosLib.AO_LOG_FORMAT_MINI:
- extension = "mini";
+ case AltosLib.AO_LOG_FORMAT_EASYMINI:
+ case AltosLib.AO_LOG_FORMAT_TELEMINI:
+ extension = "eeprom";
CaptureMini(eechunk);
break;
}
diff --git a/altosui/AltosFlightStats.java b/altosui/AltosFlightStats.java
index dee31a8d..50deb6c8 100644
--- a/altosui/AltosFlightStats.java
+++ b/altosui/AltosFlightStats.java
@@ -24,8 +24,7 @@ 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,15 +39,18 @@ 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;
}
+ if (state == null)
+ return 0;
+
double landed_height = state.height;
state = null;
@@ -57,8 +59,8 @@ 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) {
above = true;
@@ -74,80 +76,70 @@ 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 = AltosRecord.MISSING;
+ AltosState state = null;
- for (AltosRecord record : iterable) {
- state = new AltosState(record, state);
-
+ for (AltosState s : states) {
+ state = s;
if (state.acceleration < 1)
boost_time = state.time;
if (state.state >= Altos.ao_flight_boost)
break;
}
- if (boost_time == -1000)
+ if (state == null)
+ return 0;
+
+ if (boost_time == AltosRecord.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 = AltosRecord.MISSING;
+ hour = minute = second = AltosRecord.MISSING;
+ serial = flight = AltosRecord.MISSING;
+ lat = lon = AltosRecord.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 == AltosRecord.MISSING && state.serial != AltosRecord.MISSING)
+ serial = state.serial;
+ if (flight == AltosRecord.MISSING && state.flight != AltosRecord.MISSING)
+ flight = state.flight;
+ if (state.battery_voltage != AltosRecord.MISSING)
has_other_adc = true;
- if (record.rssi != 0)
+ if (state.rssi != AltosRecord.MISSING)
has_rssi = true;
- new_state = new AltosState(record, state);
- end_time = new_state.time;
- state = new_state;
+ end_time = state.time;
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 (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.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;
- }
- }
state_accel[state.state] += state.acceleration;
- state_accel_speed[state.state] += state.accel_speed;
- state_baro_speed[state.state] += state.baro_speed;
+ state_speed[state.state] += state.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_speed = state.max_speed;
max_acceleration = state.max_acceleration;
}
if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) {
@@ -162,8 +154,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..f8a2d4de 100644
--- a/altosui/AltosFlightStatsTable.java
+++ b/altosui/AltosFlightStatsTable.java
@@ -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..0be7bb51 100644
--- a/altosui/AltosFlightStatus.java
+++ b/altosui/AltosFlightStatus.java
@@ -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 == AltosRecord.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 == AltosRecord.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");
diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java
index 6d010d23..423cf10c 100644
--- a/altosui/AltosFlightUI.java
+++ b/altosui/AltosFlightUI.java
@@ -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/AltosGraphDataPoint.java b/altosui/AltosGraphDataPoint.java
index 7454f447..537efc44 100644
--- a/altosui/AltosGraphDataPoint.java
+++ b/altosui/AltosGraphDataPoint.java
@@ -42,9 +42,10 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
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 {
@@ -63,16 +64,16 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
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;
@@ -106,7 +107,7 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
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;
@@ -116,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..1e469c8a 100644
--- a/altosui/AltosGraphDataSet.java
+++ b/altosui/AltosGraphDataSet.java
@@ -25,34 +25,31 @@ 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 != AltosRecord.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..376e9910 100644
--- a/altosui/AltosGraphUI.java
+++ b/altosui/AltosGraphUI.java
@@ -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/AltosInfoTable.java b/altosui/AltosInfoTable.java
index 3d16faf2..8601d76f 100644
--- a/altosui/AltosInfoTable.java
+++ b/altosui/AltosInfoTable.java
@@ -122,15 +122,15 @@ public class AltosInfoTable extends JTable {
if (state.speed() != AltosRecord.MISSING)
info_add_row(0, "Speed", "%8.1f m/s", state.speed());
if (state.speed() != AltosRecord.MISSING)
- info_add_row(0, "Max Speed", "%8.1f m/s", state.max_accel_speed);
+ info_add_row(0, "Max Speed", "%8.1f m/s", state.max_speed);
if (state.temperature != AltosRecord.MISSING)
info_add_row(0, "Temperature", "%9.2f °C", state.temperature);
- if (state.battery != AltosRecord.MISSING)
- info_add_row(0, "Battery", "%9.2f V", state.battery);
- if (state.drogue_sense != AltosRecord.MISSING)
- info_add_row(0, "Drogue", "%9.2f V", state.drogue_sense);
- if (state.main_sense != AltosRecord.MISSING)
- info_add_row(0, "Main", "%9.2f V", state.main_sense);
+ if (state.battery_voltage != AltosRecord.MISSING)
+ info_add_row(0, "Battery", "%9.2f V", state.battery_voltage);
+ if (state.apogee_voltage != AltosRecord.MISSING)
+ info_add_row(0, "Drogue", "%9.2f V", state.apogee_voltage);
+ if (state.main_voltage != AltosRecord.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);
@@ -148,13 +148,13 @@ 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_row(1, "Satellites", "%6d", state.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);
diff --git a/altosui/AltosKML.java b/altosui/AltosKML.java
index 140f3f07..b79f5c9e 100644
--- a/altosui/AltosKML.java
+++ b/altosui/AltosKML.java
@@ -24,8 +24,8 @@ 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 != AltosRecord.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 == AltosRecord.MISSING)
return;
- if ((record.seen & (AltosRecord.seen_gps_lon)) == 0)
+ if (gps.lon == AltosRecord.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 9dab52c4..38f273cf 100644
--- a/altosui/AltosLanded.java
+++ b/altosui/AltosLanded.java
@@ -243,24 +243,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);
- } else if (filename.endsWith("mini")) {
- FileInputStream in = new FileInputStream(file);
- records = new AltosEepromMiniIterable(in);
+ states = null; // new AltosTelemetryIterable(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..fed009cc 100644
--- a/altosui/AltosPad.java
+++ b/altosui/AltosPad.java
@@ -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 == AltosRecord.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 > 3.7);
}
}
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 == AltosRecord.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 > 3.7);
}
}
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 == AltosRecord.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 > 3.7);
}
}
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 == AltosRecord.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) {
diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java
index 0c903873..224e1e61 100644
--- a/altosui/AltosScanUI.java
+++ b/altosui/AltosScanUI.java
@@ -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 != AltosRecord.MISSING) {
+ final AltosScanResult result = new AltosScanResult(state.callsign,
+ state.serial,
+ state.flight,
frequencies[frequency_index],
telemetry);
Runnable r = new Runnable() {
diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java
index 23085f3e..c0926919 100644
--- a/altosui/AltosSiteMap.java
+++ b/altosui/AltosSiteMap.java
@@ -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 != AltosRecord.MISSING && state.pad_lon != AltosRecord.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 != AltosRecord.MISSING && gps.lon != AltosRecord.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/AltosUI.java b/altosui/AltosUI.java
index 4362e36c..b47df0d9 100644
--- a/altosui/AltosUI.java
+++ b/altosui/AltosUI.java
@@ -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,19 +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);
- else if (file.getName().endsWith("mini"))
- return new AltosEepromMiniIterable(in);
+ return new AltosEepromFile(in);
else
- return new AltosTelemetryIterable(in);
+ return new AltosTelemetryFile(in);
} catch (FileNotFoundException fe) {
System.out.printf("%s\n", fe.getMessage());
return null;
@@ -388,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");
@@ -403,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");
@@ -423,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);
@@ -437,25 +434,18 @@ 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 if (file.getName().endsWith("mini")) {
- recs = new AltosEepromMiniIterable(in);
+ return new AltosEepromFile(in);
} else {
- recs = new AltosTelemetryIterable(in);
+ return new AltosTelemetryFile(in);
}
- return recs;
}
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) {
@@ -468,11 +458,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) {
@@ -481,11 +471,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)
@@ -510,11 +500,11 @@ public class AltosUI extends AltosUIFrame {
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]);
@@ -525,6 +515,27 @@ 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) {
+ 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");
@@ -574,6 +585,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 {
@@ -600,6 +613,9 @@ public class AltosUI extends AltosUIFrame {
if (!process_summary(file))
++errors;
break;
+ case process_cat:
+ if (!process_cat(file))
+ ++errors;
}
}
}
diff --git a/altosui/AltosWriter.java b/altosui/AltosWriter.java
index 2f70b472..8de11bc9 100644
--- a/altosui/AltosWriter.java
+++ b/altosui/AltosWriter.java
@@ -22,9 +22,9 @@ import org.altusmetrum.altoslib_1.*;
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();
}