Package ptolemy.actor.lib.aspect
Class AtomicCommunicationAspect
- 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
-
- ptolemy.actor.lib.aspect.AtomicCommunicationAspect
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,CommunicationAspect
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Decorator
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
AFDXESs
,AFDXSwitch
,BasicSwitch
,Bus
,CanBus
,PacketDropFaultGenerator
,ParameterEstimator
,StuckAtFaultGenerator
,TTESwitch
public abstract class AtomicCommunicationAspect extends TypedAtomicActor implements CommunicationAspect, Decorator
This abstract class implements functionality of an atomic communication aspect. Listeners can register with this actor for events happening in this quantity manager. Events are created when, for instance, tokens are received or tokens are sent. These events are implemented in derived classes.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Patricia Derler
- Pt.AcceptedRating:
- Red (derler)
- Pt.ProposedRating:
- Yellow (derler)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<IOPort,java.util.List<Attribute>>
_parameters
List of parameters per port.protected int
_tokenCount
Amount of tokens currently being processed by the switch.-
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.CommunicationAspect
decoratorHighlightColorName
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description AtomicCommunicationAspect(CompositeEntity container, java.lang.String name)
Construct an AtomicQuantityManager with a name and a container.AtomicCommunicationAspect(Workspace workspace)
Construct an AtomicQuantityManager in the specified workspace with an empty string as a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_sendToReceiver(Receiver receiver, Token token)
Send token to receiver.java.lang.Object
clone(Workspace workspace)
Clone the object into the specified workspace.DecoratorAttributes
createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj.Receiver
createIntermediateReceiver(Receiver receiver)
Create an intermediate receiver that wraps a given receiver.java.util.List<NamedObj>
decoratedObjects()
Return a list of the entities deeply contained by the container of this resource scheduler.void
initialize()
Initialize the actor.boolean
isGlobalDecorator()
Return true to indicate that this decorator should decorate objects across opaque hierarchy boundaries.void
registerListener(CommunicationAspectListener monitor)
Add a communication aspect monitor to the list of listeners.void
sendCommunicationEvent(Actor source, int messageId, int messageCnt, CommunicationAspectListener.EventType eventType)
Notify the monitor that an event happened.void
setContainer(CompositeEntity container)
Override the base class to first set the container, then establish a connection with any decorated objects it finds in scope in the new container.-
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, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, 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, attributeChanged, 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.actor.CommunicationAspect
reset, sendToken
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
fire, 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
-
-
-
-
Constructor Detail
-
AtomicCommunicationAspect
public AtomicCommunicationAspect(Workspace workspace)
Construct an AtomicQuantityManager in the specified workspace with an empty string as a name. You can then change the name with setName(). If the workspace argument is null, then use the default workspace. The object is added to the workspace directory. Increment the version number of the workspace.- Parameters:
workspace
- The workspace that will list the entity.
-
AtomicCommunicationAspect
public AtomicCommunicationAspect(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct an AtomicQuantityManager with a name and a container. The container argument must not be null, or a NullPointerException will be thrown. This actor will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the container is incompatible with this actor.NameDuplicationException
- If the name coincides with an actor already in the container.
-
-
Method Detail
-
createDecoratorAttributes
public DecoratorAttributes createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj. If the specified target is not an Actor, return null.- Specified by:
createDecoratorAttributes
in interfaceDecorator
- Parameters:
target
- The NamedObj that will be decorated.- Returns:
- The decorated attributes for the target NamedObj, or null if the specified target is not an Actor.
-
decoratedObjects
public java.util.List<NamedObj> decoratedObjects()
Return a list of the entities deeply contained by the container of this resource scheduler.- Specified by:
decoratedObjects
in interfaceDecorator
- Returns:
- A list of the objects decorated by this decorator.
-
isGlobalDecorator
public boolean isGlobalDecorator()
Return true to indicate that this decorator should decorate objects across opaque hierarchy boundaries.- Specified by:
isGlobalDecorator
in interfaceDecorator
- Returns:
- True if decorator is global.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the object into the specified workspace.- Overrides:
clone
in classTypedAtomicActor
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new NamedObj.
- Throws:
java.lang.CloneNotSupportedException
- If any of the attributes cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
createIntermediateReceiver
public Receiver createIntermediateReceiver(Receiver receiver) throws IllegalActionException
Create an intermediate receiver that wraps a given receiver.- Specified by:
createIntermediateReceiver
in interfaceCommunicationAspect
- Parameters:
receiver
- The receiver that is being wrapped.- Returns:
- A new intermediate receiver.
- Throws:
IllegalActionException
- Not thrown in this class but may be thrown in derived classes.
-
registerListener
public void registerListener(CommunicationAspectListener monitor)
Add a communication aspect monitor to the list of listeners.- Specified by:
registerListener
in interfaceCommunicationAspect
- Parameters:
monitor
- The communication aspect monitor.
-
initialize
public void initialize() throws IllegalActionException
Initialize the actor.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Thrown by super class.
-
sendCommunicationEvent
public void sendCommunicationEvent(Actor source, int messageId, int messageCnt, CommunicationAspectListener.EventType eventType)
Notify the monitor that an event happened.- Parameters:
source
- The source actor that caused the event in the communication aspect.messageId
- The ID of the message that caused the event in the communication aspect.messageCnt
- The amount of messages currently being processed by the communication aspect.eventType
- Type of event.
-
setContainer
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
Override the base class to first set the container, then establish a connection with any decorated objects it finds in scope in the new container.- Overrides:
setContainer
in classAtomicActor<TypedIOPort>
- Parameters:
container
- The container to attach this attribute to..- Throws:
IllegalActionException
- If this attribute is not of the expected class for the container, or it has no name, or the attribute and container are not in the same workspace, or the proposed container would result in recursive containment.NameDuplicationException
- If the container already has an attribute with the name of this attribute.- See Also:
ComponentEntity.getContainer()
-
_sendToReceiver
protected void _sendToReceiver(Receiver receiver, Token token) throws NoRoomException, IllegalActionException
Send token to receiver.- Parameters:
receiver
- The receiver.token
- The token.- Throws:
NoRoomException
- If the receiver has no room for the token.IllegalActionException
- If the receiver cannot receive the token.
-
-