public class SubscriptionAggregatorPort extends SubscriberPort
This is a generalization of the SubscriberPort
(the base class) where the channel name
is interpreted as a regular expression. Data produced by all
publishers that publish on a channel name that matches the regular
expression are aggregated using the operation given by the operation
parameter.
Note that the channel
parameter of the superclass is now a regular expression in this class.
One thing to watch out for is using .
instead of \.
.
For example, channel.foo
does not mean the same thing as
channel\.foo
. The latter requires a dot between channel and
foo, where the former does not.
Note that although this is a multiport, calls to get() should only reference channel 0. An exception will be thrown otherwise. The result of the get will be the aggregate of what is received on all the input channels.
Red (eal) |
Yellow (eal) |
TypedIOPort.RunTimeTypeCheckException
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
StringParameter |
operation
The operation used to aggregate the data produced by
matching publishers.
|
_channel, _global, channel, global, initialTokens
_resolvedType, TYPE
_constantLimit, _constantToken, _constantTokensSent, _hasPortEventListeners, _portEventListeners, CONFIGURATION, defaultValue, RECEIVERS, REMOTERECEIVERS
_insideLinks, _relationsList
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
SubscriptionAggregatorPort(ComponentEntity container,
java.lang.String name)
Construct a subscriber port with a containing actor and a name.
|
Modifier and Type | Method and Description |
---|---|
protected int |
_getInsideWidth(IORelation except)
Override the base class to always return 1.
|
protected void |
_updateLinks()
Update the connection to the publishers, if there are any.
|
void |
attributeChanged(Attribute attribute)
If a publish and subscribe channel is set, then set up the connections.
|
Token |
get(int channelIndex)
Get a token from the specified channel.
|
Token[] |
get(int channelIndex,
int vectorLength)
Get an array of tokens from the specified channel.
|
int |
getWidthInside()
Return the inside width of this port, which in this class is
always 1.
|
boolean |
hasToken(int channelIndex)
Return true if any input channel has a token.
|
boolean |
hasToken(int channelIndex,
int vectorLength)
Return true if every input channel that has tokens has enough tokens.
|
void |
preinitialize()
Check that the port is not in the top level, then
call preinitialize() in the super class.
|
_updatePublisherPorts, hierarchyChanged, hierarchyWillChange, initialize, setInput, setOutput
addInitializable, clone, removeInitializable, setContainer, wrapup
_checkContainer, _checkLiberalLink, _checkLink, _checkType, _checkTypedIOPortContainer, _description, addTypeListener, broadcast, broadcast, convert, getAutomaticTypeConversion, getType, getTypeTerm, isTypeAcceptable, removeTypeListener, send, send, sendInside, setAutomaticTypeConversion, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, typeConstraintList, typeConstraints
_checkLiberalLink, _exportMoMLContents, _getOutsideWidth, _getReceiversLinkedToGroup, _newInsideReceiver, _newInsideReceiver, _newReceiver, _newReceiver, _notifyPortEventListeners, _removeReceivers, _setConstant, _wrapReceiver, addIOPortEventListener, broadcastClear, checkWidthConstraints, createReceivers, deepConnectedInPortList, deepConnectedInPorts, deepConnectedOutPortList, deepConnectedOutPorts, deepGetReceivers, getChannelForReceiver, getCommunicationAspects, getCurrentTime, getDefaultWidth, getInside, getInsideReceivers, getModelTime, getReceivers, getReceivers, getReceivers, getRelationIndex, getRemoteReceivers, getRemoteReceivers, getWidth, getWidthFromConstraints, hasNewToken, hasNewTokenInside, hasRoom, hasRoomInside, hasTokenInside, hasWidthConstraints, insertLink, insideSinkPortList, insideSourcePortList, invalidateCommunicationAspects, isInput, isInsideConnected, isKnown, isKnown, isKnownInside, isMultiport, isOutput, isOutsideConnected, liberalLink, link, numberOfSinks, numberOfSources, removeIOPortEventListener, reset, sendClear, sendClearInside, setDefaultWidth, setMultiport, setWidthEquals, setWidthEquals, sinkPortList, sourcePortList, transferInputs, transferOutputs, unlink, unlink, unlinkAll, unlinkAllInside, unlinkInside, unlinkInside
_deepConnectedPortList, _deepConnectedPorts, _deepInsidePortList, _deepInsidePorts, _isInsideLinkable, deepConnectedPortList, deepConnectedPorts, deepInsidePortList, deepInsidePorts, insertInsideLink, insidePortList, insidePorts, insideRelationList, insideRelations, isDeeplyConnected, isInsideGroupLinked, isInsideLinked, isOpaque, numInsideLinks
_getContainedObject, _propagateExistence, connectedPortList, connectedPorts, getContainer, isGroupLinked, isLinked, linkedRelationList, linkedRelations, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, numLinks, setName
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
description, getContainer, getDisplayName, getFullName, getName, getName, setName
public StringParameter operation
public SubscriptionAggregatorPort(ComponentEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container actor.name
- The name of the port.IllegalActionException
- If the port is not of an acceptable
class for the container, or if the container does not implement the
Actor interface.NameDuplicationException
- If the name coincides with
a port already in the container.public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class SubscriberPort
attribute
- The attribute that changed.IllegalActionException
- Thrown if the new color attribute cannot
be created.public Token get(int channelIndex) throws NoTokenException, IllegalActionException
operation
parameter and return the
single token result.
Specifically, it reads one token from each input channel
that has a token, aggregates these, and returns the aggregate.get
in class IOPort
channelIndex
- The channel index. This is required to be 0.NoTokenException
- If there is no token.IllegalActionException
- If there is no director, and hence
no receivers have been created, if the port is not an input port, or
if the channel index is not 0.public Token[] get(int channelIndex, int vectorLength) throws NoTokenException, IllegalActionException
operation
parameter and return the
single token result.
Specifically, it reads one token from each input channel
that has a token, aggregates these, and returns the aggregate.get
in class IOPort
channelIndex
- The channel index. This is required to be 0.vectorLength
- The number of valid tokens to get in the
returned array.NoTokenException
- If there is not enough tokens.IllegalActionException
- If there is no director, and hence
no receivers have been created, if the port is not an input port, or
if the channel index is not 0.public int getWidthInside()
getWidthInside
in class IOPort
public boolean hasToken(int channelIndex) throws IllegalActionException
hasToken
in class IOPort
channelIndex
- The channel index. This is required to be 0.IllegalActionException
- If the channel index is not 0
or if the superclass throws it.public boolean hasToken(int channelIndex, int vectorLength) throws IllegalActionException
hasToken
in class IOPort
channelIndex
- The channel index. This is required to be 0.vectorLength
- The number of tokens to query the channel for.IllegalActionException
- If the channel index is not 0
or if the superclass throws it.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class SubscriberPort
IllegalActionException
- If the port is in
the top level.protected int _getInsideWidth(IORelation except)
_getInsideWidth
in class IOPort
except
- The relation to exclude.protected void _updateLinks() throws IllegalActionException
_updateLinks
in class SubscriberPort
IllegalActionException
- If creating the link
triggers an exception.