-
Notifications
You must be signed in to change notification settings - Fork 278
getDREFs
Gets the value of one or more X-Plane datarefs.
Language | Signature |
---|---|
C | int getDREFs(XPCSocket sock, const char* drefs[], float* values[], unsigned char count, int sizes[]) |
MATLAB | result = getDREFs( drefs, socket ) |
Java | float[][] getDREFs(String[] drefs) |
Python | getDREFs(drefs) |
sock
(C): The socket used to send the command.
msg
: The string to display on the screen
drefs
: The names of the datarefs to get.
values
(C): A 2 dimensional array in which to store the result.
sizes
(C): The allocated size of each array in values
. When getDREFs
returns, each item in sizes
will be set to the number of items actually written
to the respective array in values
, which will be less than or equal to the
initial value of that item in sizes
.
socket
(MATLAB): An optional reference to a socket opened with openUDP
that
should be used to send the command.
C: A negative value if an error occurs, otherwise 0.
All others: An array representing the dataref value.
Dataref names and their associated data types can be found on the
XPSDK wiki. The size of
value
should match the size given on that page. XPC currently sends all values
as floats regardless of the type described on the wiki. This doesn't cause any
data loss for most datarefs.
C Error Code | Java Exception | Python Error | Description |
---|---|---|---|
-1 | IOException | OSError | The client is unable to send the command |
-2 | IOException | OSError | The client is unable to read the response |
#include "xplaneConnect.h"
XPCSocket sock = aopenUDP("127.0.0.1", 49007);
// Get the status of the gear handle and the actual landing gear
char* drefs[2] = {"sim/cockpit/switches/gear_handle_status", "sim/aircraft/parts/acf_gear_deploy"};
float* values[2];
values[0] = (float*)malloc(1 * sizeof(float));
values[1] = (float*)malloc(10 * sizeof(float));
int sizes[2] = { 1, 10 };
if(getDREFs(sock, drefs, &values, 2, &sizes) < 0)
{
printf("And error occured.");
}
else
{
printf("The gear handle status is %f.", values[0][0]);
}
closeUDP(sock);
import XPlaneConnect.*
DREFS = {'sim/cockpit/switches/gear_handle_status',...
'sim/aircraft/parts/acf_gear_deploy'};
result = getDREFs(DREFS);
import gov.nasa.xpc.XPlaneConnect;
try(XPlaneConnect xpc = new XPlaneConnect())
{
String[] drefs ={"sim/cockpit/switches/gear_handle_status", "sim/aircraft/parts/acf_gear_deploy"};
float[][] values = xpc.getDREFs(drefs);
System.out.print("The gear handle status is ");
System.out.println(values[0][0]);
}
import xpc
with xpc.XPlaneConnect() as client:
drefs = ["sim/cockpit/switches/gear_handle_status", "sim/aircraft/parts/acf_gear_deploy"]
values = client.getDREFs(drefs)
print "The gear handle status is " + str(values[0][0])