Fixed issues resolving Java classes.

- XPlaneConnect.jar is now only added once in openUDP.
 - Fully qualified all Java identifiers to resolve import issues.
This commit is contained in:
Jason Watkins
2015-04-22 13:41:09 -07:00
parent 6ecff63a61
commit 8bbe3a0ec9
2 changed files with 8 additions and 12 deletions

View File

@@ -29,10 +29,11 @@ addOptional(p,'port',0,@isnumeric);
parse(p,varargin{:}); parse(p,varargin{:});
%% Create client %% Create client
[folder, ~, ~] = fileparts(which('XPlaneConnect.openUDP')); if ~exist('gov.nasa.xpc.XPlaneConnect', 'class')
javaaddpath([folder, filesep, 'XPlaneConnect.jar']); [folder, ~, ~] = fileparts(which('XPlaneConnect.openUDP'));
import gov.nasa.xpc.*; javaaddpath(fullfile(folder, 'XPlaneConnect.jar'));
socket = XPlaneConnect(p.Results.xpHost, p.Results.xpPort, p.Results.port); end
socket = gov.nasa.xpc.XPlaneConnect(p.Results.xpHost, p.Results.xpPort, p.Results.port);
%% Track open clients %% Track open clients
global clients; global clients;

View File

@@ -33,19 +33,14 @@ if ~exist('socket', 'var')
end end
end end
%% Get WaypointOp class
[folder, ~, ~] = fileparts(which('XPlaneConnect.openUDP'));
javaaddpath([folder, filesep, 'XPlaneConnect.jar']);
import gov.nasa.xpc.*;
%% Validate input %% Validate input
len = uint32(length(points)); len = uint32(length(points));
assert(op > 0 && op < 4); assert(op > 0 && op < 4);
wyptOp = WaypointOp.Add; wyptOp = gov.nasa.xpc.WaypointOp.Add;
if isequal(op, 2) if isequal(op, 2)
wyptOp = WaypointOp.Del; wyptOp = gov.nasa.xpc.WaypointOp.Del;
elseif isequal(op, 3) elseif isequal(op, 3)
wyptOp = WaypointOp.Clr; wyptOp = gov.nasa.xpc.WaypointOp.Clr;
end end
assert(mod(len, 3) == 0); assert(mod(len, 3) == 0);