xxsimSaveSubmodel

PURPOSE ^

xxsimSaveSubmodel - Save the given submodel as a separate file

SYNOPSIS ^

function [result] = xxsimSaveSubmodel(varargin)

DESCRIPTION ^

 xxsimSaveSubmodel - Save the given submodel as a separate file

 Syntax:
   result = xxsimSaveSubmodel(submodelName, fileName, encryptedStatus)

 Inputs:
   submodelName = the hierachical submodel name
   fileName = directory path to which the submodel should be saved
   encryptedStatus (optional, default is 0) = if 0, then the submodel is saved unencrypted, if 1, 
   then the submodel is saved encrypted and no C-code can be generated, if 2, then the submodel is
   saved encrypted, but C-code can still be generated from it.

 Outputs:
   result = boolean indicating the success.

 Examples:
   result = xxsimSaveSubmodel('mysubmodel', 'C:\temp\mysubmodel.emx')

 See also: xxsimSaveModel, xxsimReplaceSubmodel

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [result] = xxsimSaveSubmodel(varargin)
0002 % xxsimSaveSubmodel - Save the given submodel as a separate file
0003 %
0004 % Syntax:
0005 %   result = xxsimSaveSubmodel(submodelName, fileName, encryptedStatus)
0006 %
0007 % Inputs:
0008 %   submodelName = the hierachical submodel name
0009 %   fileName = directory path to which the submodel should be saved
0010 %   encryptedStatus (optional, default is 0) = if 0, then the submodel is saved unencrypted, if 1,
0011 %   then the submodel is saved encrypted and no C-code can be generated, if 2, then the submodel is
0012 %   saved encrypted, but C-code can still be generated from it.
0013 %
0014 % Outputs:
0015 %   result = boolean indicating the success.
0016 %
0017 % Examples:
0018 %   result = xxsimSaveSubmodel('mysubmodel', 'C:\temp\mysubmodel.emx')
0019 %
0020 % See also: xxsimSaveModel, xxsimReplaceSubmodel
0021 %
0022 % Author: Controllab Products B.V.
0023 % email: info@controllab.nl
0024 % Website: http://www.controllab.nl
0025 % January 2018
0026 
0027 %------------- BEGIN CODE --------------
0028     %check input arguments
0029     modelFilename = '';
0030     
0031     if length(varargin)<2 || length(varargin)>3
0032         error('This function expects 2 or 3 input arguments: submodelName and fileName (and encryptedStatus).');
0033     end
0034     
0035     if length(varargin)==2
0036         encryptedStatus = 0;
0037     else
0038         encryptedStatus = varargin{3};
0039     end
0040     
0041     if ~ischar(varargin{1})
0042         error('Input argument 1 should be the name of the submodel (string).');
0043     else
0044         submodelName = varargin{1};
0045     end
0046     if ~ischar(varargin{2})
0047         error('Input argument 2 should be the file name (string).');
0048     else
0049         submodelFilename = varargin{2};
0050     end
0051     if ~isnumeric(encryptedStatus)
0052         error('Input argument 3 should be the encryption status (integer).');
0053     end
0054 
0055     % set the result variable
0056     result = true;
0057 
0058     reply = xrlinvoke('xxsim.model.saveSubmodel', struct('submodelName', submodelName, 'fileName', submodelFilename, 'encryption', int32(encryptedStatus)));
0059     if (length(reply) == 0 )
0060         error('could not save the submodel');
0061     end
0062 
0063     % return the succes
0064     result = true;
0065 end
0066 %------------- END OF CODE --------------

Generated on Fri 19-Jan-2018 15:01:54