ptolemy.domains.wireless.lib
Class ErasureChannel

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.actor.AtomicActor
                      extended by ptolemy.actor.TypedAtomicActor
                          extended by ptolemy.domains.wireless.kernel.AtomicWirelessChannel
                              extended by ptolemy.domains.wireless.lib.ErasureChannel
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, ChannelListener, PropertyTransformer, WirelessChannel, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, ValueListener
Direct Known Subclasses:
DelayChannel

public class ErasureChannel
extends AtomicWirelessChannel

Model of a wireless channel with a specified loss probability. If the loss probability is greater than zero then on each call to the transmit() method, for each receiver in range, with the specified probability, the transmission to that receiver will not occur. Whether a transmission occurs to a particular receiver is independent of whether it occurs to any other receiver.

For convenience, a variable named "distance" is available and equal to the distance between the transmitter and the receiver when the lossProbability is evaluated. Thus, the loss probability can be given as an expression that depends on this distance.

The distance between the transmitter and receiver is determined by the protected method _distanceBetween(), which is also used to set the value of the distance variable that can be used in the expression for loss probability. In this base class, that method uses the _location attribute of the transmit and receive actors, which corresponds to the position of the icon in the Vergil visual editor. Subclasses may override this protected method to provide some other notion of distance.

Since:
Ptolemy II 4.0
Version:
$Id: ErasureChannel.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Yellow (cxh)
Proposed Rating:
Green (cxh)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
protected  java.util.Random _random
          A random number generator.
 Variable distance
          A variable that is set to the distance between the transmitter and the receiver before the powerLossFactor expression is evaluated.
 Parameter lossProbability
          The probability that a call to transmit() will fail to deliver the token to a receiver that is in range.
 Parameter seed
          The seed that controls the random number generation.
 
Fields inherited from class ptolemy.domains.wireless.kernel.AtomicWirelessChannel
_receiversInRangeCacheValid, defaultProperties, name
 
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _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
ErasureChannel(CompositeEntity container, java.lang.String name)
          Construct a channel with the given name and container.
 
Method Summary
protected  void _transmitTo(Token token, WirelessIOPort sender, WirelessReceiver receiver, RecordToken properties)
          Transmit the specified token to the specified receiver.
 java.lang.Object clone(Workspace workspace)
          Clone the object into the specified workspace.
 void initialize()
          Initialize the random number generator with the seed, if it has been given.
 
Methods inherited from class ptolemy.domains.wireless.kernel.AtomicWirelessChannel
_distanceBetween, _isInRange, _locationOf, _receiversInRange, addChannelListener, channelNotify, getChannelPort, listeningInputPorts, listeningOutputPorts, preinitialize, registerPropertyTransformer, removeChannelListener, sendingInputPorts, sendingOutputPorts, transformProperties, transmit, unregisterPropertyTransformer, valueChanged
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, 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.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
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
 
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
fire, isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, removeInitializable, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

lossProbability

public Parameter lossProbability
The probability that a call to transmit() will fail to deliver the token to a receiver that is in range. This is a double that defaults to 0.0, which means that no loss occurs.


seed

public Parameter seed
The seed that controls the random number generation. A seed of zero is interpreted to mean that no seed is specified, which means that each execution of the model could result in distinct data. For the value 0, the seed is set to System.currentTimeMillis() + hashCode(), which means that with extremely high probability, two distinct actors will have distinct seeds. However, current time may not have enough resolution to ensure that two subsequent executions of the same model have distinct seeds. This parameter contains a LongToken, initially with value 0.


distance

public Variable distance
A variable that is set to the distance between the transmitter and the receiver before the powerLossFactor expression is evaluated.


_random

protected java.util.Random _random
A random number generator.

Constructor Detail

ErasureChannel

public ErasureChannel(CompositeEntity container,
                      java.lang.String name)
               throws IllegalActionException,
                      NameDuplicationException
Construct a channel with the given name and container. The container argument must not be null, or a NullPointerException will be thrown. If the name argument is null, then the name is set to the empty string.

Parameters:
container - The container.
name - The name of the channel.
Throws:
IllegalActionException - If the container is incompatible.
NameDuplicationException - If the name coincides with a relation already in the container.
Method Detail

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Clone the object into the specified workspace. The new object is not added to the directory of that workspace (you must do this yourself if you want it there).

Overrides:
clone in class AtomicWirelessChannel
Parameters:
workspace - The workspace for the cloned object.
Returns:
The new Attribute.
Throws:
java.lang.CloneNotSupportedException - Not thrown in this base class
See Also:
NamedObj.exportMoML(Writer, int, String), NamedObj.setDeferringChangeRequests(boolean)

initialize

public void initialize()
                throws IllegalActionException
Initialize the random number generator with the seed, if it has been given.

Specified by:
initialize in interface Initializable
Overrides:
initialize in class AtomicActor
Throws:
IllegalActionException - If the parent class throws it.

_transmitTo

protected void _transmitTo(Token token,
                           WirelessIOPort sender,
                           WirelessReceiver receiver,
                           RecordToken properties)
                    throws IllegalActionException
Transmit the specified token to the specified receiver. If the lossProbability is zero, (the default) then the specified receiver will receive the token if it has room. If lossProbability is greater than zero, the token will be lost with the specified probability, independently for each channel in range. Note that in this base class, a port is in range if it refers to this channel by name and is at the right place in the hierarchy. This base class makes no use of the properties argument. But derived classes may limit the range or otherwise change transmission properties using this argument.

Overrides:
_transmitTo in class AtomicWirelessChannel
Parameters:
token - The token to transmit, or null to clear the specified receiver.
sender - The sending port.
receiver - The receiver to which to transmit.
properties - The transmit properties (ignored in this base class).
Throws:
IllegalActionException - If the token cannot be converted or if the token argument is null and the destination receiver does not support clear.