ptolemy.domains.de.lib
Class QueueWithNextOut
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.domains.de.kernel.DEActor
ptolemy.domains.de.lib.DETransformer
ptolemy.domains.de.lib.QueueWithNextOut
- All Implemented Interfaces:
- Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, SequenceActor, java.io.Serializable, TimedActor, TypedActor
- public class QueueWithNextOut
- extends DETransformer
This actor implements an event queue. When a token is received on the
input port, it is stored in the queue.
When the trigger port receives a token, the oldest element in the
queue is output. If there is no element in the queue when a
token is received on the trigger port, then no output is
produced. The inputs can be of any token type, and the output
is constrained to be of a type at least that of the input.
An additional output port, nextOut, has been added which allows
the model to know what's next to come out. This new output produces a
token whenever the queue has been empty and a new token is queued. It
also produces an output whenever a token is taken from the queue and
at least one token remains. Otherwise, no output token is produced at
nextOut. The token produced is the oldest token remaining in
the queue. This output, also, is constrained to be at least that of
input
- Since:
- Ptolemy II 2.0
- Version:
- $Id: QueueWithNextOut.java,v 1.20 2004/04/13 03:29:38 cxh Exp $
- Author:
- Winthrop Williams (based closely on Queue by Steve Neuendorffer)
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
|
Method Summary |
java.lang.Object |
clone(Workspace workspace)
Clone the actor into the specified workspace. |
void |
fire()
If there is a token in the trigger port, emit on the
output port the most recent token from the input
port. |
boolean |
prefire()
If neither the input port nor the trigger port
has input, return false, indicating that this actor does not
want to fire. |
void |
preinitialize()
Clear the cached input tokens. |
| Methods inherited from class ptolemy.domains.de.kernel.DEActor |
newPort |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, initialize, inputPortList, iterate, newReceiver, outputPortList, postfire, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate, wrapup |
| Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables |
| Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
trigger
public TypedIOPort trigger
- The trigger port, which has undeclared type. If this port
receives a token, then the oldest token in the queue
will be emitted on the output port.
nextOut
public TypedIOPort nextOut
- The nextOut port, which has type Token. Gives a preview
of the next token that will come out of the queue. Produces
an output only when a new token is next up in the queue.
QueueWithNextOut
public QueueWithNextOut(CompositeEntity container,
java.lang.String name)
throws NameDuplicationException,
IllegalActionException
- Construct an actor with the given container and name.
- Parameters:
container - The container.name - The name of this actor.
- Throws:
IllegalActionException - If the actor cannot be contained
by the proposed container.
NameDuplicationException - If the container already has an
actor with this name.
clone
public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException
- Clone the actor into the specified workspace. This calls the
base class and then sets the ports.
- Overrides:
clone in class AtomicActor
- Parameters:
workspace - The workspace for the new object.
- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException - If a derived class has
has an attribute that cannot be cloned.
fire
public void fire()
throws IllegalActionException
- If there is a token in the trigger port, emit on the
output port the most recent token from the input
port. If there has been no input token, or there is no token
on the trigger port, emit nothing on the output
port. If a new token is next to come out, either because the
just received its first event or because one was emitted and
at least one remains, then output a preview of this token at
the nextOut port.
- Specified by:
fire in interface Executable- Overrides:
fire in class AtomicActor
- Throws:
IllegalActionException - If there is no director.
prefire
public boolean prefire()
throws IllegalActionException
- If neither the input port nor the trigger port
has input, return false, indicating that this actor does not
want to fire. This has the effect of leaving input values in
the input ports, if there are any.
- Specified by:
prefire in interface Executable- Overrides:
prefire in class AtomicActor
- Returns:
- True if this actor is ready for firing, false otherwise.
- Throws:
IllegalActionException - If there is no director.
preinitialize
public void preinitialize()
throws IllegalActionException
- Clear the cached input tokens.
- Specified by:
preinitialize in interface Executable- Overrides:
preinitialize in class AtomicActor
- Throws:
IllegalActionException - If there is no director.