ptolemy.domains.ct.lib
Class ContinuousClock

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.actor.lib.Source
                              extended by ptolemy.actor.lib.TimedSource
                                  extended by ptolemy.domains.ct.lib.DiscreteClock
                                      extended by ptolemy.domains.ct.lib.ContinuousClock
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TimedActor, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
TriggeredContinuousClock

public class ContinuousClock
extends DiscreteClock

This is a clock source used in continuous-time (CT) domain. It extends the clock actor in ptolemy/actor/lib directory but overrides the fire, initialize, preinitialize and postfire method. This actor serves as a wave form generator in CT domain.

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 time t, which is between t_minus and t_plus, the possible output of this actor can be any value between 0 and 1.

The clock has a stopTime parameter and a numberOfCycles parameter. 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 if the stop time is not reached.

Since:
Ptolemy II 2.2
Version:
$Id: ContinuousClock.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee, Haiyang Zheng
See Also:
Clock, Serialized Form
Accepted Rating:
Red (hyzheng)
Proposed Rating:
Red (hyzheng)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
 Parameter defaultValue
          The default value used after the clock stops.
 
Fields inherited from class ptolemy.domains.ct.lib.DiscreteClock
_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, stopTimeIsLocal
 
Fields inherited from class ptolemy.actor.lib.Source
output, trigger
 
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
ContinuousClock(CompositeEntity container, java.lang.String name)
          Construct an actor with the specified container and name.
 
Method Summary
 void fire()
          Update the state of the actor and schedule the next firing, if appropriate.Output the current value of the clock.
 void initialize()
          Schedule the first firing and initialize local variables.
 boolean postfire()
          Return false if the current model time exceeds the model stop time.
 void preinitialize()
          Make sure the continuous clock runs inside a CT domain.
 
Methods inherited from class ptolemy.domains.ct.lib.DiscreteClock
_getValue, _initializeCycleCount, _updateStates, _updateTentativeValues, attributeChanged, clone, prefire
 
Methods inherited from class ptolemy.actor.lib.TimedSource
getModelStopTime, getStopTime, wrapup
 
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, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
 
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, removeInitializable
 
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

defaultValue

public 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(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

fire

public void fire()
          throws IllegalActionException
Update the state of the actor and schedule the next firing, if appropriate.Output the current value of the clock.

Specified by:
fire in interface Executable
Overrides:
fire in class DiscreteClock
Throws:
IllegalActionException - If output can not send value.

initialize

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

Specified by:
initialize in interface Initializable
Overrides:
initialize in class DiscreteClock
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.

preinitialize

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

Specified by:
preinitialize in interface Initializable
Overrides:
preinitialize in class AtomicActor
Throws:
IllegalActionException - If the director is not a CTDirector or the parent class throws it.

postfire

public boolean postfire()
                 throws IllegalActionException
Return false if the current model time exceeds the model stop time. Otherwise, return true.

Specified by:
postfire in interface Executable
Overrides:
postfire in class DiscreteClock
Returns:
false if the current model time exceeds the model stop time.
Throws:
IllegalActionException - If the director throws it when scheduling the next firing.