Class FMUJUnitTest
- java.lang.Object
-
- org.ptolemy.fmi.driver.test.junit.FMUJUnitTest
-
public class FMUJUnitTest extends java.lang.ObjectInvoke the co-simulator and model exchanger on various Functional Mockup Unit (.fmu) files.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Christopher Brooks
- Pt.AcceptedRating:
- Green (cxh)
- Pt.ProposedRating:
- Green (cxh)
-
-
Constructor Summary
Constructors Constructor Description FMUJUnitTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcosimulate(java.lang.String testName, double endTime, double stepSize)Co-simulate a test.voidcosimulate(java.lang.String fmuFileName, double endTime, double stepSize, java.lang.String knownGoodFileName)Parse a Functional Mock-up Unit .fmu file, run it using co-simulation and compare the results against a known good file.voidcosimulateBouncingBall()Run the bouncing ball co-simulation functional mock-up unit test.voidcosimulateBouncingBall20()Run the bouncing ball co-simulation functional mock-up unit test.voidcosimulateDq()Run the dq co-simulation functional mock-up unit test.voidcosimulateDq20()Run the dq co-simulation functional mock-up unit test.voidcosimulateInc()Run the inc co-simulation functional mock-up unit test.voidcosimulateInc20()Run the inc co-simulation functional mock-up unit test.voidcosimulateValues()Run the values co-simulation functional mock-up unit test.voidcosimulateValues20()Run the values co-simulation functional mock-up unit test.voidcosimulateVanDerPol()Run the vanDerPol co-simulation functional mock-up unit test.voidcosimulateVanDerPol20()Run the vanDerPol co-simulation functional mock-up unit test.static voidmain(java.lang.String[] args)Run FMI model exchange tests.voidmodelExchange(java.lang.String testName)Invoke the Model exchange driver on a .fmu file.voidmodelExchange(java.lang.String fmuFileName, java.lang.String knownGoodFileName)Parse a Functional Mock-up Unit .fmu file, run it using model exchange and compare the results against a known good file.voidmodelExchangeBouncingBall()Run the bouncing ball model exchange functional mock-up unit test.voidmodelExchangeBouncingBall20()Run the bouncing ball model exchange functional mock-up unit test.voidmodelExchangeDq()Run the dq model exchange functional mock-up unit test.voidmodelExchangeDq20()Run the dq model exchange functional mock-up unit test.voidmodelExchangeInc()Run the inc model exchange functional mock-up unit test.voidmodelExchangeInc20()Run the inc model exchange functional mock-up unit test.voidmodelExchangeValues()Run the values model exchange functional mock-up unit test.voidmodelExchangeValues20()Run the values model exchange functional mock-up unit test.voidmodelExchangeVanDerPol()Run the vanDerPol model exchange functional mock-up unit test.voidmodelExchangeVanDerPol20()Run the vanDerPol model exchange functional mock-up unit test.static java.lang.StringreadFile(java.lang.String fileName)Read in the named file and returns the contents as a string.
-
-
-
Method Detail
-
cosimulate
public void cosimulate(java.lang.String fmuFileName, double endTime, double stepSize, java.lang.String knownGoodFileName) throws java.lang.ExceptionParse a Functional Mock-up Unit .fmu file, run it using co-simulation and compare the results against a known good file.- Parameters:
fmuFileName- The absolute pathname of the .fmu file. Absolute pathnames are used because this test could be run from anywhere.endTime- The end time.stepSize- The step sizeknownGoodFileName- The absolute pathname of the known good results. Note that when the test is run, the output includes the command that could be run to create the known good file.- Throws:
java.lang.Exception- If there is a problem reading or executing the test or if the results is not the same as the known good results.
-
cosimulate
public void cosimulate(java.lang.String testName, double endTime, double stepSize) throws java.lang.ExceptionCo-simulate a test.- Parameters:
testName- The name of the test with no file extension.endTime- The end time.stepSize- The step size- Throws:
java.lang.Exception- If there is a problem reading or executing the test or if the results is not the same as the known good results.
-
cosimulateBouncingBall
public void cosimulateBouncingBall() throws java.lang.ExceptionRun the bouncing ball co-simulation functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
cosimulateBouncingBall20
public void cosimulateBouncingBall20() throws java.lang.ExceptionRun the bouncing ball co-simulation functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
cosimulateDq
public void cosimulateDq() throws java.lang.ExceptionRun the dq co-simulation functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
cosimulateDq20
public void cosimulateDq20() throws java.lang.ExceptionRun the dq co-simulation functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
cosimulateInc
public void cosimulateInc() throws java.lang.ExceptionRun the inc co-simulation functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
cosimulateInc20
public void cosimulateInc20() throws java.lang.ExceptionRun the inc co-simulation functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
cosimulateValues
public void cosimulateValues() throws java.lang.ExceptionRun the values co-simulation functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
cosimulateValues20
public void cosimulateValues20() throws java.lang.ExceptionRun the values co-simulation functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
cosimulateVanDerPol
public void cosimulateVanDerPol() throws java.lang.ExceptionRun the vanDerPol co-simulation functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
cosimulateVanDerPol20
public void cosimulateVanDerPol20() throws java.lang.ExceptionRun the vanDerPol co-simulation functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchange
public void modelExchange(java.lang.String fmuFileName, java.lang.String knownGoodFileName) throws java.lang.ExceptionParse a Functional Mock-up Unit .fmu file, run it using model exchange and compare the results against a known good file.- Parameters:
fmuFileName- The absolute pathname of the .fmu file. Absolute pathnames are used because this test could be run from anywhere.knownGoodFileName- The absolute pathname of the known good results. Note that when the test is run, the output includes the command that could be run to create the known good file.- Throws:
java.lang.Exception- If there is a problem reading or executing the test or if the results is not the same as the known good results.
-
modelExchange
public void modelExchange(java.lang.String testName) throws java.lang.ExceptionInvoke the Model exchange driver on a .fmu file. The known good output is expected to be in a file whose name ends with "_me.csv".- Parameters:
testName- The name of the test with no file extension.- Throws:
java.lang.Exception- If there is a problem reading or executing the test or if the results is not the same as the known good results.
-
modelExchangeBouncingBall
public void modelExchangeBouncingBall() throws java.lang.ExceptionRun the bouncing ball model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchangeBouncingBall20
public void modelExchangeBouncingBall20() throws java.lang.ExceptionRun the bouncing ball model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchangeDq
public void modelExchangeDq() throws java.lang.ExceptionRun the dq model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchangeDq20
public void modelExchangeDq20() throws java.lang.ExceptionRun the dq model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchangeInc
public void modelExchangeInc() throws java.lang.ExceptionRun the inc model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchangeInc20
public void modelExchangeInc20() throws java.lang.ExceptionRun the inc model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchangeValues
public void modelExchangeValues() throws java.lang.ExceptionRun the values model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchangeValues20
public void modelExchangeValues20() throws java.lang.ExceptionRun the values model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchangeVanDerPol
public void modelExchangeVanDerPol() throws java.lang.ExceptionRun the vanDerPol model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchangeVanDerPol20
public void modelExchangeVanDerPol20() throws java.lang.ExceptionRun the vanDerPol model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
main
public static void main(java.lang.String[] args)
Run FMI model exchange tests.To run these tests, either us
ant testor run:(cd ../../..; java -classpath lib/jna.jar:lib/junit-4.8.2.jar:. org.ptolemy.fmi.driver.test.junit.FMUJUnitTest)- Parameters:
args- Not used.
-
readFile
public static java.lang.String readFile(java.lang.String fileName) throws java.io.IOExceptionRead in the named file and returns the contents as a string.- Parameters:
fileName- The name of the file to be read.- Returns:
- The contents of the file.
- Throws:
java.io.IOException- If there is a problem reading or closing file.
-
-