I am currently using FMIKit for Simulink found here https://github.com/CATIA-Systems/FMIKit-Simulink
From the documentation it works very well to query values of parameters within the FMU using FMIKit.getStartValue(FMUBLOCK, 'Variablename');
but only if you know the name and structure of the variable you are looking for.
I wanted to know if there is a way to extract the full list of variables in the FMU together with their values just before I start the simulation (for sim debugging purposes)?
You can get the start values of the model variables by reading the model description of the FMU (e.g. the VanDerPol.fmu from the FMI 2.0 Test FMUs):
% import the FMU and select the FMU block
% set a different start value for variable "mu"
FMIKit.setStartValue(gcb, 'mu', '1.3');
% read the model description (returns a Java object)
md = FMIKit.getModelDescription('VanDerPol.fmu');
% iterate over the list of variables
for i = 1:md.scalarVariables.size
v = md.scalarVariables.get(i-1);
% get the name and start value
name = char(v.name);
% get the start value from the FMU block
start = FMIKit.getStartValue(gcb, name); % might be empty
disp([name ': ' start])
end
gives you
x0: 2
der(x0):
x1: 0
der(x1):
mu: 1.3