load an FMU file returning its raw content.
[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)
string, a path for a model.
string, a path to the extracted file content.
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.
xmlDocument, the XML content of modelDescription.xml.
string, a path to the library used for the simulation.
string, the model identifier to pass to fmu_link.
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.
[?, 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) | ![]() | ![]() |