Class FMIModelDescription


  • public class FMIModelDescription
    extends java.lang.Object
    An object that represents the fmiModelDescription element of a modelDescription.xml file contained within a Functional Mock-up Interface (.fmu) file.

    A Functional Mock-up Unit file is a .fmu file in zip format that contains a .xml file named "modelDescription.xml". This class is a representation of the elements of that file.

    FMI documentation may be found at http://www.modelisar.com/fmi.html.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Christopher Brooks, Thierry S. Nouidui
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (cxh)
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  FMIModelDescription.ContinuousState
      A data structure representing a continuous state of the FMU.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean canGetAndSetFMUstate
      For FMI 2.0 and greater, the XML file may specify that the FMU supports getting and setting its state.
      boolean canProvideMaxStepSize
      For the IBM/UCB proposed extension to FMI 2.0, there is a capability flag canProvideMaxStepSize that indicates that the FMU implements the procedure fmiGetMaxStepSize().
      java.util.List<FMI20ContinuousStateDerivative> continuousStateDerivatives
      The list of state derivatives.
      java.util.List<java.lang.String> continuousStateNames
      The list of continuous states names.
      java.util.List<FMIModelDescription.ContinuousState> continuousStates
      The list of continuous states.
      FMICapabilities cosimulationCapabilities
      The capabilities for co-simulation.
      java.util.List<java.io.File> files
      The list of files that were extracted from the .fmu file.
      java.lang.String fmiVersion
      The fmiVersion, typically the value of the fmiVersion attribute from a .fmu file.
      java.lang.String fmuResourceLocation
      The absolute path to the resources directory.
      java.lang.String guid
      The FMI guid, typically the value of the guid attribute from a .fmu file.
      boolean handleIntegerTime
      For the IBM/UCB proposed extension to FMI 2.0, there is a capability flag handleIntegerTime that indicates that the time inside the FMU is represented with an integer m (precision) and an integer p (a counter) representing time as multiples of m.
      boolean modelExchange
      If true, then the FMU is intended for model exchange, not co-simulation.
      FMICapabilities modelExchangeCapabilities
      The capabilities for model exchange.
      java.lang.String modelIdentifier
      The FMI modelIdentifier, typically the value of the modelIdentifier attribute from a .fmu file.
      java.lang.String modelName
      The FMI modelName, typically the value of the modelName attribute from a .fmu file.
      java.util.List<FMIScalarVariable> modelVariables
      The list of ScalarVariable elements.
      java.util.List<java.lang.String> modelVariablesNames
      The list of ScalarVariable elements name.
      int numberOfContinuousStates
      Number of continuous states.
      int numberOfEventIndicators
      Number of event indicators.
      java.util.List<FMI20Output> outputs
      The list of output variables.
      java.lang.Integer precision
      For the IBM/UCB proposed extension to FMI 2.0, there is a capability flag handleIntegerTime that indicates that the time inside the FMU is represented with an integer m (precision) and an integer p (a counter) representing time as multiples of m.
      boolean providesDirectionalDerivative
      For FMI 2.0 and greater, the XML file may specify that the FMU supports providing directional derivatives state.
      java.util.Map<java.lang.String,​java.lang.String> typeDefinitions
      A map from TypeDefinition type name declarations to the defined type name.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addDefaultInputDependencies()
      Add direct dependency to each output variables from all input variables.
      void createStateVector()
      Create the state vector.
      void dispose()
      Unload the native library and free up any Java references to memory allocated by the allocate memory callback.
      static java.lang.String fmiStatusDescription​(int fmiStatus)
      Return a string describing the specified fmiStatus.
      com.sun.jna.Function getFmiFunction​(java.lang.String functionName)
      Get the native function from the native library.
      FMULibrary.FMUAllocateMemory getFMUAllocateMemory()
      Return a class that provides a callback function that allocates memory, but retains a reference so that the memory does not get gc'd.
      com.sun.jna.NativeLibrary getNativeLibrary()
      Get the native library of C functions for the current platform.
      java.lang.String getNativeLibraryPath()
      Return the canonical native library path.
      void parseDependenciese​(org.w3c.dom.Node node)
      Parse the ModelStructure to catch the I/O direct dependencies.
      java.lang.String toString()
      Return the value of the FMI modelName element.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • canGetAndSetFMUstate

        public boolean canGetAndSetFMUstate
        For FMI 2.0 and greater, the XML file may specify that the FMU supports getting and setting its state. This defaults to false if not present in the XML file.
      • canProvideMaxStepSize

        public boolean canProvideMaxStepSize
        For the IBM/UCB proposed extension to FMI 2.0, there is a capability flag canProvideMaxStepSize that indicates that the FMU implements the procedure fmiGetMaxStepSize().
      • handleIntegerTime

        public boolean handleIntegerTime
        For the IBM/UCB proposed extension to FMI 2.0, there is a capability flag handleIntegerTime that indicates that the time inside the FMU is represented with an integer m (precision) and an integer p (a counter) representing time as multiples of m.
      • precision

        public java.lang.Integer precision
        For the IBM/UCB proposed extension to FMI 2.0, there is a capability flag handleIntegerTime that indicates that the time inside the FMU is represented with an integer m (precision) and an integer p (a counter) representing time as multiples of m. This field represent the precision m used to represent Time from the FMU.
      • providesDirectionalDerivative

        public boolean providesDirectionalDerivative
        For FMI 2.0 and greater, the XML file may specify that the FMU supports providing directional derivatives state. This defaults to false if not present in the XML file.
      • files

        public java.util.List<java.io.File> files
        The list of files that were extracted from the .fmu file.
      • fmiVersion

        public java.lang.String fmiVersion
        The fmiVersion, typically the value of the fmiVersion attribute from a .fmu file. The fmiVersion field is set to 1.0 for FMI 1.0.
      • fmuResourceLocation

        public java.lang.String fmuResourceLocation
        The absolute path to the resources directory. In FMI-2.0, the fmiInstantiateXXX() method has a fmuResourceLocation parameter. This value of this parameter typically starts with "file://" but may start with "http://", "https://" or "ftp://".
      • guid

        public java.lang.String guid
        The FMI guid, typically the value of the guid attribute from a .fmu file. The value of guid in the modelDescription.xml file must match the guid in the shared library.
      • modelExchange

        public boolean modelExchange
        If true, then the FMU is intended for model exchange, not co-simulation.
      • modelIdentifier

        public java.lang.String modelIdentifier
        The FMI modelIdentifier, typically the value of the modelIdentifier attribute from a .fmu file. The modelIdentifier is the basename for the shared library.
      • modelName

        public java.lang.String modelName
        The FMI modelName, typically the value of the modelName attribute from a .fmu file. The modelName may have spaces in it.
      • modelVariables

        public java.util.List<FMIScalarVariable> modelVariables
        The list of ScalarVariable elements.
      • modelVariablesNames

        public java.util.List<java.lang.String> modelVariablesNames
        The list of ScalarVariable elements name.
      • continuousStateNames

        public java.util.List<java.lang.String> continuousStateNames
        The list of continuous states names.
      • outputs

        public java.util.List<FMI20Output> outputs
        The list of output variables.
      • numberOfContinuousStates

        public int numberOfContinuousStates
        Number of continuous states.
      • numberOfEventIndicators

        public int numberOfEventIndicators
        Number of event indicators.
      • typeDefinitions

        public java.util.Map<java.lang.String,​java.lang.String> typeDefinitions
        A map from TypeDefinition type name declarations to the defined type name.
      • cosimulationCapabilities

        public FMICapabilities cosimulationCapabilities
        The capabilities for co-simulation. FMIModelDescription has a field for Cosimulation capabilities and a field for Model Exchange capabilities. We need both because JModelica fmus define both capabilities. We use a baseclass here so that the FMIModelDescription class does not change as we support other capabilities.
      • modelExchangeCapabilities

        public FMICapabilities modelExchangeCapabilities
        The capabilities for model exchange.
    • Constructor Detail

      • FMIModelDescription

        public FMIModelDescription()
    • Method Detail

      • createStateVector

        public void createStateVector()
                               throws java.io.IOException
        Create the state vector. This should only be called on fmis with a fmiVersion greater than 1.5.
        Throws:
        java.io.IOException - If the size of the continuousStateDerivatives is not equal to the number of reals.
      • dispose

        public void dispose()
        Unload the native library and free up any Java references to memory allocated by the allocate memory callback.
      • fmiStatusDescription

        public static java.lang.String fmiStatusDescription​(int fmiStatus)
        Return a string describing the specified fmiStatus.
        Parameters:
        fmiStatus - The status returned by an FMI procedure.
        Returns:
        a String describing the status.
      • getFMUAllocateMemory

        public FMULibrary.FMUAllocateMemory getFMUAllocateMemory()
        Return a class that provides a callback function that allocates memory, but retains a reference so that the memory does not get gc'd.
        Returns:
        The class that provides a callback function that allocates memory.
      • getNativeLibraryPath

        public java.lang.String getNativeLibraryPath()
                                              throws java.io.IOException
        Return the canonical native library path. If the shared library names by FMUFile.fmuSharedLibrary(FMIModelDescription) exists, then it is returned. If it does not exist, then FMUBuilder.build(File) is invoked, which may build the shared library.
        Returns:
        The canonical native library path.
        Throws:
        java.io.IOException - If the FMU file does not contain binaries for the current platform.
      • getFmiFunction

        public com.sun.jna.Function getFmiFunction​(java.lang.String functionName)
                                            throws java.lang.UnsatisfiedLinkError,
                                                   java.io.IOException
        Get the native function from the native library.

        A FMI 1.0 FMU will have functions like MyModel_fmiGetReal().

        A FMI 2.0 FMU that is shipped with C source code or with a static library, will have functions like MyModel_fmiGetReal().

        However, a FMI 2.0 FMU that is shipped with a shared library (and without C source code), will have functions like fmiGetReal().

        This method tries both formats. The leading modelIdentifier is tried first because we believe that FMUs should be shipped with source code. If the function name with the leading modelIdentifier is not found, then just the functionName is tried.

        Parameters:
        functionName - The name of the function, without a leading underscore.
        Returns:
        The function.
        Throws:
        java.lang.UnsatisfiedLinkError - If the function is not found using either format.
        java.io.IOException - If the native library cannot be found.
      • getNativeLibrary

        public com.sun.jna.NativeLibrary getNativeLibrary()
                                                   throws java.io.IOException
        Get the native library of C functions for the current platform. A side effect is that if the native library does not exist, then FMUBuilder.build(File) is invoked, which may build the shared library.
        Returns:
        The library of functions for the current platform.
        Throws:
        java.io.IOException - If the FMU file does not contain binaries for the current platform.
      • toString

        public java.lang.String toString()
        Return the value of the FMI modelName element.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The model name.
      • parseDependenciese

        public void parseDependenciese​(org.w3c.dom.Node node)
        Parse the ModelStructure to catch the I/O direct dependencies.
        Parameters:
        node - The node to be parsed.
      • addDefaultInputDependencies

        public void addDefaultInputDependencies()
        Add direct dependency to each output variables from all input variables.