ptolemy.actor.lib
Class WallClockTime
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.WallClockTime
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
- Direct Known Subclasses:
- ButtonTime
public class WallClockTime
- extends Source
Upon firing, this actor outputs the elapsed real time in seconds
since the invocation of its initialize() method. The output type is double.
The resolution of time depends on the implementation of the Java
virtual machine, but with Sun's JDK 1.3 under Windows 2000, it is
10 milliseconds.
Note that relying on the data produced by this actor is tricky
in domains where you do not have precise control over the
scheduling, since the output reflects the wall-clock time at
which this actor is fired, which may or may not be indicative
of the times at which other actors fire. So that you can get
more control over the schedule, the input provided at the
trigger port is passed through to the passThrough
output port. This can be used to ensure that this actor
fires before another downstream actor.
- Since:
- Ptolemy II 2.0
- Version:
- $Id: WallClockTime.java 53042 2009-04-10 20:31:21Z cxh $
- Author:
- Edward A. Lee
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Method Summary |
protected double |
_getCurrentTime()
Get the elapsed time since the model starts. |
java.lang.Object |
clone(Workspace workspace)
Override the base class to set the type constraints on the ports. |
void |
fire()
Output the elapsed time in seconds since the invocation
of the initialize() method. |
void |
initialize()
Record the start time. |
Methods inherited from class ptolemy.actor.AtomicActor |
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, 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.util.NamedObj |
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, 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 |
passThrough
public TypedIOPort passThrough
- The output port to which the trigger input is passed.
The type is the same as the type of the trigger port,
which is undeclared, meaning that it will resolve to any type.
_startTime
private long _startTime
- The start time.
WallClockTime
public WallClockTime(CompositeEntity container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
- Construct an actor with the given container and name.
- 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.
clone
public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException
- Override the base class to set the type constraints on the ports.
- Overrides:
clone
in class AtomicActor
- Parameters:
workspace
- The workspace for the cloned object.
- Returns:
- A new instance of WallClockTime.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class includes
an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
fire
public void fire()
throws IllegalActionException
- Output the elapsed time in seconds since the invocation
of the initialize() method.
- Specified by:
fire
in interface Executable
- Overrides:
fire
in class Source
- Throws:
IllegalActionException
- If there is no director, or
if the base class throws it.
initialize
public void initialize()
throws IllegalActionException
- Record the start time.
- Specified by:
initialize
in interface Initializable
- Overrides:
initialize
in class AtomicActor
- Throws:
IllegalActionException
- If the base class throws it.
_getCurrentTime
protected double _getCurrentTime()
- Get the elapsed time since the model starts.
- Returns:
- A double value representing the elapsed time.