Rev 1562 | Rev 1564 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1562 | Rev 1563 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | package dongfang.mkt.frames; |
1 | package dongfang.mkt.frames; |
Line 2... | Line -... | ||
2 | - | ||
3 | public class OSDDataResponseFrame extends ResponseFrame { |
- | |
4 | - | ||
5 | public static class GPSPosition { |
- | |
6 | int longitude; // in 1E-7 degrees. 32 bit signed. |
- | |
7 | int latitude; // in 1E-7 degrees. 32 bit signed. |
- | |
8 | long altitude; // in mm. 32 bit signed. |
- | |
9 | int status; |
- | |
10 | public int getLongitude() { |
- | |
11 | return longitude; |
- | |
12 | } |
- | |
13 | public int getLatitude() { |
- | |
14 | return latitude; |
- | |
15 | } |
- | |
16 | public long getAltitude() { |
- | |
17 | return altitude; |
- | |
18 | } |
- | |
19 | public int getStatus() { |
- | |
20 | return status; |
- | |
21 | } |
- | |
22 | public void setLongitude(int longitude) { |
- | |
23 | this.longitude = longitude; |
- | |
24 | } |
- | |
25 | public void setLatitude(int latitude) { |
- | |
26 | this.latitude = latitude; |
- | |
27 | } |
- | |
28 | public void setAltitude(long altitude) { |
- | |
29 | this.altitude = altitude; |
- | |
30 | } |
- | |
31 | public void setStatus(int status) { |
- | |
32 | this.status = status; |
- | |
33 | } |
- | |
34 | - | ||
35 | public String toXML() { |
- | |
36 | double latitude = Math.abs(this.latitude); |
2 | |
37 | String result = "latitude=\"" + latitude/1E7; |
- | |
38 | if (this.latitude < 0) result+= "S"; else result+="N"; |
- | |
39 | result += "\""; |
3 | import dongfang.mkt.datatype.GPSBearingAndRange; |
40 | double longitude= Math.abs(this.longitude); |
- | |
41 | result += " longitude=\"" + longitude/1E7; |
- | |
42 | if (this.longitude < 0) result+= "W"; else result+="E"; |
- | |
43 | result += "\""; |
- | |
44 | return result; |
- | |
Line 45... | Line -... | ||
45 | } |
- | |
46 | - | ||
47 | public String toString() { |
- | |
48 | double latitude = Math.abs(this.latitude); |
- | |
49 | String result = "" + latitude/1E7; |
- | |
50 | if (this.latitude < 0) result+= "S"; else result+="N"; |
- | |
51 | result += " "; |
- | |
52 | double longitude= Math.abs(this.longitude); |
- | |
53 | result += "" + longitude/1E7; |
- | |
54 | if (this.longitude < 0) result+= "W"; else result+="E"; |
- | |
55 | return result; |
- | |
56 | } |
- | |
57 | } |
4 | import dongfang.mkt.datatype.GPSPosition; |
58 | - | ||
59 | public static class GPSDistanceAndBearing { |
- | |
60 | int distance; // in m/10. 16 bit unsigned. |
- | |
61 | int bearing; // in degrees. 16 bit signed. |
- | |
62 | public int getDistance() { |
- | |
63 | return distance; |
- | |
64 | } |
- | |
65 | public int getBearing() { |
- | |
66 | return bearing; |
- | |
67 | } |
- | |
68 | public void setDistance(int distance) { |
- | |
69 | this.distance = distance; |
- | |
70 | } |
- | |
71 | public void setBearing(int bearing) { |
- | |
72 | this.bearing = bearing; |
- | |
73 | } |
- | |
74 | public String toXML() { |
- | |
75 | String result = "distance=\"" + ((double)this.distance)/10; |
- | |
76 | result += "\" bearing=\""; |
- | |
77 | result += this.bearing; |
- | |
78 | result += "\""; |
- | |
79 | return result; |
- | |
80 | } |
- | |
81 | public String toString() { |
- | |
82 | String result = "" + ((double)this.distance)/10; |
- | |
83 | result += "m @"; |
- | |
84 | result += this.bearing; |
- | |
85 | result += "deg"; |
- | |
86 | return result; |
- | |
Line 87... | Line 5... | ||
87 | } |
5 | |
88 | } |
6 | public class OSDDataResponseFrame extends ResponseFrame { |
89 | 7 | ||
90 | private int version; |
8 | private int version; |
91 | private GPSPosition currentPosition; |
9 | private GPSPosition currentPosition; |
92 | private GPSPosition targetPosition; |
10 | private GPSPosition targetPosition; |
Line 93... | Line 11... | ||
93 | private GPSDistanceAndBearing currentToTarget; |
11 | private GPSBearingAndRange currentToTarget; |
94 | private GPSPosition homePosition; |
12 | private GPSPosition homePosition; |
Line 95... | Line 13... | ||
95 | private GPSDistanceAndBearing currentToHome; |
13 | private GPSBearingAndRange currentToHome; |
Line 138... | Line 56... | ||
138 | return currentPosition; |
56 | return currentPosition; |
139 | } |
57 | } |
140 | public GPSPosition getTargetPosition() { |
58 | public GPSPosition getTargetPosition() { |
141 | return targetPosition; |
59 | return targetPosition; |
142 | } |
60 | } |
143 | public GPSDistanceAndBearing getCurrentToTarget() { |
61 | public GPSBearingAndRange getCurrentToTarget() { |
144 | return currentToTarget; |
62 | return currentToTarget; |
145 | } |
63 | } |
146 | public GPSPosition getHomePosition() { |
64 | public GPSPosition getHomePosition() { |
147 | return homePosition; |
65 | return homePosition; |
148 | } |
66 | } |
149 | public GPSDistanceAndBearing getCurrentToHome() { |
67 | public GPSBearingAndRange getCurrentToHome() { |
150 | return currentToHome; |
68 | return currentToHome; |
151 | } |
69 | } |
152 | public int getWaypointIndex() { |
70 | public int getWaypointIndex() { |
153 | return waypointIndex; |
71 | return waypointIndex; |
154 | } |
72 | } |
Line 228... | Line 146... | ||
228 | this.currentPosition = currentPosition; |
146 | this.currentPosition = currentPosition; |
229 | } |
147 | } |
230 | public void setTargetPosition(GPSPosition targetPosition) { |
148 | public void setTargetPosition(GPSPosition targetPosition) { |
231 | this.targetPosition = targetPosition; |
149 | this.targetPosition = targetPosition; |
232 | } |
150 | } |
233 | public void setCurrentToTarget(GPSDistanceAndBearing currentToTarget) { |
151 | public void setCurrentToTarget(GPSBearingAndRange currentToTarget) { |
234 | this.currentToTarget = currentToTarget; |
152 | this.currentToTarget = currentToTarget; |
235 | } |
153 | } |
236 | public void setHomePosition(GPSPosition homePosition) { |
154 | public void setHomePosition(GPSPosition homePosition) { |
237 | this.homePosition = homePosition; |
155 | this.homePosition = homePosition; |
238 | } |
156 | } |
239 | public void setCurrentToHome(GPSDistanceAndBearing currentToHome) { |
157 | public void setCurrentToHome(GPSBearingAndRange currentToHome) { |
240 | this.currentToHome = currentToHome; |
158 | this.currentToHome = currentToHome; |
241 | } |
159 | } |
242 | public void setWaypointIndex(int waypointIndex) { |
160 | public void setWaypointIndex(int waypointIndex) { |
243 | this.waypointIndex = waypointIndex; |
161 | this.waypointIndex = waypointIndex; |
244 | } |
162 | } |