xxsimRenameSubmodel - Rename an existing submodel Syntax: result = xxsimRenameSubmodel(submodelName, newSubmodelName) Inputs: submodelName (string) = The hierarchical submodel name newSubmodelName (string) = The new submodel name (without hierarchy) Outputs: result (boolean) true on success, false otherwise. Examples: result = xxsimRenameSubmodel('submodel', 'RenamedSubmodel'); result = xxsimRenameSubmodel('some.hierarchy.submodel', 'renamedsubmodel') Author: Controllab Products B.V. email: info@controllab.nl Website: https://www.controllab.nl Oct 2021
0001 function [result] = xxsimRenameSubmodel(varargin) 0002 % xxsimRenameSubmodel - Rename an existing submodel 0003 % 0004 % Syntax: 0005 % result = xxsimRenameSubmodel(submodelName, newSubmodelName) 0006 % 0007 % Inputs: 0008 % submodelName (string) = The hierarchical submodel name 0009 % newSubmodelName (string) = The new submodel name (without hierarchy) 0010 % 0011 % Outputs: 0012 % result (boolean) true on success, false otherwise. 0013 % 0014 % Examples: 0015 % result = xxsimRenameSubmodel('submodel', 'RenamedSubmodel'); 0016 % result = xxsimRenameSubmodel('some.hierarchy.submodel', 'renamedsubmodel') 0017 % 0018 % Author: Controllab Products B.V. 0019 % email: info@controllab.nl 0020 % Website: https://www.controllab.nl 0021 % Oct 2021 0022 0023 %------------- BEGIN CODE -------------- 0024 %check input arguments 0025 modelFilename = ''; 0026 if (length(varargin) < 2) || (length(varargin) > 2) 0027 error('This function expects 2input arguments: submodelName, newSubmodelName.'); 0028 else 0029 if ~ischar(varargin{1}) 0030 error('Input argument 1 should be the name of the submodel (string).'); 0031 else 0032 submodelName = varargin{1}; 0033 end 0034 if ~ischar(varargin{2}) 0035 error('Input argument 2 should be the new submodel name (string).'); 0036 else 0037 newSubmodelName = varargin{2}; 0038 end 0039 end 0040 0041 % set the result varaible 0042 result = true; 0043 0044 reply = xrlinvoke('xxsim.model.renameSubmodel', struct('submodelName', submodelName, 'newSubmodelName', newSubmodelName)); 0045 if (length(reply) == 0 ) 0046 error('could not rename the submodel'); 0047 end 0048 0049 % return the succes 0050 result = true; 0051 end 0052 %------------- END OF CODE --------------