Class FMUJUnitTest


  • public class FMUJUnitTest
    extends java.lang.Object
    Invoke 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
      void cosimulate​(java.lang.String testName, double endTime, double stepSize)
      Co-simulate a test.
      void cosimulate​(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.
      void cosimulateBouncingBall()
      Run the bouncing ball co-simulation functional mock-up unit test.
      void cosimulateBouncingBall20()
      Run the bouncing ball co-simulation functional mock-up unit test.
      void cosimulateDq()
      Run the dq co-simulation functional mock-up unit test.
      void cosimulateDq20()
      Run the dq co-simulation functional mock-up unit test.
      void cosimulateInc()
      Run the inc co-simulation functional mock-up unit test.
      void cosimulateInc20()
      Run the inc co-simulation functional mock-up unit test.
      void cosimulateValues()
      Run the values co-simulation functional mock-up unit test.
      void cosimulateValues20()
      Run the values co-simulation functional mock-up unit test.
      void cosimulateVanDerPol()
      Run the vanDerPol co-simulation functional mock-up unit test.
      void cosimulateVanDerPol20()
      Run the vanDerPol co-simulation functional mock-up unit test.
      static void main​(java.lang.String[] args)
      Run FMI model exchange tests.
      void modelExchange​(java.lang.String testName)
      Invoke the Model exchange driver on a .fmu file.
      void modelExchange​(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.
      void modelExchangeBouncingBall()
      Run the bouncing ball model exchange functional mock-up unit test.
      void modelExchangeBouncingBall20()
      Run the bouncing ball model exchange functional mock-up unit test.
      void modelExchangeDq()
      Run the dq model exchange functional mock-up unit test.
      void modelExchangeDq20()
      Run the dq model exchange functional mock-up unit test.
      void modelExchangeInc()
      Run the inc model exchange functional mock-up unit test.
      void modelExchangeInc20()
      Run the inc model exchange functional mock-up unit test.
      void modelExchangeValues()
      Run the values model exchange functional mock-up unit test.
      void modelExchangeValues20()
      Run the values model exchange functional mock-up unit test.
      void modelExchangeVanDerPol()
      Run the vanDerPol model exchange functional mock-up unit test.
      void modelExchangeVanDerPol20()
      Run the vanDerPol model exchange functional mock-up unit test.
      static java.lang.String readFile​(java.lang.String fileName)
      Read in the named file and returns the contents as a string.
      • Methods inherited from class java.lang.Object

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

      • FMUJUnitTest

        public FMUJUnitTest()
    • Method Detail

      • cosimulate

        public void cosimulate​(java.lang.String fmuFileName,
                               double endTime,
                               double stepSize,
                               java.lang.String knownGoodFileName)
                        throws java.lang.Exception
        Parse 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 size
        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.
      • cosimulate

        public void cosimulate​(java.lang.String testName,
                               double endTime,
                               double stepSize)
                        throws java.lang.Exception
        Co-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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Parse 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.Exception
        Invoke 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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.Exception
        Run 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 test or 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.IOException
        Read 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.