xxsimReplaceSubmodel - Replace an existing submodel with the version from the provided file Syntax: result = xxsimReplaceSubmodel(submodelName, fileName, implementation) Inputs: submodelName = the hierachical submodel name fileName = path to the model with which the submodel should be replaced implementation = the implementation that should be made active when the stored submodel has multiple implementations (optional) Outputs: result = boolean indicating the success. Examples: result = xxsimReplaceSubmodel('mysubmodel', 'C:\temp\mysubmodel.emx') result = xxsimReplaceSubmodel('mysubmodel', 'C:\temp\mysubmodel.emx', 'mysubmodel implementation') See also: xxsimSaveModel Author: Controllab Products B.V. email: info@controllab.nl Website: http://www.controllab.nl July 2016
0001 function [result] = xxsimReplaceSubmodel(varargin) 0002 % xxsimReplaceSubmodel - Replace an existing submodel with the version from the 0003 % provided file 0004 % 0005 % Syntax: 0006 % result = xxsimReplaceSubmodel(submodelName, fileName, implementation) 0007 % 0008 % Inputs: 0009 % submodelName = the hierachical submodel name 0010 % fileName = path to the model with which the submodel should be replaced 0011 % implementation = the implementation that should be made active when 0012 % the stored submodel has multiple implementations 0013 % (optional) 0014 % 0015 % Outputs: 0016 % result = boolean indicating the success. 0017 % 0018 % Examples: 0019 % result = xxsimReplaceSubmodel('mysubmodel', 'C:\temp\mysubmodel.emx') 0020 % result = xxsimReplaceSubmodel('mysubmodel', 'C:\temp\mysubmodel.emx', 'mysubmodel implementation') 0021 % 0022 % See also: xxsimSaveModel 0023 % 0024 % Author: Controllab Products B.V. 0025 % email: info@controllab.nl 0026 % Website: http://www.controllab.nl 0027 % July 2016 0028 0029 %------------- BEGIN CODE -------------- 0030 %check input arguments 0031 modelFilename = ''; 0032 if (length(varargin) < 2) || (length(varargin) > 3) 0033 error('This function expects 2 or 3 input arguments: submodelName, fileName and implementation (optional).'); 0034 else 0035 if ~ischar(varargin{1}) 0036 error('Input argument 1 should be the name of the submodel (string).'); 0037 else 0038 submodelName = varargin{1}; 0039 end 0040 if ~ischar(varargin{2}) 0041 error('Input argument 2 should be the file name (string).'); 0042 else 0043 submodelFilename = varargin{2}; 0044 end 0045 if length(varargin)==3 0046 if ~ischar(varargin{3}) 0047 error('Input argument 3 should be the implementation name (string).'); 0048 else 0049 implementation = varargin{3}; 0050 end 0051 else 0052 implementation = ''; 0053 end 0054 end 0055 0056 % set the result varaible 0057 result = true; 0058 0059 reply = xrlinvoke('xxsim.model.replaceSubmodel', struct('submodelName', submodelName, 'fileName', submodelFilename, 'implementation', implementation)); 0060 if (length(reply) == 0 ) 0061 error('could not replace the submodel'); 0062 end 0063 0064 % return the succes 0065 result = true; 0066 end 0067 %------------- END OF CODE --------------