|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.domains.wireless.kernel.AtomicWirelessChannel
public class AtomicWirelessChannel
The base class for communication channels in the wireless domain.
To use this class, place it in a wireless model that contains a wireless director and wireless actors (actors whose ports are instances of WirelessIOPort). Then set the outsideChannel parameter of those ports to match the name of this channel. The model can also itself contain ports that are instances of WirelessIOPort, in which case their insideChannel parameter should contain the name of this channel if they should use this channel.
In this base class, transmission on a channel reaches all ports at the same level of the hierarchy that are instances of WirelessIOPort and that specify that they use this channel. These ports include those contained by entities that have the container as this channel and that have their outsideChannel parameter set to the name of this channel. They also include those ports whose containers are the same as the container of this channel and whose insideChannel parameter matches this channel name.
Derived classes will typically limit the range of the transmission, using for example location information from the ports. They may also introduce random losses or corruption of data. To do this, derived classes can override the _isInRange() protected method, or the transmit() public method.
Other classes may register a property transformer that allows them to modify meta data prior to transmission of the data token on the channel.
Yellow (cxh) |
Green (cxh) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.Entity |
---|
Entity.ContainedObjectsIterator |
Field Summary | |
---|---|
private java.util.Set |
_channelListeners
The channel listeners that have been added. |
private ChannelPort |
_channelPort
Dummy port used to reduce the type constraints to 2N rather than N^2. |
private java.util.List |
_listeningInputPorts
|
private long |
_listeningInputPortsVersion
|
private java.util.List |
_listeningOutputPorts
|
private long |
_listeningOutputPortsVersion
|
private java.util.Set |
_propertyTransformers
The property transformers that have been registered without specifying a port. |
private java.util.HashMap |
_propertyTransformersByPort
The property transformers that have been registered to operate on transmissions from a particular port, indexed by port. |
private java.util.HashMap |
_receiversInRangeCache
|
protected boolean |
_receiversInRangeCacheValid
Flag indicating that the cached list of receivers in range is valid. |
private java.util.HashMap |
_receiversInRangeCacheVersion
|
private java.util.List |
_sendingInputPorts
|
private long |
_sendingInputPortsVersion
|
private java.util.List |
_sendingOutputPorts
|
private long |
_sendingOutputPortsVersion
|
Parameter |
defaultProperties
The default properties for transmission. |
private static java.lang.String |
LOCATION_ATTRIBUTE_NAME
|
NameParameter |
name
When set to a non-empty value, this NameParameter will cause the name of this channel to be set to this value. |
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 | |
---|---|
AtomicWirelessChannel(CompositeEntity container,
java.lang.String name)
Construct a relation with the given name contained by the specified entity. |
Method Summary | |
---|---|
protected double |
_distanceBetween(WirelessIOPort port1,
WirelessIOPort port2)
Return the distance between two ports. |
protected boolean |
_isInRange(WirelessIOPort source,
WirelessIOPort destination,
RecordToken properties)
Return true if the specified destination port is in range of the specified source port, assuming the source port transmits with the specified properties. |
protected double[] |
_locationOf(IOPort port)
Return the location of the given port. |
protected java.util.List |
_receiversInRange(WirelessIOPort sourcePort,
RecordToken properties)
Return the list of receivers that can receive from the specified port with the specified transmission properties. |
protected void |
_transmitTo(Token token,
WirelessIOPort sender,
WirelessReceiver receiver,
RecordToken properties)
Transmit the specified token to the specified receiver. |
void |
addChannelListener(ChannelListener listener)
Add a channel listener to listen for transmissions on this channel. |
void |
channelNotify(RecordToken properties,
Token token,
WirelessIOPort source,
WirelessIOPort destination)
Notify any channel listeners that have been added. |
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace. |
ChannelPort |
getChannelPort()
Return a channel port that can be used to set type constraints between senders and receivers. |
java.util.List |
listeningInputPorts()
Return a list of input ports that can potentially receive data from this channel. |
java.util.List |
listeningOutputPorts()
Return a list of output ports that can potentially receive data from this channel. |
void |
preinitialize()
Override the base class to declare that the dummy port returned by getChannelPort() does not depend on itself in a firing. |
void |
registerPropertyTransformer(PropertyTransformer transformer,
WirelessIOPort port)
Register a property transformer for transmissions from the specified port. |
void |
removeChannelListener(ChannelListener listener)
Remove a channel listener for transmissions on this channel. |
java.util.List |
sendingInputPorts()
Return a list of input ports that can potentially send data to this channel. |
java.util.List |
sendingOutputPorts()
Return a list of output ports that can potentially send data to this channel. |
RecordToken |
transformProperties(RecordToken properties,
WirelessIOPort source,
WirelessIOPort destination)
Transform the transmission property to take into account channel losses, noise, etc., for transmission between the specified source and the specified destination. |
void |
transmit(Token token,
WirelessIOPort port,
RecordToken properties)
Transmit the specified token from the specified port with the specified properties. |
void |
unregisterPropertyTransformer(PropertyTransformer transformer,
WirelessIOPort port)
Unregister a property transformer for transmissions from the specified port (or from null for a generic property transformer). |
void |
valueChanged(Settable settable)
React to changes of the specified Settable. |
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, initialize, 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 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, initialize, 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 |
---|
public Parameter defaultProperties
public NameParameter name
protected boolean _receiversInRangeCacheValid
private java.util.List _listeningInputPorts
private long _listeningInputPortsVersion
private java.util.List _listeningOutputPorts
private long _listeningOutputPortsVersion
private java.util.Set _propertyTransformers
private java.util.HashMap _propertyTransformersByPort
private java.util.Set _channelListeners
private java.util.HashMap _receiversInRangeCache
private java.util.HashMap _receiversInRangeCacheVersion
private java.util.List _sendingInputPorts
private long _sendingInputPortsVersion
private java.util.List _sendingOutputPorts
private long _sendingOutputPortsVersion
private static final java.lang.String LOCATION_ATTRIBUTE_NAME
private ChannelPort _channelPort
Constructor Detail |
---|
public AtomicWirelessChannel(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of the relation.
IllegalActionException
- If the container is incompatible
with this relation.
NameDuplicationException
- If the name coincides with
a relation already in the container.Method Detail |
---|
public void addChannelListener(ChannelListener listener)
addChannelListener
in interface WirelessChannel
listener
- The channel listener to add.removeChannelListener(ChannelListener)
public void channelNotify(RecordToken properties, Token token, WirelessIOPort source, WirelessIOPort destination)
channelNotify
in interface ChannelListener
properties
- The transmission properties.token
- The token to be processed.source
- The sending port.destination
- The receiving port.addChannelListener(ChannelListener)
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class AtomicActor
workspace
- The workspace for the cloned object.
java.lang.CloneNotSupportedException
- Not thrown in this base classNamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public ChannelPort getChannelPort()
getChannelPort
in interface WirelessChannel
public java.util.List listeningInputPorts() throws IllegalActionException
listeningInputPorts
in interface WirelessChannel
IllegalActionException
- If a port is encountered
whose outsideChannel parameter cannot be evaluated.public java.util.List listeningOutputPorts() throws IllegalActionException
listeningOutputPorts
in interface WirelessChannel
IllegalActionException
- If a port is encountered
whose insideChannel parameter cannot be evaluated.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class AtomicActor
IllegalActionException
- If the superclass throws it.public void registerPropertyTransformer(PropertyTransformer transformer, WirelessIOPort port)
registerPropertyTransformer
in interface WirelessChannel
transformer
- The property transformer to be registered.port
- The port whose transmissions should be subject to the
property transformer, or null to make them subject to all
transmissions through this channel.public void removeChannelListener(ChannelListener listener)
removeChannelListener
in interface WirelessChannel
listener
- The channel listener to remove.addChannelListener(ChannelListener)
public java.util.List sendingInputPorts() throws IllegalActionException
sendingInputPorts
in interface WirelessChannel
IllegalActionException
- If a port is encountered
whose insideChannel parameter cannot be evaluated.public java.util.List sendingOutputPorts() throws IllegalActionException
sendingOutputPorts
in interface WirelessChannel
IllegalActionException
- If a port is encountered
whose outsideChannel parameter cannot be evaluated.public RecordToken transformProperties(RecordToken properties, WirelessIOPort source, WirelessIOPort destination) throws IllegalActionException
transformProperties
in interface PropertyTransformer
properties
- The transmission properties.source
- The sending port.destination
- The receiving port.
IllegalActionException
- If the properties cannot
be transformed. Not thrown in this base class.registerPropertyTransformer(PropertyTransformer, WirelessIOPort)
public void transmit(Token token, WirelessIOPort port, RecordToken properties) throws IllegalActionException
transmit
in interface WirelessChannel
token
- The token to transmit, or null to clear all
receivers that are in range.port
- The port from which this is being transmitted.properties
- The transmission properties (ignored in this base class).
IllegalActionException
- If a type conflict occurs, or the
director is not a WirelessDirector.public void unregisterPropertyTransformer(PropertyTransformer transformer, WirelessIOPort port)
unregisterPropertyTransformer
in interface WirelessChannel
transformer
- The property transformer to be unregistered.port
- The port whose transmissions should be subject to the
property transformer, or null for a generic transformer.registerPropertyTransformer(PropertyTransformer, WirelessIOPort)
public void valueChanged(Settable settable)
valueChanged
in interface ValueListener
settable
- The object that has changed value.protected double _distanceBetween(WirelessIOPort port1, WirelessIOPort port2) throws IllegalActionException
port1
- The first port.port2
- The second port.
IllegalActionException
- If the distance
cannot be determined.protected boolean _isInRange(WirelessIOPort source, WirelessIOPort destination, RecordToken properties) throws IllegalActionException
source
- The source port.destination
- The destination port.properties
- The transmission properties (ignored in this base class).
IllegalActionException
- If it cannot be determined
whether the destination is in range (not thrown in this base
class).protected double[] _locationOf(IOPort port) throws IllegalActionException
port
- A port with a location.
IllegalActionException
- If a valid location attribute cannot
be found.protected java.util.List _receiversInRange(WirelessIOPort sourcePort, RecordToken properties) throws IllegalActionException
sourcePort
- The sending port.properties
- The transmission properties (ignored in this base class).
IllegalActionException
- If a location of a port cannot be
evaluated.protected void _transmitTo(Token token, WirelessIOPort sender, WirelessReceiver receiver, RecordToken properties) throws IllegalActionException
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 transmission properties (ignored in this base class).
IllegalActionException
- If the token cannot be converted
or if the token argument is null and the destination receiver
does not support clear.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |