Refactored MATLAB client to use the Java client internally.

- Still need to implement selectDATA for all languages.
This commit is contained in:
Jason Watkins
2015-04-17 14:59:09 -07:00
parent 8e6819b80b
commit e191537bc9
20 changed files with 307 additions and 695 deletions

View File

@@ -1,53 +1,43 @@
function [ status ] = sendWYPT( op, points, varargin )
function sendWYPT( op, points, socket )
% sendWYPT Adds, removes, or clears a set of waypoints to be rendered in
% the simulator.
%
% Inputs
% msg: The string to be displayed
% x (optional): The distance from the left edge of the screen to display the message.
% y (optional): The distance from the bottom edge of the screen to display the message.
% 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: 0 if successful, otherwise a negative value.
% op: The operation to perform. 1=add, 2=remove, 3=clear.
% points: An array of values representing points. Each triplet in the
% array will be interpreted as a (Lat, Lon, Alt) point.
% socket (optional): The client to use when sending the command.
%
% Use
% 1. import XPlaneConnect.*;
% 2. #Set a message to be displayed near the top middle of the screen.
% 2. %Set a message to be displayed near the top middle of the screen.
% 3. status = sendTEXT('Some text', 512, 600);
%
% Contributors
% Jason Watkins
% jason.w.watkins@nasa.gov
% Jason Watkins (jason.w.watkins@nasa.gov)
%
% To Do
%
% BEGIN CODE
import XPlaneConnect.*
%% Handle Input
p = inputParser;
addRequired(p,'op');
addRequired(p,'points');
addOptional(p,'IP','127.0.0.1',@ischar);
addOptional(p,'port',49009,@isnumeric);
parse(p,op,points,varargin{:});
%% Validate Input
%% Get client
global clients;
if ~exist('socket', 'var')
assert(istrue(length(clients) < 2), '[sendCTRL] ERROR: Multiple clients open. You must specify which client to use.');
if isempty(clients)
openUDP();
end
socket = clients(1);
end
%% Validate input
len = uint32(length(points));
assert(op > 0 && op < 4);
assert(mod(len, 3) == 0);
assert(len / 3 < 20);
%% Body
header = ['WYPT'-0,0];
dataStream = [header,...
uint8(op),...
uint8(len / 3),...
typecast(single(points), 'uint8')];
% Send TEXT
status = sendUDP(dataStream, p.Results.IP, p.Results.port);
end
%% Send command
socket.sendCTRL(ctrl, ac);
end