Class FMUModelExchange


  • public class FMUModelExchange
    extends FMUDriver
    Read a Functional Mock-up Unit .fmu file and invoke it as a model exchange.

    This file is based on fmusdk/src/model_exchange/fmusim_me/main.c by Jakob Mauss, which has the following license:

    FMU SDK license

    Copyright (c) 2008-2011, QTronic GmbH. All rights reserved. The FmuSdk is licensed by the copyright holder under the BSD License (http://www.opensource.org/licenses/bsd-license.html): Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

    THIS SOFTWARE IS PROVIDED BY QTRONIC GMBH "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL QTRONIC GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$, $Id$
    Author:
    Christopher Brooks, based on fmusim_me/main.c by Jakob Mauss
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (cxh)
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void main​(java.lang.String[] args)
      Perform model exchange using the named Functional Mock-up Unit (FMU) file.
      void simulate​(java.lang.String fmuFileName, double endTime, double stepSize, boolean enableLogging, char csvSeparator, java.lang.String outputFileName)
      Perform model exchange using the named Functional Mock-up Unit (FMU) file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FMUModelExchange

        public FMUModelExchange()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Perform model exchange using the named Functional Mock-up Unit (FMU) file.

        Usage:

         java -classpath ../../../../lib/jna.jar:../../../.. org.ptolemy.fmi.driver.FMUModelExchange \
         file.fmu [endTime] [stepTime] [loggingOn] [csvSeparator] [outputFile]
         

        For example, under Mac OS X or Linux:

         java -classpath $PTII/lib/jna-4.0.0-variadic.jar:${PTII} \
            org.ptolemy.fmi.driver.FMUModelExchange \
            $PTII/org/ptolemy/fmi/fmu/me/bouncingBallME1.fmu \
            4.0 0.01 true c result.csv"
         

        The command line arguments have the following meaning:

        file.fmu
        The model exchange Functional Mock-up Unit (FMU) file. 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.
        endTime
        The endTime in seconds, defaults to 1.0.
        stepTime
        The time between steps in seconds, defaults to 0.1.
        enableLogging
        If "true", then enable logging. The default is false.
        separator
        The comma separated value separator, the default value is ',', If the separator is ',', columns are separated by ',' and '.' is used for floating-point numbers. Otherwise, the given separator (e.g. ';' or '\t') is to separate columns, and ',' is used as decimal dot in floating-point numbers.
        outputFile
        The name of the output file. The default is results.csv

        The format of the arguments is based on the fmusim command from the fmusdk by QTronic Gmbh.

        Parameters:
        args - The arguments: file.fmu [endTime] [stepTime] [loggingOn] [csvSeparator] [outputFile]
        Throws:
        java.lang.Exception - If there is a problem parsing the .fmu file or invoking the methods in the shared library.
      • simulate

        public void simulate​(java.lang.String fmuFileName,
                             double endTime,
                             double stepSize,
                             boolean enableLogging,
                             char csvSeparator,
                             java.lang.String outputFileName)
                      throws java.lang.Exception
        Perform model exchange using the named Functional Mock-up Unit (FMU) file.
        Specified by:
        simulate in class FMUDriver
        Parameters:
        fmuFileName - The pathname of the co-simulation .fmu file
        endTime - The ending time in seconds.
        stepSize - The step size in seconds.
        enableLogging - True if logging is enabled.
        csvSeparator - The character used for separating fields. Note that sometimes the decimal point in floats is converted to ','.
        outputFileName - The output file.
        Throws:
        java.lang.Exception - If there is a problem parsing the .fmu file or invoking the methods in the shared library.