public class ConstantPublisherPort extends PublisherPort
SubscriberPort
that names the same channel.
If PubSubPort.global
is false (the default), then this publisher
will only send to instances of SubscriberPort 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). If PubSubPort.global
is true,
then the subscriber may be anywhere in the model, as long as its
global parameter is also true.
Note that this port should be used just like a PublisherPort
.
If you put it in an opaque composite actor, then it requires a
token on the inside in order to produce its output. It will replace
each token with the constant value. Similarly, if it is put into
a transparent composite actor, then tokens must be sent through
it. Those tokens will be replaced with the constant value. If it
is put into an atomic actor, then the actor should call one of
its broadcast or send methods, providing a token that will be
replaced with the constant token. This pattern ensures that data
dependencies work with this port just as with any other port.
It is an error to have two instances of PublisherPort or ConstantPublisherPort using the same channel under the control of the same director. When you create a new PublisherPort or ConstantPublisherPort, by default, it has no channel name. You have to specify a channel name to use it.
How it works:
When the channel name
is specified, typically during model construction, this actor
causes a relation to be created in the least opaque composite
actor above it in the hierarchy and links to that relation.
In addition, if PubSubPort.global
is set to true, it causes
a port to be created in that composite, and also links that
port to the relation on the inside. The relation is recorded by the opaque
composite. When a SubscriberPort is preinitialized that refers
to the same channel, that SubscriberPort finds the relation (by
finding the least opaque composite actor above it) and links
to the relation. Some of these links are "liberal links" in that
they cross levels of the hierarchy.
Since publishers are linked to subscribers, 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.
TypedIOPort.RunTimeTypeCheckException
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
Parameter |
constantValue
The constant value to publish.
|
Parameter |
numberOfTokens
The number of constant tokens to publish.
|
propagateNameChanges
_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 |
---|
ConstantPublisherPort(ComponentEntity container,
java.lang.String name)
Construct a constant publisher port with the specified name and container.
|
Modifier and Type | Method and Description |
---|---|
void |
broadcast(Token token)
Override the base class to replace the specified token with
the value of constantValue.
|
void |
broadcast(Token[] tokenArray,
int vectorLength)
Override the base class to replace the specified tokens with
the value of constantValue.
|
void |
initialize()
Override the base class to initialize the token count.
|
void |
send(int channelIndex,
Token token)
Override the base class to replace the specified token with
the value of constantValue.
|
void |
send(int channelIndex,
Token[] tokenArray,
int vectorLength)
Override the base class to replace the specified tokens with
the value of constantValue.
|
addInitializable, attributeChanged, hierarchyChanged, hierarchyWillChange, preinitialize, setInput, setOutput, subscribers
clone, removeInitializable, setContainer, wrapup
_checkContainer, _checkLiberalLink, _checkLink, _checkType, _checkTypedIOPortContainer, _description, addTypeListener, convert, getAutomaticTypeConversion, getType, getTypeTerm, isTypeAcceptable, removeTypeListener, sendInside, setAutomaticTypeConversion, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, typeConstraintList, typeConstraints
_checkLiberalLink, _exportMoMLContents, _getInsideWidth, _getOutsideWidth, _getReceiversLinkedToGroup, _newInsideReceiver, _newInsideReceiver, _newReceiver, _newReceiver, _notifyPortEventListeners, _removeReceivers, _setConstant, _wrapReceiver, addIOPortEventListener, broadcastClear, checkWidthConstraints, createReceivers, deepConnectedInPortList, deepConnectedInPorts, deepConnectedOutPortList, deepConnectedOutPorts, deepGetReceivers, get, get, getChannelForReceiver, getCommunicationAspects, getCurrentTime, getDefaultWidth, getInside, getInsideReceivers, getIOPortEventListeners, getModelTime, getModelTime, getReceivers, getReceivers, getReceivers, getRelationIndex, getRemoteReceivers, getRemoteReceivers, getWidth, getWidthFromConstraints, getWidthInside, hasNewToken, hasNewTokenInside, hasRoom, hasRoomInside, hasToken, hasToken, 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 Parameter constantValue
public Parameter numberOfTokens
public ConstantPublisherPort(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 broadcast(Token token) throws IllegalActionException, NoRoomException
broadcast
in class TypedIOPort
token
- A token, which will be replaced.IllegalActionException
- Not thrown in this base class.NoRoomException
- If a send to one of the channels throws
it.public void broadcast(Token[] tokenArray, int vectorLength) throws IllegalActionException, NoRoomException
broadcast
in class TypedIOPort
tokenArray
- The token array to replace.vectorLength
- The number of elements of the token
array to send.NoRoomException
- If there is no room in the receiver.IllegalActionException
- Not thrown in this base class.public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class PublisherPort
IllegalActionException
- If initialTokens is invalid.public void send(int channelIndex, Token token) throws IllegalActionException, NoRoomException
send
in class TypedIOPort
channelIndex
- The index of the channel, from 0 to width-1token
- The token to replace, or null to send no token.NoRoomException
- If there is no room in the receiver.IllegalActionException
- Not thrown in this base class.public void send(int channelIndex, Token[] tokenArray, int vectorLength) throws IllegalActionException, NoRoomException
send
in class TypedIOPort
channelIndex
- The index of the channel, from 0 to width-1tokenArray
- The token array to replace.vectorLength
- The number of elements of of the token
array to send.NoRoomException
- If there is no room in the receiver.IllegalActionException
- Not thrown in this base class.