X-Plane Remote Access Plugin and Client Library
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
xplra.MultiBuffer Class Reference
Inheritance diagram for xplra.MultiBuffer:
xplra.MultiGetter xplra.MultiSetter

Public Member Functions

def __init__ (self, xplane, registerCommand, unregisterCommand)
 
def values (self)
 
def addInt (self, name)
 
def addFloat (self, name)
 
def addDouble (self, name)
 
def addFloatArray (self, name, length=-1, offset=0)
 
def addIntArray (self, name, length=-1, offset=0)
 
def addByteArray (self, name, length=-1, offset=0)
 
def finalize (self)
 
def register (self)
 
def unregister (self)
 
def unregisterSafely (self)
 
def execute (self)
 
def getString (self, id)
 
def __len__ (self)
 
def __getitem__ (self, id)
 
def __setitem__ (self, id, value)
 
def __iter__ (self)
 

Private Member Functions

def _reregister (self)
 
def _add (self, name, type, length=None, offset=None)
 
def _writeSpec (self, command)
 

Static Private Member Functions

def _getDefault (type, length)
 

Private Attributes

 _xplane
 the XPlane object this buffer belongs to
 
 _registerCommand
 the command used to perform the registration of this buffer (COMMAND_REGISTER_GET_MULTI or COMMAND_REGISTER_SET_MULTI)
 
 _unregisterCommand
 the command used to perform the registration of this buffer (COMMAND_UNREGISTER_GET_MULTI or COMMAND_UNREGISTER_SET_MULTI)
 
 _dataRefs
 the datarefs belonging to the buffer
 
 _values
 the value of the datarefs before setting or after querying
 
 _registeredID
 the ID with which the buffer is registered in X-Plane
 

Detailed Description

Buffer for querying or setting multi-dataref values.

Definition at line 668 of file xplra.py.

Constructor & Destructor Documentation

◆ __init__()

def xplra.MultiBuffer.__init__ (   self,
  xplane,
  registerCommand,
  unregisterCommand 
)
Construct the buffer for the given XPlane instance and with the
given register/unregister command values.

Definition at line 707 of file xplra.py.

Member Function Documentation

◆ __getitem__()

def xplra.MultiBuffer.__getitem__ (   self,
  id 
)
Get the item with the given ID.

Definition at line 881 of file xplra.py.

◆ __iter__()

def xplra.MultiBuffer.__iter__ (   self)
Get an iterator over the values of this buffer.

Definition at line 916 of file xplra.py.

◆ __len__()

def xplra.MultiBuffer.__len__ (   self)
Get the number of value items in the buffer.

Definition at line 875 of file xplra.py.

◆ __setitem__()

def xplra.MultiBuffer.__setitem__ (   self,
  id,
  value 
)
Set the item with the given ID.

Definition at line 887 of file xplra.py.

◆ _add()

def xplra.MultiBuffer._add (   self,
  name,
  type,
  length = None,
  offset = None 
)
private
Add a scalar to the buffer with the given name and type

Definition at line 850 of file xplra.py.

◆ _getDefault()

def xplra.MultiBuffer._getDefault (   type,
  length 
)
staticprivate
Get the default value for the given type.

Definition at line 692 of file xplra.py.

◆ _reregister()

def xplra.MultiBuffer._reregister (   self)
private
Re-register the buffer in X-Plane, if it has been registered earlier

If it has not been registered, nothing is done. Otherwise the buffer
gets registered, and the old ID is forgotten. This function is meant to
be used by the XPlane object when it creates a new connection. If the
registration fails, the original ID is restored, so the _reregister()
could be called again

Definition at line 832 of file xplra.py.

◆ _writeSpec()

def xplra.MultiBuffer._writeSpec (   self,
  command 
)
private
Write the specification preceded by the given command and check for
the result.

The specification is basically the list of the datarefs.

Definition at line 857 of file xplra.py.

◆ addByteArray()

def xplra.MultiBuffer.addByteArray (   self,
  name,
  length = -1,
  offset = 0 
)
Add a byte array to the buffer with the given name.

Returns an ID (or index) of the dataref.

Definition at line 756 of file xplra.py.

◆ addDouble()

def xplra.MultiBuffer.addDouble (   self,
  name 
)
Add a double to the buffer with the given name

Returns an ID (or index) of the dataref.

Definition at line 738 of file xplra.py.

◆ addFloat()

def xplra.MultiBuffer.addFloat (   self,
  name 
)
Add a float to the buffer with the given name

Returns an ID (or index) of the dataref.

Definition at line 732 of file xplra.py.

◆ addFloatArray()

def xplra.MultiBuffer.addFloatArray (   self,
  name,
  length = -1,
  offset = 0 
)
Add a floating point array to the buffer with the given name.

Returns an ID (or index) of the dataref.

Definition at line 744 of file xplra.py.

◆ addInt()

def xplra.MultiBuffer.addInt (   self,
  name 
)
Add an integer to the buffer with the given name

Returns an ID (or index) of the dataref.

Definition at line 726 of file xplra.py.

◆ addIntArray()

def xplra.MultiBuffer.addIntArray (   self,
  name,
  length = -1,
  offset = 0 
)
Add an integer array to the buffer with the given name.

Returns an ID (or index) of the dataref.

Definition at line 750 of file xplra.py.

◆ execute()

def xplra.MultiBuffer.execute (   self)
Perform the querying or the setting of the values.

It first checks if the buffer is finalized. If not, it will be
finalized. However, if it is not finalized but also registered, it will
first be unregistered and the re-registered after finalizing.

Definition at line 801 of file xplra.py.

◆ finalize()

def xplra.MultiBuffer.finalize (   self)
Finalize the buffer, if not finalized yet.

It initializes the array of values with some defaults.

Returns whether there is any data in the buffer.

Definition at line 762 of file xplra.py.

◆ getString()

def xplra.MultiBuffer.getString (   self,
  id 
)
Get the value of the dataref with the given ID as a string.

The dataref should be of type byte array.

Definition at line 818 of file xplra.py.

◆ register()

def xplra.MultiBuffer.register (   self)
Register the buffer in X-Plane.

Definition at line 773 of file xplra.py.

◆ unregister()

def xplra.MultiBuffer.unregister (   self)
Unregister the buffer from X-Plane.

Definition at line 779 of file xplra.py.

◆ unregisterSafely()

def xplra.MultiBuffer.unregisterSafely (   self)
Unregister the buffer from X-Plane, ignoring exceptions.

Returns True if the unregistration succeeded, False otherwise.

Definition at line 788 of file xplra.py.

◆ values()

def xplra.MultiBuffer.values (   self)
Query the values as a list.

Definition at line 720 of file xplra.py.


The documentation for this class was generated from the following file: