File: AltData.java

package info (click to toggle)
openrocket 12.03-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 41,220 kB
  • sloc: java: 69,764; xml: 1,400; php: 198; perl: 38; sh: 36; makefile: 18
file content (81 lines) | stat: -rw-r--r-- 1,441 bytes parent folder | download | duplicates (2)
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
package altimeter;

public class AltData {

	private int mslLevel = 0;
	private int samples = 0;
	private int[] data = null;
	private byte[] version = null;
	
	
	public void setMslLevel(int msl) {
		mslLevel = msl;
	}
	public int getMslLevel() {
		return mslLevel;
	}
	
	public void setDataSamples(int s) {
		samples = s;
	}
	public int getDataSamples() {
		return samples;
	}
	
	public void setVersion(byte[] v) {
		if (v==null)
			version = null;
		else 
			version = v.clone();
	}
	public byte[] getVersion() {
		if (version == null)
			return null;
		return version.clone();		
	}
	
	public void setData(int[] data) {
		if (data==null)
			this.data = null;
		else 
			this.data = data.clone();
	}
	public int[] getData() {
		if (data == null)
			return null;
		return data.clone();
	}

	public int getApogee() {
		if (data == null || data.length==0)
			return 0;
		int max = Integer.MIN_VALUE;
		for (int i=0; i<data.length; i++) {
			if (data[i] > max)
				max = data[i];
		}
		return max;
	}
	
	@Override
	public String toString() {
		String s = "AltData(";
		s += "MSL:"+getMslLevel()+",";
		s += "Apogee:"+getApogee()+",";
		s += "Samples:"+getDataSamples();
		s += ")";
		return s;
	}
	
	public void printData() {
		System.out.println(toString()+":");
		for (int i=0; i<data.length; i+=8) {
			String s = "  "+i+":";
			for (int j=0; j<8 && (i+j)<data.length; j++) {
				s += " "+data[i+j];
			}
			System.out.println(s);
		}
	}
	
}