public class AtomicWirelessChannel extends TypedAtomicActor implements WirelessChannel, ValueListener
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.
Entity.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected boolean |
_receiversInRangeCacheValid
Flag indicating that the cached list of receivers in range
is valid.
|
Parameter |
defaultProperties
The default properties for transmission.
|
NameParameter |
name
When set to a non-empty value, this NameParameter will cause
the name of this channel to be set to this value.
|
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
AtomicWirelessChannel(CompositeEntity container,
java.lang.String name)
Construct a relation with the given name contained by the specified
entity.
|
Modifier and Type | Method and Description |
---|---|
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.
|
void |
declareDelayDependency()
Override the base class to declare that the dummy port
returned by getChannelPort() does not depend on itself
in a firing.
|
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 |
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.
|
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
fire, isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
addInitializable, initialize, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public Parameter defaultProperties
public NameParameter name
protected boolean _receiversInRangeCacheValid
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.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 TypedAtomicActor
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- Not thrown in this base classNamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void declareDelayDependency() throws IllegalActionException
declareDelayDependency
in class AtomicActor<TypedIOPort>
IllegalActionException
- If the causality interface
cannot be computed.AtomicActor.getCausalityInterface()
,
AtomicActor._declareDelayDependency(IOPort, IOPort, double)
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 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.