Package ptolemy.actor.lib
Class Subscriber
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
SubscriptionAggregator
public class Subscriber extends TypedAtomicActor
This actor subscribes to tokens on a named channel. The tokens are "tunneled" from an instance of Publisher that names the same channel. Ifglobal
is false (the default), then this subscriber will only see instances of Publisher that are under the control of the same director. That is, it can be at a different level of the hierarchy, or in an entirely different composite actor, as long as the relevant composite actors are transparent (have no director). Ifglobal
is true, then the publisher may be anywhere in the model, as long as its global parameter is also true.Any number of instances of Subscriber can subscribe to the same channel.
This actor actually has a hidden input port that is connected to the publisher via hidden "liberal links" (links that are allowed to cross levels of the hierarchy). Consequently, any data dependencies that the director might assume on a regular "wired" connection will also be assumed across Publisher-Subscriber pairs. Similarly, type constraints will propagate across Publisher-Subscriber pairs. That is, the type of the Subscriber output will match the type of the Publisher input.
- Since:
- Ptolemy II 5.2
- Version:
- $Id$
- Author:
- Edward A. Lee, Raymond A. Cardillo, Bert Rodiers
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Green (cxh)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description StringParameter
channel
The name of the channel.Parameter
global
Specification of whether the data is subscribed globally.SubscriberPort
input
The input port.TypedIOPort
output
The output port.-
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 Subscriber(CompositeEntity container, java.lang.String name)
Construct a subscriber with the specified container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_createInputPort()
Create an input port.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
fire()
Read at most one input token from each input channel and send it to the output.java.util.Set<AtomicActor>
publishers()
Return a Set of Publishers that are connected to this Subscriber.-
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, initialize, 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, 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.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, initialize, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
channel
public StringParameter channel
The name of the channel. Subscribers that reference this same channel will receive any transmissions to this port. This is a string that defaults to "channel1".
-
global
public Parameter global
Specification of whether the data is subscribed globally. If this is set to true, then this subscriber will see values published by a publisher anywhere in the model references the same channel by name. If this is set to false (the default), then only values published by the publisher that are fired by the same director are seen by this subscriber.
-
input
public SubscriberPort input
The input port. This port is hidden and should not be directly used. This base class imposes no type constraints except that the type of the input cannot be greater than the type of the output.
-
output
public TypedIOPort output
The output port. This is a multiport. If the corresponding publisher has multiple input signals, then those multiple signals will appear on this output port. By default, the type of this output is constrained to be at least that of the input. This port is hidden by default and the actor handles creating connections to it.
-
-
Constructor Detail
-
Subscriber
public Subscriber(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a subscriber with the specified container and name.- Parameters:
container
- The container actor.name
- The name of the actor.- Throws:
IllegalActionException
- If the actor is not of an acceptable class for the container.NameDuplicationException
- If the name coincides with an actor already in the container.
-
-
Method Detail
-
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)
-
fire
public void fire() throws IllegalActionException
Read at most one input token from each input channel and send it to the output.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If there is no director, or if there is no input connection.
-
publishers
public java.util.Set<AtomicActor> publishers() throws KernelException
Return a Set of Publishers that are connected to this Subscriber.- Returns:
- A Set of Publishers that are connected to this Subscriber.
- Throws:
KernelException
- If thrown when a Manager is added to the top level or if preinitialize() fails.
-
_createInputPort
protected void _createInputPort() throws IllegalActionException, NameDuplicationException
Create an input port. This is a protected method so that subclasses can create different input ports. This is called in the constructor, so subclasses cannot reliably access local variables.- Throws:
IllegalActionException
- If creating the input port fails.NameDuplicationException
- If there is already a port named "input".
-
-