Class HlaAttributeUpdater
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- org.hlacerti.lib.HlaAttributeUpdater
-
- All Implemented Interfaces:
java.lang.Cloneable
,HlaUpdatable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class HlaAttributeUpdater extends TypedAtomicActor implements HlaUpdatable
This actor is a kind-of output port that sends the data on its input to the HLA federation through the RTI (Run Time Infrastructure). In HLA, the terminology is that this actor "updates" the specified attribute value of the specified instance whenever there is a data on its input. This attribute value will be "reflected" by all federates that have "subscribed" to this attribute. The time stamp of this update depends on the time management parameters of theHlaManager
, as explained in the documentation for that class. This actor assumes that there is exactly one HlaManager in the model that contains this actor.The attribute of an instance that this actor updates is specified using three parameters: attributeName, className, and instanceName. The updates will be reflected, for example, by an
HlaAttributeReflector
whose three parameters match those of this actor. The className and attributeName are required to match a class and attribute specified in the FED file that is specified in the HlaManager. The instanceName is an arbitrary name chosen by the designer for the instance of the class. It specifies the instance of the specified class whose attribute this actor updates.If the specified class does not have an attribute with the specified attributeName, as defined in the FED file, or there is no class matching className in the FED file, then an exception will be thrown. An exception is also thrown if the attribute name or the class name or the instance name is empty.
If a federate intends to update N attributes of an instance, then it must contain N HlaAttributeUpdater actors with the same instanceName and same className. A federate can update attributes of M different instances of a same class. In this case, the federate must contain M HlaAttributeUpdater actors for each attribute. During initialization, the HlaManager will notify the RTI of this intention in two steps:
- it "publishes" a list with all attributes of class by gathering the parameter attributeName of all HlaAttributeReflectable actors having the same className,
it "registers" each different instanceName of a class className.
The data type of the input port of this actor must have the same type of the attribute value this actor updates (as defined in the FOM). The data type is used to define the bytes that are transported via the HLA RTI. Currently, only a small set of primitive data types are supported.
The useCertiMessageBuffer parameter works together with the data type to interpret the bits that are transported over the RTI. Specifically, an HLA RTI will transport arbitrary byte sequences regardless of what they represent. CERTI, the particular RTI that Ptolemy II uses, provides a convenience feature that packs and unpacks the message bytes for a small set of data types. This feature takes into account the annoyance that the byte order can be different on different platforms (big endian or little endian). If the attribute that this actor is updating is reflected by a "foreign" federate (not implemented in Ptolemy II), then this useCertiMessageBuffer parameter should be set to true to ensure that byte order changes are handled. And in this case, only the small set of data types supported by CERTI can be used. On the other hand, if the attribute is reflected by a Ptolemy II model, and the corresponding
HlaAttributeReflector
does not not specify to use the CERTI message buffer, then this parameter should be false. See alsoMessageProcessing
class.FIXME: took from publisher actor description. Keep it or not? In a federation implemented only with Ptolemy II federates, an HlaAttributeUpdater is linked to a unique HlaAttributeReflector. Any data dependencies that the director might assume on a regular "wired" connection will also be assumed across HlaAttributeUpdater-HlaAttributeReflector pairs. Similarly, the type of the HlaAttributeReflector output must match the type of the HlaAttributeUpdater input.
- Since:
- Ptolemy II 11.0
- Version:
- $Id: HlaAttributeUpdater.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 StringParameter
attributeName
The name of the attribute this actor updates.StringParameter
className
The name of the class whose attribute this actor updates.TypedIOPort
input
The input port providing the new value that will update the specified attribute of the specified instance.StringParameter
instanceName
The name of the instance of the class to whose attribute this actor updates.Parameter
useCertiMessageBuffer
Indicate whether the attribute value is conveyed through 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 HlaAttributeUpdater(CompositeEntity container, java.lang.String name)
Construct the HlaAttributeUpdater 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()
Ask theHlaManager
for updating the event in the input port (with time-stamp t) to the federation, by calling the UAV service (with time-stamp t') related to the HLA attribute of an instance (mapped to this actor).java.lang.String
getHlaAttributeName()
Return the value of the attributeName parameter.java.lang.String
getHlaClassName()
Return the value of the className parameter.java.lang.String
getHlaInstanceName()
Return the value of the instanceName parameter.TypedIOPort
getInputPort()
FIXME: This should probably not be here.void
initialize()
Retrieve and check if there is one and only oneHlaManager
deployed in the Ptolemy model.boolean
useCertiMessageBuffer()
Indicate if the HLA publisher actor uses the CERTI message buffer API.-
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, wrapup
-
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, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
attributeName
public StringParameter attributeName
The name of the attribute this actor updates. This defaults to an empty string, but it must be non-empty to run the model.
-
className
public StringParameter className
The name of the class whose attribute this actor updates. This defaults to an empty string, but it must be non-empty to run the model.
-
instanceName
public StringParameter instanceName
The name of the instance of the class to whose attribute this actor updates. This defaults to an empty string, but it must be non-empty to run the model.
-
input
public TypedIOPort input
The input port providing the new value that will update the specified attribute of the specified instance. The type of the input port corresponds to the type of the attribute (that would be defined in the FOM, but is not described in the FED file). This type must be the same as attributeType inHlaAttributeReflector
.
-
useCertiMessageBuffer
public Parameter useCertiMessageBuffer
Indicate whether the attribute value is conveyed through a CERTI message buffer. This is a boolean that defaults to false. It should be set to true if the attribute to which this actor listens is updated by a foreign simulator. It can be false if the attribute is reflected by a federate implemented in Ptolemy II, and if this corresponding parameter in the actor doing the reflecting is also false.
-
-
Constructor Detail
-
HlaAttributeUpdater
public HlaAttributeUpdater(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct the HlaAttributeUpdater 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 has set all information related to HLA to publish, for registering instances- 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
Retrieve and check if there is one and only oneHlaManager
deployed in the Ptolemy model. TheHlaManager
provides the method to publish the attributes of a class, register an instance of a class and update the value of a HLA attribute of a class instance to the HLA/CERTI Federation.- 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
Ask theHlaManager
for updating the event in the input port (with time-stamp t) to the federation, by calling the UAV service (with time-stamp t') related to the HLA attribute of an instance (mapped to this actor). The value of t' depends on t and the time management parameters used (NER or TAR, seeHlaManager
code).- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown in this base class.
-
getHlaAttributeName
public java.lang.String getHlaAttributeName() throws IllegalActionException
Return the value of the attributeName parameter.- Specified by:
getHlaAttributeName
in interfaceHlaUpdatable
- Returns:
- The value of the attributeName parameter.
- Throws:
IllegalActionException
- If the class name is empty.
-
getHlaClassName
public java.lang.String getHlaClassName() throws IllegalActionException
Return the value of the className parameter.- Specified by:
getHlaClassName
in interfaceHlaUpdatable
- Returns:
- The value of the className parameter.
- Throws:
IllegalActionException
- If the class name is empty.
-
getHlaInstanceName
public java.lang.String getHlaInstanceName() throws IllegalActionException
Return the value of the instanceName parameter.- Specified by:
getHlaInstanceName
in interfaceHlaUpdatable
- Returns:
- The value of the instanceName parameter.
- Throws:
IllegalActionException
- If the class name is empty.
-
getInputPort
public TypedIOPort getInputPort()
FIXME: This should probably not be here. See HlaManager.- Specified by:
getInputPort
in interfaceHlaUpdatable
-
useCertiMessageBuffer
public boolean useCertiMessageBuffer()
Indicate if the HLA publisher actor uses the CERTI message buffer API.- Specified by:
useCertiMessageBuffer
in interfaceHlaUpdatable
- Returns:
- true if the HLA publisher actor uses the CERTI message and false if it doesn't.
-
-