Changeset 66:f7c8521991df in xplra for src/client/python
- Timestamp:
- 04/09/13 15:41:24 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.