summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-03-30 11:48:03 -0700
committerKeith Packard <keithp@keithp.com>2011-03-30 11:48:03 -0700
commitf558cfa1df77c36a459168c1953d0945ee5a7f9f (patch)
tree4fbc53c7ab676252acde905c6d85518a9d341da7
parenta9df9fc257eb2d7038d66ac7c2539aae4474bf12 (diff)
altosui: Only plot acceleration when present in data file
Eliminates a bogus axis and data line for devices which do not have an accelerometer. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--altosui/AltosDataPointReader.java10
-rw-r--r--altosui/AltosEepromIterable.java20
-rw-r--r--altosui/AltosGraphUI.java33
-rw-r--r--altosui/AltosRecord.java20
-rw-r--r--altosui/AltosRecordIterable.java3
-rw-r--r--altosui/AltosTelemetryIterable.java13
6 files changed, 75 insertions, 24 deletions
diff --git a/altosui/AltosDataPointReader.java b/altosui/AltosDataPointReader.java
index ee57d2ce..4335421c 100644
--- a/altosui/AltosDataPointReader.java
+++ b/altosui/AltosDataPointReader.java
@@ -14,12 +14,18 @@ class AltosDataPointReader implements Iterable<AltosDataPoint> {
Iterator<AltosRecord> iter;
AltosState state;
AltosRecord record;
+ boolean has_gps;
+ boolean has_accel;
+ boolean has_ignite;
final static int MISSING = AltosRecord.MISSING;
- public AltosDataPointReader(Iterable<AltosRecord> reader) {
+ public AltosDataPointReader(AltosRecordIterable reader) {
this.iter = reader.iterator();
this.state = null;
+ has_accel = reader.has_accel();
+ has_gps = reader.has_gps();
+ has_ignite = reader.has_ignite();
}
private void read_next_record()
@@ -46,7 +52,7 @@ class AltosDataPointReader implements Iterable<AltosDataPoint> {
public double acceleration() { return record.acceleration(); }
public double pressure() { return record.raw_pressure(); }
public double altitude() { return record.raw_altitude(); }
- public double height() { return record.raw_height(); }
+ public double height() { return record.raw_height(); }
public double accel_speed() { return record.accel_speed(); }
public double baro_speed() { return state.baro_speed; }
public double temperature() { return record.temperature(); }
diff --git a/altosui/AltosEepromIterable.java b/altosui/AltosEepromIterable.java
index a7fd742f..624e1dd3 100644
--- a/altosui/AltosEepromIterable.java
+++ b/altosui/AltosEepromIterable.java
@@ -57,6 +57,11 @@ class AltosOrderedRecord extends AltosEepromRecord implements Comparable<AltosOr
index = in_index;
}
+ public String toString() {
+ return String.format("%d.%d %04x %04x %04x",
+ cmd, index, tick, a, b);
+ }
+
public int compareTo(AltosOrderedRecord o) {
int tick_diff = tick - o.tick;
if (tick_diff != 0)
@@ -75,7 +80,11 @@ public class AltosEepromIterable extends AltosRecordIterable {
static final int seen_gps_lat = 32;
static final int seen_gps_lon = 64;
- static final int seen_basic = seen_flight|seen_sensor|seen_temp_volt|seen_deploy;
+ static final int seen_basic = seen_flight|seen_sensor;
+
+ boolean has_accel;
+ boolean has_gps;
+ boolean has_ignite;
AltosEepromRecord flight_record;
AltosEepromRecord gps_date_record;
@@ -123,9 +132,10 @@ public class AltosEepromIterable extends AltosRecordIterable {
state.flight_vel += (state.accel_plus_g - state.accel);
}
eeprom.seen |= seen_sensor;
+ has_accel = true;
break;
case Altos.AO_LOG_HEIGHT:
- state.height = record.a;
+ state.height = (short) record.a;
eeprom.seen |= seen_sensor;
break;
case Altos.AO_LOG_TEMP_VOLT:
@@ -137,6 +147,7 @@ public class AltosEepromIterable extends AltosRecordIterable {
state.drogue = record.a;
state.main = record.b;
eeprom.seen |= seen_deploy;
+ has_ignite = true;
break;
case Altos.AO_LOG_STATE:
state.state = record.a;
@@ -161,6 +172,7 @@ public class AltosEepromIterable extends AltosRecordIterable {
state.gps.locked = (flags & Altos.AO_GPS_VALID) != 0;
state.gps.nsat = (flags & Altos.AO_GPS_NUM_SAT_MASK) >>
Altos.AO_GPS_NUM_SAT_SHIFT;
+ has_gps = true;
break;
case Altos.AO_LOG_GPS_LAT:
int lat32 = record.a | (record.b << 16);
@@ -254,6 +266,10 @@ public class AltosEepromIterable extends AltosRecordIterable {
return list.iterator();
}
+ public boolean has_gps() { return has_gps; }
+ public boolean has_accel() { return has_accel; }
+ public boolean has_ignite() { return has_ignite; }
+
public void write_comments(PrintStream out) {
Iterator<AltosOrderedRecord> iterator = records.iterator();
out.printf("# Comments\n");
diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java
index cd158651..e98c302b 100644
--- a/altosui/AltosGraphUI.java
+++ b/altosui/AltosGraphUI.java
@@ -96,10 +96,14 @@ public class AltosGraphUI extends JFrame
public ArrayList<AltosGraph> graphs() {
ArrayList<AltosGraph> graphs = new ArrayList<AltosGraph>();
- graphs.add( myAltosGraphTime("Summary")
- .addElement(height)
- .addElement(speed)
- .addElement(acceleration) );
+ graphs.add( myAltosGraphTime("Summary")
+ .addElement(height)
+ .addElement(speed)
+ .addElement(acceleration) );
+
+ graphs.add( myAltosGraphTime("Summary")
+ .addElement(height)
+ .addElement(speed));
graphs.add( myAltosGraphTime("Altitude")
.addElement(height) );
@@ -107,15 +111,15 @@ public class AltosGraphUI extends JFrame
graphs.add( myAltosGraphTime("Speed")
.addElement(speed) );
- graphs.add( myAltosGraphTime("Acceleration")
- .addElement(acceleration) );
+ graphs.add( myAltosGraphTime("Acceleration")
+ .addElement(acceleration) );
graphs.add( myAltosGraphTime("Temperature")
.addElement(temperature) );
- graphs.add( myAltosGraphTime("Continuity")
- .addElement(drogue_voltage)
- .addElement(main_voltage) );
+ graphs.add( myAltosGraphTime("Continuity")
+ .addElement(drogue_voltage)
+ .addElement(main_voltage) );
return graphs;
}
@@ -154,20 +158,23 @@ public class AltosGraphUI extends JFrame
public AltosGraphUI(AltosRecordIterable records) {
super("Altos Graph");
- Iterable<AltosDataPoint> reader = new AltosDataPointReader (records);
+ AltosDataPointReader reader = new AltosDataPointReader (records);
if (reader == null)
return;
- init(reader, 0);
+ if (reader.has_accel)
+ init(reader, 0);
+ else
+ init(reader, 1);
}
- public AltosGraphUI(Iterable<AltosDataPoint> data, int which)
+ public AltosGraphUI(AltosDataPointReader data, int which)
{
super("Altos Graph");
init(data, which);
}
- private void init(Iterable<AltosDataPoint> data, int which) {
+ private void init(AltosDataPointReader data, int which) {
AltosGraph graph = createGraph(data, which);
JFreeChart chart = graph.createChart();
diff --git a/altosui/AltosRecord.java b/altosui/AltosRecord.java
index 46e96b95..200fffe5 100644
--- a/altosui/AltosRecord.java
+++ b/altosui/AltosRecord.java
@@ -139,7 +139,7 @@ public class AltosRecord {
double g = ground_altitude();
if (r == MISSING || g == MISSING)
- return MISSING;
+ return height;
return r - g;
}
@@ -246,6 +246,9 @@ public class AltosRecord {
ground_pres = old.ground_pres;
accel_plus_g = old.accel_plus_g;
accel_minus_g = old.accel_minus_g;
+ acceleration = old.acceleration;
+ speed = old.speed;
+ height = old.height;
gps = new AltosGPS(old.gps);
}
@@ -258,12 +261,12 @@ public class AltosRecord {
status = 0;
state = Altos.ao_flight_startup;
tick = 0;
- accel = 0;
- pres = 0;
- temp = 0;
- batt = 0;
- drogue = 0;
- main = 0;
+ accel = MISSING;
+ pres = MISSING;
+ temp = MISSING;
+ batt = MISSING;
+ drogue = MISSING;
+ main = MISSING;
flight_accel = 0;
ground_accel = 0;
flight_vel = 0;
@@ -271,6 +274,9 @@ public class AltosRecord {
ground_pres = 0;
accel_plus_g = 0;
accel_minus_g = 0;
+ acceleration = MISSING;
+ speed = MISSING;
+ height = MISSING;
gps = new AltosGPS();
}
}
diff --git a/altosui/AltosRecordIterable.java b/altosui/AltosRecordIterable.java
index a7df92d1..45843b92 100644
--- a/altosui/AltosRecordIterable.java
+++ b/altosui/AltosRecordIterable.java
@@ -31,4 +31,7 @@ import java.util.concurrent.LinkedBlockingQueue;
public abstract class AltosRecordIterable implements Iterable<AltosRecord> {
public abstract Iterator<AltosRecord> iterator();
public void write_comments(PrintStream out) { }
+ public boolean has_accel() { return false; }
+ public boolean has_gps() { return false; }
+ public boolean has_ignite() { return false; };
}
diff --git a/altosui/AltosTelemetryIterable.java b/altosui/AltosTelemetryIterable.java
index 14b5f27f..44e5ad8f 100644
--- a/altosui/AltosTelemetryIterable.java
+++ b/altosui/AltosTelemetryIterable.java
@@ -28,6 +28,13 @@ public class AltosTelemetryIterable extends AltosRecordIterable {
return records.iterator();
}
+ boolean has_gps = false;
+ boolean has_accel = false;
+ boolean has_ignite = false;
+ public boolean has_gps() { return has_gps; }
+ public boolean has_accel() { return has_accel; }
+ public boolean has_ignite() { return has_ignite; };
+
public AltosTelemetryIterable (FileInputStream input) {
boolean saw_boost = false;
int current_tick = 0;
@@ -59,6 +66,12 @@ public class AltosTelemetryIterable extends AltosRecordIterable {
saw_boost = true;
boost_tick = record.tick;
}
+ if (record.accel != AltosRecord.MISSING)
+ has_accel = true;
+ if (record.gps != null)
+ has_gps = true;
+ if (record.main != AltosRecord.MISSING)
+ has_ignite = true;
records.add(record);
} catch (ParseException pe) {
System.out.printf("parse exception %s\n", pe.getMessage());