1 | /* Copyright (c) 2013 by István Váradi
|
---|
2 | *
|
---|
3 | * This file is part of XPLRA, a remote-access plugin for X-Plane
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions are met:
|
---|
7 | *
|
---|
8 | * 1. Redistributions of source code must retain the above copyright notice, this
|
---|
9 | * list of conditions and the following disclaimer.
|
---|
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
11 | * this list of conditions and the following disclaimer in the documentation
|
---|
12 | * and/or other materials provided with the distribution.
|
---|
13 | *
|
---|
14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
---|
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
---|
16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
17 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
---|
18 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
---|
19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
24 | *
|
---|
25 | * The views and conclusions contained in the software and documentation are those
|
---|
26 | * of the authors and should not be interpreted as representing official policies,
|
---|
27 | * either expressed or implied, of the FreeBSD Project.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifndef HU_VARADIISTVAN_XPLRA_XPLRA_H
|
---|
31 | #define HU_VARADIISTVAN_XPLRA_XPLRA_H
|
---|
32 | /*----------------------------------------------------------------------------*/
|
---|
33 |
|
---|
34 | #include <stdlib.h>
|
---|
35 | #include <inttypes.h>
|
---|
36 |
|
---|
37 | /*----------------------------------------------------------------------------*/
|
---|
38 |
|
---|
39 | #ifdef __cplusplus
|
---|
40 | extern "C" {
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | /*----------------------------------------------------------------------------*/
|
---|
44 |
|
---|
45 | /** No error occured */
|
---|
46 | #define ERROR_NONE 0
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * An I/O error has occured. The subcode is the errno value on Linux, or the
|
---|
50 | * Windows error code.
|
---|
51 | */
|
---|
52 | #define ERROR_IO 1
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * A protocol error has occured. The subcode is one of the
|
---|
56 | * ERROR_PROTOCOL_XXX values.
|
---|
57 | */
|
---|
58 | #define ERROR_PROTOCOL 2
|
---|
59 |
|
---|
60 | /** Invalid command was passed to the plugin */
|
---|
61 | #define ERROR_PROTOCOL_INVALID_COMMAND = 1
|
---|
62 |
|
---|
63 | /** An unknown dataref was specified */
|
---|
64 | #define ERROR_PROTOCOL_UNKNOWN_DATAREF = 2
|
---|
65 |
|
---|
66 | /** An invalid type was specified */
|
---|
67 | #define ERROR_PROTOCOL_INVALID_TYPE = 3
|
---|
68 |
|
---|
69 | /** An invalid length was specified */
|
---|
70 | #define ERROR_PROTOCOL_INVALID_LENGTH = 4
|
---|
71 |
|
---|
72 | /** An invalid offset was specified */
|
---|
73 | #define ERROR_PROTOCOL_INVALID_OFFSET = 5
|
---|
74 |
|
---|
75 | /** An invalid count was specified */
|
---|
76 | #define ERROR_PROTOCOL_INVALID_COUNT = 6
|
---|
77 |
|
---|
78 | /** An invalid ID was specified */
|
---|
79 | #define ERROR_PROTOCOL_INVALID_ID = 7
|
---|
80 |
|
---|
81 | /** An invalid duration was specified */
|
---|
82 | #define ERROR_PROTOCOL_INVALID_DURATION = 8
|
---|
83 |
|
---|
84 | /** Other protocol error */
|
---|
85 | #define ERROR_PROTOCOL_OTHER = 255
|
---|
86 |
|
---|
87 | /** A function requiring a connection is called without a connection */
|
---|
88 | #define ERROR_NOT_CONNECTED 3
|
---|
89 |
|
---|
90 | /** A type-specific function was called for a dataref of a different type */
|
---|
91 | #define ERROR_TYPE_MISMATCH 4
|
---|
92 |
|
---|
93 | /** An invalid ID was passed to a function */
|
---|
94 | #define ERROR_INVALID_ID 5
|
---|
95 |
|
---|
96 | /** Some other error */
|
---|
97 | #define ERROR_OTHER 255
|
---|
98 |
|
---|
99 | /*----------------------------------------------------------------------------*/
|
---|
100 |
|
---|
101 | #define INVALID_DATAREF_ID ((size_t)-1)
|
---|
102 |
|
---|
103 | /*----------------------------------------------------------------------------*/
|
---|
104 |
|
---|
105 | /**
|
---|
106 | * Get the last error code with the subcode.
|
---|
107 | *
|
---|
108 | * @return the last error code, or -1 if the given connection ID is invalid.
|
---|
109 | */
|
---|
110 | int xplra_get_last_error(int connectionID, unsigned long* subCode);
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * Get a string representation of the last error.
|
---|
114 | *
|
---|
115 | * @return the string representation of the last error, or 0 if there
|
---|
116 | * was no last error, or the connection ID is invalid.
|
---|
117 | */
|
---|
118 | const char* xplra_get_last_error_string(int connectionID);
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Clear the last error.
|
---|
122 | */
|
---|
123 | void xplra_clear_last_error(int connectionID);
|
---|
124 |
|
---|
125 | /*----------------------------------------------------------------------------*/
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * Connect to the simulator.
|
---|
129 | *
|
---|
130 | * @return an ID for the created connection, or -1 on error.
|
---|
131 | */
|
---|
132 | int xplra_connect();
|
---|
133 |
|
---|
134 | /*----------------------------------------------------------------------------*/
|
---|
135 |
|
---|
136 | /**
|
---|
137 | * Get the versions of X-Plane, the XPLM library and XPLRA
|
---|
138 | */
|
---|
139 | int xplra_get_versions(int connectionID,
|
---|
140 | int* xplaneVersion, int* xplmVersion,
|
---|
141 | int* xplraVersion);
|
---|
142 |
|
---|
143 | /*----------------------------------------------------------------------------*/
|
---|
144 |
|
---|
145 | /**
|
---|
146 | * Reload the plugins in X-Plane. After this the connection fails.
|
---|
147 | */
|
---|
148 | int xplra_reload_plugins(int connectionID);
|
---|
149 |
|
---|
150 | /*----------------------------------------------------------------------------*/
|
---|
151 | /* Single dataref support */
|
---|
152 | /*----------------------------------------------------------------------------*/
|
---|
153 |
|
---|
154 | /**
|
---|
155 | * Get an integer value from the simulator.
|
---|
156 | *
|
---|
157 | * @return 0 on success, -1 on error
|
---|
158 | */
|
---|
159 | int xplra_get_int(int* value, int connectionID, const char* name);
|
---|
160 |
|
---|
161 | /*----------------------------------------------------------------------------*/
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * Get a float value from the simulator.
|
---|
165 | *
|
---|
166 | * @return 0 on success, -1 on error
|
---|
167 | */
|
---|
168 | int xplra_get_float(float* value, int connectionID, const char* name);
|
---|
169 |
|
---|
170 | /*----------------------------------------------------------------------------*/
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * Get a double value from the simulator.
|
---|
174 | *
|
---|
175 | * @return 0 on success, -1 on error
|
---|
176 | */
|
---|
177 | int xplra_get_double(double* value, int connectionID, const char* name);
|
---|
178 |
|
---|
179 | /*----------------------------------------------------------------------------*/
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * Get an array of floats into a buffer.
|
---|
183 | *
|
---|
184 | * @param dest the array into which to get the data
|
---|
185 | * @param length the length of the destination buffer
|
---|
186 | * @param offset the offset from which to query the array
|
---|
187 | *
|
---|
188 | * @return the actual number of elements returned in case of success,
|
---|
189 | * -1 on error
|
---|
190 | */
|
---|
191 | ssize_t xplra_get_float_array(float* dest, size_t length, size_t offset,
|
---|
192 | int connectionID, const char* name);
|
---|
193 |
|
---|
194 | /*----------------------------------------------------------------------------*/
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * Get an array of floats into a newly allocated buffer.
|
---|
198 | *
|
---|
199 | * @param length pointer to a variable containing the length to
|
---|
200 | * query. On return it will be set to the actual length, which can be
|
---|
201 | * less than or equal to the input value.
|
---|
202 | * @param offset the offset from which to query the array
|
---|
203 | *
|
---|
204 | * @return the new array on success, 0 on error
|
---|
205 | */
|
---|
206 | float* xplra_get_float_array_new(size_t* length, size_t offset,
|
---|
207 | int connectionID, const char* name);
|
---|
208 |
|
---|
209 | /*----------------------------------------------------------------------------*/
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * Get an array of integers into a buffer.
|
---|
213 | *
|
---|
214 | * @param dest the array into which to get the data
|
---|
215 | * @param length the length of the destination buffer
|
---|
216 | * @param offset the offset from which to query the array
|
---|
217 | *
|
---|
218 | * @return the actual number of elements returned in case of success,
|
---|
219 | * -1 on error
|
---|
220 | */
|
---|
221 | ssize_t xplra_get_int_array(int32_t* dest, size_t length, size_t offset,
|
---|
222 | int connectionID, const char* name);
|
---|
223 |
|
---|
224 | /*----------------------------------------------------------------------------*/
|
---|
225 |
|
---|
226 | /**
|
---|
227 | * Get an array of integers into a newly allocated buffer.
|
---|
228 | *
|
---|
229 | * @param length pointer to a variable containing the length to
|
---|
230 | * query. On return it will be set to the actual length, which can be
|
---|
231 | * less than or equal to the input value.
|
---|
232 | * @param offset the offset from which to query the array
|
---|
233 | *
|
---|
234 | * @return the new array on success, 0 on error
|
---|
235 | */
|
---|
236 | int32_t* xplra_get_int_array_new(size_t* length, size_t offset,
|
---|
237 | int connectionID, const char* name);
|
---|
238 |
|
---|
239 | /*----------------------------------------------------------------------------*/
|
---|
240 |
|
---|
241 | /**
|
---|
242 | * Get an array of bytes into a buffer.
|
---|
243 | *
|
---|
244 | * @param dest the array into which to get the data
|
---|
245 | * @param length the length of the destination buffer
|
---|
246 | * @param offset the offset from which to query the array
|
---|
247 | *
|
---|
248 | * @return the actual number of elements returned in case of success,
|
---|
249 | * -1 on error
|
---|
250 | */
|
---|
251 | ssize_t xplra_get_byte_array(void* dest, size_t length, size_t offset,
|
---|
252 | int connectionID, const char* name);
|
---|
253 |
|
---|
254 | /*----------------------------------------------------------------------------*/
|
---|
255 |
|
---|
256 | /**
|
---|
257 | * Get an array of bytes into a newly allocated buffer.
|
---|
258 | *
|
---|
259 | * @param length pointer to a variable containing the length to
|
---|
260 | * query. On return it will be set to the actual length, which can be
|
---|
261 | * less than or equal to the input value.
|
---|
262 | * @param offset the offset from which to query the array
|
---|
263 | *
|
---|
264 | * @return the new array on success, 0 on error
|
---|
265 | */
|
---|
266 | uint8_t* xplra_get_byte_array_new(size_t* length, size_t offset,
|
---|
267 | int connectionID, const char* name);
|
---|
268 |
|
---|
269 | /*----------------------------------------------------------------------------*/
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * Set the integer dataref with the given name to the given value.
|
---|
273 | *
|
---|
274 | * @return 0 on success, -1 on error.
|
---|
275 | */
|
---|
276 | int xplra_set_int(int connectionID, const char* name, int value);
|
---|
277 |
|
---|
278 | /*----------------------------------------------------------------------------*/
|
---|
279 |
|
---|
280 | /**
|
---|
281 | * Set the float dataref with the given name to the given value.
|
---|
282 | *
|
---|
283 | * @return 0 on success, -1 on error.
|
---|
284 | */
|
---|
285 | int xplra_set_float(int connectionID, const char* name, float value);
|
---|
286 |
|
---|
287 | /*----------------------------------------------------------------------------*/
|
---|
288 |
|
---|
289 | /**
|
---|
290 | * Set the double dataref with the given name to the given value.
|
---|
291 | *
|
---|
292 | * @return 0 on success, -1 on error.
|
---|
293 | */
|
---|
294 | int xplra_set_double(int connectionID, const char* name, double value);
|
---|
295 |
|
---|
296 | /*----------------------------------------------------------------------------*/
|
---|
297 |
|
---|
298 | /**
|
---|
299 | * Set the array of float values with the given name from the given
|
---|
300 | * buffer.
|
---|
301 | *
|
---|
302 | * @return 0 on success, -1 on error.
|
---|
303 | */
|
---|
304 | int xplra_set_float_array(int connectionID, const char* name,
|
---|
305 | const float* values, size_t length, size_t offset);
|
---|
306 |
|
---|
307 | /*----------------------------------------------------------------------------*/
|
---|
308 |
|
---|
309 | /**
|
---|
310 | * Set the array of integer values with the given name from the given
|
---|
311 | * buffer.
|
---|
312 | *
|
---|
313 | * @return 0 on success, -1 on error.
|
---|
314 | */
|
---|
315 | int xplra_set_int_array(int connectionID, const char* name,
|
---|
316 | const int32_t* values, size_t length, size_t offset);
|
---|
317 |
|
---|
318 | /*----------------------------------------------------------------------------*/
|
---|
319 |
|
---|
320 | /**
|
---|
321 | * Set the array of byte values with the given name from the given
|
---|
322 | * buffer.
|
---|
323 | *
|
---|
324 | * @return 0 on success, -1 on error.
|
---|
325 | */
|
---|
326 | int xplra_set_byte_array(int connectionID, const char* name,
|
---|
327 | const void* values, size_t length, size_t offset);
|
---|
328 |
|
---|
329 | /*----------------------------------------------------------------------------*/
|
---|
330 |
|
---|
331 | /**
|
---|
332 | * Set the array of byte values with the given name from the given
|
---|
333 | * string. The string will be padded with 0 if it has a length less
|
---|
334 | * than the given length.
|
---|
335 | *
|
---|
336 | * @return 0 on success, -1 on error.
|
---|
337 | */
|
---|
338 | int xplra_set_string(int connectionID, const char* name,
|
---|
339 | const char* value, size_t length, size_t offset);
|
---|
340 |
|
---|
341 | /*----------------------------------------------------------------------------*/
|
---|
342 | /* Multi-dataref support */
|
---|
343 | /*----------------------------------------------------------------------------*/
|
---|
344 |
|
---|
345 | /**
|
---|
346 | * Create a multi-dataref getter for the given connection.
|
---|
347 | *
|
---|
348 | * @return the ID of the new getter, or -1 on error
|
---|
349 | */
|
---|
350 | int xplra_multi_create_getter(int connectionID);
|
---|
351 |
|
---|
352 | /*----------------------------------------------------------------------------*/
|
---|
353 |
|
---|
354 | /**
|
---|
355 | * Create a multi-dataref setter for the given connection.
|
---|
356 | *
|
---|
357 | * @return the ID of the new setter, or -1 on error
|
---|
358 | */
|
---|
359 | int xplra_multi_create_setter(int connectionID);
|
---|
360 |
|
---|
361 | /*----------------------------------------------------------------------------*/
|
---|
362 |
|
---|
363 | /**
|
---|
364 | * Add an integer dataref to a multi-dataref buffer.
|
---|
365 | *
|
---|
366 | * @return the ID of the dataref that can be used later. If the buffer
|
---|
367 | * ID is invalid, INVALID_DATAREF_ID is returned.
|
---|
368 | */
|
---|
369 | size_t xplra_multi_add_int(int bufferID, const char* name);
|
---|
370 |
|
---|
371 | /*----------------------------------------------------------------------------*/
|
---|
372 |
|
---|
373 | /**
|
---|
374 | * Add a float dataref to a multi-dataref buffer.
|
---|
375 | *
|
---|
376 | * @return the ID of the dataref that can be used later. If the buffer
|
---|
377 | * ID is invalid, INVALID_DATAREF_ID is returned.
|
---|
378 | */
|
---|
379 | size_t xplra_multi_add_float(int bufferID, const char* name);
|
---|
380 |
|
---|
381 | /*----------------------------------------------------------------------------*/
|
---|
382 |
|
---|
383 | /**
|
---|
384 | * Add a double dataref to a multi-dataref buffer.
|
---|
385 | *
|
---|
386 | * @return the ID of the dataref that can be used later. If the buffer
|
---|
387 | * ID is invalid, INVALID_DATAREF_ID is returned.
|
---|
388 | */
|
---|
389 | size_t xplra_multi_add_double(int bufferID, const char* name);
|
---|
390 |
|
---|
391 | /*----------------------------------------------------------------------------*/
|
---|
392 |
|
---|
393 | /**
|
---|
394 | * Add a float array dataref to a multi-dataref buffer.
|
---|
395 | *
|
---|
396 | * @return the ID of the dataref that can be used later. If the buffer
|
---|
397 | * ID is invalid, INVALID_DATAREF_ID is returned.
|
---|
398 | */
|
---|
399 | size_t xplra_multi_add_float_array(int bufferID, const char* name,
|
---|
400 | size_t length, size_t offset);
|
---|
401 |
|
---|
402 | /*----------------------------------------------------------------------------*/
|
---|
403 |
|
---|
404 | /**
|
---|
405 | * Add an integer array dataref to a multi-dataref buffer.
|
---|
406 | *
|
---|
407 | * @return the ID of the dataref that can be used later. If the buffer
|
---|
408 | * ID is invalid, INVALID_DATAREF_ID is returned.
|
---|
409 | */
|
---|
410 | size_t xplra_multi_add_int_array(int bufferID, const char* name,
|
---|
411 | size_t length, size_t offset);
|
---|
412 |
|
---|
413 | /*----------------------------------------------------------------------------*/
|
---|
414 |
|
---|
415 | /**
|
---|
416 | * Add a byte array dataref to a multi-dataref buffer.
|
---|
417 | *
|
---|
418 | * @return the ID of the dataref that can be used later. If the buffer
|
---|
419 | * ID is invalid, INVALID_DATAREF_ID is returned.
|
---|
420 | */
|
---|
421 | size_t xplra_multi_add_byte_array(int bufferID, const char* name,
|
---|
422 | size_t length, size_t offset);
|
---|
423 |
|
---|
424 | /*----------------------------------------------------------------------------*/
|
---|
425 |
|
---|
426 | /**
|
---|
427 | * Finalize the given buffer, if not finalized yet.
|
---|
428 | *
|
---|
429 | * @return -1 on error (if the buffer ID is invalid), 0 if there is no
|
---|
430 | * data in the buffer, 1 if there is data in it.
|
---|
431 | */
|
---|
432 | int xplra_multi_finalize(int bufferID);
|
---|
433 |
|
---|
434 | /*----------------------------------------------------------------------------*/
|
---|
435 |
|
---|
436 | /**
|
---|
437 | * Register the buffer with the given ID in X-Plane. If needed, it
|
---|
438 | * will be finalized too.
|
---|
439 | *
|
---|
440 | * @return 0 on success, -1 on error
|
---|
441 | */
|
---|
442 | int xplra_multi_register(int bufferID);
|
---|
443 |
|
---|
444 | /*----------------------------------------------------------------------------*/
|
---|
445 |
|
---|
446 | /**
|
---|
447 | * Unregister the buffer with the given ID from X-Plane. If needed, it
|
---|
448 | * will be finalized too.
|
---|
449 | *
|
---|
450 | * @return 0 on success, -1 on error
|
---|
451 | */
|
---|
452 | int xplra_multi_unregister(int bufferID);
|
---|
453 |
|
---|
454 | /*----------------------------------------------------------------------------*/
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * Execute the buffer with the given ID. If the buffer is not
|
---|
458 | * finalized, it will be finalized. If it is not finalized, but
|
---|
459 | * registered, the registration will be cleared, and it will be
|
---|
460 | * re-registered after finalizing.
|
---|
461 | *
|
---|
462 | * @return 0 on success, -1 on error
|
---|
463 | */
|
---|
464 | int xplra_multi_execute(int bufferID);
|
---|
465 |
|
---|
466 | /*----------------------------------------------------------------------------*/
|
---|
467 |
|
---|
468 | /**
|
---|
469 | * Set the value of an integer dataref with the given ID.
|
---|
470 | *
|
---|
471 | * @return 0 on success, -1 on error.
|
---|
472 | */
|
---|
473 | int xplra_multi_set_int(int bufferID, size_t datarefID, int value);
|
---|
474 |
|
---|
475 | /*----------------------------------------------------------------------------*/
|
---|
476 |
|
---|
477 | /**
|
---|
478 | * Get the value of an integer dataref with the given ID.
|
---|
479 | *
|
---|
480 | * @param dest pointer to the variable that will receive the value
|
---|
481 | *
|
---|
482 | * @return 0 on success, -1 on error.
|
---|
483 | */
|
---|
484 | int xplra_multi_get_int(int* dest, int bufferID, size_t datarefID);
|
---|
485 |
|
---|
486 | /*----------------------------------------------------------------------------*/
|
---|
487 |
|
---|
488 | /**
|
---|
489 | * Get a const pointer to the integer dataref with the given ID
|
---|
490 | *
|
---|
491 | * @return the pointer or success, 0 on error.
|
---|
492 | */
|
---|
493 | const int32_t* xplra_multi_get_int_const_ptr(int bufferID, size_t datarefID);
|
---|
494 |
|
---|
495 | /*----------------------------------------------------------------------------*/
|
---|
496 |
|
---|
497 | /**
|
---|
498 | * Get a pointer to the integer dataref with the given ID
|
---|
499 | *
|
---|
500 | * @return the pointer or success, 0 on error.
|
---|
501 | */
|
---|
502 | int32_t* xplra_multi_get_int_ptr(int bufferID, size_t datarefID);
|
---|
503 |
|
---|
504 | /*----------------------------------------------------------------------------*/
|
---|
505 |
|
---|
506 | /**
|
---|
507 | * Set the value of a float dataref with the given ID.
|
---|
508 | *
|
---|
509 | * @return 0 on success, -1 on error.
|
---|
510 | */
|
---|
511 | int xplra_multi_set_float(int bufferID, size_t datarefID, float value);
|
---|
512 |
|
---|
513 | /*----------------------------------------------------------------------------*/
|
---|
514 |
|
---|
515 | /**
|
---|
516 | * Get the value of a float dataref with the given ID.
|
---|
517 | *
|
---|
518 | * @param dest pointer to the variable that will receive the value
|
---|
519 | *
|
---|
520 | * @return 0 on success, -1 on error.
|
---|
521 | */
|
---|
522 | int xplra_multi_get_float(float* dest, int bufferID, size_t datarefID);
|
---|
523 |
|
---|
524 | /*----------------------------------------------------------------------------*/
|
---|
525 |
|
---|
526 | /**
|
---|
527 | * Get a const pointer to the float dataref with the given ID
|
---|
528 | *
|
---|
529 | * @return the pointer or success, 0 on error.
|
---|
530 | */
|
---|
531 | const float* xplra_multi_get_float_const_ptr(int bufferID, size_t datarefID);
|
---|
532 |
|
---|
533 | /*----------------------------------------------------------------------------*/
|
---|
534 |
|
---|
535 | /**
|
---|
536 | * Get a pointer to the float dataref with the given ID
|
---|
537 | *
|
---|
538 | * @return the pointer or success, 0 on error.
|
---|
539 | */
|
---|
540 | float* xplra_multi_get_float_ptr(int bufferID, size_t datarefID);
|
---|
541 |
|
---|
542 | /*----------------------------------------------------------------------------*/
|
---|
543 |
|
---|
544 | /**
|
---|
545 | * Set the value of a double dataref with the given ID.
|
---|
546 | *
|
---|
547 | * @return 0 on success, -1 on error.
|
---|
548 | */
|
---|
549 | int xplra_multi_set_double(int bufferID, size_t datarefID, double value);
|
---|
550 |
|
---|
551 | /*----------------------------------------------------------------------------*/
|
---|
552 |
|
---|
553 | /**
|
---|
554 | * Get the value of a double dataref with the given ID.
|
---|
555 | *
|
---|
556 | * @param dest pointer to the variable that will receive the value
|
---|
557 | *
|
---|
558 | * @return 0 on success, -1 on error.
|
---|
559 | */
|
---|
560 | int xplra_multi_get_double(double* dest, int bufferID, size_t datarefID);
|
---|
561 |
|
---|
562 | /*----------------------------------------------------------------------------*/
|
---|
563 |
|
---|
564 | /**
|
---|
565 | * Get a const pointer to the double dataref with the given ID
|
---|
566 | *
|
---|
567 | * @return the pointer or success, 0 on error.
|
---|
568 | */
|
---|
569 | const double* xplra_multi_get_double_const_ptr(int bufferID, size_t datarefID);
|
---|
570 |
|
---|
571 | /*----------------------------------------------------------------------------*/
|
---|
572 |
|
---|
573 | /**
|
---|
574 | * Get a pointer to the double dataref with the given ID
|
---|
575 | *
|
---|
576 | * @return the pointer or success, 0 on error.
|
---|
577 | */
|
---|
578 | double* xplra_multi_get_double_ptr(int bufferID, size_t datarefID);
|
---|
579 |
|
---|
580 | /*----------------------------------------------------------------------------*/
|
---|
581 |
|
---|
582 | /**
|
---|
583 | * Set the contents of the float array dataref with the given ID.
|
---|
584 | *
|
---|
585 | * @param length the amount of data. If 0, it is assumed to be the
|
---|
586 | * length of the data in the buffer minus the offset.
|
---|
587 | * @param offset the offset within the buffer to set the data from
|
---|
588 | *
|
---|
589 | * @return the number of data items set, or -1 on error.
|
---|
590 | */
|
---|
591 | ssize_t xplra_multi_set_float_array(int bufferID, size_t datarefID,
|
---|
592 | const float* value, size_t length,
|
---|
593 | size_t offset);
|
---|
594 |
|
---|
595 | /*----------------------------------------------------------------------------*/
|
---|
596 |
|
---|
597 | /**
|
---|
598 | * Get the contents of the float array with the given ID.
|
---|
599 | *
|
---|
600 | * @param length the amount of data. If 0, it is assumed to be the
|
---|
601 | * length of the data in the buffer minus the offset.
|
---|
602 | * @param offset the offset within the buffer to get the data from
|
---|
603 | *
|
---|
604 | * @return the number of data items retrieved, or -1 on error.
|
---|
605 | */
|
---|
606 | ssize_t xplra_multi_get_float_array(float* value,
|
---|
607 | size_t length, size_t offset,
|
---|
608 | int bufferID, size_t datarefID);
|
---|
609 |
|
---|
610 | /*----------------------------------------------------------------------------*/
|
---|
611 |
|
---|
612 | /**
|
---|
613 | * Get a pointer to the float array with the given ID.
|
---|
614 | *
|
---|
615 | * @param offset the offset within the buffer.
|
---|
616 | *
|
---|
617 | * @return the pointer on success, 0 on error.
|
---|
618 | */
|
---|
619 | const float* xplra_multi_get_float_array_ptr(int bufferID, size_t datarefID,
|
---|
620 | size_t offset);
|
---|
621 |
|
---|
622 | /*----------------------------------------------------------------------------*/
|
---|
623 |
|
---|
624 | /**
|
---|
625 | * Set the contents of the integer array dataref with the given ID.
|
---|
626 | *
|
---|
627 | * @param length the amount of data. If 0, it is assumed to be the
|
---|
628 | * length of the data in the buffer minus the offset.
|
---|
629 | * @param offset the offset within the buffer to set the data from
|
---|
630 | *
|
---|
631 | * @return the number of data items set, or -1 on error.
|
---|
632 | */
|
---|
633 | ssize_t xplra_multi_set_int_array(int bufferID, size_t datarefID,
|
---|
634 | const int32_t* value, size_t length,
|
---|
635 | size_t offset);
|
---|
636 |
|
---|
637 | /*----------------------------------------------------------------------------*/
|
---|
638 |
|
---|
639 | /**
|
---|
640 | * Get the contents of the integer array with the given ID.
|
---|
641 | *
|
---|
642 | * @param length the amount of data. If 0, it is assumed to be the
|
---|
643 | * length of the data in the buffer minus the offset.
|
---|
644 | * @param offset the offset within the buffer to get the data from
|
---|
645 | *
|
---|
646 | * @return the number of data items retrieved, or -1 on error.
|
---|
647 | */
|
---|
648 | ssize_t xplra_multi_get_int_array(int32_t* value,
|
---|
649 | size_t length, size_t offset,
|
---|
650 | int bufferID, size_t datarefID);
|
---|
651 |
|
---|
652 | /*----------------------------------------------------------------------------*/
|
---|
653 |
|
---|
654 | /**
|
---|
655 | * Get a pointer to the integer array with the given ID.
|
---|
656 | *
|
---|
657 | * @param offset the offset within the buffer.
|
---|
658 | *
|
---|
659 | * @return the pointer on success, 0 on error.
|
---|
660 | */
|
---|
661 | const int32_t* xplra_multi_get_int_array_ptr(int bufferID, size_t datarefID,
|
---|
662 | size_t offset);
|
---|
663 |
|
---|
664 | /*----------------------------------------------------------------------------*/
|
---|
665 |
|
---|
666 | /**
|
---|
667 | * Set the contents of the byte array dataref with the given ID.
|
---|
668 | *
|
---|
669 | * @param length the amount of data. If 0, it is assumed to be the
|
---|
670 | * length of the data in the buffer minus the offset.
|
---|
671 | * @param offset the offset within the buffer to set the data from
|
---|
672 | *
|
---|
673 | * @return the number of data items set, or -1 on error.
|
---|
674 | */
|
---|
675 | ssize_t xplra_multi_set_byte_array(int bufferID, size_t datarefID,
|
---|
676 | const void* value, size_t length,
|
---|
677 | size_t offset);
|
---|
678 |
|
---|
679 | /*----------------------------------------------------------------------------*/
|
---|
680 |
|
---|
681 | /**
|
---|
682 | * Get the contents of the byte array with the given ID.
|
---|
683 | *
|
---|
684 | * @param length the amount of data. If 0, it is assumed to be the
|
---|
685 | * length of the data in the buffer minus the offset.
|
---|
686 | * @param offset the offset within the buffer to get the data from
|
---|
687 | *
|
---|
688 | * @return the number of data items retrieved, or -1 on error.
|
---|
689 | */
|
---|
690 | ssize_t xplra_multi_get_byte_array(void* value,
|
---|
691 | size_t length, size_t offset,
|
---|
692 | int bufferID, size_t datarefID);
|
---|
693 |
|
---|
694 | /*----------------------------------------------------------------------------*/
|
---|
695 |
|
---|
696 | /**
|
---|
697 | * Get a pointer to the byte array with the given ID.
|
---|
698 | *
|
---|
699 | * @param offset the offset within the buffer.
|
---|
700 | *
|
---|
701 | * @return the pointer on success, 0 on error.
|
---|
702 | */
|
---|
703 | const uint8_t* xplra_multi_get_byte_array_ptr(int bufferID, size_t datarefID,
|
---|
704 | size_t offset);
|
---|
705 |
|
---|
706 | /*----------------------------------------------------------------------------*/
|
---|
707 |
|
---|
708 | /**
|
---|
709 | * Set the value of the byte array with the given ID from the given
|
---|
710 | * string. If the string is shorter than the array, the rest will be
|
---|
711 | * filled with 0s.
|
---|
712 | *
|
---|
713 | * @return the number of bytes set, or -1 on error
|
---|
714 | */
|
---|
715 | ssize_t xplra_multi_set_string(int bufferID, size_t datarefID,
|
---|
716 | const char* value, size_t offset);
|
---|
717 |
|
---|
718 | /*----------------------------------------------------------------------------*/
|
---|
719 |
|
---|
720 | /**
|
---|
721 | * Get a pointer as a string pointer to the byte array with the given
|
---|
722 | * ID.
|
---|
723 | *
|
---|
724 | * @return the pointer on success, 0 on error.
|
---|
725 | */
|
---|
726 | const char* xplra_multi_get_string_ptr(int bufferID, size_t datarefID,
|
---|
727 | size_t offset);
|
---|
728 |
|
---|
729 | /*----------------------------------------------------------------------------*/
|
---|
730 |
|
---|
731 | /**
|
---|
732 | * Destroy a multi-dataref buffer for the given connection.
|
---|
733 | *
|
---|
734 | * @param connectionID the ID of the connection for which the buffer
|
---|
735 | * has been created.
|
---|
736 | *
|
---|
737 | * @return 0 on success, -1 on error.
|
---|
738 | */
|
---|
739 | int xplra_multi_destroy_buffer(int connectionID, int bufferID);
|
---|
740 |
|
---|
741 | /*----------------------------------------------------------------------------*/
|
---|
742 | /*----------------------------------------------------------------------------*/
|
---|
743 |
|
---|
744 | /**
|
---|
745 | * Show a message in the simulator window for the given duration.
|
---|
746 | */
|
---|
747 | int xplra_show_message(int connectionID, const char* message, float duration);
|
---|
748 |
|
---|
749 | /*----------------------------------------------------------------------------*/
|
---|
750 | /*----------------------------------------------------------------------------*/
|
---|
751 |
|
---|
752 | /**
|
---|
753 | * Destroy the connection with the given ID.
|
---|
754 | *
|
---|
755 | * @return 0 on success, -1 on error.
|
---|
756 | */
|
---|
757 | int xplra_disconnect(int connectionID);
|
---|
758 |
|
---|
759 | /*----------------------------------------------------------------------------*/
|
---|
760 |
|
---|
761 | #ifdef __cplusplus
|
---|
762 | } // extern "C"
|
---|
763 | #endif
|
---|
764 |
|
---|
765 | /*----------------------------------------------------------------------------*/
|
---|
766 | #endif // HU_VARADIISTVAN_XPLRA_XPLRA_H
|
---|