Package ptolemy.domains.de.lib.aspect
Class TTESwitch
- 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 TTESwitch extends AtomicCommunicationAspect
This actor is anCommunicationAspect
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. The actor differentiates between two kinds of tokens: time-triggered and event-triggered, which is defined by the parameter type in the port which is associated with this communication aspect. When tokens are received they are delivered with a delay given by the serviceTime parameter. If the actor is currently servicing a previous event-triggered token when it receives a time-triggered token, the event-triggered token is queued again and the time-triggered token is serviced. After the time-triggered token is sent, the event-triggered token in the queue is selected and delivered after the full serviceTime. If an event-triggered token arrives while another event-triggered token arrives, the new event-triggered token is queued. If a time-triggered token is received while another time-triggered token is serviced an exception is thrown. Time-triggered messages should have a fixed delay. In a time-triggered ethernet implementation an offline calculated schedule ensures that only one time-triggered message is received by the TTESwitch at a time. Event-triggered tokens are processed in FIFO order..
- 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 Parameter
serviceTime
The service time.-
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 TTESwitch(CompositeEntity container, java.lang.String name)
Construct a TTESwitch with a name and a container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attributeChanged(Attribute attribute)
If the attribute is serviceTime, then ensure that the value is positive.java.lang.Object
clone(Workspace workspace)
Clone this actor into the specified workspace.IntermediateReceiver
createIntermediateReceiver(Receiver receiver)
Create an intermediate receiver and determine type of tokens received on the port associated with this receiver.void
fire()
If there is a time-triggered token scheduled to be sent then deliver this token, otherwise send first token in the queue of event-triggered tokens.Receiver
getReceiver(Receiver receiver, IOPort port)
Create a receiver to mediate a communication via the specified receiver.boolean
postfire()
If a token has been sent in the fire method then schedule the next firing.void
reset()
Reset the communication aspect and clear the tokens.void
sendToken(Receiver source, Receiver receiver, Token token)
Receive a token and store it in the queue.-
Methods inherited from class ptolemy.actor.lib.aspect.AtomicCommunicationAspect
_sendToReceiver, createDecoratorAttributes, decoratedObjects, initialize, isGlobalDecorator, registerListener, sendCommunicationEvent, setContainer
-
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
-
serviceTime
public Parameter serviceTime
The service time. This is a double with default 0.1. It is required to be positive.
-
-
Constructor Detail
-
TTESwitch
public TTESwitch(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a TTESwitch 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. This actor will have no local director initially, and its executive director will be simply the director of the container.- 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
-
createIntermediateReceiver
public IntermediateReceiver createIntermediateReceiver(Receiver receiver) throws IllegalActionException
Create an intermediate receiver and determine type of tokens received on the port associated with this receiver. The type is specified in a parameter of the port (time-triggered or event-triggered).- Specified by:
createIntermediateReceiver
in interfaceCommunicationAspect
- Overrides:
createIntermediateReceiver
in classAtomicCommunicationAspect
- Parameters:
receiver
- The receiver that is being wrapped.- Returns:
- A new intermediate receiver.
- Throws:
IllegalActionException
- If parameter
-
getReceiver
public Receiver getReceiver(Receiver receiver, IOPort port) throws IllegalActionException
Create a receiver to mediate a communication via the specified receiver. This receiver is linked to a specific port of the communication aspect.- Parameters:
receiver
- Receiver whose communication is to be mediated.port
- Port of the communication aspect.- Returns:
- A new receiver.
- Throws:
IllegalActionException
- If the receiver cannot be created.
-
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 TTESwitch.
- 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)
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
If the attribute is serviceTime, then ensure that the value is positive.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the service time is negative.
-
fire
public void fire() throws IllegalActionException
If there is a time-triggered token scheduled to be sent then deliver this token, otherwise send first token in the queue of event-triggered tokens.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown in this base class.
-
postfire
public boolean postfire() throws IllegalActionException
If a token has been sent in the fire method then schedule the next firing.- 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
Receive a token and store it in the queue. Schedule a refiring.- Parameters:
source
- Receiver that sent the token.receiver
- The receiver for which this communication aspect is mediating communication.token
- The token for the communication to mediate.- Throws:
IllegalActionException
- If the token cannot be sent.
-
reset
public void reset()
Reset the communication aspect and clear the tokens.
-
-