File: AltosEepromList.java

package info (click to toggle)
altos 1.9.22-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 83,712 kB
  • sloc: ansic: 120,853; java: 42,921; makefile: 8,573; sh: 4,995; xml: 2,154; pascal: 2,008
file content (82 lines) | stat: -rw-r--r-- 2,265 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * Copyright © 2011 Keith Packard <keithp@keithp.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 */

package org.altusmetrum.altoslib_14;

import java.io.*;
import java.util.*;
import java.text.*;
import java.util.concurrent.*;

/*
 * Temporary structure to hold the list of stored flights;
 * each of these will be queried in turn to generate more
 * complete information
 */

class AltosEepromFlight {
	int	flight;
	int	start;
	int	end;

	public AltosEepromFlight(int in_flight, int in_start, int in_end) {
		flight = in_flight;
		start = in_start;
		end = in_end;
	}

	public AltosEepromFlight() {
		flight = 0;
		start = 0;
		end = 0;
	}
}

/*
 * Construct a list of flights available in a connected device
 */

public class AltosEepromList extends ArrayList<AltosEepromLog> {
	public AltosConfigData	config_data;

	public AltosEepromList (AltosLink link, boolean remote)
		throws IOException, InterruptedException, TimeoutException
	{
		try {
			if (remote)
				link.start_remote();
			config_data = new AltosConfigData (link);

			/* With the list of flights collected, collect more complete
			 * information on them by reading the first block or two of
			 * data. This will add GPS coordinates and a date. For older
			 * firmware, this will also extract the flight number.
			 */
			if (config_data.flights != null) {
				for (AltosEepromFlight flight : config_data.flights) {
					add(new AltosEepromLog(config_data, link,
							       flight.flight, flight.start, flight.end));
				}
			}
		} finally {
			if (remote)
				link.stop_remote();
			link.flush_output();
		}
	}
}