Rev 1559 | Rev 1563 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1559 | - | 1 | package dongfang.mkt.frames; |
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 | } |
||
1562 | - | 34 | |
35 | public String toXML() { |
||
36 | double latitude = Math.abs(this.latitude); |
||
37 | String result = "latitude=\"" + latitude/1E7; |
||
38 | if (this.latitude < 0) result+= "S"; else result+="N"; |
||
39 | result += "\""; |
||
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; |
||
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 | } |
||
1559 | - | 57 | } |
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 | } |
||
1562 | - | 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; |
||
87 | } |
||
1559 | - | 88 | } |
89 | |||
90 | private int version; |
||
91 | private GPSPosition currentPosition; |
||
92 | private GPSPosition targetPosition; |
||
93 | private GPSDistanceAndBearing currentToTarget; |
||
94 | private GPSPosition homePosition; |
||
95 | private GPSDistanceAndBearing currentToHome; |
||
96 | |||
97 | private int waypointIndex; |
||
98 | private int waypointCount; |
||
99 | |||
100 | private int numberOfSatellites; |
||
101 | private int heightByPressure; // 16 bit signed. |
||
102 | private int verticalVelocityByPressure; // 16 bit signed. |
||
103 | |||
104 | private int flightTime; // in secs. 16 bit unsigned. |
||
105 | private int batteryVoltage; // in 0.1 volts. |
||
106 | |||
107 | private int groundSpeed; // in cm/s. 16 bit unsigned. |
||
1562 | - | 108 | private int directionOfFlight; // of movement. 16 bit signed. |
1559 | - | 109 | private int compassHeading;// 16 bit signed. |
110 | |||
111 | private int pitchAngle; |
||
112 | private int rollAngle; |
||
113 | |||
114 | private int rcQuality; |
||
115 | private int fcFlags; |
||
116 | private int ncFlags; |
||
117 | private int errorCode; |
||
118 | |||
119 | private int operatingRadius; |
||
120 | private int verticalVelocityByGPS; // 16 bit signed. |
||
121 | |||
122 | private int targetLoiterTime; |
||
123 | private int fcFlags2; |
||
124 | private int setpointForAltitude; // 16 bit signed. |
||
125 | |||
126 | private int throttle; |
||
127 | private int current; // 16 bit unsigned. |
||
128 | private int capacityUsed; // 16 bit unsigned. |
||
129 | |||
130 | public OSDDataResponseFrame(int address) { |
||
131 | super(address); |
||
132 | } |
||
133 | |||
134 | public int getVersion() { |
||
135 | return version; |
||
136 | } |
||
137 | public GPSPosition getCurrentPosition() { |
||
138 | return currentPosition; |
||
139 | } |
||
140 | public GPSPosition getTargetPosition() { |
||
141 | return targetPosition; |
||
142 | } |
||
143 | public GPSDistanceAndBearing getCurrentToTarget() { |
||
144 | return currentToTarget; |
||
145 | } |
||
146 | public GPSPosition getHomePosition() { |
||
147 | return homePosition; |
||
148 | } |
||
149 | public GPSDistanceAndBearing getCurrentToHome() { |
||
150 | return currentToHome; |
||
151 | } |
||
152 | public int getWaypointIndex() { |
||
153 | return waypointIndex; |
||
154 | } |
||
155 | public int getWaypointCount() { |
||
156 | return waypointCount; |
||
157 | } |
||
158 | public int getNumberOfSatellites() { |
||
159 | return numberOfSatellites; |
||
160 | } |
||
161 | public int getHeightByPressure() { |
||
162 | return heightByPressure; |
||
163 | } |
||
164 | public int getVerticalVelocityByPressure() { |
||
165 | return verticalVelocityByPressure; |
||
166 | } |
||
167 | public int getFlightTime() { |
||
168 | return flightTime; |
||
169 | } |
||
170 | public int getBatteryVoltage() { |
||
171 | return batteryVoltage; |
||
172 | } |
||
173 | public int getGroundSpeed() { |
||
174 | return groundSpeed; |
||
175 | } |
||
1562 | - | 176 | public int getDirectionOfFlight() { |
177 | return directionOfFlight; |
||
1559 | - | 178 | } |
179 | public int getCompassHeading() { |
||
180 | return compassHeading; |
||
181 | } |
||
182 | public int getPitchAngle() { |
||
183 | return pitchAngle; |
||
184 | } |
||
185 | public int getRollAngle() { |
||
186 | return rollAngle; |
||
187 | } |
||
188 | public int getRcQuality() { |
||
189 | return rcQuality; |
||
190 | } |
||
191 | public int getFcFlags() { |
||
192 | return fcFlags; |
||
193 | } |
||
194 | public int getNcFlags() { |
||
195 | return ncFlags; |
||
196 | } |
||
197 | public int getErrorCode() { |
||
198 | return errorCode; |
||
199 | } |
||
200 | public int getOperatingRadius() { |
||
201 | return operatingRadius; |
||
202 | } |
||
203 | public int getVerticalVelocityByGPS() { |
||
204 | return verticalVelocityByGPS; |
||
205 | } |
||
206 | public int getTargetLoiterTime() { |
||
207 | return targetLoiterTime; |
||
208 | } |
||
209 | public int getFcFlags2() { |
||
210 | return fcFlags2; |
||
211 | } |
||
212 | public int getSetpointForAltitude() { |
||
213 | return setpointForAltitude; |
||
214 | } |
||
215 | public int getThrottle() { |
||
216 | return throttle; |
||
217 | } |
||
218 | public int getCurrent() { |
||
219 | return current; |
||
220 | } |
||
221 | public int getCapacityUsed() { |
||
222 | return capacityUsed; |
||
223 | } |
||
224 | public void setVersion(int version) { |
||
225 | this.version = version; |
||
226 | } |
||
227 | public void setCurrentPosition(GPSPosition currentPosition) { |
||
228 | this.currentPosition = currentPosition; |
||
229 | } |
||
230 | public void setTargetPosition(GPSPosition targetPosition) { |
||
231 | this.targetPosition = targetPosition; |
||
232 | } |
||
233 | public void setCurrentToTarget(GPSDistanceAndBearing currentToTarget) { |
||
234 | this.currentToTarget = currentToTarget; |
||
235 | } |
||
236 | public void setHomePosition(GPSPosition homePosition) { |
||
237 | this.homePosition = homePosition; |
||
238 | } |
||
239 | public void setCurrentToHome(GPSDistanceAndBearing currentToHome) { |
||
240 | this.currentToHome = currentToHome; |
||
241 | } |
||
242 | public void setWaypointIndex(int waypointIndex) { |
||
243 | this.waypointIndex = waypointIndex; |
||
244 | } |
||
245 | public void setWaypointCount(int waypointCount) { |
||
246 | this.waypointCount = waypointCount; |
||
247 | } |
||
248 | public void setNumberOfSatellites(int numberOfSatellites) { |
||
249 | this.numberOfSatellites = numberOfSatellites; |
||
250 | } |
||
251 | public void setHeightByPressure(int heightByPressure) { |
||
252 | this.heightByPressure = heightByPressure; |
||
253 | } |
||
254 | public void setVerticalVelocityByPressure(int verticalVelocityByPressure) { |
||
255 | this.verticalVelocityByPressure = verticalVelocityByPressure; |
||
256 | } |
||
257 | public void setFlightTime(int flightTime) { |
||
258 | this.flightTime = flightTime; |
||
259 | } |
||
260 | public void setBatteryVoltage(int batteryVoltage) { |
||
261 | this.batteryVoltage = batteryVoltage; |
||
262 | } |
||
263 | public void setGroundSpeed(int groundSpeed) { |
||
264 | this.groundSpeed = groundSpeed; |
||
265 | } |
||
1562 | - | 266 | public void setDirectionOfFlight(int heading) { |
267 | this.directionOfFlight = heading; |
||
1559 | - | 268 | } |
269 | public void setCompassHeading(int compassHeading) { |
||
270 | this.compassHeading = compassHeading; |
||
271 | } |
||
272 | public void setPitchAngle(int pitchAngle) { |
||
273 | this.pitchAngle = pitchAngle; |
||
274 | } |
||
275 | public void setRollAngle(int rollAngle) { |
||
276 | this.rollAngle = rollAngle; |
||
277 | } |
||
278 | public void setRcQuality(int rcQuality) { |
||
279 | this.rcQuality = rcQuality; |
||
280 | } |
||
281 | public void setFcFlags(int fcFlags) { |
||
282 | this.fcFlags = fcFlags; |
||
283 | } |
||
284 | public void setNcFlags(int ncFlags) { |
||
285 | this.ncFlags = ncFlags; |
||
286 | } |
||
287 | public void setErrorCode(int errorCode) { |
||
288 | this.errorCode = errorCode; |
||
289 | } |
||
290 | public void setOperatingRadius(int operatingRadius) { |
||
291 | this.operatingRadius = operatingRadius; |
||
292 | } |
||
293 | public void setVerticalVelocityByGPS(int verticalVelocityByGPS) { |
||
294 | this.verticalVelocityByGPS = verticalVelocityByGPS; |
||
295 | } |
||
296 | public void setTargetLoiterTime(int targetLoiterTime) { |
||
297 | this.targetLoiterTime = targetLoiterTime; |
||
298 | } |
||
299 | public void setFcFlags2(int fcFlags2) { |
||
300 | this.fcFlags2 = fcFlags2; |
||
301 | } |
||
302 | public void setSetpointForAltitude(int setpointForAltitude) { |
||
303 | this.setpointForAltitude = setpointForAltitude; |
||
304 | } |
||
305 | public void setThrottle(int throttle) { |
||
306 | this.throttle = throttle; |
||
307 | } |
||
308 | public void setCurrent(int current) { |
||
309 | this.current = current; |
||
310 | } |
||
311 | public void setCapacityUsed(int capacityUsed) { |
||
312 | this.capacityUsed = capacityUsed; |
||
313 | } |
||
1562 | - | 314 | |
315 | @Override |
||
316 | public boolean isResponseTo(RequestFrame r) { |
||
317 | return r instanceof OSDDataRequestFrame; |
||
318 | } |
||
319 | |||
320 | public String toString() { |
||
321 | StringBuilder result = new StringBuilder(); |
||
322 | result.append("OSDData version=" + this.version + "\n"); |
||
323 | result.append("currentPosition: " + this.currentPosition + "\n"); |
||
324 | result.append("targetPosition: " + this.targetPosition + " (" + this.currentToTarget + ")" + "\n"); |
||
325 | result.append("homePosition: " + this.homePosition + " (" + this.currentToHome + ")" + "\n"); |
||
326 | result.append("heightByPressure: " + this.heightByPressure + "\n"); |
||
327 | result.append("verticalVelocityByPressure: " + this.verticalVelocityByPressure + "\n"); |
||
328 | result.append("verticalVelocityByGPS: " + this.verticalVelocityByGPS + "\n"); |
||
329 | result.append("direction of flight: " + this.directionOfFlight + "\n"); |
||
330 | result.append("compassHeading: " + this.compassHeading + "\n"); |
||
331 | result.append("pitchAngle: " + this.pitchAngle + "\n"); |
||
332 | result.append("rollAngle: " + this.rollAngle + "\n"); |
||
333 | result.append("battery voltage: " + ((double)this.batteryVoltage)/10 + "\n"); |
||
334 | result.append("throttle: " + this.throttle + "\n"); |
||
335 | return result.toString(); |
||
336 | } |
||
1559 | - | 337 | } |
338 |