Class CertiRtig

  • All Implemented Interfaces:
    java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class CertiRtig
    extends NamedObj

    Execute the HLA/CERTI RTIG in a subprocess.

    This object is based on the Exec actor implementation. It invokes the HLA/CERTI RTIG as a subprocess in a specified directory with a specified environment. A default platform-dependent shell command is preprended so the RTIG is executed within the shell. If another RTIG process is running the current subprocess is destroyed.

    This object is used by the HlaManager and need to be performed before the initialization of a HLA/CERTI Federate. That's why we execute this mechanism in the HlaManager preinitialize() method.

    The specified directory is the current directory of the Ptolemy simulation and needs to contain the Federate Object Management file (.fed). This directory is provided by the specification of the .fed file path during the configuration of the HlaManager attribute. FIXMEjc: check last changes concerning JCERTI and the way to give the .fed file address.

    For a correct execution, the CERTI_HOME environment variable has to be set. It could be set in the shell (by running one of the scripts provided by CERTI) where Vergil is executed, or as a parameter of the Ptolemy model or as a parameter of the HlaManager: FIXMEjc: As for today, certi_home is not set in Ptolemy model neither is a parameter in hlaManager. Only in the shel, or in .bashrc ou .bash_profile.

     CERTI_HOME="/absolute/path/to/certi/"
     

    Otherwise, the current implementation is not able to find the CERTI environment, the RTIG binary and to perform its execution.

    Current limitation:
    Federate that has launched the RTIG could shutdown the subprocess at the end of the simulation before the other Federates have left the Federation. Then an exception is throwed. FIXMEjc: the above limitation was present in Oct 2013. Check if it is still true.
    Since:
    Ptolemy II 11.0
    Version:
    $Id: CertiRtig.java 214 2018-04-01 13:32:02Z j.cardoso $
    Author:
    Gilles Lasnier, Christopher Brooks
    Pt.AcceptedRating:
    Red (glasnier)
    Pt.ProposedRating:
    Yellow (glasnier)
    • Constructor Detail

      • CertiRtig

        public CertiRtig​(HlaManager hm,
                         java.lang.Boolean addDebugListener)
        Construct an actor with the given HlaManager reference and debug mode status.
        Parameters:
        hm - A reference to the associated HlaManager.
        addDebugListener - The debug mode status.
    • Method Detail

      • exec

        public void exec()
                  throws IllegalActionException
        Execute a command, set _process to point to the subprocess and set up _errorGobbler and _outputGobbler to read data.
        Throws:
        IllegalActionException - If the execution of the Runtime.exec() failed or if the RTIG subprocess it not running.
      • initialize

        public void initialize​(java.lang.String directory)
                        throws IllegalActionException
        Initialize command, arguments and environment variables to invoke the subprocess.
        Parameters:
        directory - The current path where the simulation is executed. FIXMEjc: check if is where the simulation is executed, or where the fed file is.
        Throws:
        IllegalActionException - If the directory to launch the RTIG process doesn't exit.
      • isRunning

        public boolean isRunning()
        Indicate if the current subprocess is running.
        Returns:
        True if the RTIG is running, False otherwise.
      • terminateProcess

        public void terminateProcess()
                              throws IllegalActionException
        Terminate the process and close any associated streams.
        Throws:
        IllegalActionException - If the closing stdin of the subprocess threw an IOException.