xxsimSetImplementations

PURPOSE ^

xxsimSetImplementations - Change the implementation of one or more submodels.

SYNOPSIS ^

function retval = xxsimSetImplementations(varargin)

DESCRIPTION ^

 xxsimSetImplementations - Change the implementation of one or more submodels.

 Syntax: 
   retval = xxsimSetImplementations(names, implementations, processModel)

 Inputs:
   names  = the hierarchical names of the submodels of which you want to select the implementation.
   implementations = the implementation names to select.
   processModel = (optional) boolean to indicate whether the model should be processed afterwards. Defaults to true.

 Outputs:
   result  = returns true if the call succeeded, false otherwise.

 Examples:
   xxsimSetImplementations('Submodel1', 'ImplementationA');
   xxsimSetImplementations({'Submodel1', 'Submodel2'}, {'ImplementationA', 'ImplementationB'});
   xxsimSetImplementations({'Submodel1', 'Submodel2'}, {'ImplementationA', 'ImplementationB'}, false);

 See also: xxsimGetImplementations, xxsimQueryImplementations

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function retval = xxsimSetImplementations(varargin)
0002 % xxsimSetImplementations - Change the implementation of one or more submodels.
0003 %
0004 % Syntax:
0005 %   retval = xxsimSetImplementations(names, implementations, processModel)
0006 %
0007 % Inputs:
0008 %   names  = the hierarchical names of the submodels of which you want to select the implementation.
0009 %   implementations = the implementation names to select.
0010 %   processModel = (optional) boolean to indicate whether the model should be processed afterwards. Defaults to true.
0011 %
0012 % Outputs:
0013 %   result  = returns true if the call succeeded, false otherwise.
0014 %
0015 % Examples:
0016 %   xxsimSetImplementations('Submodel1', 'ImplementationA');
0017 %   xxsimSetImplementations({'Submodel1', 'Submodel2'}, {'ImplementationA', 'ImplementationB'});
0018 %   xxsimSetImplementations({'Submodel1', 'Submodel2'}, {'ImplementationA', 'ImplementationB'}, false);
0019 %
0020 % See also: xxsimGetImplementations, xxsimQueryImplementations
0021 %
0022 % Author: Controllab Products B.V.
0023 % email: info@controllab.nl
0024 % Website: http://www.controllab.nl
0025 % October 2014
0026 
0027 %------------- BEGIN CODE --------------
0028 
0029     % decode variable arguments
0030     if length(varargin)> 3
0031         error('Too many input arguments.');
0032     end
0033     if length(varargin)< 2
0034         error('Too few input arguments.');
0035     end
0036     
0037     % Get the input arguments
0038     names = varargin{1};
0039     implementations = varargin{2};
0040     processModel = false;
0041     if length(varargin)==3
0042         processModel = varargin{3};
0043     else
0044         processModel = true;
0045     end
0046 
0047     use_names = {};
0048     use_implem = {};
0049 
0050     % check input arguments
0051     if ~ischar(names)
0052         use_names = names;
0053     else
0054         use_names = {names};
0055     end
0056 
0057     if iscell(implementations)
0058         use_implem = implementations;
0059     else
0060         use_implem = {implementations};
0061     end
0062 
0063     % test if the given arguments have the same length
0064     if length(use_names) ~= length(use_implem)
0065         error('array size mismatch in given names and implementations');
0066     end
0067 
0068     % create a an array of struct with name and values
0069     for i=1:length(use_names)
0070         %For matlab compatibility create the first element without index.
0071         if i == 1
0072             changelist = struct('name', use_names{i}, 'implementation', use_implem{i});
0073         else
0074             changelist(i) = struct('name', use_names{i}, 'implementation', use_implem{i});
0075         end
0076             
0077     end
0078       
0079     % and make the actual call to 20-sim
0080     retval = xrlinvoke('xxsim.model.changeImplementations', struct('implementations', {{changelist, 'array'}}, 'processModel', processModel));
0081 end
0082 %------------- END CODE --------------

Generated on Sun 10-Dec-2017 19:24:51