ptolemy.domains.ct.lib
Class ContinuousClock

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.InstantiableNamedObj
          extended byptolemy.kernel.Entity
              extended byptolemy.kernel.ComponentEntity
                  extended byptolemy.actor.AtomicActor
                      extended byptolemy.actor.TypedAtomicActor
                          extended byptolemy.actor.lib.Source
                              extended byptolemy.actor.lib.TimedSource
                                  extended byptolemy.actor.lib.Clock
                                      extended byptolemy.domains.ct.lib.ContinuousClock
All Implemented Interfaces:
ptolemy.actor.Actor, ptolemy.kernel.util.Changeable, java.lang.Cloneable, ptolemy.kernel.util.Debuggable, ptolemy.kernel.util.DebugListener, ptolemy.kernel.util.Derivable, ptolemy.actor.Executable, ptolemy.kernel.util.Instantiable, ptolemy.kernel.util.ModelErrorHandler, ptolemy.kernel.util.MoMLExportable, ptolemy.kernel.util.Nameable, java.io.Serializable, TimedActor, ptolemy.actor.TypedActor
Direct Known Subclasses:
TriggeredContinuousClock

public class ContinuousClock
extends Clock

This is a clock source used in continuous time domain. It extends the clock actor in ptolemy/actor/lib directory but overrides the fire() method and postfire() method.

The actor uses the fireAt() method of the director to request firings at the beginning of each period plus each of the offsets, which are treated as breakpoints. At each breakpoint, the actor produces two outputs, one at t_minus phase and the other one at t_plus phase. The time does not advance at these two phases. For example, with the default settings, at time 1.0, the actor produces 0 at t_minus phase and 1 at t_plus phase. Note, at the breakpoint, we treat the output of this actor as any value between 0 and 1.

There is a defaultValue parameter which is used as output after the clock reachs the number of cycles. In the triggered continuous clock which extends this class, the defaultValue parameter is also used as output before the clock starts. The default value is 0.

The clock has a stopTime parameter and a numberOfCycles parameter. If the stopTime is a positive double, the whole model will stop execution when the stop time is reached. If the numberOfCycles is set to a positive integer, the clock will continue outputting the value of the defaultValue parameter after the number of cycles are reached.

Since:
Ptolemy II 2.2
Version:
$Id: ContinuousClock.java,v 1.18.2.2 2004/07/31 17:24:41 cxh Exp $
Author:
Edward A. Lee, Haiyang Zheng
See Also:
Clock, Serialized Form
Accepted Rating:
Red (hyzheng)
Proposed Rating:
Red (hyzheng)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
ptolemy.kernel.Entity.ContainedObjectsIterator
 
Field Summary
 ptolemy.data.expr.Parameter defaultValue
          The default value used after the clock stops.
 
Fields inherited from class ptolemy.actor.lib.Clock
_currentValue, _cycleCount, _cycleStartTime, _done, _offsets, _phase, _startTime, _tentativeCurrentValue, _tentativeCycleCount, _tentativeCycleCountIncrement, _tentativeCycleStartTime, _tentativeDone, _tentativeNextFiringTime, _tentativePhase, _tentativeStartTime, numberOfCycles, offsets, period, values
 
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
ContinuousClock(ptolemy.kernel.CompositeEntity container, java.lang.String name)
          Construct an actor with the specified container and name.
 
Method Summary
 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.
 void preinitialize()
          Make sure the continuous clock runs inside a CT domain.
 
Methods inherited from class ptolemy.actor.lib.Clock
_getValue, _initializeCycleCount, _updateTentativeValues, attributeChanged, clone, prefire
 
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, 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, 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

defaultValue

public ptolemy.data.expr.Parameter defaultValue
The default value used after the clock stops. In the triggered continuous clock, which extends this class and has a start trigger, the default value is used as output before the clock starts. This parameter must contain a token, and it defaults to 0.

Constructor Detail

ContinuousClock

public ContinuousClock(ptolemy.kernel.CompositeEntity container,
                       java.lang.String name)
                throws ptolemy.kernel.util.NameDuplicationException,
                       ptolemy.kernel.util.IllegalActionException
Construct an actor with the specified container and name.

Parameters:
container - The container.
name - The name of this actor.
Throws:
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

fire

public void fire()
          throws ptolemy.kernel.util.IllegalActionException
Output the current value of the clock.

Specified by:
fire in interface ptolemy.actor.Executable
Overrides:
fire in class Clock
Throws:
ptolemy.kernel.util.IllegalActionException - 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 ptolemy.kernel.util.IllegalActionException
Schedule the first firing and initialize local variables.

Specified by:
initialize in interface ptolemy.actor.Executable
Overrides:
initialize in class Clock
Throws:
ptolemy.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.

preinitialize

public void preinitialize()
                   throws ptolemy.kernel.util.IllegalActionException
Make sure the continuous clock runs inside a CT domain.

Throws:
ptolemy.kernel.util.IllegalActionException - If the director is not a CTDirector or the parent class throws it.

postfire

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

Specified by:
postfire in interface ptolemy.actor.Executable
Overrides:
postfire in class Clock
Throws:
ptolemy.kernel.util.IllegalActionException - If the director throws it when scheduling the next firing.