xxsimGetSubmodelTree - Get the list of submodels underneath the specified submodel. Syntax: retval = xxsimGetSubmodelTree('submodel_name', recursive, includeSelf) Inputs: submodelName = The hierarchical submodel name or the empty string for the overall model. recursive = (optional, default=false) false: returns one level below the submodel, true: returns recursively the tree below the specified submodel includeSelf = (optional, default=false) false: returns only the submodels below submodelName; true: includes submodelName in the result Outputs: retval = returns a structure array of the requested properties. Examples: retval = xxsimGetSubmodelProperties('Controller.PID') - returns the structure array with all submodel properties for the submodel "PID" within the submodel "Controller". retval = xxsimGetSubmodelProperties('PID', 'Keywords', 'Title') - returns the structure array with the Keywords and Title properties of the submodel named "PID". Author: Controllab Products B.V. email: info@controllab.nl Website: https://www.20sim.com December 2018
0001 function retval = xxsimGetSubmodelTree(submodelName, varargin) 0002 % xxsimGetSubmodelTree - Get the list of submodels underneath the specified 0003 % submodel. 0004 % 0005 % Syntax: 0006 % retval = xxsimGetSubmodelTree('submodel_name', recursive, includeSelf) 0007 % 0008 % Inputs: 0009 % submodelName = The hierarchical submodel name or the empty string for the 0010 % overall model. 0011 % recursive = (optional, default=false) false: returns one level below the 0012 % submodel, true: returns recursively the tree below the 0013 % specified submodel 0014 % includeSelf = (optional, default=false) false: returns only the submodels 0015 % below submodelName; true: includes submodelName in the result 0016 % 0017 % Outputs: 0018 % retval = returns a structure array of the requested properties. 0019 % 0020 % Examples: 0021 % retval = xxsimGetSubmodelProperties('Controller.PID') 0022 % 0023 % - returns the structure array with all submodel properties for the 0024 % submodel "PID" within the submodel "Controller". 0025 % 0026 % retval = xxsimGetSubmodelProperties('PID', 'Keywords', 'Title') 0027 % 0028 % - returns the structure array with the Keywords and Title properties of the 0029 % submodel named "PID". 0030 % 0031 % 0032 % Author: Controllab Products B.V. 0033 % email: info@controllab.nl 0034 % Website: https://www.20sim.com 0035 % December 2018 0036 0037 %------------- BEGIN CODE -------------- 0038 0039 % Check if the submodelName is a string. 0040 if(~ischar(submodelName)) 0041 error('Please specify a valid submodel name.'); 0042 end; 0043 0044 recursive = false; 0045 includeSelf = false; 0046 0047 if length(varargin)>= 1 0048 if islogical(varargin{1}) 0049 recursive = varargin{1}; 0050 else 0051 if (varargin{1} != 0) 0052 recursive = true 0053 end 0054 end 0055 end 0056 0057 if length(varargin)>= 2 0058 if islogical(varargin{2}) 0059 includeSelf = varargin{2}; 0060 else 0061 if (varargin{2} != 0) 0062 includeSelf = true 0063 end 0064 end 0065 end 0066 0067 retval = xrlinvoke('xxsim.model.getSubmodelTree', struct('submodelName',submodelName, 0068 'recursive',recursive, 0069 'includeSelf',includeSelf)); 0070 end