ptolemy.actor.lib
Class Recorder

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.Sink
                              extended byptolemy.actor.lib.Recorder
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, ptolemy.actor.TypedActor

public class Recorder
extends Sink

Record all input tokens for later querying. This actor can be used for testing configurations of actors. It can also be used in programs that invoke Ptolemy models and wish to query the results after the model is run. The input tokens are read in the postfire() method so that in domains with fixed-point semantics, only the final, settled value is recorded. The current time is also recorded for each value.

The capacity parameter limits the size of the record. If the capacity is set to zero, then no tokens are recorded, but the total number of input tokens is counted. You can access the count via the getCount() method. If the capacity is 1, then only the most recently seen token on each channel is recorded. If the capacity is negative (the default), then the capacity is infinite.

Since:
Ptolemy II 0.3
Version:
$Id: Recorder.java,v 1.32 2004/04/13 05:12:27 cxh Exp $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Green (bilung)
Proposed Rating:
Green (eal)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
ptolemy.kernel.Entity.ContainedObjectsIterator
 
Field Summary
 ptolemy.data.expr.Parameter capacity
          The capacity of the record for each channel.
 
Fields inherited from class ptolemy.actor.lib.Sink
input
 
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
Recorder(ptolemy.kernel.CompositeEntity container, java.lang.String name)
          Construct an actor with an input multiport that can accept any Token.
 
Method Summary
 int getCount()
          Get the total number of events seen so far.
 java.util.List getHistory(int channel)
          Get the history for the specified channel number.
 ptolemy.data.Token getLatest(int channel)
          Get the latest input for the specified channel.
 java.util.Enumeration getRecord(int channel)
          Deprecated. This method is deprecated. Use getHistory().
 java.util.List getTimeHistory()
          Get the history of the time of each invocation of postfire().
 java.util.Enumeration getTimeRecord()
          Deprecated. This method is deprecated. Use getTimeHistory().
 void initialize()
          Initialize the lists used to record input data.
 boolean postfire()
          Read at most one token from each input channel and record its value.
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList
 
Methods inherited from class ptolemy.actor.AtomicActor
_createReceivers, clone, connectionsChanged, fire, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate, wrapup
 
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, attributeChanged, 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
fire, iterate, prefire, preinitialize, stop, stopFire, terminate, wrapup
 
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

capacity

public ptolemy.data.expr.Parameter capacity
The capacity of the record for each channel. This parameter must contain an IntToken.

Constructor Detail

Recorder

public Recorder(ptolemy.kernel.CompositeEntity container,
                java.lang.String name)
         throws ptolemy.kernel.util.NameDuplicationException,
                ptolemy.kernel.util.IllegalActionException
Construct an actor with an input multiport that can accept any Token.

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

getCount

public int getCount()
Get the total number of events seen so far.

Returns:
The total number of events seen so far.

getHistory

public java.util.List getHistory(int channel)
Get the history for the specified channel number. If in any firing there is no such channel, or no token was read on that channel, then a string token with value "_" is returned in the position of the list corresponding to that firing. If nothing has been recorded (there have been no firings), then return an empty list.

Parameters:
channel - The input channel for which the history is desired.
Returns:
A list of Token objects.

getLatest

public ptolemy.data.Token getLatest(int channel)
Get the latest input for the specified channel. If there has been no record yet for the specified channel, then return the string token "_", representing "bottom".

Parameters:
channel - The input channel for the record is desired.
Returns:
The latest input token.

getRecord

public java.util.Enumeration getRecord(int channel)
Deprecated. This method is deprecated. Use getHistory().

Get the record for the specified channel number. If in any firing there is no such channel, or no token was read on that channel, then a string token with value "_" is returned. If nothing has been recorded (there have been no firings), then return an empty enumeration.

Parameters:
channel - The input channel for the record is desired.
Returns:
An enumeration of Token objects.

getTimeHistory

public java.util.List getTimeHistory()
Get the history of the time of each invocation of postfire().

Returns:
A list of Double objects.

getTimeRecord

public java.util.Enumeration getTimeRecord()
Deprecated. This method is deprecated. Use getTimeHistory().

Get the record of the current time of each invocation of postfire().

Returns:
An enumeration of Double objects.

initialize

public void initialize()
                throws ptolemy.kernel.util.IllegalActionException
Initialize the lists used to record input data.

Throws:
ptolemy.kernel.util.IllegalActionException - If the parent class throws it.

postfire

public boolean postfire()
                 throws ptolemy.kernel.util.IllegalActionException
Read at most one token from each input channel and record its value.

Throws:
ptolemy.kernel.util.IllegalActionException - If there is no director.