ptolemy.actor.lib
Class Sequencer

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.InstantiableNamedObj
          extended byptolemy.kernel.Entity
              extended byptolemy.kernel.ComponentEntity
                  extended byptolemy.actor.AtomicActor
                      extended byptolemy.actor.TypedAtomicActor
                          extended byptolemy.actor.lib.Transformer
                              extended byptolemy.actor.lib.Sequencer
All Implemented Interfaces:
ptolemy.actor.Actor, ptolemy.kernel.util.Changeable, java.lang.Cloneable, ptolemy.kernel.util.Debuggable, ptolemy.kernel.util.DebugListener, ptolemy.kernel.util.Derivable, ptolemy.actor.Executable, ptolemy.kernel.util.Instantiable, ptolemy.kernel.util.ModelErrorHandler, ptolemy.kernel.util.MoMLExportable, ptolemy.kernel.util.Nameable, SequenceActor, java.io.Serializable, ptolemy.actor.TypedActor

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,v 1.17 2004/04/13 05:12:30 cxh Exp $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Yellow (ctsay)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
ptolemy.kernel.Entity.ContainedObjectsIterator
 
Field Summary
 ptolemy.actor.TypedIOPort sequenceNumber
          Input for the sequence number.
 ptolemy.data.expr.Parameter startingSequenceNumber
          The first number of the sequence.
 
Fields inherited from class ptolemy.actor.lib.Transformer
input, output
 
Fields inherited from class ptolemy.actor.AtomicActor
_stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
Sequencer(ptolemy.kernel.CompositeEntity container, java.lang.String name)
          Construct an actor in the specified container with the specified name.
 
Method Summary
 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.TypedAtomicActor
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList
 
Methods inherited from class ptolemy.actor.AtomicActor
_createReceivers, clone, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate, wrapup
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, propagateExistence, setName
 
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.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition
 
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
 
Methods inherited from interface ptolemy.actor.Actor
getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
iterate, preinitialize, stop, stopFire, terminate, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getFullName, getName, getName
 

Field Detail

sequenceNumber

public ptolemy.actor.TypedIOPort sequenceNumber
Input for the sequence number. The type is int.


startingSequenceNumber

public ptolemy.data.expr.Parameter startingSequenceNumber
The first number of the sequence. This is an int that defaults to 0.

Constructor Detail

Sequencer

public Sequencer(ptolemy.kernel.CompositeEntity container,
                 java.lang.String name)
          throws ptolemy.kernel.util.IllegalActionException,
                 ptolemy.kernel.util.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:
ptolemy.kernel.util.IllegalActionException - If the actor cannot be contained by the proposed container.
ptolemy.kernel.util.NameDuplicationException - If the name coincides with an actor already in the container.
Method Detail

fire

public void fire()
          throws ptolemy.kernel.util.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 ptolemy.actor.Executable
Throws:
ptolemy.kernel.util.IllegalActionException - If there is no director.

initialize

public void initialize()
                throws ptolemy.kernel.util.IllegalActionException
Reset current sequence number to the value given by the startingSequenceNumber parameter.

Specified by:
initialize in interface ptolemy.actor.Executable
Throws:
ptolemy.kernel.util.IllegalActionException - If accessing the startingSequenceNumber parameter causes an exception.

postfire

public boolean postfire()
                 throws ptolemy.kernel.util.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 ptolemy.actor.Executable
Throws:
ptolemy.kernel.util.IllegalActionException - If there is no director.

prefire

public boolean prefire()
                throws ptolemy.kernel.util.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 ptolemy.actor.Executable
Returns:
False if there are not enough tokens to fire.
Throws:
ptolemy.kernel.util.IllegalActionException - If there is no director.