1 package net.sf.tourviewer.lib.ciclo;
2
3
4 public class DataBlock {
5
6 private int altitudeDelta;
7 private int pulseDelta;
8 private int distanceDelta;
9
10 public DataBlock(int value) {
11
12
13
14 if ((value & 0x8000) != 0)
15 pulseDelta = (((value & 0x7000) >> 12) - 8) * 2;
16 else
17 pulseDelta = ((value & 0x7000) >> 12) * 2;
18
19
20 if ((value & 0x0800) != 0) {
21 altitudeDelta = -32 + ((value & 0x07C0) >> 6);
22 if (altitudeDelta < -16)
23 altitudeDelta = -16 + ((altitudeDelta + 16) * 7);
24 } else {
25 altitudeDelta = (value & 0x07C0) >> 6;
26 if (altitudeDelta > 16)
27 altitudeDelta = 16 + ((altitudeDelta - 16) * 7);
28 }
29
30
31 distanceDelta = value & 0x003F;
32 }
33
34 @Override
35 public String toString()
36 {
37 return String.format("[P%3d,A%5d,D%2d]", pulseDelta, altitudeDelta, distanceDelta);
38 }
39
40
41 public int getAltitudeDelta()
42 {
43 return altitudeDelta;
44 }
45
46
47 public int getDistanceDelta()
48 {
49 return distanceDelta;
50 }
51
52
53 public int getPulseDelta()
54 {
55 return pulseDelta;
56 }
57
58 }