Package org.ptolemy.fmi
A Functional Mock-up Unit (FMU) is a file that contains functionality that may
be invoked either via co-simulation or model exchange. Typically, a FMU file has
a .fmu
extension. A FMU file is a zip file that contains a file
named modelDescription.xml
and one or more platform-dependent
shared libraries.
The org.ptolemy.fmi package and subpackages are a BSD-licensed interface between Java and FMI.
FMI documentation may be found at http://www.modelisar.com/fmi.html.
Code
Below is a description of the packages- org.ptolemy.fmi - Read .fmu files and provide access to the data contained in the modelDescription.xml file of the .fmu file
- org.ptolemy.fmi.type - Data types that are passed to and from a FMU.
- org.ptolemy.fmi.driver - Simple drivers for co-simulation and model exchange
- JUnit tests - tests
org.ptolemy.fmi - Read .fmu files and provide access to the data contained in the modelDescription.xml file of the .fmu file
- FMICallbackFunctions.java
- Functional Mock-up Interface (FMI) callback functions needed by Java Native Access (JNA) so that a FMU * can perform functions like allocating and freeing memory, printing log messages and handle the end of a step.
- FMIEventInfo.java
- Functional Mock-up Interface (FMI) event information.
The C language interface to Functional Mock-up Unit (FMU) files includes an structure that represents event information. This class represents that structure.
- FMILibrary.java
- A Java Native Acess (JNA) Wrapper for a Functional Mock-up Unit shared library.
- FMIModelDescription.java
- An object that represents the fmiModelDescription element of a modelDescription.xml file contained within a Functional Mock-up Unit (FMU) file.
- FMIScalarVariable.java
- An object that represents the ScalarVariable element of a modelDescription.xml file contained within a Functional Mock-up Interface .fmu XML file.
- FMUFile.java
- Parse a Functional Mock-up Interface (FMI) 1.0 Functional Mock-up Unit (FMU) file and create a FMIModelDescription for later use. The parseFMUFile() method in this class is the primary entry point into this package.
- FMULibrary.java
- An interface that is used by Java Native Access (JNA) to handle callbacks.
This class contains implementations of methods that are registered with the FMI and then called back from by the FMI. The callback methods allocate and free memory, handle logging and are sometimes called when the step ends. For each callback we define an inner class that implements the appropriate interface and has one method that provides the body of the callback.
- FMULog.java
- A Functional Mock-up Interface (FMI) log method implementation.
- NativeSizeT.java
- A Java representation for a C type size_t, which is 32 or 64 bits.
org.ptolemy.fmi.type - Data types that are passed to and from a FMU.
- FMIBooleanType.java
- An Functional Mock-up Interface type that represents a Boolean.
- FMIIntegerType.java
- An Functional Mock-up Interface type that represents an Integer.
- FMIRealType.java
- An Functional Mock-up Interface type that represents a Real.
- FMIStringType.java
- An Functional Mock-up Interface type that represents a String.
- FMIType.java
- The base type of all of the other FMI types.
org.ptolemy.fmi.driver - Simple drivers for co-simulation and model exchange
The org.ptolemy.fmi.drivers package is based on FMUSDK 1.0.2 from http://www.qtronic.de/en/fmusdk.html, which has has a BSD-style license.
The code in org.ptolemy.fmi does not depend on the org.ptolemy.fmi.drivers package and thus the code in org.ptolemy.fmi is not encumbered by this license.
In FMI-1.0, co-simulation fmu files contain a modelDescription.xml file that has an <Implementation> element. Model exchange fmu files do not have this element.
- FMUCoSimulation.java
- A simple example that reads a co-simulation .fmu file and performs co-simulation.
- FMUDriver.java
- The base clase for the co-simulation and model exchange drivers.
- FMUModelExchange.java
- A simple example that reads a model exchagen .fmu file and performs model exchange.
- OutputRow.java
- Given a fmu component, output the current state.
These drivers are based on code found in FMUSDK 1.0.2. These drivers are simple examples that do not read inputs and contain other common functionality that would be used by a real system.
JUnit tests - tests
To run the tests, do:
cd org/ptolemy/fmu ant test
Sample .fmu files may be found in fmu/cs and fmu/me. for the following architectures: darwin64, linux32, linux64, win32 and win64. These files were generated using a port of the FMUSDK which may be found at http://github.com/cxbrooks/fmusdk.
Sponsors
This package was developed under a Department of Energy Contract for the Building Controls Virtual Test Bed (BCVTB) see http://simulationresearch.lbl.gov/bcvtb.
Additional support was provided by Ptolemy II, which is supported by the following organizations: The Center for Hybrid and Embedded Software Systems (CHESS) at UC Berkeley, which receives support from the National Science Foundation (NSF awards #0720882 (CSR-EHS: PRET), #1035672 (CPS: PTIDES), and #0931843 (ActionWebs)), the U. S. Army Research Laboratory (ARL #W911NF-11-2-0038), the Air Force Research Lab (AFRL), the Multiscale Systems Center (MuSyC), one of six research centers funded under the Focus Center Research Program, a Semiconductor Research Corporation program, and the following companies: Bosch, National Instruments, Thales, and Toyota.
Authors
The org.ptolemy.fmi package has the following authors.
David Broman (UC Berkeley)
Christopher Brooks (UC Berkeley)
Edward A. Lee (UC Berkeley)
Thierry Stephane Nouidui (Lawrence Berkeley National Laboratory)
Michael Wetter (Lawrence Berkeley National Laboratory)
The org.ptolemy.fmi.drivers package is based on FMUSDK 1.0.2 from http://www.qtronic.de/en/fmusdk.html.
Support
This package is delivered without support. However, the BCVTB mailing list at https://groups.google.com/group/bcvtb maybe be used for questions.
- Since:
- Ptolemy II 8.1
-
Interface Summary Interface Description FMILibrary A Java Native Access (JNA) Wrapper for a Functional Mock-up Unit shared library.FMILibrary.FMICallbackAllocateMemory A callback for the fmiCallbackAllocateMemory() function.FMILibrary.FMICallbackFreeMemory A callback for the fmiCallbackFreeMemory() function.FMILibrary.FMICallbackLogger A interface for the fmiCallbackLogger() function.FMILibrary.FMIStatus An enumeration of status values returned by fmi*() methods.FMILibrary.FMIStatusKind An enumeration of status information returned by a slave.FMILibrary.FMIStepFinished A callback for the fmiStepFinished() method.FMULibrary An interface that is used by Java Native Access (JNA) to handle callbacks. -
Class Summary Class Description FMI20CallbackFunctions Functional Mock-up Interface (FMI) 2.0 callback functions needed by Java Native Access (JNA) so that a FMU * can perform functions like allocating and freeing memory, printing log messages and handle the end of a step.FMI20ContinuousStateDerivative An object that represents the Derivatives of a continuous state variable of an FMU for FMI-2.0.FMI20CoSimulationCapabilities An object that represents the the capabilities of a FMI co-simulation slave for FMI-2.0.FMI20EventInfo Functional Mock-up Interface (FMI) 2.0 event information.FMI20EventInfo.ByReference Access the structure by reference.FMI20EventInfo.ByValue Access the structure by value.FMI20ModelExchangeCapabilities An object that represents the the capabilities of a FMI Model Exchange FMU.FMI20ModelInstance A Java Native Access (JNA) interface to the Functional Mock-up Interface 2.0 ModelInstance struct.FMI20ModelInstance.ByReference Access the structure by reference.FMI20ModelInstance.ByValue Access the structure by value.FMI20Output An object that represents the Output of an FMUFMICallbackFunctions Functional Mock-up Interface (FMI) callback functions needed by Java Native Access (JNA) so that a FMU * can perform functions like allocating and freeing memory, printing log messages and handle the end of a step.FMICallbackFunctions.ByValue A class that contains references to the callback functions.FMICapabilities An object that represents the the capabilities of a FMI co-simulation slave.FMICoSimulationCapabilities An object that represents the the capabilities of a FMI co-simulation slave for FMI-1.0;FMIEventInfo Functional Mock-up Interface (FMI) event information for FMI-1.0.FMIEventInfo.ByReference Access the structure by reference.FMIEventInfo.ByValue Access the structure by value.FMIModelDescription An object that represents the fmiModelDescription element of a modelDescription.xml file contained within a Functional Mock-up Interface (.fmu) file.FMIModelDescription.ContinuousState A data structure representing a continuous state of the FMU.FMIScalarVariable An object that represents the ScalarVariable element of a modelDescription.xml file contained within a Functional Mock-up Interface .fmu XML file.FMUBuilder Build a FMU shared object.FMUFile Parse a Functional Mock-up Interface (FMI) 1.0 Functional Mock-up Unit (FMU) file and create a FMIModelDescription for later use.FMULibrary.FMUAllocateMemory Class for the allocate memory callback function.FMULibrary.FMUFreeMemory A class providing a callback method that frees memory.FMULibrary.FMULogger The logging callback function.FMULibrary.FMUStepFinished A callback for when the step is finished.FMULog A Functional Mock-up Interface (FMI) log method implementation.FMULogUtilities Utilities for the FMU Logger.NativeSizeT A Java representation for a C type size_t, which is 32 or 64 bits. -
Enum Summary Enum Description FMIScalarVariable.Alias Acceptable values for the alias xml attribute.FMIScalarVariable.Causality Acceptable values for the causality xml attribute.FMIScalarVariable.Initial Acceptable values for the initial xml attribute.FMIScalarVariable.Variability Acceptable values for the variability xml attribute.