
Clock |
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 returns false from the postfire method. FIXME: is this
the desired behavior?
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. One of their key differences
is that a Clock outputs a DISCRETE signal while a ContinuousClock outputs
a CONTINUOUS signal.
Author(s): Edward A. Lee, Haiyang Zheng
Version:$Id: Clock.java,v 1.99 2005/07/08 19:55:56 cxh Exp $
Pt.Proposed Rating:Yellow (eal)
Pt.Accepted Rating:Yellow (yuhong)
numberOfCycles
The number of cycles to produce, or -1 to specify no limit.
This is an integer with default -1.
offsets
The offsets at which the specified values will be produced.
This parameter must contain an array of doubles, and it defaults
to {0.0, 1.0}.
period
The period of the output waveform.
This parameter must contain a DoubleToken, and it defaults to 2.0.
values
The values that will be produced at the specified offsets.
This parameter must contain an ArrayToken, and it defaults to
{1, 0}