Eliminates a bogus axis and data line for devices which do not have an
accelerometer.
Signed-off-by: Keith Packard <keithp@keithp.com>
Iterator<AltosRecord> iter;
AltosState state;
AltosRecord record;
Iterator<AltosRecord> iter;
AltosState state;
AltosRecord record;
+ boolean has_gps;
+ boolean has_accel;
+ boolean has_ignite;
final static int MISSING = AltosRecord.MISSING;
final static int MISSING = AltosRecord.MISSING;
- public AltosDataPointReader(Iterable<AltosRecord> reader) {
+ public AltosDataPointReader(AltosRecordIterable reader) {
this.iter = reader.iterator();
this.state = null;
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()
}
private void read_next_record()
public double acceleration() { return record.acceleration(); }
public double pressure() { return record.raw_pressure(); }
public double altitude() { return record.raw_altitude(); }
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(); }
public double accel_speed() { return record.accel_speed(); }
public double baro_speed() { return state.baro_speed; }
public double temperature() { return record.temperature(); }
+ 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)
public int compareTo(AltosOrderedRecord o) {
int tick_diff = tick - o.tick;
if (tick_diff != 0)
static final int seen_gps_lat = 32;
static final int seen_gps_lon = 64;
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;
AltosEepromRecord flight_record;
AltosEepromRecord gps_date_record;
state.flight_vel += (state.accel_plus_g - state.accel);
}
eeprom.seen |= seen_sensor;
state.flight_vel += (state.accel_plus_g - state.accel);
}
eeprom.seen |= seen_sensor;
break;
case Altos.AO_LOG_HEIGHT:
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:
eeprom.seen |= seen_sensor;
break;
case Altos.AO_LOG_TEMP_VOLT:
state.drogue = record.a;
state.main = record.b;
eeprom.seen |= seen_deploy;
state.drogue = record.a;
state.main = record.b;
eeprom.seen |= seen_deploy;
break;
case Altos.AO_LOG_STATE:
state.state = record.a;
break;
case Altos.AO_LOG_STATE:
state.state = record.a;
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;
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;
break;
case Altos.AO_LOG_GPS_LAT:
int lat32 = record.a | (record.b << 16);
break;
case Altos.AO_LOG_GPS_LAT:
int lat32 = record.a | (record.b << 16);
return list.iterator();
}
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");
public void write_comments(PrintStream out) {
Iterator<AltosOrderedRecord> iterator = records.iterator();
out.printf("# Comments\n");
public ArrayList<AltosGraph> graphs() {
ArrayList<AltosGraph> graphs = new ArrayList<AltosGraph>();
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) );
graphs.add( myAltosGraphTime("Altitude")
.addElement(height) );
graphs.add( myAltosGraphTime("Speed")
.addElement(speed) );
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("Temperature")
.addElement(temperature) );
- graphs.add( myAltosGraphTime("Continuity")
- .addElement(drogue_voltage)
- .addElement(main_voltage) );
+ graphs.add( myAltosGraphTime("Continuity")
+ .addElement(drogue_voltage)
+ .addElement(main_voltage) );
public AltosGraphUI(AltosRecordIterable records) {
super("Altos Graph");
public AltosGraphUI(AltosRecordIterable records) {
super("Altos Graph");
- Iterable<AltosDataPoint> reader = new AltosDataPointReader (records);
+ AltosDataPointReader reader = new AltosDataPointReader (records);
if (reader == null)
return;
if (reader == null)
return;
+ 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);
}
{
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();
AltosGraph graph = createGraph(data, which);
JFreeChart chart = graph.createChart();
double g = ground_altitude();
if (r == MISSING || g == MISSING)
double g = ground_altitude();
if (r == MISSING || g == MISSING)
ground_pres = old.ground_pres;
accel_plus_g = old.accel_plus_g;
accel_minus_g = old.accel_minus_g;
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);
}
gps = new AltosGPS(old.gps);
}
status = 0;
state = Altos.ao_flight_startup;
tick = 0;
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;
flight_accel = 0;
ground_accel = 0;
flight_vel = 0;
ground_pres = 0;
accel_plus_g = 0;
accel_minus_g = 0;
ground_pres = 0;
accel_plus_g = 0;
accel_minus_g = 0;
+ acceleration = MISSING;
+ speed = MISSING;
+ height = MISSING;
gps = new AltosGPS();
}
}
gps = new AltosGPS();
}
}
public abstract class AltosRecordIterable implements Iterable<AltosRecord> {
public abstract Iterator<AltosRecord> iterator();
public void write_comments(PrintStream out) { }
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; };
return records.iterator();
}
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;
public AltosTelemetryIterable (FileInputStream input) {
boolean saw_boost = false;
int current_tick = 0;
saw_boost = true;
boost_tick = record.tick;
}
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());
records.add(record);
} catch (ParseException pe) {
System.out.printf("parse exception %s\n", pe.getMessage());