Class LimitedRangeChannel

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, ChannelListener, PropertyTransformer, WirelessChannel, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, ValueListener
    Direct Known Subclasses:
    BluetoothChannel, PowerLossChannel

    public class LimitedRangeChannel
    extends DelayChannel
    This is a model of a wireless channel with a specified transmission range. The transmission range can be specified in one of two ways. Either it is the value of the range field in the defaultProperties parameter (a record) of this channel, or it is provided by the transmitter on each call to transmit() as a property argument. To use the latter mechanism, it is necessary that the property token be an instance of RecordToken with a field named "range" that can be converted to a double (i.e., it can be a double, an int, or a byte). The default value for range is Infinity, which indicates that by default, there is no range limit.

    Any receiver that is within the specified range when transmit() is called will receive the transmission. The distance between the transmitter and receiver is determined by the protected method _distanceBetween(). 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$
    Author:
    Edward A. Lee
    Pt.AcceptedRating:
    Yellow (cxh)
    Pt.ProposedRating:
    Green (cxh)
    • Constructor Detail

      • LimitedRangeChannel

        public LimitedRangeChannel​(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 an actor already in the container.
    • Method Detail

      • valueChanged

        public void valueChanged​(Settable settable)
        React to a change of the specified Settable value. This class registers as a listener to attributes that specify transmit properties. If those change, then it is necessary to invalidate the cache of receivers in range. This method simply invalidates the cache if it is called, so subclasses should be careful to not register as value listeners unnecessarily to objects that do not affect the validity of this cache.
        Specified by:
        valueChanged in interface ValueListener
        Overrides:
        valueChanged in class AtomicWirelessChannel
        Parameters:
        settable - The object that has changed value.
      • _isInRange

        protected boolean _isInRange​(WirelessIOPort source,
                                     WirelessIOPort destination,
                                     RecordToken properties)
                              throws IllegalActionException
        Return true if the specified port is in range of the specified source port, assuming the source port transmits with the specified properties. The properties are an instance of RecordToken. If the properties have a "range" field given by a double value, then that value is assumed to be the range of the transmission. Otherwise, use the "range" field value of the defaultProperties as the range of the transmission. This method returns true if the distance between the source and the destination is less than or equal to the value of the properties. If the properties argument is not a DoubleToken, then it simply returns true.
        Overrides:
        _isInRange in class AtomicWirelessChannel
        Parameters:
        source - The source port.
        destination - The destination port.
        properties - Properties of the transmission.
        Returns:
        True if the destination is in range of the source.
        Throws:
        IllegalActionException - If it cannot be determined whether the destination is in range (not thrown in this base class).