function  PATCHA  = readPATCHA(fid)
%
% <<<<<<<<<< CLASSIFICATION: UNCLASSIFIED >>>>>>>>>>
%
% READPATCHA Create structure for metadata fields.
%   PATCHA = READPATCHA(FID) returns a structure of fields and their
%   associated values.

% Written by Matt Donath, NGA, matthew.b.donath@nga.ic.gov
% References:
%  > MIL-STD-2500A, NATIONAL IMAGERY TRANSMISSION FORMAT VERSION 2.0
%  > MIL-STD-2500C, NATIONAL IMAGERY TRANSMISSION FORMAT VERSION 2.1
%  > STDI-0001,     NATIONAL SUPPORT DATA EXTENSIONS (SDE)(VERSION 1.3/CN2)
%                   FOR THE NATIONAL IMAGERY TRANSMISSION FORMAT (NITF)
%  > STDI-0002,     THE COMPENDIUM OF CONTROLLED EXTENSIONS (CE) FOR THE
%                   NATIONAL IMAGERY TRANSMISSION FORMAT (NITF) VERSION 2.1
%
% //////////////////////////////////////////
% /// CLASSIFICATION: UNCLASSIFIED       ///
% //////////////////////////////////////////

%% Create the metadata structure for PATCHA.

PATCHA.CETAG = fread(fid,6,'uint8=>char')';
PATCHA.CEL = str2double(fread(fid,5,'uint8=>char')');

PATCHA.PAT_NO = str2double(fread(fid,4,'uint8=>char')');
PATCHA.LAST_PAT_FLAG = fread(fid,1,'uint8=>char')';
PATCHA.LNSTRT = str2double(fread(fid,7,'uint8=>char')');
PATCHA.LNSTOP = str2double(fread(fid,7,'uint8=>char')');
PATCHA.AZL = str2double(fread(fid,5,'uint8=>char')');
PATCHA.NVL = str2double(fread(fid,5,'uint8=>char')');
PATCHA.FVL = str2double(fread(fid,3,'uint8=>char')');
PATCHA.NPIXEL = str2double(fread(fid,5,'uint8=>char')');
PATCHA.FVPIX = str2double(fread(fid,5,'uint8=>char')');
PATCHA.FRAME = str2double(fread(fid,3,'uint8=>char')');
PATCHA.UTC = str2double(fread(fid,8,'uint8=>char')');
PATCHA.SHEAD = str2double(fread(fid,7,'uint8=>char')');
PATCHA.GRAVITY = str2double(fread(fid,7,'uint8=>char')');
PATCHA.INS_V_NC = str2double(fread(fid,5,'uint8=>char')');
PATCHA.INS_V_EC = str2double(fread(fid,5,'uint8=>char')');
PATCHA.INS_V_DC = str2double(fread(fid,5,'uint8=>char')');
PATCHA.OFFLAT = str2double(fread(fid,8,'uint8=>char')');
PATCHA.OFFLONG = str2double(fread(fid,8,'uint8=>char')');
PATCHA.TRACK = str2double(fread(fid,3,'uint8=>char')');
PATCHA.GSWEEP = str2double(fread(fid,6,'uint8=>char')');
PATCHA.SHEAR = str2double(fread(fid,8,'uint8=>char')');

% //////////////////////////////////////////
% /// CLASSIFICATION: UNCLASSIFIED       ///
% //////////////////////////////////////////


%CVX_END_SET  Completes a cvx set specification.

cvx_end

% Copyright 2010 Michael C. Grant and Stephen P. Boyd.
% See the file COPYING.txt for full copyright information.
% The command 'cvx_where' will show where this file is located.


classdef dme_xfmr3p_opf < mp.dme_xfmr3p & mp.dme_shared_opf

%   MATPOWER
%   Copyright (c) 2022, Power Systems Engineering Research Center (PSERC)
%   by Ray Zimmerman, PSERC Cornell
%
%   This file is part of MATPOWER.
%   Covered by the 3-clause BSD License (see LICENSE file for details).
%   See https://matpower.org for more info.

%     properties
%     end     %% properties

%     methods
%     end     %% methods
end         %% classdef


function n = ndims(v,varargin)
% overloads ndims

n = ndims(v.x,varargin{:});


classdef nme_gen_acp < mp.nme_gen_ac & mp.form_acp

%   MATPOWER
%   Copyright (c) 2019-2020, Power Systems Engineering Research Center (PSERC)
%   by Ray Zimmerman, PSERC Cornell
%
%   This file is part of MATPOWER.
%   Covered by the 3-clause BSD License (see LICENSE file for details).
%   See https://matpower.org for more info.

%     properties
%     end     %% properties

%     methods
%     end     %% methods
end         %% classdef


function [ y, ierror ] = y_check_republican ( y )

%*****************************************************************************80
%
%% Y_CHECK_REPUBLICAN checks a Republican year.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    06 March 2013
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input/output, integer Y, the year, which must not be 0.
%
%    Output, integer IERROR, is 0 if Y is legal, and 1 otherwise.
%
  if ( 0 < y )
    ierror = 0;
  else
    ierror = 1;
  end

  return
end


classdef Voigt2Tensor3Drepresentation < handle

    properties (Access = protected)
        indexTransformer
    end

    methods (Access = protected)

        function createIndexTransformer(obj)
            obj.indexTransformer = TensorVoigtIndexTransformer3D();
        end

    end

end


 function run_mfile_local(arg, varargin)
%function run_mfile_local(arg)
%|
%| run an mfile in a local environment so that workspace variables
%| are untouched.  useful for tests.
%| arg can be a cell with many mfiles to run
%| options
%|	'draw'	1|0	1 to draw after each test (default: 0)
%|	'pause'	1|0	1 to pause after each test (default: 0)
%|	'abort'	1|0	1 to abort if any test fails (default: 0)
%|
%| Copyright 2005-6-21, Jeff Fessler, University of Michigan

if nargin < 1, ir_usage, end

opt.draw = false;
opt.pause = false;
opt.abort = false;
opt = vararg_pair(opt, varargin);

% track which tests open a figure even though they should not if im disabled
check_fig = ~figure_opened && ~im;
bad_fig = {};

test_bad = {};
test_good = {};
if iscell(arg)

	tmp = cpu('etic');

	for ii=1:length(arg)
		printf('\n\nTesting: %s\n\n', arg{ii})
		try
			time1 = cpu('etic');
			run_mfile_local(arg{ii})
			time1 = cpu(time1);
			test_good{end+1} = sprintf('%s (%.2f)', arg{ii}, time1);
		catch
			time1 = cpu(time1);
			test_bad{end+1} = sprintf('%s (%.2f)', arg{ii}, time1);
			if opt.abort
				fail('test "%s" failed', arg{ii})
			end
		end
		if opt.draw, drawnow, end
		if opt.pause, printm 'pausing', pause, end

		drawnow;
		if check_fig && figure_opened
			bad_fig{end+1} = arg{ii};
			close all
		end
	end

	if length(test_good)
		printf('\n----\n')
		printm('in "%s" the following test(s) passed:\n', caller_name)
		disp(char(test_good))
	end

	if length(bad_fig)
		warn('in %s: the following test(s) had figure issues:', caller_name)
		disp(char(bad_fig))
	end

	cpu(tmp, [caller_name ' time'])

	if length(test_bad)
		warn('in "%s" the following test(s) failed:', caller_name)
		disp(char(test_bad))
		error 'the above tests failed'
	else
		printm('in "%s" all %d tests passed!', caller_name, length(arg))
	end

else
	eval(arg)
end

% try to determine if any figure window is opened
function out = figure_opened
if isfreemat
	out = true; % freemat will not tell, so assume yes
else
	out = ~isempty(get(0, 'children')); % matlab knows
end


%Coverage
%  Generates XML coverage reports of executed code in 1 format:
%  - Cobertura
%
%  Example usage:
%    report = edu.stanford.covert.test.Coverage(<source dir>, <profile data (optional)>);
%    report.exportCoberturaXML(<fileName>);
%
%  This class was inspired by the mlcovr package by David Hart at Sandia
%  National Labs
%  (http://www.mathworks.com/matlabcentral/fileexchange/24985-mlcovr-package).
%
%  Author: Jonathan Karr
%  Affiliation: Covert Lab, Bioengineering, Stanford University
%  Last Updated: 12/16/2010
classdef Coverage
    properties
        sources
        basePath
        timeStamp
        stats
        packages
    end

    methods
        %- sources is a string indicating a source file directory, or a cell
        %  array containing multiple directories.
        %- basepath is string indicaticating path relative to which fileNames
        %  should be reported
        %- Optionall profData is a struct containing profile data generated by
        %  the MATLAB profiler and constructed by calling
        %    profData = profile('info')
        %  If profData is not provided the current profile data is used.
        function this = Coverage(sources, basePath, profData)
            if ~exist('sources', 'var')
                sources = {'.' 'r'};
            end
            if ~exist('basePath', 'var')
                basePath = '.';
            end
            basePath = absolutepath(basePath);

            if ~iscell(sources)
                sources = {sources 'r'};
            end
            for i = 1:size(sources, 1)
                sources{i, 1} = absolutepath(sources{i,1});

                if ~isdir(sources{i,1})
                    throw(MException('Coverage:invalidSource', 'Sources must be directories'));
                end

                if numel(basePath) > numel(sources{i,1}) || ~strcmp(sources{i,1}(1:numel(basePath)), basePath)
                    throw(MException('Coverage:invalidPath', 'source path must be contained within base path'));
                end
            end

            if ~exist('profData', 'var')
                profData = profile('info');
            end

            this.sources = sources;
            this.basePath = basePath;
            this.timeStamp = datestr(now, 31);
            this = this.buildReportFromDir(profData);
        end
    end

    methods (Access = protected)
        function this = buildReportFromDir(this, profData)
            %% get package names
            packageNames = {};
            for i = 1:size(this.sources, 1)
                packageNames = [packageNames; this.getPackageNamesFromDir(this.sources{i,1})];
            end
            packageNames = unique(packageNames);

            %% build report
            %packages
            packages = repmat(struct('name', [], ...
                'linesCovered', [], 'linesValid', [], 'lineRate', [], ...
                'branchesCovered', [], 'branchesValid',[], 'branchRate', [], ...
                'complexity', [], ...
                'classes', []), [0 1]); %#ok<*PROP>

            this.stats = struct('lineRate', [], 'branchRate', []);
            this.stats.linesCovered = 0;
            this.stats.linesValid = 0;
            this.stats.branchesCovered = 0;
            this.stats.branchesValid = 0;
            this.stats.complexity = 0;

            for i = 1:numel(packageNames)
                package = this.buildPackageReport(meta.package.fromName(packageNames{i}), profData);

                if isempty(package)
                    continue;
                end

                packages = [packages;
                    package];

                this.stats.linesCovered = this.stats.linesCovered + package.linesCovered;
                this.stats.linesValid = this.stats.linesValid + package.linesValid;
                this.stats.branchesCovered = this.stats.branchesCovered + package.branchesCovered;
                this.stats.branchesValid = this.stats.branchesValid + package.branchesValid;
                this.stats.complexity = this.stats.complexity + package.complexity;
            end

            %overall stats
            this.packages = packages;
            this.stats.lineRate = this.stats.linesCovered / this.stats.linesValid;
            this.stats.branchRate = this.stats.branchesCovered / this.stats.branchesValid;
        end

        function package = buildPackageReport(this, metaPackage, profData)
            package = [];

            if isempty(metaPackage.Classes) && isempty(metaPackage.Functions)
                return;
            end

            package.name = metaPackage.Name;
            package.classes = [];
            package.linesCovered = 0;
            package.branchesCovered = 0;
            package.linesValid = 0;
            package.branchesValid = 0;
            package.complexity = 0;
            package.classes = [];

            %classes
            for i = 1:numel(metaPackage.Classes)
                class = this.buildClassReport(metaPackage.Classes{i}, profData);

                if isempty(class); continue; end

                package.classes = [
                    package.classes;
                    class];

                package.linesCovered = package.linesCovered + class.linesCovered;
                package.branchesCovered = package.branchesCovered + class.branchesCovered;
                package.linesValid = package.linesValid + class.linesValid;
                package.branchesValid = package.branchesValid + class.branchesValid;
                package.complexity = package.complexity + class.complexity;
            end

            %package functions
            for i = 1:numel(metaPackage.Functions)
                class = this.buildFunctionReport(metaPackage.Name, metaPackage.Functions{i}, profData);

                if isempty(class); continue; end

                package.classes = [
                    package.classes;
                    class];

                package.linesCovered = package.linesCovered + class.linesCovered;
                package.branchesCovered = package.branchesCovered + class.branchesCovered;
                package.linesValid = package.linesValid + class.linesValid;
                package.branchesValid = package.branchesValid + class.branchesValid;
                package.complexity = package.complexity + class.complexity;
            end

            if isempty(package.classes)
                package = [];
                return;
            end

            %package stats
            package.lineRate = package.linesCovered / package.linesValid;
            package.branchRate = package.branchesCovered / package.branchesValid;
        end

        function class = buildClassReport(this, metaClass, profData)
            class = [];

            %check that metadata is valid
            try
                meta.class.fromName(metaClass.Name);
            catch %#ok<CTCH>
                warning('Coverage:warning', 'Invalid meta data for class %s', metaClass.Name);
            end

            fileName = which(metaClass.Name);
            inSources = false;
            for i = 1:size(this.sources, 1)
                source = this.sources{i, 1};
                if ...
                        (isequal(this.sources{i, 2}, 'r') && numel(fileName) >= numel(source) && strcmp(fileName(1:numel(source)+1), [source filesep])) || ...
                        (~isequal(this.sources{i, 2}, 'r') && numel(fileName) >= numel(source) && strcmp(fileName(1:numel(source)+1), [source filesep]) && ~any(strcmp(fileName(numel(source)+2:end), filesep)))
                    inSources = true;
                    break;
                end
            end

            if ~inSources
                return;
            end

            class.name = metaClass.Name;
            class.fileName = fileName;
            class.linesCovered = 0;
            class.branchesCovered = 0;
            class.linesValid = 0;
            class.branchesValid = 0;
            class.complexity = 0;
            class.methods = [];
            class.lines = [];

            shortClassName = metaClass.Name(find(metaClass.Name == '.', 1, 'last')+1:end);
            methodsCallInfo = getcallinfo(fileName);
            runnableLineIndex = unique(callstats('file_lines', fileName));
            code = {};
            fid = fopen(fileName, 'r');
            while ~feof(fid)
                code{end+1} = fgetl(fid);
            end
            fclose(fid);

            %methods
            metaClass; %#ok<VUNUS> %This line needed, otherwise numel(metaClass.Methods) incorrectly returns 0
            for i = 1:numel(metaClass.Methods)
                metaMethod = metaClass.Methods{i};

                if ~isequal(metaMethod.DefiningClass, metaClass)
                    continue;
                end

                signature = sprintf('[%s] = %s(%s)', ...
                    strjoin(', ', metaMethod.OutputNames{:}),...
                    metaMethod.Name, ...
                    strjoin(', ', metaMethod.InputNames{:}));

                method = this.buildMethodReport(...
                    metaMethod.Name, signature, ...
                    shortClassName, fileName, methodsCallInfo, runnableLineIndex, code, profData);

                if isempty(method); continue; end;

                class.methods = [
                    class.methods;
                    method];

                class.linesCovered = class.linesCovered + sum([method.linesCovered]);
                class.branchesCovered = class.branchesCovered + sum([method.branchesCovered]);
                class.linesValid = class.linesValid + sum([method.linesValid]);
                class.branchesValid = class.branchesValid + sum([method.branchesValid]);
                class.complexity = class.complexity + sum([method.complexity]);
            end

            %getters
            for i = 1:numel(metaClass.Properties)
                if ~isequal(metaClass.Properties{i}.DefiningClass, metaClass)
                    continue;
                end

                method = this.buildMethodReport(...
                    ['get.' metaClass.Properties{i}.Name], ['value = get.' metaClass.Properties{i}.Name '(this)'], ...
                    shortClassName, fileName, methodsCallInfo, runnableLineIndex, code, profData);

                if isempty(method); continue; end;

                class.methods = [
                    class.methods;
                    method];

                class.linesCovered = class.linesCovered + method.linesCovered;
                class.branchesCovered = class.branchesCovered + method.branchesCovered;
                class.linesValid = class.linesValid + method.linesValid;
                class.branchesValid = class.branchesValid + method.branchesValid;
                class.complexity = class.complexity + method.complexity;
            end

            %setters
            for i = 1:numel(metaClass.Properties)
                if ~isequal(metaClass.Properties{i}.DefiningClass, metaClass)
                    continue;
                end

                method = this.buildMethodReport(...
                    ['set.' metaClass.Properties{i}.Name], ['set.' metaClass.Properties{i}.Name '(this, value)'], ...
                    shortClassName, fileName, methodsCallInfo, runnableLineIndex, code, profData);

                if isempty(method); continue; end;

                class.methods = [
                    class.methods;
                    method];

                class.linesCovered = class.linesCovered + method.linesCovered;
                class.branchesCovered = class.branchesCovered + method.branchesCovered;
                class.linesValid = class.linesValid + method.linesValid;
                class.branchesValid = class.branchesValid + method.branchesValid;
                class.complexity = class.complexity + method.complexity;
            end

            %nested functions and subfunctions
            for i = 1:numel(methodsCallInfo)
                methodCallInfo = methodsCallInfo(i);
                if ~ismember(methodCallInfo.type, {'nested-function', 'subfunction'})
                    continue;
                end

                method = this.buildMethodReport(...
                    methodCallInfo.fullname(find(methodCallInfo.fullname == '.',1,'first')+1:end), [], ...
                    shortClassName, fileName, methodsCallInfo, runnableLineIndex, code, profData);

                if isempty(method); continue; end;

                class.methods = [
                    class.methods;
                    method];

                class.linesCovered = class.linesCovered + method.linesCovered;
                class.branchesCovered = class.branchesCovered + method.branchesCovered;
                class.linesValid = class.linesValid + method.linesValid;
                class.branchesValid = class.branchesValid + method.branchesValid;
                class.complexity = class.complexity + method.complexity;
            end

            %lines
            for i = 1:numel(class.methods)
                if ~strcmp(class.methods(i).fileName, fileName); continue; end;

                class.lines = [
                    class.lines;
                    class.methods(i).lines];
            end

            %class stats
            class.lineRate = class.linesCovered / class.linesValid;
            class.branchRate = class.branchesCovered / class.branchesValid;
        end

        function method = buildMethodReport(this, name, signature, shortClassName, fileName, methodsCallInfo, runnableLineIndex, code, profData)
            %initialize output
            method = [];

            methodCallInfo = [
                methodsCallInfo(strcmp({methodsCallInfo.type}, 'class method') & strcmp({methodsCallInfo.name}, name));
                methodsCallInfo(strcmp({methodsCallInfo.type}, 'nested-function') & strcmp({methodsCallInfo.fullname}, [shortClassName '>' shortClassName '.' name]));
                methodsCallInfo(strcmp({methodsCallInfo.type}, 'subfunction') & strcmp({methodsCallInfo.fullname}, [shortClassName '>' name]))];

            %method not defined in main class file
            if isempty(methodCallInfo)
                if ~any(fileName == '@'); return; end;
                methodFileName = [fileName(1:find(fileName == filesep, 1, 'last')) name '.m'];
                if ~exist(methodFileName, 'file'); return; end;

                try
                    methodCallInfo = getcallinfo(methodFileName);
                    runnableLineIndex = unique(callstats('file_lines', methodFileName));
                catch %#ok<CTCH>
                    return;
                end
                code = {};
                fid = fopen(methodFileName, 'r');
                while ~feof(fid)
                    code{end+1} = fgetl(fid);
                end
                fclose(fid);

                method = [];
                for i = 1:numel(methodCallInfo)
                    if i == 1
                        methodProfData = profData.FunctionTable(strcmp({profData.FunctionTable.CompleteName}, [methodFileName '>' name]));
                    else
                        methodProfData = profData.FunctionTable(strcmp({profData.FunctionTable.CompleteName}, [methodFileName '>' name '.' methodCallInfo(i).name]));
                        signature = [];
                    end
                    method = [method;
                        this.buildSubFunctionReport(methodFileName, code, runnableLineIndex, methodCallInfo(i), signature, methodProfData)];
                end
                return;
            end

            %method defined in main class file
            method.name = name;
            method.fileName = fileName;
            method.signature = signature;

            %lines
            methodProfData = profData.FunctionTable(strcmp({profData.FunctionTable.CompleteName}, [fileName '>' shortClassName '.' name]));
            [method.lines, method.linesCovered, method.linesValid, method.lineRate, ...
                method.branchesCovered, method.branchesValid, method.branchRate, method.complexity] = ...
                this.buildLinesReport(code, runnableLineIndex, methodCallInfo, methodProfData);

            %method stats
            if ~isempty(methodProfData)
                method.calls = methodProfData.NumCalls;
                method.time = methodProfData.TotalTime;
            else
                method.calls = 0;
                method.time = 0;
            end
        end

        function class = buildFunctionReport(this, packageName, metaFunction, profData)
            class = [];

            fileName = which([packageName '.' metaFunction.Name]);
            inSources = false;
            for i = 1:size(this.sources, 1)
                source = this.sources{i, 1};
                if ...
                        (isequal(this.sources{i, 2}, 'r') && numel(fileName) >= numel(source) && strcmp(fileName(1:numel(source)+1), [source filesep])) || ...
                        (~isequal(this.sources{i, 2}, 'r') && numel(fileName) >= numel(source) && strcmp(fileName(1:numel(source)+1), [source filesep]) && ~any(strcmp(fileName(numel(source)+2:end), filesep)))
                    inSources = true;
                    break;
                end
            end

            if ~inSources
                return;
            end

            class.name = ['_' metaFunction.Name];
            class.fileName = fileName;
            class.methods = [];
            class.lines = [];
            class.linesCovered = 0;
            class.branchesCovered = 0;
            class.linesValid = 0;
            class.branchesValid = 0;
            class.complexity = 0;

            methodsCallInfo = getcallinfo(fileName);
            runnableLineIndex = unique(callstats('file_lines', fileName));
            code = {};
            fid = fopen(fileName, 'r');
            while ~feof(fid)
                code{end+1} = fgetl(fid);
            end
            fclose(fid);

            for i = 1:numel(methodsCallInfo)
                methodCallInfo = methodsCallInfo(i);
                methodProfData = profData.FunctionTable(strcmp({profData.FunctionTable.CompleteName}, [fileName '>' methodCallInfo.name]));
                method = this.buildSubFunctionReport(fileName, code, runnableLineIndex, methodCallInfo, [], methodProfData);

                class.methods = [
                    class.methods;
                    method];

                class.linesCovered = class.linesCovered + method.linesCovered;
                class.branchesCovered = class.branchesCovered + method.branchesCovered;
                class.linesValid = class.linesValid + method.linesValid;
                class.branchesValid = class.branchesValid +method.branchesValid;
                class.complexity = class.complexity + method.complexity;
            end

            %lines
            class.lines = [];
            for i = 1:numel(class.methods)
                class.lines = [
                    class.lines;
                    class.methods(i).lines];
            end

            %stats
            class.lineRate = class.linesCovered / class.linesValid;
            class.branchRate = class.branchesCovered / class.branchesValid;
        end

        function method = buildSubFunctionReport(this, fileName, code, runnableLineIndex, callInfo, signature, profData)
            method.name = callInfo.name;
            method.fileName = fileName;
            method.signature = signature;

            %lines
            [method.lines, method.linesCovered, method.linesValid, method.lineRate, ...
                method.branchesCovered, method.branchesValid, method.branchRate, method.complexity] = ...
                this.buildLinesReport(code, runnableLineIndex, callInfo, profData);

            %method stats
            if ~isempty(profData)
                method.calls = profData.NumCalls;
                method.time = profData.TotalTime;
            else
                method.calls = 0;
                method.time = 0;
            end
        end

        function [lines, linesCovered, linesValid, lineRate, branchesCovered, branchesValid, branchRate, complexity] = ...
                buildLinesReport(~, code, runLineIndex, callInfo, profData)
            lines = repmat(struct('number', [], 'hits', [], 'branch', [], 'time', [], 'complex', []), ...
                sum(runLineIndex >= callInfo.firstline & runLineIndex <= callInfo.lastline), 1);

            linesCovered = 0;
            branchesCovered = 0;
            linesValid = 0;
            branchesValid = 0;
            complexity = 0;

            l2 = 0;
            for l1 = callInfo.firstline:callInfo.lastline
                if ~any(runLineIndex == l1); continue; end;
                l2 = l2+1;

                hits = 0;
                time = 0;
                if ~isempty(profData)
                    idx = find(profData.ExecutedLines(:, 1) == l1);
                    if ~isempty(idx)
                        hits = profData.ExecutedLines(idx, 2);
                        time = profData.ExecutedLines(idx, 3);
                    end
                end

                branch = ~isempty(regexp(code{l1}, '\<(if|switch|try)\>', 'once', 'tokens'));
                complex = ~isempty(regexp(code{l1},'(\<otherwise\>)|(\<catch\>)|(\<elseif\>)|(\<if\>)|(\<while\>)|(\<for\>)|(\<case\>)|(\<continue\>)|(&&)|(||)','once','tokens'));
                lines(l2, 1).number = l1;
                lines(l2, 1).hits = hits;
                lines(l2, 1).branch = branch;
                lines(l2, 1).time = time;
                lines(l2, 1).complex = complex;

                linesValid = linesValid + 1;
                if branch; branchesValid = branchesValid + 1; end;
                if hits > 0; linesCovered = linesCovered + 1; end;
                if hits > 0 && branch; branchesCovered = branchesCovered + 1; end;
                if complex; complexity = complexity + 1; end;
            end

            lineRate = linesCovered / linesValid;
            branchRate = branchesCovered / branchesCovered;
        end

        function packageNames = getPackageNamesFromDir(this, source)
            if source(end) ~= filesep
                source = [source filesep];
            end
            packageNames = {};

            files = dir(source);
            for i = 1:numel(files)
                if files(i).isdir && files(i).name(1) ~= '.'
                    if files(i).name(1) == '+'
                        metaPackage = meta.package.fromName(files(i).name(2:end));
                        if isempty(metaPackage); continue; end;
                        packageNames = [packageNames;
                            this.getSubPackageNamesFromPackage(metaPackage)];
                    else
                        packageNames = [packageNames;
                            this.getPackageNamesFromDir([source files(i).name])];
                    end
                end
            end
        end

        function packageNames = getSubPackageNamesFromPackage(this, metaPackage)
            packageNames = {metaPackage.Name};

            for i = 1:numel(metaPackage.Packages)
                packageNames = [packageNames; this.getSubPackageNamesFromPackage(metaPackage.Packages{i})];
            end
        end

        function relativePath = relativeToBasePath(this, absolutePath)
            if numel(this.basePath) > numel(absolutePath) || ~strcmp(absolutePath(1:numel(this.basePath)), this.basePath)
                throw(MException('Coverage:invalidPath', 'path must be contained within base path'));
            end
            relativePath = absolutePath(numel(this.basePath)+1:end);
        end
    end

    methods
        %See also http://cobertura.sourceforge.net/xml/coverage-04.dtd
        function xml = exportXML(this, fileName)
            %initialize
            xml = sprintf('<?xml version="1.0" encoding="UTF-8"?>\n');
            xml = [xml sprintf('<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">\n')];

            %top-level
            xml = [xml sprintf('<coverage\n')];
            xml = [xml sprintf('\tline-rate="%f"\n', this.stats.lineRate)];
            xml = [xml sprintf('\tbranch-rate="%f"\n', this.stats.branchRate)];
            xml = [xml sprintf('\tlines-covered="%d"\n', this.stats.linesCovered)];
            xml = [xml sprintf('\tlines-valid="%d"\n', this.stats.linesValid)];
            xml = [xml sprintf('\tbranches-covered="%d"\n', this.stats.branchesCovered)];
            xml = [xml sprintf('\tbranches-valid="%d"\n', this.stats.branchesValid)];
            xml = [xml sprintf('\tcomplexity="%f"\n', this.stats.complexity)];
            xml = [xml sprintf('\tversion="%s"\n', '0.1')];
            xml = [xml sprintf('\ttimestamp="%s">\n', this.timeStamp)];
            xml = [xml sprintf('\t<sources>\n')];
            for i = 1:size(this.sources, 1)
                xml = [xml sprintf('\t\t<source><![CDATA[%s]]></source>\n', this.sources{i, 1})];
            end
            xml = [xml sprintf('\t</sources>\n')];
            xml = [xml sprintf('\t<packages>\n')];

            %packages
            for i = 1:numel(this.packages)
                package = this.packages(i);

                xml = [xml sprintf('\t\t<package name="%s" lines-covered="%d" lines-valid="%d" line-rate="%f" branches-covered="%d" branches-valid="%d" branch-rate="%f" complexity="%f">\n', ...
                    package.name, ...
                    package.linesCovered, package.linesValid, package.lineRate, ...
                    package.branchesCovered, package.branchesValid, package.branchRate, ...
                    package.complexity)]; %#ok<*AGROW>
                xml = [xml sprintf('\t\t\t<classes>\n')];
                %classes in package
                for j = 1:numel(package.classes)
                    class = package.classes(j);

                    xml = [xml sprintf('\t\t\t\t<class name="%s" filename="%s" lines-covered="%d" lines-valid="%d" line-rate="%f" branches-covered="%d" branches-valid="%d" branch-rate="%f" complexity="%f">\n', ...
                        class.name, this.relativeToBasePath(class.fileName), ...
                        class.linesCovered, class.linesValid, class.lineRate, ...
                        class.branchesCovered, class.branchesValid, class.branchRate, ...
                        class.complexity)];
                    xml = [xml sprintf('\t\t\t\t\t<methods>\n')];
                    %methods in class
                    for k = 1:numel(class.methods)
                        method = class.methods(k);

                        xml = [xml sprintf('\t\t\t\t\t\t<method name="%s" filename="%s" signature="%s" lines-covered="%d" lines-valid="%d" line-rate="%f" branches-covered="%d" branches-valid="%d" branch-rate="%f" complexity="%f" calls="%d" time="%f">\n', ...
                            method.name, this.relativeToBasePath(method.fileName), method.signature, ...
                            method.linesCovered, method.linesValid, method.lineRate, ...
                            method.branchesCovered, method.branchesValid, method.branchRate, ...
                            method.complexity, ...
                            method.calls, method.time)];
                        xml = [xml sprintf('\t\t\t\t\t\t\t<lines>\n')];
                        for l = 1:numel(method.lines)
                            line = method.lines(l);
                            xml = [xml sprintf('\t\t\t\t\t\t\t\t<line number="%d" hits="%d" branch="%d" time="%f" condition-coverage="0%% (0/0)"/>\n', ...
                                line.number, line.hits, line.branch, line.time)];
                        end
                        xml = [xml sprintf('\t\t\t\t\t\t\t</lines>\n')];
                        xml = [xml sprintf('\t\t\t\t\t\t</method>\n')];
                    end
                    xml = [xml sprintf('\t\t\t\t\t</methods>\n')];

                    %lines in class
                    xml = [xml sprintf('\t\t\t\t\t<lines>\n')];
                    for k = 1:numel(class.lines)
                        line = class.lines(k);
                        xml = [xml sprintf('\t\t\t\t\t\t<line number="%d" hits="%d" branch="%d" time="%f" condition-coverage="0%% (0/0)"/>\n',...
                            line.number, line.hits, line.branch, line.time)];
                    end
                    xml = [xml sprintf('\t\t\t\t\t</lines>\n')];
                    xml = [xml sprintf('\t\t\t\t</class>\n')];
                end
                xml = [xml sprintf('\t\t\t</classes>\n')];
                xml = [xml sprintf('\t\t</package>\n')];
            end
            xml = [xml sprintf('\t</packages>\n')];
            xml = [xml sprintf('</coverage>\n')];

            if exist('fileName', 'var')
                fid = fopen(fileName, 'w');
                fwrite(fid, xml);
                fclose(fid);
            end
        end
    end
end


function [methodinfo,structs,enuminfo,ThunkLibName]=remoteApiProto
%REMOTEAPIPROTO Create structures to define interfaces found in 'extApi'.

%This function was generated by loadlibrary.m parser version 1.1.6.32
%perl options:'extApi.i -outfile=remoteApiProto.m'
ival={cell(1,0)}; % change 0 to the actual number of functions to preallocate the data.
structs=[];enuminfo=[];fcnNum=1;
fcns=struct('name',ival,'calltype',ival,'LHS',ival,'RHS',ival,'alias',ival);
ThunkLibName=[];

% extern  simxInt mtlb_simxSetJointPosition ( simxInt clientID , simxInt jointHandle , simxFloat* position , simxInt operationMode );
fcns.name{fcnNum}='mtlb_simxSetJointPosition'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxSetJointTargetVelocity ( simxInt clientID , simxInt jointHandle , simxFloat* targetVelocity , simxInt operationMode );
fcns.name{fcnNum}='mtlb_simxSetJointTargetVelocity'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxSetJointTargetPosition ( simxInt clientID , simxInt jointHandle , simxFloat* targetPosition , simxInt operationMode );
fcns.name{fcnNum}='mtlb_simxSetJointTargetPosition'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxSetJointForce ( simxInt clientID , simxInt jointHandle , simxFloat* force , simxInt operationMode );
fcns.name{fcnNum}='mtlb_simxSetJointForce'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxSetFloatSignal ( simxInt clientID , const simxChar * signalName , simxFloat* signalValue , simxInt operationMode );
fcns.name{fcnNum}='mtlb_simxSetFloatSignal'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxSetObjectFloatParameter ( simxInt clientID , simxInt objectHandle , simxInt parameterID , simxFloat* parameterValue , simxInt operationMode );
fcns.name{fcnNum}='mtlb_simxSetObjectFloatParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxSetFloatingParameter ( simxInt clientID , simxInt paramIdentifier , simxFloat* paramValue , simxInt operationMode );
fcns.name{fcnNum}='mtlb_simxSetFloatingParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxCreateDummy ( simxInt clientID , simxFloat* size , const simxUChar * colors , simxInt * objectHandle , simxInt operationMode );
fcns.name{fcnNum}='mtlb_simxCreateDummy'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'singlePtr', 'uint8Ptr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;

% extern  simxInt mtlb_simxReadProximitySensor(simxInt* clientIDandSensorHandle,simxUChar* detectionState,simxFloat* detectedPoint,simxInt* detectedObjectHandle,simxFloat* detectedSurfaceNormalVector,simxInt operationMode);
fcns.name{fcnNum}='mtlb_simxReadProximitySensor'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32Ptr', 'uint8Ptr', 'singlePtr', 'int32Ptr', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxAuxiliaryConsoleOpen(simxInt* clientIDandMaxLinesAndModeAndPositionAndSize,const simxChar* title,simxFloat* textColor,simxFloat* backgroundColor,simxInt* consoleHandle,simxInt operationMode);
fcns.name{fcnNum}='mtlb_simxAuxiliaryConsoleOpen'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32Ptr', 'int8Ptr', 'singlePtr', 'singlePtr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxDisplayDialog(simxInt* clientIDandDlgTypeAndOperationMode,const simxChar* titleText,const simxChar* mainText,const simxChar* initialText,const simxFloat* titleColorsAndDlgColors,simxInt* dialogHandleAndUiHandle);
fcns.name{fcnNum}='mtlb_simxDisplayDialog'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32Ptr', 'int8Ptr', 'int8Ptr','int8Ptr', 'singlePtr', 'int32Ptr'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxQuery(simxInt* clientIDandSignalLengthAndTimeOutInMs,const simxChar* signalName,const simxUChar* signalValue,const simxChar* retSignalName,simxUChar** retSignalValue,simxInt* retSignalLength);
fcns.name{fcnNum}='mtlb_simxQuery'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32Ptr', 'int8Ptr', 'uint8Ptr', 'int8Ptr', 'uint8PtrPtr', 'int32Ptr'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxGetObjectGroupData(simxInt* clientIDandObjectTypeAndDataTypeAndOperationMode,simxInt* handlesCountAndIntDataCountAndFloatDataCountAndStringDataCount,simxInt** handles,simxInt** intData,simxFloat** floatData,simxChar** stringData);
fcns.name{fcnNum}='mtlb_simxGetObjectGroupData'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32Ptr', 'int32Ptr', 'int32PtrPtr', 'int32PtrPtr', 'singlePtrPtr', 'int8PtrPtr'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxCallScriptFunction_a(const simxInt* variousIntsIn,const simxChar* scriptDescriptionAndFunctionName,const simxInt* inInt,const simxFloat* inFloat,const simxChar* inString,const simxUChar* inBuffer);
fcns.name{fcnNum}='mtlb_simxCallScriptFunction_a'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32Ptr', 'int8Ptr', 'int32Ptr', 'singlePtr', 'int8Ptr', 'uint8Ptr'};fcnNum=fcnNum+1;
% extern  simxInt mtlb_simxCallScriptFunction_b(simxInt clientID,simxInt* variousIntsOut,simxInt** outInt,simxFloat** outFloat,simxChar** outString,simxUChar** outBuffer);
fcns.name{fcnNum}='mtlb_simxCallScriptFunction_b'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32Ptr', 'int32PtrPtr', 'singlePtrPtr', 'int8PtrPtr', 'uint8PtrPtr'};fcnNum=fcnNum+1;

% extern  simxInt simxGetJointPosition ( simxInt clientID , simxInt jointHandle , simxFloat * position , simxInt operationMode );
fcns.name{fcnNum}='simxGetJointPosition'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetJointMatrix ( simxInt clientID , simxInt jointHandle , simxFloat * matrix , simxInt operationMode );
fcns.name{fcnNum}='simxGetJointMatrix'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetSphericalJointMatrix ( simxInt clientID , simxInt jointHandle , simxFloat * matrix , simxInt operationMode );
fcns.name{fcnNum}='simxSetSphericalJointMatrix'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetJointForce ( simxInt clientID , simxInt jointHandle , simxFloat * force , simxInt operationMode );
fcns.name{fcnNum}='simxGetJointForce'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxReadForceSensor ( simxInt clientID , simxInt forceSensorHandle , simxUChar * state , simxFloat * forceVector , simxFloat * torqueVector , simxInt operationMode );
fcns.name{fcnNum}='simxReadForceSensor'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'uint8Ptr', 'singlePtr', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxBreakForceSensor ( simxInt clientID , simxInt forceSensorHandle , simxInt operationMode );
fcns.name{fcnNum}='simxBreakForceSensor'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxReadVisionSensor ( simxInt clientID , simxInt sensorHandle , simxUChar * detectionState , simxFloat ** auxValues , simxInt ** auxValuesCount , simxInt operationMode );
fcns.name{fcnNum}='simxReadVisionSensor'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'uint8Ptr', 'singlePtrPtr', 'int32PtrPtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetObjectHandle ( simxInt clientID , const simxChar * objectName , simxInt * handle , simxInt operationMode );
fcns.name{fcnNum}='simxGetObjectHandle'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetVisionSensorImage ( simxInt clientID , simxInt sensorHandle , simxInt * resolution , simxUChar ** image , simxUChar options , simxInt operationMode );
fcns.name{fcnNum}='simxGetVisionSensorImage'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32Ptr', 'uint8PtrPtr', 'uint8', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetVisionSensorImage ( simxInt clientID , simxInt sensorHandle , simxUChar * image , simxInt bufferSize , simxUChar options , simxInt operationMode );
fcns.name{fcnNum}='simxSetVisionSensorImage'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'uint8Ptr', 'int32', 'uint8', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetVisionSensorDepthBuffer ( simxInt clientID , simxInt sensorHandle , simxInt * resolution , simxFloat ** buffer , simxInt operationMode );
fcns.name{fcnNum}='simxGetVisionSensorDepthBuffer'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32Ptr', 'singlePtrPtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetObjectChild ( simxInt clientID , simxInt parentObjectHandle , simxInt childIndex , simxInt * childObjectHandle , simxInt operationMode );
fcns.name{fcnNum}='simxGetObjectChild'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetObjectParent ( simxInt clientID , simxInt childObjectHandle , simxInt * parentObjectHandle , simxInt operationMode );
fcns.name{fcnNum}='simxGetObjectParent'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxLoadModel ( simxInt clientID , const simxChar * modelPathAndName , simxUChar options , simxInt * baseHandle , simxInt operationMode );
fcns.name{fcnNum}='simxLoadModel'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'uint8', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxLoadUI ( simxInt clientID , const simxChar * uiPathAndName , simxUChar options , simxInt * count , simxInt ** uiHandles , simxInt operationMode );
fcns.name{fcnNum}='simxLoadUI'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'uint8', 'int32Ptr', 'int32PtrPtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxLoadScene ( simxInt clientID , const simxChar * scenePathAndName , simxUChar options , simxInt operationMode );
fcns.name{fcnNum}='simxLoadScene'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'uint8', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxStartSimulation ( simxInt clientID , simxInt operationMode );
fcns.name{fcnNum}='simxStartSimulation'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxPauseSimulation ( simxInt clientID , simxInt operationMode );
fcns.name{fcnNum}='simxPauseSimulation'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxStopSimulation ( simxInt clientID , simxInt operationMode );
fcns.name{fcnNum}='simxStopSimulation'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetUIHandle ( simxInt clientID , const simxChar * uiName , simxInt * handle , simxInt operationMode );
fcns.name{fcnNum}='simxGetUIHandle'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetUISlider ( simxInt clientID , simxInt uiHandle , simxInt uiButtonID , simxInt * position , simxInt operationMode );
fcns.name{fcnNum}='simxGetUISlider'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetUISlider ( simxInt clientID , simxInt uiHandle , simxInt uiButtonID , simxInt position , simxInt operationMode );
fcns.name{fcnNum}='simxSetUISlider'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetUIEventButton ( simxInt clientID , simxInt uiHandle , simxInt * uiEventButtonID , simxInt * auxValues , simxInt operationMode );
fcns.name{fcnNum}='simxGetUIEventButton'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32Ptr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetUIButtonProperty ( simxInt clientID , simxInt uiHandle , simxInt uiButtonID , simxInt * prop , simxInt operationMode );
fcns.name{fcnNum}='simxGetUIButtonProperty'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetUIButtonProperty ( simxInt clientID , simxInt uiHandle , simxInt uiButtonID , simxInt prop , simxInt operationMode );
fcns.name{fcnNum}='simxSetUIButtonProperty'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxAddStatusbarMessage ( simxInt clientID , const simxChar * message , simxInt operationMode );
fcns.name{fcnNum}='simxAddStatusbarMessage'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxAuxiliaryConsoleClose ( simxInt clientID , simxInt consoleHandle , simxInt operationMode );
fcns.name{fcnNum}='simxAuxiliaryConsoleClose'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxAuxiliaryConsolePrint ( simxInt clientID , simxInt consoleHandle , const simxChar * txt , simxInt operationMode );
fcns.name{fcnNum}='simxAuxiliaryConsolePrint'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int8Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxAuxiliaryConsoleShow ( simxInt clientID , simxInt consoleHandle , simxUChar showState , simxInt operationMode );
fcns.name{fcnNum}='simxAuxiliaryConsoleShow'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'uint8', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetObjectOrientation ( simxInt clientID , simxInt objectHandle , simxInt relativeToObjectHandle , simxFloat * eulerAngles , simxInt operationMode );
fcns.name{fcnNum}='simxGetObjectOrientation'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetObjectQuaternion ( simxInt clientID , simxInt objectHandle , simxInt relativeToObjectHandle , simxFloat * eulerAngles , simxInt operationMode );
fcns.name{fcnNum}='simxGetObjectQuaternion'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetObjectPosition ( simxInt clientID , simxInt objectHandle , simxInt relativeToObjectHandle , simxFloat * position , simxInt operationMode );
fcns.name{fcnNum}='simxGetObjectPosition'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetObjectOrientation ( simxInt clientID , simxInt objectHandle , simxInt relativeToObjectHandle , const simxFloat * eulerAngles , simxInt operationMode );
fcns.name{fcnNum}='simxSetObjectOrientation'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetObjectQuaternion ( simxInt clientID , simxInt objectHandle , simxInt relativeToObjectHandle , const simxFloat * eulerAngles , simxInt operationMode );
fcns.name{fcnNum}='simxSetObjectQuaternion'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetObjectPosition ( simxInt clientID , simxInt objectHandle , simxInt relativeToObjectHandle , const simxFloat * position , simxInt operationMode );
fcns.name{fcnNum}='simxSetObjectPosition'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetObjectParent ( simxInt clientID , simxInt objectHandle , simxInt parentObject , simxUChar keepInPlace , simxInt operationMode );
fcns.name{fcnNum}='simxSetObjectParent'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'uint8', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetUIButtonLabel ( simxInt clientID , simxInt uiHandle , simxInt uiButtonID , const simxChar * upStateLabel , const simxChar * downStateLabel , simxInt operationMode );
fcns.name{fcnNum}='simxSetUIButtonLabel'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'int8Ptr', 'int8Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetLastErrors ( simxInt clientID , simxInt * errorCnt , simxChar ** errorStrings , simxInt operationMode );
fcns.name{fcnNum}='simxGetLastErrors'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32Ptr', 'int8PtrPtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetArrayParameter ( simxInt clientID , simxInt paramIdentifier , simxFloat * paramValues , simxInt operationMode );
fcns.name{fcnNum}='simxGetArrayParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetArrayParameter ( simxInt clientID , simxInt paramIdentifier , const simxFloat * paramValues , simxInt operationMode );
fcns.name{fcnNum}='simxSetArrayParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetBooleanParameter ( simxInt clientID , simxInt paramIdentifier , simxUChar * paramValue , simxInt operationMode );
fcns.name{fcnNum}='simxGetBooleanParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'uint8Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetBooleanParameter ( simxInt clientID , simxInt paramIdentifier , simxUChar paramValue , simxInt operationMode );
fcns.name{fcnNum}='simxSetBooleanParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'uint8', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetIntegerParameter ( simxInt clientID , simxInt paramIdentifier , simxInt * paramValue , simxInt operationMode );
fcns.name{fcnNum}='simxGetIntegerParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetIntegerParameter ( simxInt clientID , simxInt paramIdentifier , simxInt paramValue , simxInt operationMode );
fcns.name{fcnNum}='simxSetIntegerParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetFloatingParameter ( simxInt clientID , simxInt paramIdentifier , simxFloat * paramValue , simxInt operationMode );
fcns.name{fcnNum}='simxGetFloatingParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetStringParameter ( simxInt clientID , simxInt paramIdentifier , simxChar ** paramValue , simxInt operationMode );
fcns.name{fcnNum}='simxGetStringParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int8PtrPtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetCollisionHandle ( simxInt clientID , const simxChar * collisionObjectName , simxInt * handle , simxInt operationMode );
fcns.name{fcnNum}='simxGetCollisionHandle'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetDistanceHandle ( simxInt clientID , const simxChar * distanceObjectName , simxInt * handle , simxInt operationMode );
fcns.name{fcnNum}='simxGetDistanceHandle'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetCollectionHandle ( simxInt clientID , const simxChar * collectionName , simxInt * handle , simxInt operationMode );
fcns.name{fcnNum}='simxGetCollectionHandle'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxReadCollision ( simxInt clientID , simxInt collisionObjectHandle , simxUChar * collisionState , simxInt operationMode );
fcns.name{fcnNum}='simxReadCollision'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'uint8Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxReadDistance ( simxInt clientID , simxInt distanceObjectHandle , simxFloat * minimumDistance , simxInt operationMode );
fcns.name{fcnNum}='simxReadDistance'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxRemoveObject ( simxInt clientID , simxInt objectHandle , simxInt operationMode );
fcns.name{fcnNum}='simxRemoveObject'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxRemoveModel ( simxInt clientID , simxInt objectHandle , simxInt operationMode );
fcns.name{fcnNum}='simxRemoveModel'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxRemoveUI ( simxInt clientID , simxInt uiHandle , simxInt operationMode );
fcns.name{fcnNum}='simxRemoveUI'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxCloseScene ( simxInt clientID , simxInt operationMode );
fcns.name{fcnNum}='simxCloseScene'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetObjects ( simxInt clientID , simxInt objectType , simxInt * objectCount , simxInt ** objectHandles , simxInt operationMode );
fcns.name{fcnNum}='simxGetObjects'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32Ptr', 'int32PtrPtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxEndDialog ( simxInt clientID , simxInt dialogHandle , simxInt operationMode );
fcns.name{fcnNum}='simxEndDialog'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetDialogInput ( simxInt clientID , simxInt dialogHandle , simxChar ** inputText , simxInt operationMode );
fcns.name{fcnNum}='simxGetDialogInput'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int8PtrPtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetDialogResult ( simxInt clientID , simxInt dialogHandle , simxInt * result , simxInt operationMode );
fcns.name{fcnNum}='simxGetDialogResult'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxCopyPasteObjects ( simxInt clientID , const simxInt * objectHandles , simxInt objectCount , simxInt ** newObjectHandles , simxInt * newObjectCount , simxInt operationMode );
fcns.name{fcnNum}='simxCopyPasteObjects'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32Ptr', 'int32', 'int32PtrPtr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetObjectSelection ( simxInt clientID , simxInt ** objectHandles , simxInt * objectCount , simxInt operationMode );
fcns.name{fcnNum}='simxGetObjectSelection'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32PtrPtr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetObjectSelection ( simxInt clientID , const simxInt * objectHandles , simxInt objectCount , simxInt operationMode );
fcns.name{fcnNum}='simxSetObjectSelection'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32Ptr', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxClearFloatSignal ( simxInt clientID , const simxChar * signalName , simxInt operationMode );
fcns.name{fcnNum}='simxClearFloatSignal'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxClearIntegerSignal ( simxInt clientID , const simxChar * signalName , simxInt operationMode );
fcns.name{fcnNum}='simxClearIntegerSignal'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxClearStringSignal ( simxInt clientID , const simxChar * signalName , simxInt operationMode );
fcns.name{fcnNum}='simxClearStringSignal'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetFloatSignal ( simxInt clientID , const simxChar * signalName , simxFloat * signalValue , simxInt operationMode );
fcns.name{fcnNum}='simxGetFloatSignal'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetIntegerSignal ( simxInt clientID , const simxChar * signalName , simxInt * signalValue , simxInt operationMode );
fcns.name{fcnNum}='simxGetIntegerSignal'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetStringSignal ( simxInt clientID , const simxChar * signalName , simxUChar ** signalValue , simxInt * signalLength , simxInt operationMode );
fcns.name{fcnNum}='simxGetStringSignal'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'uint8PtrPtr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetAndClearStringSignal ( simxInt clientID , const simxChar * signalName , simxUChar ** signalValue , simxInt * signalLength , simxInt operationMode );
fcns.name{fcnNum}='simxGetAndClearStringSignal'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'uint8PtrPtr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxReadStringStream ( simxInt clientID , const simxChar * signalName , simxUChar ** signalValue , simxInt * signalLength , simxInt operationMode );
fcns.name{fcnNum}='simxReadStringStream'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'uint8PtrPtr', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetIntegerSignal ( simxInt clientID , const simxChar * signalName , simxInt signalValue , simxInt operationMode );
fcns.name{fcnNum}='simxSetIntegerSignal'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetStringSignal ( simxInt clientID , const simxChar * signalName , const simxUChar * signalValue , simxInt signalLength , simxInt operationMode );
fcns.name{fcnNum}='simxSetStringSignal'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'uint8Ptr', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxAppendStringSignal ( simxInt clientID , const simxChar * signalName , const simxUChar * signalValue , simxInt signalLength , simxInt operationMode );
fcns.name{fcnNum}='simxAppendStringSignal'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'uint8Ptr', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxWriteStringStream ( simxInt clientID , const simxChar * signalName , const simxUChar * signalValue , simxInt signalLength , simxInt operationMode );
fcns.name{fcnNum}='simxWriteStringStream'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'uint8Ptr', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetObjectFloatParameter ( simxInt clientID , simxInt objectHandle , simxInt parameterID , simxFloat * parameterValue , simxInt operationMode );
fcns.name{fcnNum}='simxGetObjectFloatParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetObjectIntParameter ( simxInt clientID , simxInt objectHandle , simxInt parameterID , simxInt * parameterValue , simxInt operationMode );
fcns.name{fcnNum}='simxGetObjectIntParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetObjectIntParameter ( simxInt clientID , simxInt objectHandle , simxInt parameterID , simxInt parameterValue , simxInt operationMode );
fcns.name{fcnNum}='simxSetObjectIntParameter'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetModelProperty ( simxInt clientID , simxInt objectHandle , simxInt * prop , simxInt operationMode );
fcns.name{fcnNum}='simxGetModelProperty'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32Ptr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSetModelProperty ( simxInt clientID , simxInt objectHandle , simxInt prop , simxInt operationMode );
fcns.name{fcnNum}='simxSetModelProperty'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetObjectVelocity ( simxInt clientID , simxInt objectHandle , simxFloat * linearVelocity , simxFloat * angularVelocity , simxInt operationMode );
fcns.name{fcnNum}='simxGetObjectVelocity'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'singlePtr', 'singlePtr', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxStart ( const simxChar * connectionAddress , simxInt connectionPort , simxUChar waitUntilConnected , simxUChar doNotReconnectOnceDisconnected , simxInt timeOutInMs , simxInt commThreadCycleInMs );
fcns.name{fcnNum}='simxStart'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int8Ptr', 'int32', 'uint8', 'uint8', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxVoid simxFinish ( simxInt clientID );
fcns.name{fcnNum}='simxFinish'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}=[]; fcns.RHS{fcnNum}={'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxGetPingTime ( simxInt clientID , simxInt * pingTime );
fcns.name{fcnNum}='simxGetPingTime'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32Ptr'};fcnNum=fcnNum+1;
% extern  simxInt simxGetLastCmdTime ( simxInt clientID );
fcns.name{fcnNum}='simxGetLastCmdTime'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSynchronousTrigger ( simxInt clientID );
fcns.name{fcnNum}='simxSynchronousTrigger'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxSynchronous ( simxInt clientID , simxUChar enable );
fcns.name{fcnNum}='simxSynchronous'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'uint8'};fcnNum=fcnNum+1;
% extern  simxInt simxPauseCommunication ( simxInt clientID , simxUChar pause );
fcns.name{fcnNum}='simxPauseCommunication'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'uint8'};fcnNum=fcnNum+1;
% extern  simxInt simxGetInMessageInfo ( simxInt clientID , simxInt infoType , simxInt * info );
fcns.name{fcnNum}='simxGetInMessageInfo'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32Ptr'};fcnNum=fcnNum+1;
% extern  simxInt simxGetOutMessageInfo ( simxInt clientID , simxInt infoType , simxInt * info );
fcns.name{fcnNum}='simxGetOutMessageInfo'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'int32Ptr'};fcnNum=fcnNum+1;
% extern  simxInt simxGetConnectionId ( simxInt clientID );
fcns.name{fcnNum}='simxGetConnectionId'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32'};fcnNum=fcnNum+1;
% extern  simxUChar * simxCreateBuffer ( simxInt bufferSize );
fcns.name{fcnNum}='simxCreateBuffer'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='uint8Ptr'; fcns.RHS{fcnNum}={'int32'};fcnNum=fcnNum+1;
% extern  simxVoid simxReleaseBuffer ( simxUChar * buffer );
fcns.name{fcnNum}='simxReleaseBuffer'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}=[]; fcns.RHS{fcnNum}={'uint8Ptr'};fcnNum=fcnNum+1;
% extern  simxInt simxTransferFile ( simxInt clientID , const simxChar * filePathAndName , const simxChar * fileName_serverSide , simxInt timeOut , simxInt operationMode );
fcns.name{fcnNum}='simxTransferFile'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int8Ptr', 'int32', 'int32'};fcnNum=fcnNum+1;
% extern  simxInt simxEraseFile ( simxInt clientID , const simxChar * fileName_serverSide , simxInt operationMode );
fcns.name{fcnNum}='simxEraseFile'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int8Ptr', 'int32'};fcnNum=fcnNum+1;
methodinfo=fcns;

github-repos/MATLAB/xuhuairuogu-V-REP-Simulation-Projects/V-REP-Simulation-Projects-841b944af4ea3a8fb250578d36434515f577f411/admittance control(adapted from an example in the book--A Systematic Approach to Learning Robot Programming with ROS)/vrep_matlab_communication/remoteApiProto.m


function CERRImportDCM4CHE()
% CERRImportDCM4CHE
% imports the DICOM data into CERR plan format. This function is based on
% the Java code dcm4che.
% written DK, WY
%
% Copyright 2010, Joseph O. Deasy, on behalf of the CERR development team.
%
% This file is part of The Computational Environment for Radiotherapy Research (CERR).
%
% CERR development has been led by:  Aditya Apte, Divya Khullar, James Alaly, and Joseph O. Deasy.
%
% CERR has been financially supported by the US National Institutes of Health under multiple grants.
%
% CERR is distributed under the terms of the Lesser GNU Public License.
%
%     This version of CERR is free software: you can redistribute it and/or modify
%     it under the terms of the GNU General Public License as published by
%     the Free Software Foundation, either version 3 of the License, or
%     (at your option) any later version.
%
% CERR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
% without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% See the GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with CERR.  If not, see <http://www.gnu.org/licenses/>.

global stateS
if ~isfield(stateS,'initDicomFlag')
    flag = init_ML_DICOM;
    if ~flag
        return;
    end
elseif isfield(stateS,'initDicomFlag') && ~stateS.initDicomFlag
    return;
end

% Get the path of the directory to be selected for import.
dirPath = uigetdir(pwd','Select the DICOM directory to scan:');
%pause(0.1);

if ~dirPath
    disp('DICOM import aborted');
    return
end

tic;

% Read options file
pathStr = getCERRPath;
optName = [pathStr,'CERROptions.json'];
optS = opts4Exe(optName);

%hWaitbar = waitbar(0,'Scanning Directory Please wait...');
%CERRStatusString('Scanning DICOM directory');
disp('CERR>>  Scanning DICOM directory')

dcmdirS = [];
patientNum = 1;
excludePixelDataFlag = true;

patient = scandir_mldcm(dirPath, excludePixelDataFlag);
if ~isempty(patient)
    for j = 1:length(patient.PATIENT)
        dcmdirS.(['patient_' num2str(patientNum)]) = patient.PATIENT(j);
        patientNum = patientNum + 1;
    end
end
if isfield(optS,'importDICOMsubDirs') && strcmpi(optS.importDICOMsubDirs,'yes') % && ~isempty(dirsInCurDir)

    [filesInCurDir,dirsInCurDir] = rdir(dirPath);

    for i = 1:length(dirsInCurDir)
        %     patient = scandir_mldcm(fullfile(dirPath, dirs(i).name), hWaitbar, i);
        patient = scandir_mldcm(dirsInCurDir(i).fullpath, excludePixelDataFlag);
        if ~isempty(patient)
            for j = 1:length(patient.PATIENT)
                dcmdirS.(['patient_' num2str(patientNum)]) = patient.PATIENT(j);
                patientNum = patientNum + 1;
            end
        end
    end
end

if isempty(dcmdirS)
    %close(hWaitbar);
    msgbox('There is no dicom data!','Application Info','warn');
    return;
end

%close(hWaitbar);

mergeScansFlag = 'No'; % define it in CERROptions?
%selected = showDCMInfo(dcmdirS);
selected = 'all';
patNameC = fieldnames(dcmdirS);
if isempty(selected)
    return
elseif strcmpi(selected,'all')
    combinedDcmdirS = struct('STUDY',dcmdirS.(patNameC{1}).STUDY,'info',dcmdirS.(patNameC{1}).info);
    count = 0;
    for studyCount = 1:length(combinedDcmdirS.STUDY)
        for seriesCount = 1:length(combinedDcmdirS.STUDY(studyCount).SERIES)
            count = count + 1;
            newCombinedDcmdirS.STUDY.SERIES(count) = combinedDcmdirS.STUDY(studyCount).SERIES(seriesCount);
        end
    end
    combinedDcmdirS = newCombinedDcmdirS;

    for i = 2:length(patNameC)
        for  k = 1:length(dcmdirS.(patNameC{i}).STUDY)
            for j = 1:length(dcmdirS.(patNameC{i}).STUDY(k).SERIES)
                combinedDcmdirS.STUDY.SERIES(end+1) = dcmdirS.(patNameC{i}).STUDY(k).SERIES(j);
            end
        end
    end
    % Pass the java dicom structures to function to create CERR plan
    planC = dcmdir2planC(combinedDcmdirS,mergeScansFlag,optS);
else
    % Pass the java dicom structures to function to create CERR plan
    planC = dcmdir2planC(dcmdirS.(selected),mergeScansFlag,optS); %wy
end

indexS = planC{end};

%-------------Store CERR version number---------------%
[version, date] = CERRCurrentVersion;
planC{indexS.header}.CERRImportVersion = [version, ', ', date];

toc;
pause(0.05)
save_planC(planC,planC{indexS.CERROptions});


function o = horzcat(varargin)
% Horizontal concatenation of file_array objects
% _______________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

%
% $Id: horzcat.m 1143 2008-02-07 19:33:33Z spm $

o    = cat(2,varargin{:});
return;


function fullpath = export_figure(handle, filename, format, varargin)
% export_figure Export a figure to various formats
%
% Utility function that exports a figure to various formats taking care
% of caching as well as some other options.
%
% Input:
% - handle (handle): Handle of a figure.
% - filename (string): Filename of the target file without extension.
% - format (string): Target format (fig, eps or png).
% - varargin[Cache] (boolean): Use caching. Disabled by default.
%
% Output:
% - fullpath (string): Path to the resulting file.
%

cache = false;

for i = 1:2:length(varargin)
    switch lower(varargin{i})
        case 'cache'
            cache = varargin{i+1};
        otherwise
            error(['Unknown switch ', varargin{i},'!']) ;
    end
end

fullpath = [filename, '.', format];

if isa(handle, 'function_handle')
    autoclose = true;
    cache = true;
else
    autoclose = false;
end

if cache && exist(fullpath, 'file')
    return;
end;

if isa(handle, 'function_handle')
    handle = handle();
end;

switch lower(format)
    case 'fig'
        saveas(handle, filename, 'fig');
    case 'eps'
        allca = num2cell(findall(handle, 'type', 'axes'));
        allbackup = cellfun(@update_axis, allca, 'UniformOutput', false);
        print( handle, '-depsc', [filename, '.eps']);
        cellfun(@restore_axis, allca, allbackup, 'UniformOutput', false);
    case 'png'
        ah = get(handle, 'CurrentAxes');
        title = get(ah, 'Title');
        set(title, 'Visible', 'off');
        print( handle, '-dpng', '-r130', [filename, '.png']);
        set(title, 'Visible', 'on');
    otherwise
        error('Unknown format');
end;

if autoclose
    close(handle);
end

end

function [backup] = update_axis(ha)
    backup.fontSize = get(ha, 'FontSize');
    backup.fontWeight = get(ha, 'FontWeight');
    backup.lineWidth = get(ha, 'LineWidth');
    set(ha, 'FontSize', 10, 'FontWeight', 'bold', 'LineWidth', 2);
end

function [backup] = restore_axis(ha, backup)
    set(ha, 'FontSize', backup.fontSize, 'FontWeight', backup.fontWeight, 'LineWidth', backup.lineWidth);
end


classdef LaunchVehicleTankState < matlab.mixin.SetGet & matlab.mixin.Copyable
    %LaunchVehicle Summary of this class goes here
    %   Detailed explanation goes here

    properties
        %validators commented out to improve performance
        stageState = LaunchVehicleStageState.empty(1,0)% LaunchVehicleStageState
        tank% LaunchVehicleTank
        tankMass = 0%(1,1) double = 0; %mT
    end

    methods
        function obj = LaunchVehicleTankState(stageState)
            obj.stageState = stageState;
        end

        function tankMass = getTankMass(obj)
            tankMass = [obj.tankMass];
        end

        function setTankMass(obj, tankMass)
            obj.tankMass = tankMass;
        end

        function newTankState = deepCopy(obj)
%             newTankState = LaunchVehicleTankState(obj.stageState);
            newTankState = obj.copy();

%             newTankState.tank = obj.tank;
%             newTankState.tankMass = obj.tankMass;
        end
    end
end


function SaveEvents(filename,events)

%SaveEvents - Write events to file.
%
%  USAGE
%
%    SaveEvents(filename,events)
%
%    filename            event file name
%    events              event data
%
%  SEE
%
%    See also NewEvents, LoadEvents, SaveRippleEvents.

% Copyright (C) 2004-2011 by Michaël Zugaro
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 3 of the License, or
% (at your option) any later version.

if exist(filename), error('File already exists. Aborting.'); end

file = fopen(filename,'w');
if file == -1,
	error(['Cannot write to ' filename]);
end

for i = 1:length(events.time),
	fprintf(file,'%f\t%s\n',events.time(i)*1000,events.description{i}); % Convert to milliseconds
end

fclose(file);

%


% Copyright (C) 1993-2013, by Peter I. Corke
%
% This file is part of The Machine Vision Toolbox for MATLAB (MVTB).
%
% MVTB is free software: you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% MVTB is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU Lesser General Public License for more details.
%
% You should have received a copy of the GNU Leser General Public License
% along with MVTB.  If not, see <http://www.gnu.org/licenses/>.
%
% http://www.petercorke.com

%%begin

% We will show how to acquire images from movie files.

% First we create an object to connect us to the image source which in
% this example is a movie file, a standard MPG format movie file
camera = Movie('traffic_sequence.mpg');
about camera
% and we see that the result is a Movie object

% The displayed value of this object
camera
% shows the frame dimension, frame rate, number of frames etc.

% To grab a frame from the movie
im = camera.grab();
% and then display it
idisp(im)

% We can display subsequent frames from the movie (note the traffic moving)
camera.grab();
camera.grab();
camera.grab();
camera.grab();
% Note that if we call the grab() method without a return argument the image
% is automatically displayed.

% Finally we destroy the camera object which deallocates resources
clear camera


function complete_run(ssh_path, eddies_save_path, tracks_save_path, fake_eddies, viewer_data_save_path, viewer_path, varargin)
% NOTE: Please provide full path names for all paths.
%
% The purpose of this function is to automate the entire gauntlet of
% running all of the code to go from having only MATLAB SSH data to getting
% the data set up to be viewed on the tracks viewer. This function should
% automate the following steps:
% 1. Scan SSH data for eddies
% 2. Save detected eddies
% 3. Build LNN tracks for these eddies (Possibly with fake eddies, if the
%    user of the script wants fake eddies)
% 4. Format and process saved data so that it can be viewed in Hung's
%    viewer that we include
%
% NOTE: The process of turning NetCDF file data into MATLAB data is not
% accomplished in this function.
% The function set_up_ssh_data is provided that will accomplish this for
% the user, but the user will have to provide the variable names that match
% the function inputs. Refer to the comments at the top of the function
% set_up_ssh_data for a description of what each of the required variables are.
%
% This script will not open the viewer for the user.
% To open the viewer, run the start_track_viewer script inside the
% tracks_viewer directory.

p = inputParser;
defaultLat = NaN;
defaultLon = NaN;
defaultDates = NaN;
defaultAreaMap = NaN;
defaultScanType = 'v2';
defaultMinPixelSize = 9;
defaultThresholdStep = 0.05;
defaultSSHUnits = 'centimeters';
defaultPaddingFlag = true;

addRequired(p, 'ssh_dir');
addRequired(p, 'eddies_save_path');
addRequired(p, 'fake_eddies');

addParameter(p, 'lat', defaultLat);
addParameter(p, 'lon', defaultLon);
addParameter(p, 'dates', defaultDates);
addParameter(p, 'area_map', defaultAreaMap);
addParameter(p, 'scan_type', defaultScanType);
addParameter(p, 'minimumArea', defaultMinPixelSize, @isnumeric);
addParameter(p, 'thresholdStep', defaultThresholdStep, @isnumeric);
addParameter(p, 'isPadding', defaultPaddingFlag);
addParameter(p, 'sshUnits', defaultSSHUnits);

parse(p, ssh_path, eddies_save_path, fake_eddies, varargin{:});

lat = p.Results.lat;
lon = p.Results.lon;
dates = p.Results.dates;
area_map = p.Results.area_map;
scan_type = p.Results.scan_type;
minimumArea = p.Results.minimumArea;
thresholdStep = p.Results.thresholdStep;
isPadding = p.Results.isPadding;
SSH_Units = p.Results.sshUnits;
if ~strcmp(ssh_path(end), '/')
    ssh_path = strcat(ssh_path, '/');
end
if ~strcmp(eddies_save_path(end), '/')
    eddies_save_path = strcat(eddies_save_path, '/');
end
if ~strcmp(tracks_save_path(end), '/')
    tracks_save_path = strcat(tracks_save_path, '/');
end
if ~strcmp(viewer_data_save_path(end), '/')
    viewer_data_save_path = strcat(viewer_data_save_path, '/');
end
ssh_names = get_ssh_names(ssh_path);
if isnan(lat)
    vars = load([ssh_path, 'lat.mat']);
    names = fieldnames(vars);
    lat = vars.(names{1});
end
if isnan(lon)
    vars = load([ssh_path, 'lon.mat']);
    names = fieldnames(vars);
    lon = vars.(names{1});
end
if isnan(dates)
    vars = load([ssh_path, 'dates.mat']);
    names = fieldnames(vars);
    dates = vars.(names{1});
end
if isnan(area_map)
    vars = load([ssh_path, 'area_map.mat']);
    names = fieldnames(vars);
    area_map = vars.(names{1});
end
if ~exist(eddies_save_path, 'dir')
    mkdir(eddies_save_path);
end
old_path = cd('eddyscan/');
disp('Scanning SSH data for eddies');
for i = 1:length(ssh_names)
    disp(['Iteration ', num2str(i)]);
    vars = load(ssh_names{i});
    names = fieldnames(vars);
    ssh_data = vars.(names{1});
    ant_eddies = scan_single(ssh_data, lat, lon, dates(i), 'anticyc', scan_type, area_map, 'sshUnits', SSH_Units,...
                             'thresholdStep', thresholdStep, 'minimumArea', minimumArea, 'isPadding', isPadding);
    par_save([eddies_save_path, 'anticyc_', num2str(dates(i)), '.mat'], ant_eddies);
    cyc_eddies = scan_single(ssh_data, lat, lon, dates(i), 'cyclonic', scan_type, area_map, 'sshUnits', SSH_Units,...
                             'thresholdStep', thresholdStep, 'minimumArea', minimumArea, 'isPadding', isPadding);
    par_save([eddies_save_path, 'cyclonic_', num2str(dates(i)), '.mat'], cyc_eddies);
end
cd(old_path);
% Track eddies and save tracks
if ~exist(tracks_save_path, 'dir')
    mkdir(tracks_save_path);
end
if ~exist(viewer_data_save_path, 'dir')
    mkdir(viewer_data_save_path);
end
old_path = cd('track_lnn/');
disp('Tracking eddies');
if strcmp(fake_eddies, 'yes')
    anticyclonic_tracks = tolerance_track_lnn(eddies_save_path, 'anticyc', 1, 1, minimumArea);
    cyclonic_tracks = tolerance_track_lnn(eddies_save_path, 'cyclonic', 1, 1, minimumArea);
    modified_eddies_path = [viewer_data_save_path, 'modified_eddies/'];
    modified_tracks_path = [viewer_data_save_path, 'modified_tracks/'];
    if ~exist(modified_eddies_path, 'dir')
        mkdir(modified_eddies_path);
    end
    if ~exist(modified_tracks_path, 'dir')
        mkdir(modified_tracks_path);
    end
    disp('Modifying eddy data to include fake eddies (for the sake of the tracks)');
    process_eddies_and_tracks_tolerance('anticyc', dates, eddies_save_path, anticyclonic_tracks, modified_eddies_path, modified_tracks_path);
    process_eddies_and_tracks_tolerance('cyclonic', dates, eddies_save_path, cyclonic_tracks, modified_eddies_path, modified_tracks_path);
    vars = load([modified_tracks_path, 'anticyc_tracks_processed.mat']);
    s = fieldnames(vars);
    anticyclonic_tracks = vars.(s{1});
    vars = load([modified_tracks_path, 'cyclonic_tracks_processed.mat']);
    s = fieldnames(vars);
    cyclonic_tracks = vars.(s{1});
    eddies_save_path = modified_eddies_path;
else
    anticyclonic_tracks = track_lnn(eddies_save_path, 'anticyc', 1); % Possibly change this so it can be an optional argument in input parser
    cyclonic_tracks = track_lnn(eddies_save_path, 'cyclonic', 1); % Same as above
end
save([tracks_save_path, 'anticyclonic_tracks.mat'], 'anticyclonic_tracks');
save([tracks_save_path, 'cyclonic_tracks.mat'], 'cyclonic_tracks');
eddies_t = reformat_track_data_to_chelton(eddies_save_path, dates, anticyclonic_tracks, cyclonic_tracks);%#ok
save([tracks_save_path, 'chelton_structured_tracks.mat'], 'eddies_t');
% Set up data for viewer
disp('Preparing data for viewer');
prepare_eddy_data_for_viewer(viewer_data_save_path, dates, eddies_save_path, cyclonic_tracks, anticyclonic_tracks, ssh_path);
cd(old_path);
% Deleting old viewer files
files = dir([viewer_path, 'SSH/']);
old_path = cd([viewer_path, 'SSH/']);
for i = 1:length(files)
    file = files(i).name;
    if ~strcmp(file, '.') && ~strcmp(file, '..')
        if files(i).isdir
            rmdir(file, 's');
        else
            delete(file);
        end
    end
end
files = dir([viewer_path, 'track_data/']);
cd([viewer_path, 'track_data/']);
for i = 1:length(files)
    file = files(i).name;
    if ~strcmp(file, '.') && ~strcmp(file, '..')
        if files(i).isdir
            rmdir(file, 's');
        else
            delete(file);
        end
    end
end
files = dir([viewer_path, 'attributes/']);
cd([viewer_path, 'attributes/']);
for i = 1:length(files)
    file = files(i).name;
    if ~strcmp(file, '.') && ~strcmp(file, '..')
        if files(i).isdir
            rmdir(file, 's');
        else
            delete(file);
        end
    end
end
files = dir([viewer_path, 'pixels_data/']);
cd([viewer_path, 'pixels_data/']);
for i = 1:length(files)
    file = files(i).name;
    if ~strcmp(file, '.') && ~strcmp(file, '..')
        if files(i).isdir
            rmdir(file, 's');
        else
            delete(file);
        end
    end
end
cd(old_path);
% Copying new viewer files into place
files = dir(ssh_path);
for i = 1:length(files)
    file = files(i).name;
    if ~strcmp(file, '.') && ~strcmp(file, '..')
        copyfile([ssh_path, file], [viewer_path, 'SSH/', file]);
    end
end
files = dir(tracks_save_path);
for i = 1:length(files)
    file = files(i).name;
    if ~strcmp(file, '.') && ~strcmp(file, '..')
        copyfile([tracks_save_path, file], [viewer_path, 'track_data/', file]);
    end
end
files = dir(viewer_data_save_path);
for i = 1:length(files)
    file = files(i).name;
    if ~strcmp(file, '.') && ~strcmp(file, '..')
        if ~files(i).isdir
            if strcmp(file, 'anticyclonic_tags.mat') || strcmp(file, 'cyclonic_tags.mat')
                copyfile([viewer_data_save_path, file], [viewer_path, 'track_data/', file]);
            else
                copyfile([viewer_data_save_path, file], [viewer_path, 'attributes/', file]);
            end
        end
    end
end
files = dir([viewer_data_save_path, 'pixel_data/']);
for i = 1:length(files)
    file = files(i).name;
    if ~strcmp(file, '.') && ~strcmp(file, '..')
        copyfile([viewer_data_save_path, 'pixel_data/', file], [viewer_path, 'pixels_data/', file]);
    end
end

end

function par_save(path, eddies)%#ok
save(path, 'eddies');
end

function [ssh_names] = get_ssh_names(path)
% path is the path to the eddies directory
% type is anticyclonic or cyclonic
if ~strcmp(path(end), '/')
    path = strcat(path, '/');
end
files = dir(path);
x = 0;
for i = 1:length(files)
    if ~isempty(strfind(files(i).name, 'ssh_'))
        x = x + 1;
    end
end
ssh_names = cell(x, 1);
x = 1;
for i = 1:length(files)
    if files(i).isdir && ~isequal(files(i).name, '.') && ~isequal(files(i).name, '..')
        rec_names = get_ssh_names([path, files(i).name, '/']);
        for j = 1:length(rec_names)
            ssh_names{x} = rec_names{j};
            x = x + 1;
        end
        continue;
    end
    file = files(i).name;
    [~, name, ext] = fileparts([path, file]);
    if ~isempty(strfind(name, 'ssh_')) && strcmp(ext, '.mat')
        ssh_names{x} = [path, file];
        x = x + 1;
    end
end
end


%% Plotting
%
% Below you find a list of plotting tools included in the MTEX toolbox. Of
% special importance is the command <saveFigure.html saveFigure> which
% allows saving plots in any kinds of image files.
%%
%