ptolemy.actor.lib
Class TimedSource
java.lang.Object
ptolemy.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
- All Implemented Interfaces:
- Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable, TimedActor, TypedActor
- Direct Known Subclasses:
- Clock, CurrentTime, PoissonClock
- public class TimedSource
- extends Source
- implements TimedActor
Base class for time-based sources. A time-based source is
a source where the output value is a function of current time.
For some sequence-based domains, such as SDF, actors of this type
probably do not make sense because current time is not incremented.
This actor has a parameter, stopTime, that optionally controls
the duration for which the actor is fired. If this number is
t > 0.0, then when current time reaches t,
postfire() returns false. This indicates
to the director that this actor should not be invoked again.
The default value of stopTime is 0.0, which results in postfire
always returning true. In other words, this makes the lifetime
infinite. Derived classes must call super.postfire() for this mechanism to
work.
- Since:
- Ptolemy II 0.3
- Version:
- $Id: TimedSource.java,v 1.42 2004/04/13 03:04:45 cxh Exp $
- Author:
- Edward A. Lee
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
|
Field Summary |
Parameter |
stopTime
If greater than zero, then this parameter gives the time at which
postfire() should return false. |
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
|
Constructor Summary |
TimedSource(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name.
|
|
Method Summary |
void |
attributeChanged(Attribute attribute)
If the stopTime parameter is changed and the model is
executing, then if the new value is greater
than zero and greater than the current time, then ask the director
to fire this actor at that time. |
void |
initialize()
Initialize the actor. |
boolean |
postfire()
Return false if the current time is greater than or equal to
the stopTime parameter value.
|
void |
wrapup()
Override the base class to reset a flag that indicates that the
model is executing. |
| Methods inherited from class ptolemy.actor.lib.Source |
fire |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, clone, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate |
| 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.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 |
stopTime
public Parameter stopTime
- If greater than zero, then this parameter gives the time at which
postfire() should return false.
TimedSource
public TimedSource(CompositeEntity container,
java.lang.String name)
throws NameDuplicationException,
IllegalActionException
- Construct an actor with the given container and name.
The stopTime parameter is also constructed.
- Parameters:
container - The container.name - The name of this actor.
- Throws:
IllegalActionException - If the actor cannot be contained
by the proposed container.
NameDuplicationException - If the container already has an
actor with this name.
attributeChanged
public void attributeChanged(Attribute attribute)
throws IllegalActionException
- If the stopTime parameter is changed and the model is
executing, then if the new value is greater
than zero and greater than the current time, then ask the director
to fire this actor at that time. If the new value is less than
the current time, then request refiring at the current time.
- Overrides:
attributeChanged in class NamedObj
- Parameters:
attribute - The attribute that changed.
- Throws:
IllegalActionException - If the superclass throws it.
initialize
public void initialize()
throws IllegalActionException
- Initialize the actor. Schedule a refiring of this actor at the
stop time given by the stopTime parameter.
- Specified by:
initialize in interface Executable- Overrides:
initialize in class AtomicActor
- Throws:
IllegalActionException - If there is no director.
postfire
public boolean postfire()
throws IllegalActionException
- Return false if the current time is greater than or equal to
the stopTime parameter value.
Otherwise, return true. Derived classes should call this
at the end of their postfire() method and return its returned
value.
- Specified by:
postfire in interface Executable- Overrides:
postfire in class AtomicActor
- Returns:
- True if execution can continue into the next iteration.
- Throws:
IllegalActionException - Not thrown in this base class.
wrapup
public void wrapup()
throws IllegalActionException
- Override the base class to reset a flag that indicates that the
model is executing. This method is invoked exactly once per execution
of an application. None of the other action methods should be
be invoked after it.
- Specified by:
wrapup in interface Executable- Overrides:
wrapup in class AtomicActor
- Throws:
IllegalActionException - Not thrown in this base class.