Changeset 66:f7c8521991df in xplra
- Timestamp:
- 04/09/13 15:41:24 (12 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
.hgignore
r63 r66 14 14 build 15 15 dist 16 doc/html -
src/client/c/hu/varadiistvan/xplra/MultiBuffer.cc
r57 r66 259 259 //------------------------------------------------------------------------------ 260 260 261 size_t MultiBuffer::addInt(const st ring& name) throw()261 size_t MultiBuffer::addInt(const std::string& name) throw() 262 262 { 263 263 unfinalize(); … … 268 268 //------------------------------------------------------------------------------ 269 269 270 size_t MultiBuffer::addFloat(const st ring& name) throw()270 size_t MultiBuffer::addFloat(const std::string& name) throw() 271 271 { 272 272 unfinalize(); … … 277 277 //------------------------------------------------------------------------------ 278 278 279 size_t MultiBuffer::addDouble(const st ring& name) throw()279 size_t MultiBuffer::addDouble(const std::string& name) throw() 280 280 { 281 281 unfinalize(); … … 286 286 //------------------------------------------------------------------------------ 287 287 288 size_t MultiBuffer::addFloatArray(const st ring& name, size_t length,288 size_t MultiBuffer::addFloatArray(const std::string& name, size_t length, 289 289 size_t offset) throw() 290 290 { … … 297 297 //------------------------------------------------------------------------------ 298 298 299 size_t MultiBuffer::addIntArray(const st ring& name, size_t length,299 size_t MultiBuffer::addIntArray(const std::string& name, size_t length, 300 300 size_t offset) throw() 301 301 { … … 308 308 //------------------------------------------------------------------------------ 309 309 310 size_t MultiBuffer::addByteArray(const st ring& name, size_t length,310 size_t MultiBuffer::addByteArray(const std::string& name, size_t length, 311 311 size_t offset) throw() 312 312 { -
src/client/c/hu/varadiistvan/xplra/MultiBuffer.h
r57 r66 329 329 * Set the value of the float array dataref with the given ID. 330 330 * 331 * @param id the ID of the float array dataref 332 * @param value the source buffer 331 333 * @param length the amount of data, i.e. you can set only a part 332 334 * of the data in the buffer. If 0, it is assumed to be the length … … 344 346 * Get the value of the float array dataref with the given ID 345 347 * 348 * @param id the ID of the float array dataref 349 * @param value the destination buffer 346 350 * @param length the size of the buffer. If 0, it is assumed to be 347 351 * the length of the data in the buffer minus the offset (see … … 360 364 * buffer. 361 365 * 366 * @param id the ID of the float array dataref 362 367 * @param offset the offset within the buffer. If it is not less 363 368 * than the length of the buffer, 0 is returned. … … 369 374 * Set the value of the integer array dataref with the given ID. 370 375 * 376 * @param id the ID of the integer array dataref 377 * @param value the source buffer 371 378 * @param length the amount of data, i.e. you can set only a part 372 379 * of the data in the buffer. If 0, it is assumed to be the length … … 384 391 * Get the value of the integer array dataref with the given ID 385 392 * 393 * @param id the ID of the integer array dataref 394 * @param value the destination buffer 386 395 * @param length the size of the buffer. If 0, it is assumed to be 387 396 * the length of the data in the buffer minus the offset (see … … 399 408 * Get the array of integer values as a directly readable buffer. 400 409 * 410 * @param id the ID of the float array dataref 401 411 * @param offset the offset within the buffer. If it is not less 402 412 * than the length of the buffer, 0 is returned. … … 409 419 * Set the value of the byte array dataref with the given ID. 410 420 * 421 * @param id the ID of the byte array dataref 422 * @param value the source buffer 411 423 * @param length the amount of data, i.e. you can set only a part 412 424 * of the data in the buffer. If 0, it is assumed to be the length … … 424 436 * Get the value of the byte array dataref with the given ID 425 437 * 438 * @param id the ID of the byte array dataref 439 * @param value the destination buffer 426 440 * @param length the size of the buffer. If 0, it is assumed to be 427 441 * the length of the data in the buffer minus the offset (see … … 433 447 */ 434 448 size_t getByteArray(size_t id, uint8_t* value, 435 size_t length = 0, size_t offset = 0) const449 size_t length = 0, size_t offset = 0) const 436 450 throw(InvalidIDException, TypeMismatchException); 437 451 … … 439 453 * Get the array of byte values as a directly readable buffer. 440 454 * 455 * @param id the ID of the byte array dataref 441 456 * @param offset the offset within the buffer. If it is not less 442 457 * than the length of the buffer, 0 is returned. -
src/client/c/hu/varadiistvan/xplra/XPlane.h
r54 r66 173 173 * Get a possibly partial array of floats. 174 174 * 175 * @param name the name of the dataref 176 * @param dest the destination buffer 175 177 * @param length the length of the destination buffer 176 178 * @param offset the offset from which to get the array … … 185 187 * be created with a length needed to hold the returned value. 186 188 * 189 * @param name the name of the dataref 190 * @param length will contain the number of floats read 187 191 * @param offset the offset from which to get the array 188 192 */ … … 193 197 * Get a possibly partial array of integers. 194 198 * 199 * @param name the name of the dataref 200 * @param dest the destination buffer 195 201 * @param length the length of the destination buffer 196 202 * @param offset the offset from which to get the array … … 205 211 * be created with a length needed to hold the returned value. 206 212 * 213 * @param name the name of the dataref 214 * @param length will contain the number of integers read 207 215 * @param offset the offset from which to get the array 208 216 */ … … 213 221 * Get a possibly partial array of bytes. 214 222 * 223 * @param name the name of the dataref 224 * @param dest the destination buffer 215 225 * @param length the length of the destination buffer 216 226 * @param offset the offset from which to get the array … … 225 235 * be created with a length needed to hold the returned value. 226 236 * 227 * @param offset the offset from which to get the array 228 */ 229 uint8_t* getByteArray(const char* name, size_t& lengyh, 237 * @param name the name of the dataref 238 * @param length will contain the number of bytes read on return 239 * @param offset the offset from which to get the array 240 */ 241 uint8_t* getByteArray(const char* name, size_t& length, 230 242 size_t offset = 0) throw(Exception); 231 243 -
src/client/python/xplra.py
r64 r66 8 8 #------------------------------------------------------------------------------- 9 9 10 ## @package xplra 11 # 12 # Python client module and C/C++ client library for the X-Plane Remote 13 # Access plugin 14 15 #------------------------------------------------------------------------------- 16 17 ## Protocol command: query the value of a single dataref 10 18 COMMAND_GET_SINGLE = 0x01 11 19 20 ## Protocol command: set the value of a single dataref 12 21 COMMAND_SET_SINGLE = 0x02 13 22 23 ## Protocol command: query the value of several datarefs 14 24 COMMAND_GET_MULTI = 0x03 15 25 26 ## Protocol command: set the value of several datarefs 16 27 COMMAND_SET_MULTI = 0x04 17 28 29 ## Protocol command: register a multi-dataref getter 18 30 COMMAND_REGISTER_GET_MULTI = 0x11 19 31 32 ## Protocol command: unregister a multi-dataref getter 20 33 COMMAND_UNREGISTER_GET_MULTI = 0x12 21 34 35 ## Protocol command: execute a registered multi-dataref getter 22 36 COMMAND_EXECUTE_GET_MULTI = 0x13 23 37 38 ## Protocol command: register a multi-dataref setter 24 39 COMMAND_REGISTER_SET_MULTI = 0x21 25 40 41 ## Protocol command: unregister a multi-dataref setter 26 42 COMMAND_UNREGISTER_SET_MULTI = 0x22 27 43 44 ## Protocol command: execute a registered multi-dataref setter 28 45 COMMAND_EXECUTE_SET_MULTI = 0x23 29 46 47 ## Protocol command: get the versions of X-Plane, XPLM and XPLRA 30 48 COMMAND_GET_VERSIONS = 0x31 31 49 50 ## Protocol command: reload all plugins 32 51 COMMAND_RELOAD_PLUGINS = 0x32 33 52 53 ## Protocol command: show a message to the pilot 34 54 COMMAND_SHOW_MESSAGE = 0x41 35 55 56 ## Protocol command: register hotkeys 36 57 COMMAND_REGISTER_HOTKEYS = 0x51 37 58 59 ## Protocol command: query the status of registered hotkeys 38 60 COMMAND_QUERY_HOTKEYS = 0x52 39 61 62 ## Protocol command: unregister hotkeys 40 63 COMMAND_UNREGISTER_HOTKEYS = 0x53 41 64 65 ## Protocol type constant: integer 42 66 TYPE_INT = 0x01 43 67 68 ## Protocol type constant: single-precision floating point 44 69 TYPE_FLOAT = 0x02 45 70 71 ## Protocol type constant: double-precision floating point 46 72 TYPE_DOUBLE = 0x03 47 73 74 ## Protocol type constant: array of single-precision floating point values 48 75 TYPE_FLOAT_ARRAY = 0x11 49 76 77 ## Protocol type constant: array of integers 50 78 TYPE_INT_ARRAY = 0x12 51 79 80 ## Protocol type constant: array of bytes 52 81 TYPE_BYTE_ARRAY = 0x13 53 82 83 ## Protocol result: OK 54 84 RESULT_OK = 0x00 55 85 86 ## Protocol result: an invalid command was sent 56 87 RESULT_INVALID_COMMAND = 0x01 57 88 89 ## Protocol result: an unknown dataref was attempted to query or set 58 90 RESULT_UNKNOWN_DATAREF = 0x02 59 91 92 ## Protocol result: invalid type 60 93 RESULT_INVALID_TYPE = 0x03 61 94 95 ## Protocol result: invalid length 62 96 RESULT_INVALID_LENGTH = 0x04 63 97 98 ## Protocol result: invalid offset 64 99 RESULT_INVALID_OFFSET = 0x05 65 100 101 ## Protocol result: invalid count 66 102 RESULT_INVALID_COUNT = 0x06 67 103 104 ## Protocol result: invalid ID 68 105 RESULT_INVALID_ID = 0x07 69 106 107 ## Protocol result: invalid duration 70 108 RESULT_INVALID_DURATION = 0x08 71 109 110 ## Protocol result: other error 72 111 RESULT_OTHER_ERROR = 0xff 73 112 113 ## Hotkey modifier: Shift 74 114 HOTKEY_MODIFIER_SHIFT = 0x0100 75 115 116 ## Hotkey modifier: Control 76 117 HOTKEY_MODIFIER_CONTROL = 0x0200 77 118 … … 80 121 class ProtocolException(Exception): 81 122 """Exception to signify protocol errors.""" 123 124 ## mapping from result codes to their string representation 82 125 _message = { RESULT_INVALID_COMMAND : "invalid command", 83 126 RESULT_UNKNOWN_DATAREF : "unknown dataref", … … 90 133 RESULT_OTHER_ERROR : "other error" } 91 134 135 ## @var resultCode 136 # the result code, one of the RESULT_XXX constants 137 ## @var parameter 138 # an optional parameter for the result 139 92 140 @staticmethod 93 141 def getMessage(resultCode): … … 99 147 100 148 def __init__(self, resultCode, parameter = None): 149 """Construct the exception.""" 101 150 message = "xplra.ProtocolException: " + self.getMessage(resultCode) 102 151 if parameter is not None: … … 116 165 class Win32NamedPipe(io.RawIOBase): 117 166 """A stream object to represent a Win32 named pipe.""" 167 ## @var _handle 168 # the Windows file handle for the pipe 169 118 170 def __init__(self, name): 119 171 """Construct the pipe with the given name.""" … … 211 263 class XPlane(object): 212 264 """The main class representing the connection to X-Plane.""" 265 266 ## @var _stream 267 # the data stream used to communicate with the plugin 268 ## @var _multiBuffers 269 # the list of multi-dataref buffers belonging to this object 213 270 214 271 @staticmethod … … 574 631 class MultiBuffer(object): 575 632 """Buffer for querying or setting multi-dataref values.""" 633 634 ## @var _xplane 635 # the \ref XPlane object this buffer belongs to 636 637 ## @var _registerCommand 638 # the command used to perform the registration of this buffer 639 # (\ref COMMAND_REGISTER_GET_MULTI or \ref COMMAND_REGISTER_SET_MULTI) 640 641 ## @var _unregisterCommand 642 # the command used to perform the registration of this buffer 643 # (\ref COMMAND_UNREGISTER_GET_MULTI or \ref COMMAND_UNREGISTER_SET_MULTI) 644 645 ## @var _dataRefs 646 # the datarefs belonging to the buffer 647 648 ## @var _values 649 # the value of the datarefs before setting or after querying 650 651 ## @var _registeredID 652 # the ID with which the buffer is registered in X-Plane 653 576 654 @staticmethod 577 655 def _getDefault(type, length): -
src/plugin/src/xplra/GetDataRefTask.h
r13 r66 246 246 * Construct the task for the dataref with the given name. 247 247 * 248 * @param name the name of the dataref 248 249 * @param maxCount the maximal number of items to retrieve. If <0, 249 250 * the function will perform an extra query to retrieve the size of 250 251 * of the dataref's data, which it will store in the task, so 251 252 * later on it can be reused. 253 * @param offset the offset from which to query the array 252 254 */ 253 255 GetArrayDataRefTask(const std::string& name, … … 257 259 * Construct the task for the given dataref 258 260 * 261 * @param dataRef the dataref 259 262 * @param maxCount the maximal number of items to retrieve. If <0, 260 263 * the function will perform an extra query to retrieve the size 261 264 * of the dataref's data, which it will store in the task, so 262 265 * later on it can be reused. 266 * @param offset the offset from which to query the array 263 267 */ 264 268 GetArrayDataRefTask(XPLMDataRef dataRef, … … 313 317 * Construct the task for the dataref with the given name. 314 318 * 319 * @param name the name of the dataref 315 320 * @param maxCount the maximal number of data items to 316 321 * retrieve. If <0, the function will perform an extra query to 317 322 * retrieve the size of the dataref's data, which it will store in 318 323 * the task, so later on it can be reused. 324 * @param offset the offset from which to query the array 319 325 */ 320 326 GetFloatArrayDataRefTask(const std::string& name, … … 324 330 * Construct the task for the given dataref 325 331 * 326 * @param maxBytes the maximal number of data items to 327 * retrieve. If <0, the function will perform an extra query to 328 * retrieve the size of the dataref's data, which it will store in 329 * the task, so later on it can be reused. 330 */ 331 GetFloatArrayDataRefTask(XPLMDataRef dataRef, 332 int maxCount = -1, int offset = 0); 333 }; 334 335 //------------------------------------------------------------------------------ 336 //------------------------------------------------------------------------------ 337 338 /** 339 * A dataref task which retrieves the value of an integer array. 340 */ 341 class GetIntArrayDataRefTask : 342 public GetArrayDataRefTask<int, GetIntArrayDataRefTask> 343 { 344 public: 345 /** 346 * Get the data via XPLM 347 */ 348 static int queryData(XPLMDataRef dataRef, int* dest, 349 int offset, int count); 350 351 public: 352 /** 353 * Construct the task for the dataref with the given name. 354 * 332 * @param dataRef the dataref 355 333 * @param maxCount the maximal number of data items to 356 334 * retrieve. If <0, the function will perform an extra query to 357 335 * retrieve the size of the dataref's data, which it will store in 358 336 * the task, so later on it can be reused. 359 */ 360 GetIntArrayDataRefTask(const std::string& name, 361 int maxCount = -1, int offset = 0); 362 363 /** 364 * Construct the task for the given dataref 365 * 366 * @param maxBytes the maximal number of data items to 337 * @param offset the offset from which to query the array 338 */ 339 GetFloatArrayDataRefTask(XPLMDataRef dataRef, 340 int maxCount = -1, int offset = 0); 341 }; 342 343 //------------------------------------------------------------------------------ 344 //------------------------------------------------------------------------------ 345 346 /** 347 * A dataref task which retrieves the value of an integer array. 348 */ 349 class GetIntArrayDataRefTask : 350 public GetArrayDataRefTask<int, GetIntArrayDataRefTask> 351 { 352 public: 353 /** 354 * Get the data via XPLM 355 */ 356 static int queryData(XPLMDataRef dataRef, int* dest, 357 int offset, int count); 358 359 public: 360 /** 361 * Construct the task for the dataref with the given name. 362 * 363 * @param name the name of the dataref 364 * @param maxCount the maximal number of data items to 367 365 * retrieve. If <0, the function will perform an extra query to 368 366 * retrieve the size of the dataref's data, which it will store in 369 367 * the task, so later on it can be reused. 368 * @param offset the offset from which to query the array 369 */ 370 GetIntArrayDataRefTask(const std::string& name, 371 int maxCount = -1, int offset = 0); 372 373 /** 374 * Construct the task for the given dataref 375 * 376 * @param dataRef the dataref 377 * @param maxCount the maximal number of data items to 378 * retrieve. If <0, the function will perform an extra query to 379 * retrieve the size of the dataref's data, which it will store in 380 * the task, so later on it can be reused. 381 * @param offset the offset from which to query the array 370 382 */ 371 383 GetIntArrayDataRefTask(XPLMDataRef dataRef, … … 393 405 * Construct the task for the dataref with the given name. 394 406 * 407 * @param name the name of the dataref 395 408 * @param maxBytes the maximal number of bytes to retrieve. If <0, 396 409 * the function will perform an extra query to retrieve the size 397 410 * of the dataref's data, which it will store in the task, so 398 411 * later on it can be reused. 412 * @param offset the offset from which to query the array 399 413 */ 400 414 GetByteArrayDataRefTask(const std::string& name, … … 404 418 * Construct the task for the given dataref 405 419 * 420 * @param dataRef the dataref 406 421 * @param maxBytes the maximal number of bytes to retrieve. If <0, 407 422 * the function will perform an extra query to retrieve the size 408 423 * of the dataref's data, which it will store in the task, so 409 424 * later on it can be reused. 425 * @param offset the offset from which to query the array 410 426 */ 411 427 GetByteArrayDataRefTask(XPLMDataRef dataRef, -
src/plugin/src/xplra/SetDataRefTask.h
r13 r66 62 62 * signifies an error only, if some wrong data is read. If the 63 63 * stream fails, it will indicate RESULT_OK. 64 * @param stream the stream to read from 64 65 * 65 66 * @return the new instance or 0 on error.
Note:
See TracChangeset
for help on using the changeset viewer.