|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.Source
ptolemy.actor.lib.TimedSource
ptolemy.actor.lib.Clock
This actor produces a periodic signal, a sequence of events at regularly spaced intervals. It can generate finite pulses by specifying a finite numberOfCycles. The numberOfCycles has a default value as -1, indicating infinite length of executions. If numberOfCycles is a positive number, once the specified number of cycles has been completed, then this actor will output zeros with the same type as the values in the values parameter.
At the beginning of each time interval of length given by period, this actor initiates a sequence of output events with values given by values and offset into the period given by offsets. These parameters contain arrays, which are required to have the same length. The offsets array contains doubles, which must be nondecreasing and nonnegative, or an exception will be thrown when it is set. Moreover, its largest entry must be smaller than period or an exception will be thrown by the fire() method.
The values parameter by default contains an array of IntTokens with values 1 and 0. The default offsets array is {0.0, 1.0}. Thus, the default output will be alternating 1 and 0 with 50% duty cycle. The default period is 2.0.
The actor uses the fireAt() method of the director to request firing at the beginning of each period plus each of the offsets.
The type of the output can be any token type. This type is inferred from the element type of the values parameter.
This actor is a timed source; the untimed version is Pulse.
There is another kind of clock called ContinuousClock, which produces a square wave instead of a sequence of events. The ContinuousClock is a special actor for continuous-time domain.
ContinuousClock,
Serialized Form
| Yellow (yuhong) |
| Yellow (eal) |
| Nested Class Summary |
| Nested classes inherited from class ptolemy.kernel.Entity |
ptolemy.kernel.Entity.ContainedObjectsIterator |
| Field Summary | |
protected ptolemy.data.Token |
_currentValue
The current value of the clock output. |
protected int |
_cycleCount
The count of cycles executed so far, or 0 before the start. |
protected double |
_cycleStartTime
The most recent cycle start time. |
protected boolean |
_done
Indicator of whether the specified number of cycles have been completed. |
protected double[] |
_offsets
|
protected int |
_phase
The phase of the next output. |
protected double |
_startTime
The time at which output starts. |
protected ptolemy.data.Token |
_tentativeCurrentValue
|
protected int |
_tentativeCycleCount
|
protected int |
_tentativeCycleCountIncrement
|
protected double |
_tentativeCycleStartTime
|
protected boolean |
_tentativeDone
|
protected double |
_tentativeNextFiringTime
|
protected int |
_tentativePhase
|
protected double |
_tentativeStartTime
|
ptolemy.data.expr.Parameter |
numberOfCycles
The number of cycles to produce, or -1 to specify no limit. |
ptolemy.data.expr.Parameter |
offsets
The offsets at which the specified values will be produced. |
ptolemy.data.expr.Parameter |
period
The period of the output waveform. |
ptolemy.data.expr.Parameter |
values
The values that will be produced at the specified offsets. |
| Fields inherited from class ptolemy.actor.lib.TimedSource |
stopTime |
| Fields inherited from class ptolemy.actor.lib.Source |
output, trigger |
| Fields inherited from class ptolemy.actor.AtomicActor |
_stopRequested |
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
| Fields inherited from interface ptolemy.actor.Executable |
COMPLETED, NOT_READY, STOP_ITERATING |
| Constructor Summary | |
Clock(ptolemy.kernel.CompositeEntity container,
java.lang.String name)
Construct an actor with the specified container and name. |
|
| Method Summary | |
protected ptolemy.data.Token |
_getValue(int index)
|
protected void |
_initializeCycleCount()
Initialize the cycle count and done flag. |
protected void |
_updateTentativeValues()
Copy values committed in initialize() or in the last postfire() into the corresponding tentative variables. |
void |
attributeChanged(ptolemy.kernel.util.Attribute attribute)
If the argument is the offsets parameter, check that the array is nondecreasing and has the right dimension; if the argument is period, check that it is positive. |
java.lang.Object |
clone(ptolemy.kernel.util.Workspace workspace)
Clone the actor into the specified workspace. |
void |
fire()
Output the current value of the clock. |
void |
initialize()
Schedule the first firing and initialize local variables. |
boolean |
postfire()
Update the state of the actor and schedule the next firing, if appropriate. |
boolean |
prefire()
Check that the length of the values and offsets parameters are the same. |
| Methods inherited from class ptolemy.actor.lib.TimedSource |
wrapup |
| Methods inherited from class ptolemy.actor.TypedAtomicActor |
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate |
| Methods inherited from class ptolemy.kernel.ComponentEntity |
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, propagateExistence, setName |
| 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.InstantiableNamedObj |
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition |
| 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, 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 |
| Methods inherited from interface ptolemy.actor.Actor |
getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList |
| Methods inherited from interface ptolemy.actor.Executable |
iterate, preinitialize, stop, stopFire, terminate |
| Methods inherited from interface ptolemy.kernel.util.Derivable |
getDerivedLevel, getDerivedList, propagateValue |
| Methods inherited from interface ptolemy.kernel.util.Nameable |
description, getFullName, getName, getName |
| Field Detail |
public ptolemy.data.expr.Parameter numberOfCycles
public ptolemy.data.expr.Parameter offsets
public ptolemy.data.expr.Parameter period
public ptolemy.data.expr.Parameter values
protected transient ptolemy.data.Token _currentValue
protected transient int _cycleCount
protected transient double _cycleStartTime
protected transient boolean _done
protected transient int _phase
protected transient double _startTime
protected transient ptolemy.data.Token _tentativeCurrentValue
protected transient int _tentativeCycleCount
protected transient double _tentativeCycleStartTime
protected transient boolean _tentativeDone
protected transient double _tentativeStartTime
protected transient int _tentativePhase
protected transient double[] _offsets
protected transient int _tentativeCycleCountIncrement
protected transient double _tentativeNextFiringTime
| Constructor Detail |
public Clock(ptolemy.kernel.CompositeEntity container,
java.lang.String name)
throws ptolemy.kernel.util.NameDuplicationException,
ptolemy.kernel.util.IllegalActionException
container - The container.name - The name of this actor.
ptolemy.kernel.util.IllegalActionException - If the entity cannot be contained
by the proposed container.
ptolemy.kernel.util.NameDuplicationException - If the container already has an
actor with this name.| Method Detail |
public void attributeChanged(ptolemy.kernel.util.Attribute attribute)
throws ptolemy.kernel.util.IllegalActionException
attributeChanged in class TimedSourceattribute - The attribute that changed.
ptolemy.kernel.util.IllegalActionException - If the offsets array is not
nondecreasing and nonnegative.
public java.lang.Object clone(ptolemy.kernel.util.Workspace workspace)
throws java.lang.CloneNotSupportedException
workspace - The workspace for the new object.
java.lang.CloneNotSupportedException - If a derived class contains
an attribute that cannot be cloned.
public void fire()
throws ptolemy.kernel.util.IllegalActionException
fire in interface ptolemy.actor.Executablefire in class Sourceptolemy.kernel.util.IllegalActionException - If
the value in the offsets parameter is encountered that is greater
than the period, or if there is no director.
public void initialize()
throws ptolemy.kernel.util.IllegalActionException
initialize in interface ptolemy.actor.Executableinitialize in class TimedSourceptolemy.kernel.util.IllegalActionException - If the parent class throws it,
or if the values parameter is not a row vector, or if the
fireAt() method of the director throws it.
public boolean postfire()
throws ptolemy.kernel.util.IllegalActionException
postfire in interface ptolemy.actor.Executablepostfire in class TimedSourceptolemy.kernel.util.IllegalActionException - If the director throws it when
scheduling the next firing.
public boolean prefire()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException - If the values and
offsets parameters do not have the same length.
protected ptolemy.data.Token _getValue(int index)
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionExceptionprotected void _initializeCycleCount()
protected void _updateTentativeValues()
throws ptolemy.kernel.util.IllegalActionException
ptolemy.kernel.util.IllegalActionException - Not thrown in this base class.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||