2 * Copyright © 2010 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 package org.altusmetrum.AltosLib;
23 import java.util.concurrent.*;
25 public class AltosTelemetryReader extends AltosFlightReader {
32 LinkedBlockingQueue<AltosLine> telem;
34 public AltosRecord read() throws InterruptedException, ParseException, AltosCRCException, IOException {
35 AltosLine l = telem.take();
37 throw new IOException("IO error");
38 AltosRecord next = AltosTelemetry.parse(l.line, previous);
47 public void close(boolean interrupted) {
48 link.remove_monitor(telem);
53 public void set_frequency(double in_frequency) throws InterruptedException, TimeoutException {
54 frequency = in_frequency;
55 link.set_radio_frequency(frequency);
58 public void save_frequency() {
59 AltosPreferences.set_frequency(link.serial, frequency);
62 public void set_telemetry(int in_telemetry) {
63 telemetry = in_telemetry;
64 link.set_telemetry(telemetry);
67 public void save_telemetry() {
68 AltosPreferences.set_telemetry(link.serial, telemetry);
71 public void set_monitor(boolean monitor) {
72 link.set_monitor(monitor);
75 public File backing_file() {
79 public AltosTelemetryReader (AltosLink in_link)
80 throws IOException, InterruptedException, TimeoutException {
81 log = new AltosLog(link);
84 telem = new LinkedBlockingQueue<AltosLine>();
85 frequency = AltosPreferences.frequency(link.serial);
86 set_frequency(frequency);
87 telemetry = AltosPreferences.telemetry(link.serial);
88 set_telemetry(telemetry);
89 link.add_monitor(telem);