ptolemy.actor.lib.hoc
Class ApplyFunctionOverSequence
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.hoc.ApplyFunctionOverSequence
- 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 ApplyFunctionOverSequence
- extends TypedAtomicActor
Apply a function over one or more input sequences.
This actor will collect tokens from each input port into arrays
and, when enough input tokens have arrived, pass those arrays
to the function specified either at the function parameter
or the port.
To use this actor, create any number of input ports, add
a parameter named tokenConsumptionRate to each input
port, and set the value of this parameter to the number
of tokens that you would like to be collected into an
array for each function application. Also, create
and set a parameter named tokenProductionRate
in the output port. (If tokenConsumptionRate
or tokenProductionRate are not defined, then they
will be assumed to have value one).
Then define a function that takes as many array-valued
arguments as there are input ports and returns an
array-valued result. For example, the following function
will compute the FFT of the input array using the FFT()
function in the expression language:
function(x:{double}) abs(FFT(x, 8))
Note that if the tokenConsumptionRate of a port is
changed during the execution of the model, the change is
ignored until the next execution of the model.
- Since:
- Ptolemy II 4.1
- Version:
- $Id: ApplyFunctionOverSequence.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- Steve Neuendorffer (Contributor: Edward A. Lee)
- See Also:
ApplyFunction
,
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 |
Method Summary |
void |
fire()
Consume the inputs, apply the function, and produce the result. |
boolean |
prefire()
Return true if the input ports have enough tokens. |
void |
preinitialize()
Preinitialize the actor. |
Methods inherited from class ptolemy.actor.AtomicActor |
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, 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 |
function
public PortParameter function
- The input port for function definition. The type of this port is
undeclared, but to have this actor work, the designer has to provide
a matched function token for it.
Note: The reason that we don't declare the type for it is because
currently there is not cast supported in the FunctionType class.
we'll fix this later.
output
public TypedIOPort output
- The output port.
_outputRate
private int _outputRate
_rate
private int[] _rate
ApplyFunctionOverSequence
public ApplyFunctionOverSequence(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.
fire
public void fire()
throws IllegalActionException
- Consume the inputs, apply the function, and produce the result.
- Specified by:
fire
in interface Executable
- Overrides:
fire
in class AtomicActor
- Throws:
IllegalActionException
- If a runtime type error occurs.
prefire
public boolean prefire()
throws IllegalActionException
- Return true if the input ports have enough tokens.
- Specified by:
prefire
in interface Executable
- Overrides:
prefire
in class AtomicActor
- Returns:
- True if this actor is ready for firing, false otherwise.
- Throws:
IllegalActionException
- Not thrown in this base class.
preinitialize
public void preinitialize()
throws IllegalActionException
- Preinitialize the actor. Set the type of the ports based on
the type of the function parameter.
- Specified by:
preinitialize
in interface Initializable
- Overrides:
preinitialize
in class AtomicActor
- Throws:
IllegalActionException
- Not thrown in this base class.