ptolemy.actor.lib
Class OrderedMerge
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.OrderedMerge
- All Implemented Interfaces:
- Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable, TypedActor
- public class OrderedMerge
- extends TypedAtomicActor
This actor merges two monotonically nondecreasing streams of tokens into
one monotonically nondecreasing stream. On each firing, it reads data from
one of the inputs. On the first firing, it simply records that token.
On the second firing, it reads data from the other input and outputs
the smaller of the recorded token and the one it just read. If they
are equal, then it outputs the recorded token. It then
records the larger token. On each subsequent firing, it reads a token
from the input port that did not provide the recorded token, and produces
at the output the smaller of the recorded token and the one just read.
If both input sequences are nondecreasing, then the output sequence
will be nondecreasing.
Note that if the inputs are not nondecreasing, then the output is
rather complex. The key is that in each firing, it produces the smaller
of the recorded token and the token it is currently reading.
- Since:
- Ptolemy II 2.0.1
- Version:
- $Id: OrderedMerge.java,v 1.11 2004/04/13 03:03:41 cxh Exp $
- Author:
- Edward A. Lee
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
|
Field Summary |
TypedIOPort |
inputA
The first input port, which accepts any scalar token. |
TypedIOPort |
inputB
The second input port, which accepts any scalar token with
the same type as the first input port. |
TypedIOPort |
output
The output port, which has the same type as the input ports. |
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
|
Constructor Summary |
OrderedMerge(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name. |
|
Method Summary |
java.lang.Object |
clone(Workspace workspace)
Clone the actor into the specified workspace. |
void |
fire()
Read one token from the port that did not provide the recorded
token (or inputA, on the first firing), and output the
smaller of the recorded token or the newly read token.
|
void |
initialize()
Initialize this actor to indicate that no token is recorded. |
boolean |
postfire()
Commit the recorded token. |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, prefire, preinitialize, 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 |
inputA
public TypedIOPort inputA
- The first input port, which accepts any scalar token.
inputB
public TypedIOPort inputB
- The second input port, which accepts any scalar token with
the same type as the first input port.
output
public TypedIOPort output
- The output port, which has the same type as the input ports.
OrderedMerge
public OrderedMerge(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 type constraints.
- 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
an attribute that cannot be cloned.
fire
public void fire()
throws IllegalActionException
- Read one token from the port that did not provide the recorded
token (or inputA, on the first firing), and output the
smaller of the recorded token or the newly read token.
If there is no token on the port to be read, then do nothing
and return.
- Specified by:
fire in interface Executable- Overrides:
fire in class AtomicActor
- Throws:
IllegalActionException - If there is no director.
initialize
public void initialize()
throws IllegalActionException
- Initialize this actor to indicate that no token is recorded.
- Specified by:
initialize in interface Executable- Overrides:
initialize in class AtomicActor
- Throws:
IllegalActionException - If a derived class throws it.
postfire
public boolean postfire()
throws IllegalActionException
- Commit the recorded token.
- Specified by:
postfire in interface Executable- Overrides:
postfire in class AtomicActor
- Returns:
- True.
- Throws:
IllegalActionException - Not thrown in this base class.