diff --git a/MATLAB/+XPlaneConnect/XPlaneConnect.jar b/MATLAB/+XPlaneConnect/XPlaneConnect.jar index e4c0af5..c779711 100644 Binary files a/MATLAB/+XPlaneConnect/XPlaneConnect.jar and b/MATLAB/+XPlaneConnect/XPlaneConnect.jar differ diff --git a/MATLAB/+XPlaneConnect/sendVIEW.m b/MATLAB/+XPlaneConnect/sendVIEW.m new file mode 100644 index 0000000..d95814c --- /dev/null +++ b/MATLAB/+XPlaneConnect/sendVIEW.m @@ -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 + +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 + diff --git a/TestScripts/MATLAB Tests/sendVIEWTest.m b/TestScripts/MATLAB Tests/sendVIEWTest.m new file mode 100644 index 0000000..4cfe29c --- /dev/null +++ b/TestScripts/MATLAB Tests/sendVIEWTest.m @@ -0,0 +1,26 @@ +function sendVIEWTest() +%% Setup +addpath('../../MATLAB') +import XPlaneConnect.* + +if ~exist('gov.nasa.xpc.ViewType', 'class') + [folder, ~, ~] = fileparts(which('XPlaneConnect.openUDP')); + javaaddpath(fullfile(folder, 'XPlaneConnect.jar')); +end + +dref = 'sim/graphics/view/view_type'; +fwd = 1000; +chase = 1017; + +%% Excecute +sendVIEW(gov.nasa.xpc.ViewType.Forwards); +result = getDREFs(dref); +assert(isequal(result, fwd)) + +sendVIEW(gov.nasa.xpc.ViewType.Chase); +result = getDREFs(dref); +assert(isequal(result, chase)) + + +end + diff --git a/TestScripts/MATLAB Tests/tests.m b/TestScripts/MATLAB Tests/tests.m index 6871686..11c8800 100644 --- a/TestScripts/MATLAB Tests/tests.m +++ b/TestScripts/MATLAB Tests/tests.m @@ -18,6 +18,7 @@ theTests = {{@openCloseTest, 'Open/Close Test', 0},... {@CTRLTest,'CTRL Test', 0},... {@POSITest,'POSI Test', 0},... {@sendWYPTTest,'WYPT Test', 0},... + {@sendVIEWTest,'VIEW Test', 0},... {@pauseTest,'Pause Test', 0},... {@setConnTest, 'setConn Test', 0}};