Class OMCFMUJUnitTest
- java.lang.Object
-
- ptolemy.actor.lib.fmi.fmus.omc.test.junit.OMCFMUJUnitTest
-
public class OMCFMUJUnitTest extends java.lang.ObjectInvoke the co-simulator and model exchanger on various Functional Mockup Unit (.fmu) files.- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Christopher Brooks
- Pt.AcceptedRating:
- Green (cxh)
- Pt.ProposedRating:
- Green (cxh)
-
-
Constructor Summary
Constructors Constructor Description OMCFMUJUnitTest()
-
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.static voidmain(java.lang.String[] args)Run the OpenModelica FMI model exchange tests.java.lang.StringmodelExchange(java.lang.String testName)Invoke the Model exchange driver on a .fmu file.java.lang.StringmodelExchange(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.voidmodelExchangeCheck(java.lang.String testName, java.lang.String csvFile, boolean checkX2)Check the csv file against equations.voidmodelExchangeInfluenza()Run the influenza model exchange functional mock-up unit test.voidmodelExchangeLinsys()Run the linsys model exchange functional mock-up unit test.voidmodelExchangeLinsys2()Run the linsys2 model exchange functional mock-up unit test.voidmodelExchangeTest1()Run the Test1 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.
-
modelExchange
public java.lang.String 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.- Returns:
- the file name of the .csv file that is created.
- 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 java.lang.String 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.- Returns:
- the file name of the .csv file that is created.
- 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.
-
modelExchangeCheck
public void modelExchangeCheck(java.lang.String testName, java.lang.String csvFile, boolean checkX2) throws java.lang.ExceptionCheck the csv file against equations. The equations come from sparse_fmi by James Nutaro. Some variance is acceptable, though the test fails if there is too much.- Parameters:
testName- The name of the test, ex. "Linsys".csvFile- The comma separated file to be checked, typically generated by themodelExchange(String)method.checkX2- True if the 3rd argument is x2 and should be checked.- Throws:
java.lang.Exception- If there is a problem parsing the file.
-
modelExchangeInfluenza
public void modelExchangeInfluenza() throws java.lang.ExceptionRun the influenza model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchangeLinsys2
public void modelExchangeLinsys2() throws java.lang.ExceptionRun the linsys2 model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchangeLinsys
public void modelExchangeLinsys() throws java.lang.ExceptionRun the linsys model exchange functional mock-up unit test.- Throws:
java.lang.Exception- If there is a problem reading or running the test.
-
modelExchangeTest1
public void modelExchangeTest1() throws java.lang.ExceptionRun the Test1 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 the OpenModelica 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:. ptolemy.actor.lib.fmi.fmus.omc.test.junit.OMCFMUJUnitTest)- 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.
-
-