Added MATLAB client support for WYPT command.

This commit is contained in:
Jason Watkins
2015-04-09 12:15:59 -07:00
parent 2e05f57baf
commit cfeb01fc02
3 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
function [ status ] = sendWYPT( op, points, varargin )
% 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.
%
% Use
% 1. import XPlaneConnect.*;
% 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
%
% 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
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

View File

@@ -0,0 +1,26 @@
function sendWYPTTest()
%% Setup
addpath('../../MATLAB')
import XPlaneConnect.*
points = [37.5245, -122.06899, 2500,...
37.455397, -122.050037, 2500,...
37.469567, -122.051411, 2500,...
37.479376, -122.060509, 2300,...
37.482237, -122.076130, 2100,...
37.474881, -122.087288, 1900,...
37.467660, -122.079391, 1700,...
37.466298, -122.090549, 1500,...
37.362562, -122.039223, 1000,...
37.361448, -122.034416, 1000,...
37.361994, -122.026348, 1000,...
37.365541, -122.022572, 1000,...
37.373727, -122.024803, 1000,...
37.403869, -122.041283, 50,...
37.418544, -122.049222, 6];
%% Test
sendWYPT(1, points);
end

View File

@@ -18,6 +18,7 @@ theTests = {{@openCloseTest, 'Open/Close Test', 0},...
{@DATATest,'DATA Test', 0},...
{@CTRLTest,'CTRL Test', 0},...
{@POSITest,'POSI Test', 0},...
{@sendWYPTTest,'WYPT Test', 0},...
{@pauseTest,'Pause Test', 0},...
{@struTest,'Struct Test', 0},...
{@setConnTest, 'setConn Test', 0}};