Class FMUCoSimulation
- java.lang.Object
-
- org.ptolemy.fmi.driver.FMUDriver
-
- 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.Currently, FMI 1.0 and 2.0RC1 are supported.
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_cs/main.c by Jakob Mauss
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Constructor Summary
Constructors Constructor Description FMUCoSimulation()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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, invoke
-
-
-
-
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-4.0.0-variadic.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-4.0.0-variadic.jar:${PTII} \ org.ptolemy.fmi.driver.FMUCoSimulation \ $PTII/org/ptolemy/fmi/fmu/cs/bouncingBall20.fmu \ 4.0 0.01 true c result.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 classFMUDriver
- Parameters:
fmuFileName
- The pathname of the co-simulation .fmu fileendTime
- 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.
-
-