Changeset 66:f7c8521991df in xplra for src/client
- Timestamp:
- 04/09/13 15:41:24 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/client
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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):
Note:
See TracChangeset
for help on using the changeset viewer.