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; 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_1;
20 import java.util.concurrent.TimeoutException;
30 public AltosSensorMM(AltosLink link) throws InterruptedException, TimeoutException {
33 String line = link.get_reply_no_dialog(5000);
35 throw new TimeoutException();
37 if (!line.startsWith("tick:"))
39 String[] items = line.split("\\s+");
41 for (int i = 0; i < items.length;) {
42 if (items[i].equals("tick:")) {
43 tick = Integer.parseInt(items[i+1]);
47 if (items[i].equals("0:")) {
48 sense[0] = Integer.parseInt(items[i+1]);
52 if (items[i].equals("1:")) {
53 sense[1] = Integer.parseInt(items[i+1]);
57 if (items[i].equals("2:")) {
58 sense[2] = Integer.parseInt(items[i+1]);
62 if (items[i].equals("3:")) {
63 sense[3] = Integer.parseInt(items[i+1]);
67 if (items[i].equals("4:")) {
68 sense[4] = Integer.parseInt(items[i+1]);
72 if (items[i].equals("5:")) {
73 sense[5] = Integer.parseInt(items[i+1]);
77 if (items[i].equals("6:")) {
78 v_batt = Integer.parseInt(items[i+1]);
82 if (items[i].equals("7:")) {
83 v_pyro = Integer.parseInt(items[i+1]);
87 if (items[i].equals("8:")) {
88 accel = Integer.parseInt(items[i+1]);
92 if (items[i].equals("9:")) {
93 accel_ref = Integer.parseInt(items[i+1]);