ptolemy.actor.lib
Class Sequencer
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.Transformer
ptolemy.actor.lib.Sequencer
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, SequenceActor, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
public class Sequencer
- extends Transformer
- implements SequenceActor
This actor takes a sequence of inputs tagged with a sequence number
and produces them on the output port in the order given by the
sequence number. The sequence numbers are integers starting
with zero. On each firing, this actor consumes one token
from the input port and one token from the
sequenceNumber port. If the sequence number is the
next one in the sequence, then the token read from the input
port is produced on the output port. Otherwise,
it is saved until its sequence number is the next one
in the sequence. If an output is produced, then it may
be immediately followed by tokens that were previously
saved, if their sequence numbers are next.
- Since:
- Ptolemy II 1.0
- Version:
- $Id: Sequencer.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- Edward A. Lee
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary |
Sequencer(CompositeEntity container,
java.lang.String name)
Construct an actor in the specified container with the specified
name. |
Method Summary |
java.lang.Object |
clone(Workspace workspace)
Clone the actor into the specified workspace. |
void |
fire()
Read a token from the sequenceNumber port and from
the input port, and output the next token(s) in the
sequence, or none if the next token in the sequence has not
yet been seen. |
void |
initialize()
Reset current sequence number to the value given by the
startingSequenceNumber parameter. |
boolean |
postfire()
If the fire() method produced the input token then check to
whether any pending tokens have subsequent sequence numbers. |
boolean |
prefire()
Return false if either the input port or the
sequenceNumber port lacks an input token. |
Methods inherited from class ptolemy.actor.AtomicActor |
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, 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 |
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, 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, propagateValue, propagateValues, removeChangeListener, removeDebugListener, 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 |
sequenceNumber
public TypedIOPort sequenceNumber
- Input for the sequence number. The type is int.
startingSequenceNumber
public Parameter startingSequenceNumber
- The first number of the sequence. This is an int that
defaults to 0.
_fireProducedOutput
private boolean _fireProducedOutput
_nextSequenceNumber
private int _nextSequenceNumber
_nextToken
private Token _nextToken
_pending
private java.util.TreeMap _pending
_sequenceNumberOfInput
private int _sequenceNumberOfInput
Sequencer
public Sequencer(CompositeEntity container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
- Construct an actor in the specified container with the specified
name.
- Parameters:
container
- The container.name
- The name of this actor within the container.
- Throws:
IllegalActionException
- If the actor cannot be contained
by the proposed container.
NameDuplicationException
- If the name coincides with
an actor already in the container.
clone
public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException
- Clone the actor into the specified workspace.
- 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 contains
an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
fire
public void fire()
throws IllegalActionException
- Read a token from the sequenceNumber port and from
the input port, and output the next token(s) in the
sequence, or none if the next token in the sequence has not
yet been seen. This method will throw a NoTokenException if
sequenceNumber or input does not have a token.
- Specified by:
fire
in interface Executable
- Overrides:
fire
in class AtomicActor
- Throws:
IllegalActionException
- If there is no director.
initialize
public void initialize()
throws IllegalActionException
- Reset current sequence number to the value given by the
startingSequenceNumber parameter.
- Specified by:
initialize
in interface Initializable
- Overrides:
initialize
in class AtomicActor
- Throws:
IllegalActionException
- If accessing the
startingSequenceNumber parameter causes an exception.
postfire
public boolean postfire()
throws IllegalActionException
- If the fire() method produced the input token then check to
whether any pending tokens have subsequent sequence numbers.
- Specified by:
postfire
in interface Executable
- Overrides:
postfire
in class AtomicActor
- Returns:
- True if execution can continue into the next iteration.
- Throws:
IllegalActionException
- If there is no director.
prefire
public boolean prefire()
throws IllegalActionException
- Return false if either the input port or the
sequenceNumber port lacks an input token.
Otherwise, return whatever the superclass returns.
- Specified by:
prefire
in interface Executable
- Overrides:
prefire
in class AtomicActor
- Returns:
- False if there are not enough tokens to fire.
- Throws:
IllegalActionException
- If there is no director.