ptolemy.actor.lib
Class ComputeHistogram

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.ComputeHistogram
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 ComputeHistogram
extends ptolemy.actor.TypedAtomicActor

Compute a histogram.

The output array consists of a set of vertical bars, each representing a histogram bin. The height of the bar is the count of the number of inputs that have been observed that fall within that bin. The n-th bin represents values in the range (x - w/2 + o, x + w/2 + o), where w is the value of the binWidth parameter, and o is the value of the binOffset parameter. So for example, if o = w/2, then each bin represents values from nw to (n + 1)w for some integer n. The default offset is 0.5, half the default bin width, which is 1.0.

This actor has a legend parameter, which gives a comma-separated list of labels to attach to each dataset. Normally, the number of elements in this list should equal the number of input channels, although this is not enforced.

Since:
Ptolemy II 4.0
Version:
$Id: ComputeHistogram.java,v 1.14 2004/04/13 03:02:37 cxh Exp $
Author:
Steve Neuendorffer
See Also:
Histogram, Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (eal)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
ptolemy.kernel.Entity.ContainedObjectsIterator
 
Field Summary
 ptolemy.actor.TypedIOPort input
          The input port of type double.
 ptolemy.data.expr.Parameter input_tokenConsumptionRate
          The parameter that determines the consumption rate of the input.
 PortParameter inputCount
          The number of tokens to compute the histogram for.
 ptolemy.data.expr.Parameter maximumValue
          The highest value that will be recorded in the histogram.
 ptolemy.data.expr.Parameter minimumValue
          The lowest value that will be recorded in the histogram.
 ptolemy.data.expr.Parameter numberOfBins
          The number of bins.
 ptolemy.actor.TypedIOPort output
          The input port of type array of integer.
 
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
ComputeHistogram(ptolemy.kernel.CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
 void attributeChanged(ptolemy.kernel.util.Attribute attribute)
          If the parameter is binWidth or binOffset, then configure the histogram with the specified bin width or offset.
 boolean postfire()
          Read at most one input token from each input channel and update the histogram.
 boolean prefire()
          Return false if the input does not have enough tokens to fire.
 
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, initialize, inputPortList, iterate, newReceiver, outputPortList, 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, 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, initialize, iterate, 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

minimumValue

public ptolemy.data.expr.Parameter minimumValue
The lowest value that will be recorded in the histogram. This parameter has type double, with default value 0.0.


maximumValue

public ptolemy.data.expr.Parameter maximumValue
The highest value that will be recorded in the histogram. This parameter has type double, with default value 1.0.


numberOfBins

public ptolemy.data.expr.Parameter numberOfBins
The number of bins. This parameter has type int, with default value 10.


inputCount

public PortParameter inputCount
The number of tokens to compute the histogram for.


input_tokenConsumptionRate

public ptolemy.data.expr.Parameter input_tokenConsumptionRate
The parameter that determines the consumption rate of the input.


input

public ptolemy.actor.TypedIOPort input
The input port of type double.


output

public ptolemy.actor.TypedIOPort output
The input port of type array of integer.

Constructor Detail

ComputeHistogram

public ComputeHistogram(ptolemy.kernel.CompositeEntity container,
                        java.lang.String name)
                 throws ptolemy.kernel.util.IllegalActionException,
                        ptolemy.kernel.util.NameDuplicationException
Construct an actor with the given container and name.

Parameters:
container - The container.
name - The name of this actor.
Throws:
ptolemy.kernel.util.IllegalActionException - If the actor cannot be contained by the proposed container.
ptolemy.kernel.util.NameDuplicationException - If the container already has an actor with this name.
Method Detail

attributeChanged

public void attributeChanged(ptolemy.kernel.util.Attribute attribute)
                      throws ptolemy.kernel.util.IllegalActionException
If the parameter is binWidth or binOffset, then configure the histogram with the specified bin width or offset.

Parameters:
attribute - The attribute that changed.
Throws:
ptolemy.kernel.util.IllegalActionException - If the bin width is not positive.

postfire

public boolean postfire()
                 throws ptolemy.kernel.util.IllegalActionException
Read at most one input token from each input channel and update the histogram. This is done in postfire to ensure that data has settled.

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

prefire

public boolean prefire()
                throws ptolemy.kernel.util.IllegalActionException
Return false if the input does not have enough tokens to fire. Otherwise, return true.

Returns:
False if the number of input tokens available is not at least equal to the decimation parameter multiplied by the blockSize parameter.
Throws:
ptolemy.kernel.util.IllegalActionException - If the superclass throws it.