


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

0001 function [result] = xxsimLoadSimulationState(varargin) 0002 % xxsimLoadSimulationState - Load the simulation state from a file. The current model is used for loading 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 % initializeSimulator = Boolean to indicate whether the simulator needs to be (re)initialized 0010 % 0011 % Outputs: 0012 % result = boolean true on success, false on failure 0013 % 0014 % Examples: 0015 % result = xxsimLoadSimulationState('C:\temp\test_state.xml') 0016 % 0017 % See also: xxsimSaveSimulationState 0018 % 0019 % Author: Controllab Products B.V. 0020 % email: info@controllab.nl 0021 % Website: https://www.controllab.nl 0022 % October 2023 0023 0024 %------------- BEGIN CODE -------------- 0025 %check input arguments 0026 fileName = ''; 0027 initializeSimulator = true; 0028 if length(varargin) == 0 0029 error('This function expects a file name as input argument.'); 0030 elseif length(varargin)>=1 0031 if ~ischar(varargin{1}) 0032 error('Input argument 1 should be a file name.'); 0033 else 0034 fileName = varargin{1}; 0035 end 0036 if length(varargin) == 2 0037 initializeSimulator = varargin{2}; 0038 end 0039 end 0040 0041 % set the result variable 0042 result = false; 0043 0044 reply = xrlinvoke('xxsim.simulator.loadState', struct('filename', fileName, 'initializeSimulator', initializeSimulator)); 0045 if (isempty(reply) ) 0046 error('could not save the simulator state'); 0047 end 0048 0049 % return the succes 0050 result = true; 0051 end 0052 %------------- END OF CODE --------------