Skip to content

Data Manager

Jason Watkins edited this page May 12, 2015 · 1 revision

The Data Manager component provides a wrapper around the XPLM data interface. This component provides two basic data interface mechanisms. The primary mechanism is the DREF enumeration that names commonly used X-Plane datarefs. The DataManager class provides methods to get and set the value of these datarefs in a strongly typed manner. The DataManager class also provides a secondary mechanism to get and set arbitrary datarefs by name using 32 bit floats.

###Types

####DREF An enumeration of common datarefs used by the plugin. These are mapped to XPLMDataRefs internally by the data manager.

####DataManager Contains methods to martial data between the plugin and X-Plane.

#####DataManager Methods

######Initialize Signature: static void Initialize();

Initializes the internal data used by DataManager to translate DREF values into X-Plane internal data.

######Get (String) Signature: static int Get(const std::string& dref, float values[], int size);

Gets a named dataref and converts it to a float array.

The first time this method (or the string based Set method) is called for a given dataref, it must perform a relatively expensive lookup operation to translate the given string into an X-Plane internal pointer. This value is cached, so subsequent calls will incur minimal overhead (a lookup in a std::map).

######Get (Type) Signatures:

static double GetDouble(DREF dref, char aircraft = 0);
static float GetFloat(DREF dref, char aircraft = 0);
static int GetInt(DREF dref, char aircraft = 0);
static int GetFloatArray(DREF dref, float values[], int size, char aircraft = 0);
static int GetIntArray(DREF dref, int values[], int size, char aircraft = 0);

Gets the value of the the specified dataref.

This method does not verify the type of the dataref requested. It is the responsibility of the caller to check the X-Plane documentation and call the appropriate overload of this method. If an overload that is not type compatible with the dataref is called, the value returned is determined by the X-Plane plugin manager, and is considered undefined by the plugin.

######Set (String) Signature: static void Set(const std::string& dref, float values[], int size);

Sets the value of a named dataref by converting the given values to the appropriate type.

The first time this method (or the string based Get method) is called for a given dataref, it must perform a relatively expensive lookup operation to translate the given string into an X-Plane internal pointer. This value is cached, so subsequent calls will incur minimal overhead (a lookup in a std::map).

######Set (Type) Signatures:

static void Set(DREF dref, double value, char aircraft = 0);
static void Set(DREF dref, float value, char aircraft = 0);
static void Set(DREF dref, int value, char aircraft = 0);
static void Set(DREF dref, float values[], int size, char aircraft = 0);
static void Set(DREF dref, int values[], int size, char aircraft = 0);

Sets the value of the specified dataref.

This method does not verify the type of the dref being set. It is the responsibility of the caller to check the X-Plane documentation and call the appropriate overload of this method. If an overload that is not compatible with the specified dataref is called, the operation will fail silently.

######SetGear Signature: static void SetGear(float gear, bool immediate, char aircraft = 0);

Sets the position of the landing gear on the specified aircraft. If immediate is false, only the gear handle position is set; if immediate is true, both the gear handle and the actual position of the landing gear are set. For multiplayer aircraft, only the actual position of the gear can be set.

######SetPosition Signature: static void SetPosition(float pos[3], char aircraft = 0);

Sets the global position of the specified aircraft.

######SetOrientation Signature: static void SetOrientation(float orient[3], char aircraft = 0);

Sets the pitch, roll, and yaw values of the specified aircraft.

######SetFlaps Signature: static void SetFlaps(float value);

Sets the flap deployment on the player aircraft. Values are a percentage between 0.0 and 1.0.