diff --git a/MATLAB/+XPlaneConnect/XPlaneConnect.jar b/MATLAB/+XPlaneConnect/XPlaneConnect.jar index c779711..eba5283 100644 Binary files a/MATLAB/+XPlaneConnect/XPlaneConnect.jar and b/MATLAB/+XPlaneConnect/XPlaneConnect.jar differ diff --git a/MATLAB/+XPlaneConnect/getCTRL.m b/MATLAB/+XPlaneConnect/getCTRL.m new file mode 100644 index 0000000..820afca --- /dev/null +++ b/MATLAB/+XPlaneConnect/getCTRL.m @@ -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 \ No newline at end of file diff --git a/MATLAB/+XPlaneConnect/getPOSI.m b/MATLAB/+XPlaneConnect/getPOSI.m new file mode 100644 index 0000000..35b8d5a --- /dev/null +++ b/MATLAB/+XPlaneConnect/getPOSI.m @@ -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 \ No newline at end of file diff --git a/TestScripts/MATLAB Tests/getCTRLTest.m b/TestScripts/MATLAB Tests/getCTRLTest.m new file mode 100644 index 0000000..3dc74f8 --- /dev/null +++ b/TestScripts/MATLAB Tests/getCTRLTest.m @@ -0,0 +1,15 @@ +function getCTRLTest() +%GETCTRLTEST Summary of this function goes here +% Detailed explanation goes here +addpath('../../MATLAB') +import XPlaneConnect.* + +values = [10.0, 5.0, -5.0, 0.8, 1.0, 0.5, -1.5]; +sendCTRL(values, 0); +actual = getCTRL(0); + +assert(isequal(length(actual), length(values))); +for i = 1:length(actual) + assert(abs(actual(i) - values(i)) <1e-4) +end +end diff --git a/TestScripts/MATLAB Tests/getPOSITest.m b/TestScripts/MATLAB Tests/getPOSITest.m new file mode 100644 index 0000000..c80b79a --- /dev/null +++ b/TestScripts/MATLAB Tests/getPOSITest.m @@ -0,0 +1,17 @@ +function getPOSITest() +%GETCTRLTEST Summary of this function goes here +% Detailed explanation goes here +addpath('../../MATLAB') +import XPlaneConnect.* + +values = [ 37.524, -122.06899, 2500, 45, -45, 15, 1 ]; +pauseSim(1); +sendPOSI(values, 0); +actual = getPOSI(0); +pauseSim(0); + +assert(isequal(length(actual), length(values))); +for i = 1:length(actual) + assert(abs(actual(i) - values(i)) <1e-4) +end +end diff --git a/TestScripts/MATLAB Tests/CTRLTest.m b/TestScripts/MATLAB Tests/sendCTRLTest.m similarity index 98% rename from TestScripts/MATLAB Tests/CTRLTest.m rename to TestScripts/MATLAB Tests/sendCTRLTest.m index 7b8a9bc..0569917 100644 --- a/TestScripts/MATLAB Tests/CTRLTest.m +++ b/TestScripts/MATLAB Tests/sendCTRLTest.m @@ -1,4 +1,4 @@ -function CTRLTest( ) +function sendCTRLTest( ) %CTRLTest Summary of this function goes here % Detailed explanation goes here %% Test player aircraft diff --git a/TestScripts/MATLAB Tests/POSITest.m b/TestScripts/MATLAB Tests/sendPOSITest.m similarity index 96% rename from TestScripts/MATLAB Tests/POSITest.m rename to TestScripts/MATLAB Tests/sendPOSITest.m index 16b6c8d..42a6e15 100644 --- a/TestScripts/MATLAB Tests/POSITest.m +++ b/TestScripts/MATLAB Tests/sendPOSITest.m @@ -1,4 +1,4 @@ -function POSITest( ) +function sendPOSITest( ) %POSITest Summary of this function goes here % Detailed explanation goes here addpath('../../MATLAB') diff --git a/TestScripts/MATLAB Tests/tests.m b/TestScripts/MATLAB Tests/tests.m index 13e0be4..2ef6d5f 100644 --- a/TestScripts/MATLAB Tests/tests.m +++ b/TestScripts/MATLAB Tests/tests.m @@ -18,8 +18,10 @@ theTests = {{@openCloseTest, 'Open/Close Test', 0},... {@getDREFsTest,'Request DREF Test', 0},... {@sendDREFTest,'Send DREF Test', 0},... {@DATATest,'DATA Test', 0},... - {@CTRLTest,'CTRL Test', 0},... - {@POSITest,'POSI Test', 0},... + {@sendCTRLTest,'sendCTRL Test', 0},... + {@getCTRLTest,'getCTRL Test', 0},... + {@sendPOSITest,'sendPOSI Test', 0},... + {@getPOSITest,'getPOSI Test', 0},... {@sendWYPTTest,'WYPT Test', 0},... {@sendVIEWTest,'VIEW Test', 0},... {@pauseTest,'Pause Test', 0},...