2 // Copyright (c) 2010 Anthony Towns
7 import java.io.IOException;
8 import java.text.ParseException;
9 import java.lang.UnsupportedOperationException;
10 import java.util.NoSuchElementException;
11 import java.util.Iterator;
13 class AltosDataPointReader implements Iterable<AltosDataPoint> {
14 Iterator<AltosRecord> iter;
18 final static int MISSING = AltosRecord.MISSING;
20 public AltosDataPointReader(Iterable<AltosRecord> reader) {
21 this.iter = reader.iterator();
25 private void read_next_record()
26 throws NoSuchElementException
29 state = new AltosState(record, state);
32 private AltosDataPoint current_dp() {
33 assert this.record != null;
35 return new AltosDataPoint() {
36 public int version() { return record.version; }
37 public int serial() { return record.serial; }
38 public int flight() { return record.flight; }
39 public String callsign() { return record.callsign; }
40 public double time() { return record.time; }
41 public double rssi() { return record.rssi; }
43 public int state() { return record.state; }
44 public String state_name() { return record.state(); }
46 public double acceleration() { return record.acceleration(); }
47 public double pressure() { return record.raw_pressure(); }
48 public double altitude() { return record.raw_altitude(); }
49 public double height() { return record.raw_height(); }
50 public double accel_speed() { return record.accel_speed(); }
51 public double baro_speed() { return state.baro_speed; }
52 public double temperature() { return record.temperature(); }
53 public double battery_voltage() { return record.battery_voltage(); }
54 public double drogue_voltage() { return record.drogue_voltage(); }
55 public double main_voltage() { return record.main_voltage(); }
59 public Iterator<AltosDataPoint> iterator() {
60 return new Iterator<AltosDataPoint>() {
61 public void remove() {
62 throw new UnsupportedOperationException();
64 public boolean hasNext() {
65 return iter.hasNext();
67 public AltosDataPoint next() {