xxsimGetPlotWindowIDFromName

PURPOSE ^

xxsimGetPlotWindowIDFromName - Find the corresponding window ID for a certain window name.

SYNOPSIS ^

function retval = xxsimGetPlotWindowIDFromName(windowName)

DESCRIPTION ^

 xxsimGetPlotWindowIDFromName - Find the corresponding window ID for a certain window name.

 Syntax: 
   retval = xxsimGetPlotWindowIDFromName(windowName)

 Inputs:
   windowName    = The name of the window of which you want to get the ID or the ID itself.
 
 Outputs: 
   retval = returns the ID of the plot window or -1 if there is no plot window with that name. 
             If windowName is numeric, retval will be equal to windowName.
 
 Examples:
   retval = xxsimGetPlotWindowIDFromName('Motor Torque')
   
     - retval now contains the ID of the corresponding plot window or -1 if the plot window does not exist.
     - if the input would be numeric, retval will get that numeric value.
     - Note: The simulator should be open before calling this function.  

 See also: xxsimGetPlotIDFromName, xxsimGetPlotWindows

 Author: Controllab Products B.V.
 email: info@controllab.nl
 Website: http://www.controllab.nl
 November 2015

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function retval = xxsimGetPlotWindowIDFromName(windowName)
0002 % xxsimGetPlotWindowIDFromName - Find the corresponding window ID for a certain window name.
0003 %
0004 % Syntax:
0005 %   retval = xxsimGetPlotWindowIDFromName(windowName)
0006 %
0007 % Inputs:
0008 %   windowName    = The name of the window of which you want to get the ID or the ID itself.
0009 %
0010 % Outputs:
0011 %   retval = returns the ID of the plot window or -1 if there is no plot window with that name.
0012 %             If windowName is numeric, retval will be equal to windowName.
0013 %
0014 % Examples:
0015 %   retval = xxsimGetPlotWindowIDFromName('Motor Torque')
0016 %
0017 %     - retval now contains the ID of the corresponding plot window or -1 if the plot window does not exist.
0018 %     - if the input would be numeric, retval will get that numeric value.
0019 %     - Note: The simulator should be open before calling this function.
0020 %
0021 % See also: xxsimGetPlotIDFromName, xxsimGetPlotWindows
0022 %
0023 % Author: Controllab Products B.V.
0024 % email: info@controllab.nl
0025 % Website: http://www.controllab.nl
0026 % November 2015
0027 
0028 %------------- BEGIN CODE --------------
0029 
0030   % Check the obtained amount of input arguments.
0031   if(nargin>1)
0032     error('Too many input arguments were specified.');
0033   elseif(nargin<1)
0034     error('Too little input arguments were specified.');
0035   end;
0036 
0037   % Get the window ID, either via the name of the plot window or directly the ID
0038   windowID = -1;
0039   % If the input is a string, interpret it as the name of the plot window
0040   if(ischar(windowName))
0041     windowStruct = xxsimGetPlotWindows(); % Get all ID and name pairs of all plot windows.
0042     nameCount = 0;
0043     for i=1:length(windowStruct)
0044       if(strcmp(windowStruct(i).windowName,windowName))
0045         nameCount = nameCount + 1;
0046         if(nameCount == 1)
0047           windowID = windowStruct(i).windowID; % There is a window found with the given name, and its ID is stored.
0048         elseif(nameCount == 2)
0049           warning('Multiple plot windows found with the specified name. Selected the first plot window.');
0050           break;
0051         end;
0052       end;
0053     end;
0054   % If the input is a number, then it is interpreted as the ID directly.
0055   elseif(isnumeric(windowName))
0056     windowID = windowName;
0057   % If the input is not numeric nor a string, give an error.
0058   else
0059     error('The specified plot window name is not a string nor a number.');
0060   end;
0061   
0062   retval = windowID;
0063   
0064 end
0065 %------------- END OF CODE --------------

Generated on Mon 08-Jul-2019 16:49:39