Added selectDATA command to Java client and modified MATLAB client to use it.
This commit is contained in:
@@ -46,3 +46,12 @@ end
|
||||
|
||||
%% Get data
|
||||
result.raw = socket.readDATA();
|
||||
|
||||
%% Format data
|
||||
rows = (length(result.raw) - 5) / 9;
|
||||
result.h = zeroes(rows);
|
||||
for i=1:rows
|
||||
j = 6 + (i - 1) * 9;
|
||||
result.h(i) = result.rows(j);
|
||||
result.d = [result.d; result.rows((j+1):(j+9))];
|
||||
end
|
||||
@@ -1,13 +1,9 @@
|
||||
function [ status ] = selectDATA( index, varargin )
|
||||
function selectDATA( rows, socket )
|
||||
% selectDATA Choose specific X-Plane parameters to be send over UDP
|
||||
%
|
||||
% Inputs
|
||||
% index: An array of the values that to be sent. Corresponds to the numbers on the XPlane Output screen
|
||||
% IP Address (optional): IP Address of the machine that will receive the data as a character array. Default is '127.0.0.1' (local machine)
|
||||
% port (optional): Port on the receiving machine where the data will be sent. Default is 49009 (XPlaneConnect). In general use 49009 to send to the plugin and 49005 to send to the x-plane udp
|
||||
%
|
||||
% Outputs
|
||||
% status: If there was an error. Status<0 means there was an error.
|
||||
% rows: An array of the values that to be sent. Corresponds to the numbers on the XPlane Output screen
|
||||
% socket (optional): The client to use when sending the command.
|
||||
%
|
||||
% Use
|
||||
% 1. import XPlaneConnect.*;
|
||||
@@ -15,29 +11,23 @@ function [ status ] = selectDATA( index, varargin )
|
||||
% 3. status = selectDATA( values, '127.0.0.1', 49005 ); % send to localhose port 49005
|
||||
%
|
||||
% Contributors
|
||||
% [CT] Christopher Teubert (SGT, Inc.)
|
||||
% christopher.a.teubert@nasa.gov
|
||||
%
|
||||
% To Do
|
||||
% 1. Verify Input
|
||||
%
|
||||
% BEGIN CODE
|
||||
% Christopher Teubert (SGT, Inc.) <christopher.a.teubert@nasa.gov>
|
||||
% Jason Watkins <jason.w.watkins@nasa.gov>
|
||||
|
||||
import XPlaneConnect.*
|
||||
|
||||
%% Handle Input
|
||||
p = inputParser;
|
||||
addRequired(p,'index');
|
||||
addOptional(p,'IP','127.0.0.1',@ischar);
|
||||
addOptional(p,'port',49009,@isnumeric);
|
||||
parse(p,index,varargin{:});
|
||||
|
||||
%% BODY
|
||||
dataString = ['DSEL'-0,0];
|
||||
for i=1:length(index)
|
||||
dataString = [dataString, p.Results.index(i), 0, 0, 0];
|
||||
%% 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.');
|
||||
if isempty(clients)
|
||||
openUDP();
|
||||
end
|
||||
status = sendUDP(dataStream, p.Results.IP, p.Results.port);
|
||||
|
||||
socket = clients(1);
|
||||
end
|
||||
|
||||
%% Validate input
|
||||
rows = int32(rows);
|
||||
|
||||
%% Send command
|
||||
socket.selectDATA(rows);
|
||||
|
||||
Reference in New Issue
Block a user