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 public AltosDataPointReader(Iterable<AltosRecord> reader) {
19 this.iter = reader.iterator();
23 private void read_next_record()
24 throws NoSuchElementException
27 state = new AltosState(record, state);
30 private AltosDataPoint current_dp() {
31 assert this.record != null;
33 return new AltosDataPoint() {
34 public int version() { return record.version; }
35 public int serial() { return record.serial; }
36 public int flight() { return record.flight; }
37 public String callsign() { return record.callsign; }
38 public double time() { return record.time; }
39 public double rssi() { return record.rssi; }
41 public int state() { return record.state; }
42 public String state_name() { return record.state(); }
44 public double acceleration() { return record.acceleration(); }
45 public double pressure() { return record.raw_pressure(); }
46 public double altitude() { return record.raw_altitude(); }
47 public double height() { return record.raw_height(); }
48 public double accel_speed() { return record.accel_speed(); }
49 public double baro_speed() { return state.baro_speed; }
50 public double temperature() { return record.temperature(); }
51 public double battery_voltage() { return record.battery_voltage(); }
52 public double drogue_voltage() { return record.drogue_voltage(); }
53 public double main_voltage() { return record.main_voltage(); }
57 public Iterator<AltosDataPoint> iterator() {
58 return new Iterator<AltosDataPoint>() {
59 public void remove() {
60 throw new UnsupportedOperationException();
62 public boolean hasNext() {
63 return iter.hasNext();
65 public AltosDataPoint next() {