


xxsimSaveSimulationState - Save the simulation state to a file. The current model is used for saving the state.
Syntax:
result = xxsimSaveSimulationState(fileName)
Inputs:
fileName = Name of the file to save (usually with extension .xml).
Outputs:
result = boolean true on success, false on failure
Examples:
result = xxsimSaveSimulationState('C:\temp\test_state.xml')
See also: xxsimLoadSimulationState
Author: Controllab Products B.V.
email: info@controllab.nl
Website: https://www.controllab.nl
October 2023

0001 function [result] = xxsimSaveSimulationState(varargin) 0002 % xxsimSaveSimulationState - Save the simulation state to a file. The current model is used for saving the state. 0003 % 0004 % Syntax: 0005 % result = xxsimSaveSimulationState(fileName) 0006 % 0007 % Inputs: 0008 % fileName = Name of the file to save (usually with extension .xml). 0009 % 0010 % Outputs: 0011 % result = boolean true on success, false on failure 0012 % 0013 % Examples: 0014 % result = xxsimSaveSimulationState('C:\temp\test_state.xml') 0015 % 0016 % See also: xxsimLoadSimulationState 0017 % 0018 % Author: Controllab Products B.V. 0019 % email: info@controllab.nl 0020 % Website: https://www.controllab.nl 0021 % October 2023 0022 0023 %------------- BEGIN CODE -------------- 0024 %check input arguments 0025 fileName = ''; 0026 if length(varargin)==1 0027 0028 if ~ischar(varargin{1}) 0029 error('Input argument 1 should be a file name.'); 0030 else 0031 fileName = varargin{1}; 0032 end 0033 else 0034 error('This function expects only 1 input argument: fileName'); 0035 end 0036 0037 % set the result variable 0038 result = false; 0039 0040 reply = xrlinvoke('xxsim.simulator.saveState', struct('filename', fileName)); 0041 if (isempty(reply) ) 0042 error('could not save the simulator state'); 0043 end 0044 0045 % return the succes 0046 result = true; 0047 end 0048 %------------- END OF CODE --------------