Fixed errors in MATLAB client and updated tests.

This commit is contained in:
Jason Watkins
2015-04-21 09:51:49 -07:00
parent 3ad2bb76cb
commit 1523405495
29 changed files with 109 additions and 128 deletions

View File

@@ -24,14 +24,15 @@ 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.');
assert(isequal(length(clients) < 2, 1), '[getDREFs] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
openUDP();
socket = openUDP();
else
socket = clients(1);
end
socket = clients(1);
end
%% Send command
result = socket.getDREF(drefs);
result = socket.getDREFs(drefs);
end

View File

@@ -29,7 +29,8 @@ addOptional(p,'port',0,@isnumeric);
parse(p,varargin{:});
%% Create client
javaaddpath('XPlaneConnect.jar');
[folder, ~, ~] = fileparts(which('XPlaneConnect.openUDP'));
javaaddpath([folder, '\XPlaneConnect.jar']);
import gov.nasa.xpc.*;
socket = XPlaneConnect(p.Results.xpHost, p.Results.xpPort, p.Results.port);

View File

@@ -20,11 +20,12 @@ import XPlaneConnect.*
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[pauseSim] ERROR: Multiple clients open. You must specify which client to use.');
assert(isequal(length(clients) < 2, 1), '[pauseSim] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
openUDP();
socket = openUDP();
else
socket = clients(1);
end
socket = clients(1);
end
%% Validate input

View File

@@ -37,11 +37,12 @@ import XPlaneConnect.*
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[sendDATA] ERROR: Multiple clients open. You must specify which client to use.');
assert(istrue(length(clients) < 2), '[readDATA] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
openUDP();
socket = openUDP();
else
socket = clients(1);
end
socket = clients(1);
end
%% Get data

View File

@@ -19,11 +19,12 @@ import XPlaneConnect.*
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[sendDATA] ERROR: Multiple clients open. You must specify which client to use.');
assert(istrue(length(clients) < 2), '[selectDATA] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
openUDP();
socket = openUDP();
else
socket = clients(1);
end
socket = clients(1);
end
%% Validate input

View File

@@ -32,11 +32,12 @@ import XPlaneConnect.*
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[sendCTRL] ERROR: Multiple clients open. You must specify which client to use.');
assert(isequal(length(clients) < 2, 1), '[sendCTRL] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
openUDP();
socket = openUDP();
else
socket = clients(1);
end
socket = clients(1);
end
%% Validate input

View File

@@ -28,11 +28,12 @@ import XPlaneConnect.*
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[sendDATA] ERROR: Multiple clients open. You must specify which client to use.');
assert(isequal(length(clients) < 2, 1), '[sendDATA] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
openUDP();
socket = openUDP();
else
socket = clients(1);
end
socket = clients(1);
end
%% Validate input

View File

@@ -31,11 +31,12 @@ import XPlaneConnect.*
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[pauseSim] ERROR: Multiple clients open. You must specify which client to use.');
assert(isequal(length(clients) < 2, 1), '[sendPOSI] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
openUDP();
socket = openUDP();
else
socket = clients(1);
end
socket = clients(1);
end
%% Validate input
@@ -46,6 +47,6 @@ end
ac = logical(ac);
%% Send command
socket.sendCTRL(ctrl, ac);
socket.sendPOSI(posi, ac);
end

View File

@@ -24,11 +24,12 @@ import XPlaneConnect.*
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[sendCTRL] ERROR: Multiple clients open. You must specify which client to use.');
assert(isequal(length(clients) < 2, 1), '[sendTEXT] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
openUDP();
socket = openUDP();
else
socket = clients(1);
end
socket = clients(1);
end
%% Validate input

View File

@@ -25,19 +25,31 @@ import XPlaneConnect.*
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[sendCTRL] ERROR: Multiple clients open. You must specify which client to use.');
assert(isequal(length(clients) < 2, 1), '[sendWYPT] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
openUDP();
socket = openUDP();
else
socket = clients(1);
end
socket = clients(1);
end
%% Get WaypointOp class
[folder, ~, ~] = fileparts(which('XPlaneConnect.openUDP'));
javaaddpath([folder, '\XPlaneConnect.jar']);
import gov.nasa.xpc.*;
%% Validate input
len = uint32(length(points));
assert(op > 0 && op < 4);
wyptOp = WaypointOp.Add;
if isequal(op, 2)
wyptOp = WaypointOp.Del;
elseif isequal(op, 3)
wyptOp = WaypointOp.Clr;
end
assert(mod(len, 3) == 0);
%% Send command
socket.sendCTRL(ctrl, ac);
socket.sendWYPT(wyptOp, points);
end

View File

@@ -19,11 +19,12 @@ import XPlaneConnect.*
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[sendCTRL] ERROR: Multiple clients open. You must specify which client to use.');
assert(isequal(length(clients) < 2, 1), '[setCONN] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
openUDP();
socket = openUDP();
else
socket = clients(1);
end
socket = clients(1);
end
%% Validate input

View File

@@ -23,11 +23,12 @@ import XPlaneConnect.*
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[setDREF] ERROR: Multiple clients open. You must specify which client to use.');
assert(isequal(length(clients) < 2, 1), '[setDREF] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
openUDP();
socket = openUDP();
else
socket = clients(1);
end
socket = clients(1);
end
%% Validate input