ptolemy.actor.lib
Class Switch
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.Switch
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
public class Switch
- extends Transformer
A polymorphic switch, which routes inputs to specified output channels.
This actor has two input ports, the input port for data,
and the control port to select which output channel to use.
When it fires, if an input token is available at the control
input, that token is read, and its value is noted. If an input
token is available on the input port, then that token is
read, sent to the output channel specified by the most recently
received value on the control port. If no token has been
received on the control port, then the token is sent to
channel zero. If the value of the most recently received token
on the control port is out of range (less than zero,
or greater than or equal to the width of the output), then no
output is produced, and the token is lost.
Note that it may be tempting to call an instance of this
class "switch", but recall that "switch" is a Java keyword, and
thus it cannot be the name of an object.
- Since:
- Ptolemy II 2.0
- Version:
- $Id: Switch.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- Edward A. Lee
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
Field Summary |
private int |
_control
|
TypedIOPort |
control
Input port for control tokens, which specify the output channel
to produce data on. |
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 |
Switch(CompositeEntity container,
java.lang.String name)
Construct an actor in the specified container with the specified
name. |
Method Summary |
void |
fire()
Read a control token, if there is one, and transfer an input
token, if there is one, to the output channel specified by
the most recent control token, if it is in range. |
void |
initialize()
Initialize this actor so that channel zero of input is read
from until a token arrives on the control input. |
Methods inherited from class ptolemy.actor.AtomicActor |
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, 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 |
control
public TypedIOPort control
- Input port for control tokens, which specify the output channel
to produce data on. The type is int.
_control
private int _control
Switch
public Switch(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 control token, if there is one, and transfer an input
token, if there is one, to the output channel specified by
the most recent control token, if it is in range.
- 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 channel zero of input is read
from until a token arrives on the control input.
- Specified by:
initialize
in interface Initializable
- Overrides:
initialize
in class AtomicActor
- Throws:
IllegalActionException
- If the parent class throws it.