Package ptolemy.actor.lib
Class TimedSource
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TimedActor
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
Clock
,CurrentDate
,CurrentMicrostep
,CurrentTime
,DiscreteClock
,GetCurrentMicrostep
,TopLevelCurrentTime
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. When current time reaches the stopTime, postfire() returns false. This indicates to the director that this actor should not be invoked again. The default value of stopTime is Infinity, 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$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Green (bilung)
- Pt.ProposedRating:
- Green (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
stopTime
The time at which postfire() should return false.Parameter
stopTimeIsLocal
If true, use the local time to compare against the stopTime parameter, rather than the global time.-
Fields inherited from class ptolemy.actor.lib.Source
_triggered, output, trigger
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _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
Constructors Constructor Description TimedSource(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.Time
getModelStopTime()
Get the stop time.double
getStopTime()
Deprecated.As of Ptolemy II 4.1, replaced bygetModelStopTime()
void
initialize()
Initialize the actor.boolean
postfire()
Return false if the current time is greater than or equal to the stopTime parameter value.boolean
prefire()
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
_customTypeConstraints, fire
-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, 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
-
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
_addPort, _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, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, 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, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, 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.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
stopTime
public Parameter stopTime
The time at which postfire() should return false. This is a double that defaults to Infinity, which means that postfire() never returns false (or at least, doesn't do so due to stopTime having been exceeded).
-
stopTimeIsLocal
public Parameter stopTimeIsLocal
If true, use the local time to compare against the stopTime parameter, rather than the global time. Local time may differ from global time inside modal models and certain domains that manipulate time. This is a boolean that defaults to false.
-
-
Constructor Detail
-
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.
-
-
Method Detail
-
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 classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the superclass throws it.
-
getStopTime
@Deprecated public double getStopTime()
Deprecated.As of Ptolemy II 4.1, replaced bygetModelStopTime()
Get the stop time.- Returns:
- The stop time.
-
getModelStopTime
public Time getModelStopTime()
Get the stop time.- Returns:
- The stop time.
-
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 interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- 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 interfaceExecutable
- Overrides:
postfire
in classAtomicActor<TypedIOPort>
- Returns:
- True if execution can continue into the next iteration.
- Throws:
IllegalActionException
- Not thrown in this base class.
-
prefire
public boolean prefire() throws IllegalActionException
Return false if the current time is greater than or equal to the stopTime parameter value. Otherwise, return what the superclass returns.- Specified by:
prefire
in interfaceExecutable
- Overrides:
prefire
in classSource
- Returns:
- True, unless the trigger input is connected and has no input.
- 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 interfaceInitializable
- Overrides:
wrapup
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown in this base class.
-
-