Package ptolemy.domains.de.lib.aspect
Class Bus
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,CommunicationAspect
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Decorator
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class Bus extends AtomicCommunicationAspect
This actor is aCommunicationAspect
that, when itssendToken(Receiver, Receiver, Token)
method is called, delays the delivery of the specified token to the specified receiver according to a service rule. Specifically, if the actor is not currently servicing a previous token, then it delivers the token with a delay given by the serviceTimeMultiplicationFactor parameter multiplied by the messageLength parameter specified in the port. If the actor is currently servicing a previous token, then it waits until it has finished servicing that token (and any other pending tokens), and then delays for an additional amount given by serviceTimeMultiplicationFactor * messageLength. In the default case of the messageLength = 1, the behavior is similar to theServer
actor. Tokens are processed in FIFO order.To use this communication aspect, drag an instance of this Bus into the model, and (optionally) assign it a name. Then, on any input port whose communication is to be mediated by this instance of Bus, open the configuration dialogue, select the tab with the name of the bus in the title and select the enable attribute. The message length is by default set to 1 but can be configured in this tab.
Several Bus communication aspects can be used in sequence. The order in which Tokens are sent through Buses depends on the order in which these are enabled via the DecoratorAttributes.
This actor is tested in continuous and DE.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Patricia Derler, Edward A. Lee
- Pt.AcceptedRating:
- Red (derler)
- Pt.ProposedRating:
- Yellow (derler)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Bus.BusAttributes
The port specific attributes for ports mediated by a Bus.-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
serviceTimeMultiplicationFactor
The service time for the default messageLength of 1.-
Fields inherited from class ptolemy.actor.lib.aspect.AtomicCommunicationAspect
_parameters, _tokenCount
-
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 Bus(CompositeEntity container, java.lang.String name)
Construct a Bus with a name and a container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_scheduleRefire()
Schedule a refiring of the actor.void
attributeChanged(Attribute attribute)
If the attribute is serviceTime, then ensure that the value is non-negative.java.lang.Object
clone(Workspace workspace)
Clone this actor into the specified workspace.DecoratorAttributes
createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj.IntermediateReceiver
createIntermediateReceiver(Receiver receiver)
Create an intermediate receiver that wraps a given receiver.void
fire()
Send first token in the queue to the target receiver.void
initialize()
Initialize the actor.boolean
postfire()
If there are still tokens in the queue and a token has been produced in the fire, schedule a refiring.void
reset()
Nothing to do.void
sendToken(Receiver source, Receiver receiver, Token token)
Initiate a send of the specified token to the specified receiver.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.void
setMessageLength(IOPort port, double messageLength)
Set the message length for tokens sent to this actor port.-
Methods inherited from class ptolemy.actor.lib.aspect.AtomicCommunicationAspect
_sendToReceiver, decoratedObjects, isGlobalDecorator, registerListener, sendCommunicationEvent
-
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, 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, 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, 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
-
serviceTimeMultiplicationFactor
public Parameter serviceTimeMultiplicationFactor
The service time for the default messageLength of 1. This is a double with default 0.1. It is required to be positive.
-
-
Constructor Detail
-
Bus
public Bus(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a Bus 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
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
If the attribute is serviceTime, then ensure that the value is non-negative.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the service time is negative.
-
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
- Overrides:
createDecoratorAttributes
in classAtomicCommunicationAspect
- 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.
-
createIntermediateReceiver
public IntermediateReceiver createIntermediateReceiver(Receiver receiver) throws IllegalActionException
Create an intermediate receiver that wraps a given receiver.- Specified by:
createIntermediateReceiver
in interfaceCommunicationAspect
- Overrides:
createIntermediateReceiver
in classAtomicCommunicationAspect
- Parameters:
receiver
- The receiver that is being wrapped.- Returns:
- A new intermediate receiver.
- Throws:
IllegalActionException
- Thrown if Bus is used in container different from the container of the bus.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone this actor into the specified workspace. The new actor is not added to the directory of that workspace (you must do this yourself if you want it there). The result is a new actor with the same ports as the original, but no connections and no container. A container must be set before much can be done with this actor.- Overrides:
clone
in classAtomicCommunicationAspect
- Parameters:
workspace
- The workspace for the cloned object.- Returns:
- A new Bus.
- Throws:
java.lang.CloneNotSupportedException
- If cloned ports cannot have as their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Send first token in the queue to the target receiver.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown in this base class.
-
initialize
public void initialize() throws IllegalActionException
Initialize the actor.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAtomicCommunicationAspect
- Throws:
IllegalActionException
- If the superclass throws it.
-
postfire
public boolean postfire() throws IllegalActionException
If there are still tokens in the queue and a token has been produced in the fire, schedule a refiring.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classAtomicActor<TypedIOPort>
- Returns:
- True if execution can continue into the next iteration.
- Throws:
IllegalActionException
- Not thrown in this base class.
-
sendToken
public void sendToken(Receiver source, Receiver receiver, Token token) throws IllegalActionException
Initiate a send of the specified token to the specified receiver. This method will schedule a refiring of this actor if there is not one already scheduled.- Parameters:
source
- Sender of the token.receiver
- The receiver to send to.token
- The token to send.- Throws:
IllegalActionException
- If the refiring request fails.
-
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 classAtomicCommunicationAspect
- 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()
-
setMessageLength
public void setMessageLength(IOPort port, double messageLength)
Set the message length for tokens sent to this actor port.- Parameters:
port
- The actor port.messageLength
- The message length.
-
reset
public void reset()
Nothing to do.
-
_scheduleRefire
protected void _scheduleRefire() throws IllegalActionException
Schedule a refiring of the actor.- Throws:
IllegalActionException
- Thrown if the actor cannot be rescheduled
-
-