ptolemy.actor.lib
Class BooleanSelect
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.BooleanSelect
- All Implemented Interfaces:
- Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable, TypedActor
- public class BooleanSelect
- extends TypedAtomicActor
A type polymorphic select with boolean valued control. In an
iteration, if an input token is available at the control input,
that token is read, and its value is noted. Its value specifies the
input port that should be read next. If the control input is
true, then if an input token is available on the trueInput
port, then it is is read and sent to the output. Likewise with a
false input and the falseInput port. The token sent to the
output is determined by the control input, which must be a
boolean value. Because tokens are immutable, the same Token is sent
to the output, rather than a copy. The trueInput and
falseInput port may receive Tokens of any type.
The actor indicates a willingness to fire in its prefire() method
if there is an input available on the channel specified by the most
recently seen token on the control port. If no token has ever
been received on the control port, then falseInput is
assumed to be the one to read.
This actor is similar to the BooleanMultiplexor actor, except that
it never discards input tokens. Tokens on channels that are not
selected are not consumed.
- Since:
- Ptolemy II 2.0
- Version:
- $Id: BooleanSelect.java,v 1.14 2004/04/13 03:02:23 cxh Exp $
- Author:
- Steve Neuendorffer, Adam Cataldo
- 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 |
|
Constructor Summary |
BooleanSelect(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 each input port. |
void |
initialize()
Initialize this actor so that the falseInput is read
from until a token arrives on the control input. |
boolean |
prefire()
Return false if any input channel does not have a token.
|
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, clone, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, postfire, 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 |
trueInput
public TypedIOPort trueInput
- Input for tokens on the true path. The type can be anything.
falseInput
public TypedIOPort falseInput
- Input for tokens on the false path. The type can be anything.
control
public TypedIOPort control
- Input that selects one of the other input ports. The type is
BooleanToken.
output
public TypedIOPort output
- The output port. The type is at least the type of
trueInput and falseInput
BooleanSelect
public BooleanSelect(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.
fire
public void fire()
throws IllegalActionException
- Read a token from each input port. If the token from the
control input is true, then output the token consumed from the
trueInput port, otherwise output the token from the
falseInput port.
This method will throw a NoTokenException if any
input channel 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
- Initialize this actor so that the falseInput is read
from until a token arrives on the control input.
- Specified by:
initialize in interface Executable- Overrides:
initialize in class AtomicActor
- Throws:
IllegalActionException - If the parent class throws it.
prefire
public boolean prefire()
throws IllegalActionException
- Return false if any input channel does not have a 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.