altosui: Remove unused AltosConfigData from AltosTelemetryReader
[fw/altos] / altosui / AltosTelemetryReader.java
index 6c5a93978c69a4156e0e44fe3b94b3ea7a9c92c0..6abe95d8f3b917680bdc0a91317f3727c8a03eb9 100644 (file)
@@ -26,6 +26,9 @@ class AltosTelemetryReader extends AltosFlightReader {
        AltosDevice     device;
        AltosSerial     serial;
        AltosLog        log;
+       AltosRecord     previous;
+       double          frequency;
+       int             telemetry;
 
        LinkedBlockingQueue<AltosLine> telem;
 
@@ -33,7 +36,13 @@ class AltosTelemetryReader extends AltosFlightReader {
                AltosLine l = telem.take();
                if (l.line == null)
                        throw new IOException("IO error");
-               return new AltosTelemetry(l.line);
+               AltosRecord     next = AltosTelemetry.parse(l.line, previous);
+               previous = next;
+               return next;
+       }
+
+       void flush() {
+               telem.clear();
        }
 
        void close(boolean interrupted) {
@@ -42,20 +51,38 @@ class AltosTelemetryReader extends AltosFlightReader {
                serial.close();
        }
 
-       void set_channel(int channel) {
-               serial.set_channel(channel);
-               AltosPreferences.set_channel(device.getSerial(), channel);
+       public void set_frequency(double in_frequency) throws InterruptedException, TimeoutException {
+               frequency = in_frequency;
+               serial.set_radio_frequency(frequency);
+       }
+
+       void save_frequency() {
+               AltosPreferences.set_frequency(device.getSerial(), frequency);
+       }
+
+       void set_telemetry(int in_telemetry) {
+               telemetry = in_telemetry;
+               serial.set_telemetry(telemetry);
+       }
+
+       void save_telemetry() {
+               AltosPreferences.set_telemetry(device.getSerial(), telemetry);
        }
 
        public AltosTelemetryReader (AltosDevice in_device)
-               throws FileNotFoundException, AltosSerialInUseException, IOException {
+               throws FileNotFoundException, AltosSerialInUseException, IOException, InterruptedException, TimeoutException {
                device = in_device;
                serial = new AltosSerial(device);
                log = new AltosLog(serial);
                name = device.toShortString();
+               previous = null;
 
                telem = new LinkedBlockingQueue<AltosLine>();
-               serial.set_radio();
+               frequency = AltosPreferences.frequency(device.getSerial());
+               set_frequency(frequency);
+               telemetry = AltosPreferences.telemetry(device.getSerial());
+               set_telemetry(telemetry);
+               serial.set_callsign(AltosPreferences.callsign());
                serial.add_monitor(telem);
        }
 }