org.ptolemy.fmi.driver
Class FMUCoSimulation

java.lang.Object
  extended by org.ptolemy.fmi.driver.FMUDriver
      extended by org.ptolemy.fmi.driver.FMUCoSimulation

public class FMUCoSimulation
extends FMUDriver

Read a Functional Mock-up Unit .fmu file and invoke it as a co-simulation.

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.

Version:
$Id: FMUCoSimulation.java 66026 2013-04-07 16:41:23Z cxh $
Author:
Christopher Brooks, based on fmusim_cs/main.c by Jakob Mauss
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Field Summary
 
Fields inherited from class org.ptolemy.fmi.driver.FMUDriver
_csvSeparator, _enableLogging, _endTime, _fmuAllocateMemory, _fmuFileName, _modelIdentifier, _nativeLibrary, _outputFileName, _stepSize
 
Constructor Summary
FMUCoSimulation()
           
 
Method Summary
static void main(java.lang.String[] args)
          Perform co-simulation 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 co-simulation using the named Functional Mock-up Unit (FMU) file.
 
Methods inherited from class org.ptolemy.fmi.driver.FMUDriver
_processArgs, _setEnableLogging, getFunction, invoke, invoke
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FMUCoSimulation

public FMUCoSimulation()
Method Detail

main

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

Usage:

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

For example, under Mac OS X or Linux:

  java -classpath $PTII/lib/jna.jar:${PTII} org.ptolemy.fmi.driver.FMUCoSimulation \
  $PTII/org/ptolemy/fmi/fmu/cs/bouncingBall.fmu 1.0 0.1 true c foo.csv
  

The command line arguments have the following meaning:

file.fmu
The co-simulation 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 co-simulation 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.