2 * Copyright © 2012 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; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 package org.altusmetrum.altoslib_11;
21 import java.util.concurrent.*;
24 public class AltosMag implements Cloneable {
29 public static final double counts_per_gauss = 1090;
31 public static double convert_gauss(double counts) {
32 return counts / counts_per_gauss;
35 public boolean parse_string(String line) {
36 // if (line.startsWith("Syntax error")) {
37 // along = across = through = 0;
41 if (!line.startsWith("X:"))
44 String[] items = line.split("\\s+");
46 if (items.length >= 6) {
47 along = Integer.parseInt(items[1]);
48 across = Integer.parseInt(items[3]);
49 through = Integer.parseInt(items[5]);
54 public AltosMag clone() {
55 AltosMag n = new AltosMag();
64 along = AltosLib.MISSING;
65 across = AltosLib.MISSING;
66 through = AltosLib.MISSING;
69 public AltosMag(int along, int across, int through) {
72 this.through = through;
75 static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException {
77 AltosMag mag = new AltosMag(link);
81 } catch (TimeoutException te) {
85 public AltosMag(AltosLink link) throws InterruptedException, TimeoutException {
89 String line = link.get_reply_no_dialog(5000);
91 throw new TimeoutException();
93 if (parse_string(line))