-
Notifications
You must be signed in to change notification settings - Fork 276
/
getDREFs.m
38 lines (34 loc) · 1019 Bytes
/
getDREFs.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function result = getDREFs( drefs, socket )
%requestDREF request the value of a specific DataRef from X-Plane over UDP
%
%Inputs
% drefs: Cell Array of DataRefs to be requested
% socket (optional): The client to use when sending the command.
%Outputs
% result: cell array of resulting data.
%
%Use
% 1. import XPlaneConnect.*;
% 2. socket = opendUDP();
% 3. drefs = {'sim/cockpit2/controls/yoke_heading_ratio','sim/cockpit2/controls/yoke_roll_ratio'};
% 4. result = requestDREF(drefs, socket);
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
% [JW] Jason Watkins
% jason.w.watkins@nasa.gov
import XPlaneConnect.*
%% Get client
global clients;
if ~exist('socket', 'var')
assert(isequal(length(clients) < 2, 1), '[getDREFs] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
socket = openUDP();
else
socket = clients(1);
end
end
%% Send command
result = socket.getDREFs(drefs);
end