Class Recorder
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
RecorderGeneral
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$
- 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
capacity
The capacity of the record for each channel.-
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 Recorder(CompositeEntity container, java.lang.String name)
Construct an actor with an input multiport that can accept any Token.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.Token
getLatest(int channel)
Get the latest input for the specified channel.java.util.Enumeration
getRecord(int channel)
Deprecated.This method is deprecated.java.util.List
getTimeHistory()
Get the history of the time of each invocation of postfire().java.util.Enumeration
getTimeRecord()
Deprecated.This method is deprecated.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
_containedTypeConstraints, _customTypeConstraints, _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, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, 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
_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, attributeChanged, 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
fire, isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
capacity
public Parameter capacity
The capacity of the record for each channel. This parameter must contain an IntToken.
-
-
Constructor Detail
-
Recorder
public Recorder(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct an actor with an input multiport that can accept any Token.- 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
-
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 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
@Deprecated 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
@Deprecated 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 IllegalActionException
Initialize the lists used to record input data.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If the parent class throws it.
-
postfire
public boolean postfire() throws IllegalActionException
Read at most one token from each input channel and record its value.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classAtomicActor<TypedIOPort>
- Returns:
- True if execution can continue into the next iteration.
- Throws:
IllegalActionException
- If there is no director.
-
-