Class CertiRtig
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- org.hlacerti.lib.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 theHlaManager
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)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
-
Constructor Summary
Constructors Constructor Description CertiRtig(HlaManager hm, java.lang.Boolean addDebugListener)
Construct an actor with the givenHlaManager
reference and debug mode status.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
exec()
Execute a command, set _process to point to the subprocess and set up _errorGobbler and _outputGobbler to read data.void
initialize(java.lang.String directory)
Initialize command, arguments and environment variables to invoke the subprocess.boolean
isRunning()
Indicate if the current subprocess is running.void
terminateProcess()
Terminate the process and close any associated streams.-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getContainedObject, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateExistence, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getContainer, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setName, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
-
-
-
-
Constructor Detail
-
CertiRtig
public CertiRtig(HlaManager hm, java.lang.Boolean addDebugListener)
Construct an actor with the givenHlaManager
reference and debug mode status.- Parameters:
hm
- A reference to the associatedHlaManager
.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.
-
-