ptolemy.domains.wireless.lib
Class Triangulator

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.domains.wireless.lib.Triangulator
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 Triangulator
extends ptolemy.actor.TypedAtomicActor

Given inputs that represent the location of a sensor and the time at which those sensors detect an event, this actor outputs the location of the source of the event. It uses the specified signalPropagationSpeed and triangulates.

The input is a record with two fields named "location" and "time". The location field is an array of doubles, and the time is a double. In the current implementation, the actor assumes a two-dimensional space, so the location field is assumed to be an array with two doubles, which represent the horizontal (east-west) and vertical (north-south) location of the sensor. The time field is assumed to be a double representing the time at which the event was detected by the sensor.

The triangulation algorithm requires three distinct sensor inputs for the same event in order to be able to calculate the location of the origin of the event. Suppose that the event occurred at time t and location x. Suppose that three sensors at locations y1, y2, and y3 have each detected events at times t1, t2, and t3, respectively. Then this actor looks for a solution for x and t in the following equations: distance(x, y1)/v = t1 - t,
distance(x, y2)/v = t2 - t,
distance(x, y3)/v = t3 - t,
where v is the value of propagationSpeed. If such a solution is found, then the output x is produced.

Since three distinct observations are required, this actor will produce no output until it has received three distinct observations. The observations are distinct if the sensor locations are distinct. If the three observations yield no solution, then this actor will produce no output. However, it is possible for the three observations to come from distinct events, in which case the output may be erroneous. To guard against this, this actor provides a timeWindow parameter. The times of the three observations must be within the value of timeWindow, or no output will be produced. The output is an array of doubles, which in this implementation represent the X and Y locations of the event.

Since:
Ptolemy II 4.0
Version:
$Id: Triangulator.java,v 1.11 2004/04/13 03:38:25 cxh Exp $
Author:
Xiaojun Liu, Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Red (ptolemy)
Proposed Rating:
Yellow (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 for an event detection, which is a record containing the location of a sensor that has detected the event and the time at which the sensor detected the event.
 ptolemy.actor.TypedIOPort output
          The output producing the calculated event location.
 ptolemy.data.expr.Parameter signalPropagationSpeed
          Speed of propagation of the signal to be used for triangulation.
 ptolemy.data.expr.Parameter timeWindow
          Time window within which observations are assumed to come from the same sound event.
 
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
Triangulator(ptolemy.kernel.CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
 void fire()
          Read all available input tokens and attempt to use them to triangulate the signal source.
 void initialize()
          Override the base class to initialize the signal count.
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList
 
Methods inherited from class ptolemy.actor.AtomicActor
_createReceivers, clone, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, postfire, 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
iterate, postfire, 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

input

public ptolemy.actor.TypedIOPort input
The input port for an event detection, which is a record containing the location of a sensor that has detected the event and the time at which the sensor detected the event. This has type {location = {double}, time = double} The location is assumed to have two entries.


output

public ptolemy.actor.TypedIOPort output
The output producing the calculated event location. This has type {double}, a double array with two entries.


signalPropagationSpeed

public ptolemy.data.expr.Parameter signalPropagationSpeed
Speed of propagation of the signal to be used for triangulation. This is a double that defaults to 344.0 (the speed of sound in air at room temperature, in meters per second).


timeWindow

public ptolemy.data.expr.Parameter timeWindow
Time window within which observations are assumed to come from the same sound event. This is a double that defaults to 0.5 (in seconds).

Constructor Detail

Triangulator

public Triangulator(ptolemy.kernel.CompositeEntity container,
                    java.lang.String name)
             throws ptolemy.kernel.util.NameDuplicationException,
                    ptolemy.kernel.util.IllegalActionException
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

fire

public void fire()
          throws ptolemy.kernel.util.IllegalActionException
Read all available input tokens and attempt to use them to triangulate the signal source. If the attempt is successful, then output the location of the signal source. Otherwise, output nothing. This method keeps a buffer of the three most recently seen inputs from distinct sensors (as determined by their locations). If a new input token has a location field that matches a location already in the buffer, then the new input simply replaces that previous observation. Otherwise, it replaces the oldest observation in the buffer. If there are three observations in the buffer with time stamps within the timeWindow parameter value, then triangulation is performed, and if the the three observations are consistent, then an output is produced.

Throws:
ptolemy.kernel.util.IllegalActionException - If there is no director, or if the parameters cannot be evaluated.

initialize

public void initialize()
                throws ptolemy.kernel.util.IllegalActionException
Override the base class to initialize the signal count.

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