Class Pulse
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,SequenceActor
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class Pulse extends SequenceSource
Produce a pulse with a shape specified by the parameters. The values parameter contains an ArrayToken, which specifies the sequence of values to produce at the output. The indexes parameter contains an array of integers, which specifies when those values should be produced. The array in the indexes parameter must have the same length as that in the values parameter or an exception will be thrown by the fire() method. Also, the indexes array must be increasing and non-negative, or an exception will be thrown when it is set.Eventually, this actor will support various kinds of interpolation. For now, it outputs a zero (of the same type as the values) whenever the iteration count does not match an index in indexes.
The default for the values parameter is an integer vector of form {1, 0}. The default indexes array is {0, 1}. Thus, the default output sequence will be 1, 0, 0, ...
However, the Pulse actor has a repeat parameter. When set to true, the defined sequence is repeated indefinitely. Otherwise, the default sequence of zero values result.
The type of the output can be any token type. This type is inferred from the element type of the values parameter.
The Ptolemy Expression language has several constructs that are useful for creating arrays for use as values or indexes:
[0:1:100].toArray()
- Matlab style array construction that creates an array of 100 elements, 0 through 99.
repeat(100, {1}(0))
- Creat a sequence of one hundred 1's.
NOTE: A reset input for this actor would be useful. This would reset the iterations count, to cause the pulse to emerge again.
- Since:
- Ptolemy II 0.2
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Yellow (cxh)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
indexes
The indexes at which the specified values will be produced.Parameter
repeat
The flag that indicates whether the pulse sequence needs to be repeated.Parameter
values
The values that will be produced at the specified indexes.-
Fields inherited from class ptolemy.actor.lib.LimitedFiringSource
_firingCountLimit, firingCountLimit
-
Fields inherited from class ptolemy.actor.lib.Source
_triggered, output, trigger
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description Pulse(CompositeEntity container, java.lang.String name)
Construct an actor with the specified container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attributeChanged(Attribute attribute)
If the attribute being changed is indexes, then check that it is increasing and nonnegative.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
fire()
Output a value if the count of iterations matches one of the entries in the indexes array.void
initialize()
Set the iteration count to zero.boolean
postfire()
Update the iteration counters until they exceed the values in the indexes array.boolean
prefire()
Start an iteration.-
Methods inherited from class ptolemy.actor.lib.Source
_customTypeConstraints
-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, 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
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, 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, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, 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
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
indexes
public Parameter indexes
The indexes at which the specified values will be produced. This parameter is an array of integers, with default value {0, 1}.
-
repeat
public Parameter repeat
The flag that indicates whether the pulse sequence needs to be repeated. This is a boolean, and defaults to false.
-
values
public Parameter values
The values that will be produced at the specified indexes. This parameter is an array, with default value {1, 0}.
-
-
Constructor Detail
-
Pulse
public Pulse(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct an actor with the specified container and name.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the entity cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
If the attribute being changed is indexes, then check that it is increasing and nonnegative.- Overrides:
attributeChanged
in classLimitedFiringSource
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the indexes vector is not increasing and nonnegative, or the indexes is not a row vector.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace. This overrides the base class to handle type constraints.- Overrides:
clone
in classTypedAtomicActor
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Output a value if the count of iterations matches one of the entries in the indexes array. Otherwise output a zero token with the same type as the values in the value array.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classSource
- Throws:
IllegalActionException
- If the values and indexes parameters do not have the same length, or if there is no director.
-
initialize
public void initialize() throws IllegalActionException
Set the iteration count to zero.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classLimitedFiringSource
- Throws:
IllegalActionException
- If the parent class throws it.
-
postfire
public boolean postfire() throws IllegalActionException
Update the iteration counters until they exceed the values in the indexes array.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classLimitedFiringSource
- Returns:
- True if execution can continue into the next iteration.
- Throws:
IllegalActionException
- If the expression of indexes is not valid.
-
prefire
public boolean prefire() throws IllegalActionException
Start an iteration.- Specified by:
prefire
in interfaceExecutable
- Overrides:
prefire
in classSource
- Returns:
- True, unless the trigger input is connected and has no input.
- Throws:
IllegalActionException
- If the base class throws it.
-
-