Class Sensor

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class Sensor
    extends TypedAtomicActor
    This is a wireless sensor node that senses evaders in the sensor field. The sensors in the field communicate with each other to construct a spanning tree from the root node (where the evader is close to) to nodes that are one hop from the root node and so on. When a sensor detects the evader, it sets itself as the root and broadcast a message to its neighbor nodes. The message includes the time when the evader is detected, the location and the depth, zero for the root node, of the sensor. If a sensor receives a message from another sensor, it checks whether the root node has been changed from last time (by check the detected time), or whether there is a shorter path to the root node. If so, it records the detected time, updates the information of its parent node (location and depth in the tree) and broadcast a message, include the detected time, its location and depth in the tree, to it neighbot nodes. By doing this in a sensor network, a spaning tree is constructed distributedly and sensors are indexed according to how far it is from the root node. With the evader moving, it may be detected by another sensor, and the tree changes dynamically.
    Since:
    Ptolemy II 4.0
    Version:
    $ $
    Author:
    Yang Zhao
    Pt.AcceptedRating:
    Red (pjb2e)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Detail

      • input

        public WirelessIOPort input
        Port that receives update message for the spanning tree.
      • signal

        public WirelessIOPort signal
        Port that receives a signal from the envader or pursuer.
      • messageChannelName

        public StringParameter messageChannelName
        Name of the channel for messaging between sensors. This is a string that defaults to "messageChannel".
      • signalChannelName

        public StringParameter signalChannelName
        Name of the channel for sensors to detect envader or pursuer. This is a string that defaults to "signalChannel".
      • output

        public WirelessIOPort output
        Port that transmits the update message for the spanning tree. This has type {location={double}, time=double, depth =int}, a record token.
      • outputChannelName

        public StringParameter outputChannelName
        Name of the output channel. This is a string that defaults to "OutputChannel".
      • range

        public Parameter range
        The transmission range of the sensor. The icon for this sensor node includes a circle with this as its radius. This is a double and default to 50.0.
    • Method Detail

      • fire

        public void fire()
                  throws IllegalActionException
        When it receives token from the signal port, which is used to receive signal from the pursuer or the evader. it tells what the signal is from by checking the signal header. If it is from the evader, it set itself to be the root node and broadcast a message for updating the tree. Otherwise, it output a message to the pursuer to tell it the location of its parent node, and the pursuer will move closer to the evader using this information. When it receives token from the input port, which is used to receive message from other sensors, it check whether the rootnode has been changed or whether there is a shorter path. If so, it performs update and broadcast a message. Otherwise, simply consumes the messge.
        Specified by:
        fire in interface Executable
        Overrides:
        fire in class AtomicActor<TypedIOPort>
        Throws:
        IllegalActionException - Not thrown in this base class.
      • _getLocation

        protected double[] _getLocation()
                                 throws IllegalActionException
        Return the location of this sensor. In this base class, this is determined by looking for an attribute with name "_location" and class Location. Normally, a visual editor such as Vergil will create this icon, so the location will be determined by the visual editor. Derived classes can override this method to specify the location in some other way.
        Returns:
        An array identifying the location.
        Throws:
        IllegalActionException - If the location attribute does not exist or cannot be evaluated.