Refactored MATLAB client to use the Java client internally.
- Still need to implement selectDATA for all languages.
This commit is contained in:
37
MATLAB/+XPlaneConnect/getDREFs.m
Normal file
37
MATLAB/+XPlaneConnect/getDREFs.m
Normal file
@@ -0,0 +1,37 @@
|
||||
function result = requestDREFs( 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(istrue(length(clients) < 2), '[getDREFs] ERROR: Multiple clients open. You must specify which client to use.');
|
||||
if isempty(clients)
|
||||
openUDP();
|
||||
end
|
||||
socket = clients(1);
|
||||
end
|
||||
|
||||
%% Send command
|
||||
result = socket.getDREF(drefs);
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user