Merge branch 'master' into develop
# Conflicts: # xpcPlugin/XPlaneConnect/mac.xpl # xpcPlugin/xpcPlugin.xcodeproj/project.pbxproj
This commit is contained in:
Binary file not shown.
@@ -22,6 +22,10 @@ socket.close;
|
||||
|
||||
%% Track open clients
|
||||
global clients;
|
||||
%TODO: Remove stale clients
|
||||
for i = 1:length(clients)
|
||||
if socket == clients(i)
|
||||
clients = [clients(1:i-1) clients(i+1:length(clients))];
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
29
MATLAB/+XPlaneConnect/getCTRL.m
Normal file
29
MATLAB/+XPlaneConnect/getCTRL.m
Normal file
@@ -0,0 +1,29 @@
|
||||
function ctrl = getCTRL(ac, socket)
|
||||
% getCTRL Gets control surface information for the specified aircraft
|
||||
%
|
||||
% Inputs
|
||||
% ac: The aircraft number to get control surface data for.
|
||||
% Outputs
|
||||
% posi: An array of values matching the the format used by sendCTRL
|
||||
|
||||
|
||||
import XPlaneConnect.*
|
||||
|
||||
%% Get client
|
||||
global clients;
|
||||
if ~exist('socket', 'var')
|
||||
assert(isequal(length(clients) < 2, 1), '[getCTRL] ERROR: Multiple clients open. You must specify which client to use.');
|
||||
if isempty(clients)
|
||||
socket = openUDP();
|
||||
else
|
||||
socket = clients(1);
|
||||
end
|
||||
end
|
||||
|
||||
%% Validate input
|
||||
ac = int32(ac);
|
||||
|
||||
%% Send command
|
||||
ctrl = socket.getCTRL(ac);
|
||||
|
||||
end
|
||||
29
MATLAB/+XPlaneConnect/getPOSI.m
Normal file
29
MATLAB/+XPlaneConnect/getPOSI.m
Normal file
@@ -0,0 +1,29 @@
|
||||
function posi = getPOSI(ac, socket)
|
||||
% getPOSI Gets position information for the specified aircraft
|
||||
%
|
||||
% Inputs
|
||||
% ac: The aircraft number to get position data for.
|
||||
% Outputs
|
||||
% posi: An array of values matching the the format used by sendPOSI
|
||||
|
||||
|
||||
import XPlaneConnect.*
|
||||
|
||||
%% Get client
|
||||
global clients;
|
||||
if ~exist('socket', 'var')
|
||||
assert(isequal(length(clients) < 2, 1), '[getPOSI] ERROR: Multiple clients open. You must specify which client to use.');
|
||||
if isempty(clients)
|
||||
socket = openUDP();
|
||||
else
|
||||
socket = clients(1);
|
||||
end
|
||||
end
|
||||
|
||||
%% Validate input
|
||||
ac = int32(ac);
|
||||
|
||||
%% Send command
|
||||
posi = socket.getPOSI(ac);
|
||||
|
||||
end
|
||||
@@ -26,6 +26,7 @@ p = inputParser;
|
||||
addOptional(p,'xpHost','127.0.0.1',@ischar);
|
||||
addOptional(p,'xpPort',49009,@isnumeric);
|
||||
addOptional(p,'port',0,@isnumeric);
|
||||
addOptional(p,'timeout',100,@isnumeric);
|
||||
parse(p,varargin{:});
|
||||
|
||||
%% Create client
|
||||
@@ -33,7 +34,7 @@ if ~exist('gov.nasa.xpc.XPlaneConnect', 'class')
|
||||
[folder, ~, ~] = fileparts(which('XPlaneConnect.openUDP'));
|
||||
javaaddpath(fullfile(folder, 'XPlaneConnect.jar'));
|
||||
end
|
||||
socket = gov.nasa.xpc.XPlaneConnect(p.Results.xpHost, p.Results.xpPort, p.Results.port);
|
||||
socket = gov.nasa.xpc.XPlaneConnect(p.Results.xpHost, p.Results.xpPort, p.Results.port, p.Results.timeout);
|
||||
|
||||
%% Track open clients
|
||||
global clients;
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
function sendDREF( dref, value, socket )
|
||||
% sendDREF Sends a command to X-Plane that sets the given DREF.
|
||||
% sendDREFs Sends a command to X-Plane that sets the given DREF. This
|
||||
% function is now an alias to sendDREFs. It is kept only for backwards
|
||||
% compatibility.
|
||||
%
|
||||
% Inputs
|
||||
% dref: The name of the X-Plane dataref to set.
|
||||
% Value: An array of floating point values whose structure depends on the dref specified.
|
||||
% socket (optional): The client to use when sending the command.
|
||||
%
|
||||
% Use
|
||||
% 1. import XPlaneConnect.*
|
||||
% 2. dataRef = 'sim/aircraft/parts/acf_gear_deploy'; // Landing Gear
|
||||
% 3. Value = 0;
|
||||
% 4. status = setDREF(dataRef, Value);
|
||||
%
|
||||
% Contributors
|
||||
% [CT] Christopher Teubert (SGT, Inc.)
|
||||
% christopher.a.teubert@nasa.gov
|
||||
@@ -20,19 +11,8 @@ function sendDREF( dref, value, socket )
|
||||
|
||||
import XPlaneConnect.*
|
||||
|
||||
%% Get client
|
||||
global clients;
|
||||
if ~exist('socket', 'var')
|
||||
assert(isequal(length(clients) < 2, 1), '[setDREF] ERROR: Multiple clients open. You must specify which client to use.');
|
||||
if isempty(clients)
|
||||
socket = openUDP();
|
||||
else
|
||||
socket = clients(1);
|
||||
end
|
||||
end
|
||||
|
||||
%% Validate input
|
||||
value = single(value);
|
||||
|
||||
%%Send command
|
||||
socket.sendDREF(dref, value);
|
||||
sendDREFs(dref, value)
|
||||
else
|
||||
sendDREFs(dref, value, socket)
|
||||
end
|
||||
37
MATLAB/+XPlaneConnect/sendDREFs.m
Normal file
37
MATLAB/+XPlaneConnect/sendDREFs.m
Normal file
@@ -0,0 +1,37 @@
|
||||
function sendDREFs( drefs, values, socket )
|
||||
% sendDREFs Sends a command to X-Plane that sets the given DREF(s).
|
||||
%
|
||||
% Inputs
|
||||
% dref: The name or names of the X-Plane dataref(s) to set.
|
||||
% Value: An array or an multidimensional array of floating point values
|
||||
% whose structure depends on the dref specified.
|
||||
% socket (optional): The client to use when sending the command.
|
||||
%
|
||||
% Use
|
||||
% 1. import XPlaneConnect.*
|
||||
% 2. dataRef = 'sim/aircraft/parts/acf_gear_deploy'; // Landing Gear
|
||||
% 3. Value = 0;
|
||||
% 4. status = setDREF(dataRef, Value);
|
||||
%
|
||||
% Contributors
|
||||
% [JW] Jason Watkins
|
||||
% jason.w.watkins@nasa.gov
|
||||
|
||||
import XPlaneConnect.*
|
||||
|
||||
%% Get client
|
||||
global clients;
|
||||
if ~exist('socket', 'var')
|
||||
assert(isequal(length(clients) < 2, 1), '[setDREF] ERROR: Multiple clients open. You must specify which client to use.');
|
||||
if isempty(clients)
|
||||
socket = openUDP();
|
||||
else
|
||||
socket = clients(1);
|
||||
end
|
||||
end
|
||||
|
||||
%% Validate input
|
||||
values = single(values);
|
||||
|
||||
%%Send command
|
||||
socket.sendDREFs(drefs, values);
|
||||
35
MATLAB/+XPlaneConnect/sendVIEW.m
Normal file
35
MATLAB/+XPlaneConnect/sendVIEW.m
Normal file
@@ -0,0 +1,35 @@
|
||||
function sendVIEW(view, socket)
|
||||
% sendVIEW Sets the camera
|
||||
%
|
||||
%Inputs
|
||||
% view: The view to use.
|
||||
% socket (optional): The client to use when sending the command.
|
||||
%
|
||||
%Use
|
||||
% 1. import XPlaneConnect.*;
|
||||
% 2. sendView(Forwards);
|
||||
%
|
||||
% Contributors
|
||||
% [JW] Jason Watkins <jason.w.watkins@nasa.gov>
|
||||
|
||||
import XPlaneConnect.*
|
||||
|
||||
%% Get client
|
||||
global clients;
|
||||
if ~exist('socket', 'var')
|
||||
assert(isequal(length(clients) < 2, 1), '[pauseSim] ERROR: Multiple clients open. You must specify which client to use.');
|
||||
if isempty(clients)
|
||||
socket = openUDP();
|
||||
else
|
||||
socket = clients(1);
|
||||
end
|
||||
end
|
||||
|
||||
%% Validate input
|
||||
|
||||
|
||||
%% Send command
|
||||
socket.sendVIEW(view)
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user