ptolemy.backtrack.automatic.ptolemy.actor.lib
Class SequentialClock

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.actor.AtomicActor
                      extended by ptolemy.actor.TypedAtomicActor
                          extended by ptolemy.backtrack.automatic.ptolemy.actor.lib.SequentialClock
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, SequenceActor, TypedActor, Rollbackable, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

Deprecated. Use Clock instead.

public class SequentialClock
extends TypedAtomicActor
implements SequenceActor, Rollbackable

A clock source for sequence-capable domains. This actor is considerably simpler than the Clock actor. On each firing, it produces the next value from its values parameter, and schedules another firing at a future time determined by the offsets and period parameters.

This actor can be used in the DE domain to generate a sequence of events at regularly spaced intervals. It cannot be used in CT, because CT will invoke it at times where it has not requested a firing, and it will inappropriately advance to the next output value.

At the beginning of each time interval of length given by period, it 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 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. It assumes that all of its firings are in response to such requests.

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.

Since:
Ptolemy II 1.0
Version:
$Id: SequentialClock.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Red (yuhong)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
private  Token _currentValue
          Deprecated.  
private  Time _cycleStartTime
          Deprecated.  
private  boolean _firstFiring
          Deprecated.  
private  double[] _offsets
          Deprecated.  
private  int _phase
          Deprecated.  
protected  Checkpoint $CHECKPOINT
          Deprecated.  
private  FieldRecord $RECORD$_currentValue
          Deprecated.  
private  FieldRecord $RECORD$_cycleStartTime
          Deprecated.  
private  FieldRecord $RECORD$_firstFiring
          Deprecated.  
private  FieldRecord $RECORD$_offsets
          Deprecated.  
private  FieldRecord $RECORD$_phase
          Deprecated.  
protected  CheckpointRecord $RECORD$$CHECKPOINT
          Deprecated.  
private  FieldRecord[] $RECORDS
          Deprecated.  
 Parameter offsets
          Deprecated. The offsets at which the specified values will be produced.
 TypedIOPort output
          Deprecated. The output port.
 Parameter period
          Deprecated. The period of the output waveform.
 Parameter values
          Deprecated. The values that will be produced at the specified offsets.
 
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _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
SequentialClock(CompositeEntity container, java.lang.String name)
          Deprecated. Construct an actor with the specified container and name.
 
Method Summary
private  Token $ASSIGN$_currentValue(Token newValue)
          Deprecated.  
private  Time $ASSIGN$_cycleStartTime(Time newValue)
          Deprecated.  
private  boolean $ASSIGN$_firstFiring(boolean newValue)
          Deprecated.  
private  double[] $ASSIGN$_offsets(double[] newValue)
          Deprecated.  
private  double $ASSIGN$_offsets(int index0, double newValue)
          Deprecated.  
private  int $ASSIGN$_phase(int newValue)
          Deprecated.  
private  int $ASSIGN$SPECIAL$_phase(int operator, long newValue)
          Deprecated.  
 void $COMMIT(long timestamp)
          Deprecated. Commit changes up to the given timestamp, but not including changes made at timestamp and afterward.
 Checkpoint $GET$CHECKPOINT()
          Deprecated. Get the checkpoint object that monitors this rollbackable object.
 void $RESTORE(long timestamp, boolean trim)
          Deprecated. Restore a previous state to all the private fields of this rollbackable object.
 java.lang.Object $SET$CHECKPOINT(Checkpoint checkpoint)
          Deprecated. Set the checkpoint object of this rollbackable object.
 void attributeChanged(Attribute attribute)
          Deprecated. 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(Workspace workspace)
          Deprecated. Clone the actor into the specified workspace.
 void fire()
          Deprecated. Output the current value of the clock.
 void initialize()
          Deprecated. Schedule the first firing and initialize local variables.
 boolean postfire()
          Deprecated. Update the state of the actor and schedule the next firing, if appropriate.
 boolean prefire()
          Deprecated. Set the current value.
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, 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
_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, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, 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
 
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
 
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
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

$CHECKPOINT

protected transient Checkpoint $CHECKPOINT
Deprecated. 

output

public TypedIOPort output
Deprecated. 
The output port. The type of this port is determined by from the values parameter.


offsets

public Parameter offsets
Deprecated. 
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

public Parameter period
Deprecated. 
The period of the output waveform. This parameter must contain a DoubleToken, and defaults to 2.0.


values

public Parameter values
Deprecated. 
The values that will be produced at the specified offsets. This parameter must contain an ArrayToken, and defaults to {1, 0}.


_currentValue

private transient Token _currentValue
Deprecated. 

_cycleStartTime

private transient Time _cycleStartTime
Deprecated. 

_firstFiring

private boolean _firstFiring
Deprecated. 

_offsets

private transient double[] _offsets
Deprecated. 

_phase

private transient int _phase
Deprecated. 

$RECORD$$CHECKPOINT

protected transient CheckpointRecord $RECORD$$CHECKPOINT
Deprecated. 

$RECORD$_currentValue

private transient FieldRecord $RECORD$_currentValue
Deprecated. 

$RECORD$_cycleStartTime

private transient FieldRecord $RECORD$_cycleStartTime
Deprecated. 

$RECORD$_firstFiring

private transient FieldRecord $RECORD$_firstFiring
Deprecated. 

$RECORD$_offsets

private transient FieldRecord $RECORD$_offsets
Deprecated. 

$RECORD$_phase

private transient FieldRecord $RECORD$_phase
Deprecated. 

$RECORDS

private transient FieldRecord[] $RECORDS
Deprecated. 
Constructor Detail

SequentialClock

public SequentialClock(CompositeEntity container,
                       java.lang.String name)
                throws NameDuplicationException,
                       IllegalActionException
Deprecated. 
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
Deprecated. 
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. Other sanity checks with period and values are done in the fire() method.

Overrides:
attributeChanged in class NamedObj
Parameters:
attribute - The attribute that changed.
Throws:
IllegalActionException - If the offsets array is not nondecreasing and nonnegative, or it is not a row vector.

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Deprecated. 
Clone the actor into the specified workspace. This calls the base class and then sets the parameter public members to refer to the parameters of the new actor.

Overrides:
clone in class AtomicActor
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
Deprecated. 
Output the current value of the clock.

Specified by:
fire in interface Executable
Overrides:
fire in class AtomicActor
Throws:
IllegalActionException - If the values and offsets parameters do not have the same length, or if the value in the offsets parameter is encountered that is greater than the period, or if there is no director.

initialize

public void initialize()
                throws IllegalActionException
Deprecated. 
Schedule the first firing and initialize local variables.

Specified by:
initialize in interface Initializable
Overrides:
initialize in class AtomicActor
Throws:
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, or if the director does not agree to fire the actor at the specified time.

postfire

public boolean postfire()
                 throws IllegalActionException
Deprecated. 
Update the state of the actor and schedule the next firing, if appropriate.

Specified by:
postfire in interface Executable
Overrides:
postfire in class AtomicActor
Returns:
True if execution can continue into the next iteration.
Throws:
IllegalActionException - If the director throws it when scheduling the next firing, or if the length of the values and offsets parameters don't match.

prefire

public boolean prefire()
                throws IllegalActionException
Deprecated. 
Set the current value.

Specified by:
prefire in interface Executable
Overrides:
prefire in class AtomicActor
Returns:
True.
Throws:
IllegalActionException - If there is no director.

$ASSIGN$_currentValue

private final Token $ASSIGN$_currentValue(Token newValue)
Deprecated. 

$ASSIGN$_cycleStartTime

private final Time $ASSIGN$_cycleStartTime(Time newValue)
Deprecated. 

$ASSIGN$_firstFiring

private final boolean $ASSIGN$_firstFiring(boolean newValue)
Deprecated. 

$ASSIGN$_offsets

private final double[] $ASSIGN$_offsets(double[] newValue)
Deprecated. 

$ASSIGN$_offsets

private final double $ASSIGN$_offsets(int index0,
                                      double newValue)
Deprecated. 

$ASSIGN$_phase

private final int $ASSIGN$_phase(int newValue)
Deprecated. 

$ASSIGN$SPECIAL$_phase

private final int $ASSIGN$SPECIAL$_phase(int operator,
                                         long newValue)
Deprecated. 

$COMMIT

public void $COMMIT(long timestamp)
Deprecated. 
Description copied from interface: Rollbackable
Commit changes up to the given timestamp, but not including changes made at timestamp and afterward.

Specified by:
$COMMIT in interface Rollbackable
Parameters:
timestamp - The timestamp.

$RESTORE

public void $RESTORE(long timestamp,
                     boolean trim)
Deprecated. 
Description copied from interface: Rollbackable
Restore a previous state to all the private fields of this rollbackable object.

Specified by:
$RESTORE in interface Rollbackable
Parameters:
timestamp - The timestamp taken at the time when the previous state was recorded.
trim - Whether to delete the records used for the rollback.
See Also:
Checkpoint.rollback(long, boolean)

$GET$CHECKPOINT

public final Checkpoint $GET$CHECKPOINT()
Deprecated. 
Description copied from interface: Rollbackable
Get the checkpoint object that monitors this rollbackable object.

Specified by:
$GET$CHECKPOINT in interface Rollbackable
Returns:
The checkpoint object.

$SET$CHECKPOINT

public final java.lang.Object $SET$CHECKPOINT(Checkpoint checkpoint)
Deprecated. 
Description copied from interface: Rollbackable
Set the checkpoint object of this rollbackable object. A merge operation is performed on the current checkpoint object and the new checkpoint object, so that the two checkpoint objects monitor the same set of objects when this function returns.

Specified by:
$SET$CHECKPOINT in interface Rollbackable
Parameters:
checkpoint - The new checkpoint object.
Returns:
This rollbackable object itself.
See Also:
Checkpoint.setCheckpoint(Checkpoint)