<< importFMU fmu_wrapper Comparison of numerical results of simulation >>

fmu_wrapper >> fmu_wrapper > loadFMU

loadFMU

load an FMU file returning its raw content.

Calling Sequence

[workdir, xml] = loadFMU(filepath)
[workdir, xml, libname] loadFMU(filepath)
[workdir, xml, libname, modelIdentifier, fmuImpl] = loadFMU(filepath, workdir)
[workdir, xml, libname, modelIdentifier] = loadFMU(filepath, workdir, fmuImpl)

Arguments

filepath

string, a path for a model.

workdir

string, a path to the extracted file content.

fmuImpl

string, the FMU versioned implementation like "me 1.0" for Model Exchange 1.0. Multiple values can be returned if the FMU supports multiple versions.

xml

xmlDocument, the XML content of modelDescription.xml.

libname

string, a path to the library used for the simulation.

modelIdentifier

string, the model identifier to pass to fmu_link.

Description

loadFMU is the function which decompress a model at TMPDIR Folder with the same name as the name of the FMU file. It also extracts the XML information of the modelDescription.xml file which contains all the information about the FMU as well as returns the path to the shared library associated with the current operating system and architecture.

The workdir can be passed around the function to retrieve part of the information at different times without unzipping the FMU multiple times.

To link and use an FMU, you shoud pass libname, modelIdentifier, fmuImpl output arguments to fmu_link and use fmu_callto manipulate the FMU.

Examples

[?, p] = libraryinfo("xcos_fmulib");

// Decompressing the model "SCADE_CruiseControl__CruiseControl_FMU".
filepath = fullfile(p, "..", "tests", "unit_tests", "SCADE_CruiseControl__CruiseControl_FMU.fmu");
[workdir, xml] = loadFMU(filepath);

// check the xml, retrieve the inputs and outputs
in = xmlXPath(xml, "//ScalarVariable[@causality=""input""]")
out = xmlXPath(xml, "//ScalarVariable[@causality=""output""]")

// link the FMU, retrieve the type and version
[workdir, xml, libname, modelIdentifier, fmuImpl] = loadFMU(filepath, workdir);

disp(fmuImpl)
[?, p] = libraryinfo("xcos_fmulib");

FMUs = listfiles(fullfile(p, "..", "tests", "unit_tests", "*.fmu"));

// display fmuImpl for each FMU
st = struct();
for filepath=FMUs'
    try
        [workdir, xml, libname, modelIdentifier, fmuImpl] = loadFMU(filepath);
        
        st(fmuImpl)($+1) = modelIdentifier;
        
        rmdir(workdir,'s');
    catch
        st("invalid") = modelIdentifier;
    end
end
disp(st)

See Also


Report an issue
<< importFMU fmu_wrapper Comparison of numerical results of simulation >>