Class HlaSubscriber
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,HlaReflectable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class HlaSubscriber extends TypedAtomicActor implements HlaReflectable
This actor provides information to subscribe, discover and reflect (i.e., receive) updated values in the Ptolemy-HLA/CERTI framework.This actor is associated with a unique HLA attribute of a given object instance. Reflected values of this HLA attribute are received from the HLA Federation by the
HlaManager
attribute deployed in the same model. TheHlaManager
invokes the putReflectedAttribute() to put the received value in the HlaSubscriber actor token queue and to program its firing time, using the _fireAt() method.Parameters classObjectName and attributeName need to match the name of the class and the name of the attribute defined in the Federate Object Model (FOM) specified for the Federation and indicated in the FED file. The data type of the output port of this actor must have the same type of the HLA attribute (defined in the FOM, not present in the FED file).
The parameter classInstanceName is chosen by the user.
Entering in more details: This actor provides 3 information: a class name C, an attribute name attr and an instance name i. To each HlaSubscriber actor in a Ptolemy model (federate) corresponds a unique
HlaPublisher
actor in a (unique) federate with the same information. Let us recall some terms: - FOM: Federation Object Model - FED: Federation Execution Data, contains classes and attributes defined in the FOM and, for each attribute, if it is timestamped and its QoS - RTI: Run-Time Infrastructure. The RTI has a Central RTI Component (CRC) and one or more Local RTI Components (LRC). The LRC has a numerical representation (handle) for all object classes and object class attributes contained in the FED file. The information supplied in this actor by the user is used in the following way by theHlaManager
attribute (deployed in the same model): 1. During the initialization phase, theHlaManager
: - Subscribes to all the kattr-kC (gathered from kclassHandleC; _attributesLocal is the set constructed by calling rtia.getAttributeHandle() for each attrC); - Receives the HLA callback informing the discovering of an instance of class C named i: rtia.discoverObjectInstance(instanceHandle, classHandle, someName), with someName = i; instanceHandle and classHandle are handles provided by the RTI. 2. During the simulation loop phase, theHlaManager
receives the RAV callback from the RTI with the new value of an attribute of a class instance. Each HlaSubscriber actor is related to one RAV callback: rtia.reflectAttributeValues(instanceHandle, suppAttributes, tag, ravTimeStamp). The RAV callback, with a timestamp t'=ravTimeStamp<\i> is received at the input port of the HlaPublisher actor, during the advance time phase that starts when the federate wants to advanced its time to t<\i> (using NER or TAR time management, seeHlaManager
code). The optional parameter tag is not used in the current implementation.- Since:
- Ptolemy II 11.0
- Version:
- $Id: HlaSubscriber.java 214 2018-04-01 13:32:02Z j.cardoso $
- Author:
- Gilles Lasnier, Contributors: Patricia Derler, David Come
- Pt.AcceptedRating:
- Red (glasnier)
- Pt.ProposedRating:
- Yellow (glasnier)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
attributeName
The HLA attribute name the HLASubscriber is mapped to.Parameter
classInstanceName
The name of the HLA class instance for this HlaSubscriber.Parameter
classObjectName
The object class of the HLA attribute to subscribe to.TypedIOPort
output
The output port.StringParameter
typeSelector
The type of the output port specified through the user interface.Parameter
useCertiMessageBuffer
Indicate if the event is wrapped in a CERTI message buffer.-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
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
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description HlaSubscriber(CompositeEntity container, java.lang.String name)
Construct a HlaSubscriber actor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attributeChanged(Attribute attribute)
Call the attributeChanged method of the parent.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
fire()
Put in the Ptolemy queue the token (with time-stamp t) corresponding to the RAV (with time-stamp t'=ravTimeStamp<\i> related to the HLA attribute of an instance (mapped to this actor).int
getAttributeHandle()
Return the HLA attribute handle.int
getClassHandle()
Return the HLA class handle.java.lang.String
getHlaAttributeName()
Return the HLA attribute name provided by this HlaSubscriber actor.java.lang.String
getHlaClassName()
Return the HLA class object name provided by this HlaSubscriber actor.java.lang.String
getHlaInstanceName()
Return HLA class instance name provided by this HlaSubscriber actor.int
getInstanceHandle()
Returns the HLA object instance.TypedIOPort
getOutputPort()
FIXME: This should probably not be here.void
initialize()
Check if there is one and only oneHlaManager
deployed in the Ptolemy model.void
putReflectedHlaAttribute(HlaTimedEvent event)
Store each updated value of the HLA attribute (mapped to this actor) in the token queue.void
setAttributeHandle(int attributeHandle)
Set the HLA attribute handle.void
setClassHandle(int classHandle)
Set the HLA class handle.void
setInstanceHandle(int instanceHandle)
Set the HLA object instance.boolean
useCertiMessageBuffer()
Indicate if the HLA subscriber actor uses the CERTI message buffer API.void
wrapup()
Manage the correct termination of theHlaSubscriber
.-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
attributeName
public Parameter attributeName
The HLA attribute name the HLASubscriber is mapped to.
-
classObjectName
public Parameter classObjectName
The object class of the HLA attribute to subscribe to.
-
classInstanceName
public Parameter classInstanceName
The name of the HLA class instance for this HlaSubscriber.
-
output
public TypedIOPort output
The output port.
-
typeSelector
public StringParameter typeSelector
The type of the output port specified through the user interface.
-
useCertiMessageBuffer
public Parameter useCertiMessageBuffer
Indicate if the event is wrapped in a CERTI message buffer.
-
-
Constructor Detail
-
HlaSubscriber
public HlaSubscriber(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct a HlaSubscriber actor.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the entity cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
Call the attributeChanged method of the parent. Check if the user as set all information relative to HLA to subscribe to, for discovering instances and receive (reflect) updated values.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If one of the parameters is empty.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace.- Overrides:
clone
in classTypedAtomicActor
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
initialize
public void initialize() throws IllegalActionException
Check if there is one and only oneHlaManager
deployed in the Ptolemy model.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If there is zero or more than oneHlaManager
per Ptolemy model.
-
fire
public void fire() throws IllegalActionException
Put in the Ptolemy queue the token (with time-stamp t) corresponding to the RAV (with time-stamp t'=ravTimeStamp<\i> related to the HLA attribute of an instance (mapped to this actor). The value of t depends on t' and the time management used (NER or TAR, seeHlaManager
code).- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown here.
-
getAttributeHandle
public int getAttributeHandle()
Return the HLA attribute handle.- Specified by:
getAttributeHandle
in interfaceHlaReflectable
- Returns:
- The HLA attribute handle.
-
getClassHandle
public int getClassHandle()
Return the HLA class handle.- Specified by:
getClassHandle
in interfaceHlaReflectable
- Returns:
- the HLA class handle.
-
getInstanceHandle
public int getInstanceHandle()
Returns the HLA object instance.- Specified by:
getInstanceHandle
in interfaceHlaReflectable
- Returns:
- The HLA object instance handle.
-
setAttributeHandle
public void setAttributeHandle(int attributeHandle)
Set the HLA attribute handle.- Specified by:
setAttributeHandle
in interfaceHlaReflectable
- Parameters:
attributeHandle
- The attributeHandle to set.
-
setClassHandle
public void setClassHandle(int classHandle)
Set the HLA class handle.- Specified by:
setClassHandle
in interfaceHlaReflectable
- Parameters:
classHandle
- The classHandle to set.
-
setInstanceHandle
public void setInstanceHandle(int instanceHandle)
Set the HLA object instance.- Specified by:
setInstanceHandle
in interfaceHlaReflectable
- Parameters:
instanceHandle
- The HLA object instance to set.
-
putReflectedHlaAttribute
public void putReflectedHlaAttribute(HlaTimedEvent event) throws IllegalActionException
Store each updated value of the HLA attribute (mapped to this actor) in the token queue. Then, program the next firing time of this actor to send the token at its expected time. This method is called by theHlaManager
attribute.- Specified by:
putReflectedHlaAttribute
in interfaceHlaReflectable
- Parameters:
event
- The event containing the new value of the HLA attribute and its time-stamp.- Throws:
IllegalActionException
- Not thrown here.
-
useCertiMessageBuffer
public boolean useCertiMessageBuffer()
Indicate if the HLA subscriber actor uses the CERTI message buffer API.- Specified by:
useCertiMessageBuffer
in interfaceHlaReflectable
- Returns:
- true if the HLA actor uses the CERTI message and false if it doesn't.
-
getHlaAttributeName
public java.lang.String getHlaAttributeName() throws IllegalActionException
Return the HLA attribute name provided by this HlaSubscriber actor. It must match the attribute name defined in the FOM for a class classObjectName.- Specified by:
getHlaAttributeName
in interfaceHlaReflectable
- Returns:
- the HLA attribute name.
- Throws:
IllegalActionException
- if a bad token string value is provided.
-
getHlaInstanceName
public java.lang.String getHlaInstanceName() throws IllegalActionException
Return HLA class instance name provided by this HlaSubscriber actor.- Specified by:
getHlaInstanceName
in interfaceHlaReflectable
- Returns:
- The HLA class instance name.
- Throws:
IllegalActionException
- if a bad token string value is provided.
-
getHlaClassName
public java.lang.String getHlaClassName() throws IllegalActionException
Return the HLA class object name provided by this HlaSubscriber actor. It must match the class name defined in the FOM (that has the attribute attributeName of this actor).- Specified by:
getHlaClassName
in interfaceHlaReflectable
- Returns:
- The HLA class object name.
- Throws:
IllegalActionException
- if a bad token string value is provided.
-
getOutputPort
public TypedIOPort getOutputPort()
FIXME: This should probably not be here. See HlaManager.- Specified by:
getOutputPort
in interfaceHlaReflectable
-
wrapup
public void wrapup() throws IllegalActionException
Manage the correct termination of theHlaSubscriber
. Reset HLA attribute handle, class handler and instance handler.- Specified by:
wrapup
in interfaceInitializable
- Overrides:
wrapup
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If the parent class throws it.
-
-