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{:});
%% Create client
[folder, ~, ~] = fileparts(which('XPlaneConnect.openUDP'));
javaaddpath([folder, filesep, 'XPlaneConnect.jar']);
import gov.nasa.xpc.*;
socket = XPlaneConnect(p.Results.xpHost, p.Results.xpPort, p.Results.port);
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);
%% Track open clients
global clients;

View File

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