Package se.sics.cooja.interfaces

Examples of se.sics.cooja.interfaces.Radio


    if (mote.getState() == Mote.State.DEAD) {
      return null;
    }

    Radio moteRadio = mote.getInterfaces().getRadio();
    if (moteRadio == null) {
      return null;
    }

    if (selectedMote != null && mote == selectedMote) {
      return new Color[] { Color.CYAN };
    }

    if (!moteRadio.isReceiverOn()) {
      return new Color[] { Color.GRAY };
    }

    if (moteRadio.isTransmitting()) {
      return new Color[] { Color.BLUE };
    }

    if (moteRadio.isInterfered()) {
      return new Color[] { Color.RED };
    }

    if (moteRadio.isReceiving()) {
      return new Color[] { Color.GREEN };
    }

    return null;
  }
View Full Code Here


      int x = pixelCoord.x;
      int y = pixelCoord.y;

      // Fetch current output power indicator (scale with as percent)
      if (selectedMote.getInterfaces().getRadio() != null) {
        Radio selectedRadio = selectedMote.getInterfaces().getRadio();
        double moteInterferenceRange =
          radioMedium.INTERFERENCE_RANGE
          * ((double) selectedRadio.getCurrentOutputPowerIndicator()
              / (double) selectedRadio.getOutputPowerIndicatorMax());
        double moteTransmissionRange =
          radioMedium.TRANSMITTING_RANGE
          * ((double) selectedRadio.getCurrentOutputPowerIndicator()
              / (double) selectedRadio.getOutputPowerIndicatorMax());

        Point translatedZero = visualizer.transformPositionToPixel(0.0, 0.0, 0.0);
        Point translatedInterference = visualizer.transformPositionToPixel(moteInterferenceRange, moteInterferenceRange, 0.0);
        Point translatedTransmission = visualizer.transformPositionToPixel(moteTransmissionRange, moteTransmissionRange, 0.0);

        translatedInterference.x = Math.abs(translatedInterference.x - translatedZero.x);
        translatedInterference.y = Math.abs(translatedInterference.y - translatedZero.y);
        translatedTransmission.x = Math.abs(translatedTransmission.x - translatedZero.x);
        translatedTransmission.y = Math.abs(translatedTransmission.y - translatedZero.y);

        /* Interference range */
        g.setColor(COLOR_INTERFERENCE);
        g.fillOval(
            x - translatedInterference.x,
            y - translatedInterference.y,
            2 * translatedInterference.x,
            2 * translatedInterference.y);

        /* Transmission range */
        g.setColor(COLOR_TX);
        g.fillOval(
            x - translatedTransmission.x,
            y - translatedTransmission.y,
            2 * translatedTransmission.x,
            2 * translatedTransmission.y);
      }
    }

    /* Paint active connections in black */
    RadioConnection[] conns = radioMedium.getActiveConnections();
    if (conns != null) {
      g.setColor(Color.BLACK);
      for (RadioConnection conn : conns) {
        Radio source = conn.getSource();
        Point sourcePoint = visualizer.transformPositionToPixel(source.getPosition());
        for (Radio destRadio : conn.getDestinations()) {
          Position destPos = destRadio.getPosition();
          Point destPoint = visualizer.transformPositionToPixel(destPos);
          g.drawLine(sourcePoint.x, sourcePoint.y, destPoint.x, destPoint.y);

View Full Code Here

    }
  }

  private void addMoteObservers(Mote mote, final MoteEvents moteEvents) {
    final LED moteLEDs = mote.getInterfaces().getLED();
    final Radio moteRadio = mote.getInterfaces().getRadio();
    final Log moteLog = mote.getInterfaces().getLog();
    /* TODO Watchpoints? */

    /* LEDs */
    if (moteLEDs != null) {
      LEDEvent startupEv = new LEDEvent(
          simulation.getSimulationTime(),
          moteLEDs.isRedOn(),
          moteLEDs.isGreenOn(),
          moteLEDs.isYellowOn()
      );
      moteEvents.addLED(startupEv);
      Observer observer = new Observer() {
        public void update(Observable o, Object arg) {
          LEDEvent ev = new LEDEvent(
              simulation.getSimulationTime(),
              moteLEDs.isRedOn(),
              moteLEDs.isGreenOn(),
              moteLEDs.isYellowOn()
          );

          moteEvents.addLED(ev);
        }
      };

      moteLEDs.addObserver(observer);
      activeMoteObservers.add(new MoteObservation(mote, moteLEDs, observer));
    }

    /* Radio HW */
    if (moteRadio != null) {
      RadioHWEvent startupHW = new RadioHWEvent(
          simulation.getSimulationTime(), moteRadio.isReceiverOn());
      moteEvents.addRadioHW(startupHW);
      RadioRXTXEvent startupRXTX = new RadioRXTXEvent(
          simulation.getSimulationTime(), RadioEvent.UNKNOWN);
      moteEvents.addRadioRXTX(startupRXTX);
      Observer observer = new Observer() {
        public void update(Observable o, Object arg) {
          /* Radio HW events */
          if (moteRadio.getLastEvent() == RadioEvent.HW_ON ||
              moteRadio.getLastEvent() == RadioEvent.HW_OFF) {
            RadioHWEvent ev = new RadioHWEvent(
                simulation.getSimulationTime(), moteRadio.getLastEvent()==RadioEvent.HW_ON);

            moteEvents.addRadioHW(ev);
            return;
          }

          /* Radio RXTX events */
          if (moteRadio.getLastEvent() == RadioEvent.TRANSMISSION_STARTED ||
              moteRadio.getLastEvent() == RadioEvent.TRANSMISSION_FINISHED ||
              moteRadio.getLastEvent() == RadioEvent.RECEPTION_STARTED ||
              moteRadio.getLastEvent() == RadioEvent.RECEPTION_INTERFERED ||
              moteRadio.getLastEvent() == RadioEvent.RECEPTION_FINISHED) {
            RadioRXTXEvent ev = new RadioRXTXEvent(
                simulation.getSimulationTime(), moteRadio.getLastEvent());

            moteEvents.addRadioRXTX(ev);
            return;
          }

        }
      };

      moteRadio.addObserver(observer);
      activeMoteObservers.add(new MoteObservation(mote, moteRadio, observer));
    }

  }
View Full Code Here

          return false;
        }

        if (col == COLUMN_TO) {
          /* Highlight all destinations */
          Radio dests[] = connections.get(row).connection.getDestinations();
          for (Radio dest: dests) {
            gui.signalMoteHighlight(dest.getMote());
          }
          return false;
        }
View Full Code Here

    int edges = 0;
    for (Mote d: dests) {
      if (d == selectedMote) {
        continue;
      }
      final Radio dRadio = d.getInterfaces().getRadio();
      TxPair txPair = new RadioPair() {
        public Radio getFromRadio() {
          return selectedMote.getInterfaces().getRadio();
        }
        public Radio getToRadio() {
View Full Code Here

      if (sender.getChannel() >= 0 &&
          recv.getChannel() >= 0 &&
          sender.getChannel() != recv.getChannel()) {
        continue;
      }
      final Radio recvFinal = recv;

      /* Calculate receive probability */
      TxPair txPair = new RadioPair() {
        public Radio getFromRadio() {
          return sender;
View Full Code Here

    if (!WITH_NOISE) return;
    for (Radio noiseRadio: getRegisteredRadios()) {
      if (!(noiseRadio instanceof NoiseSourceRadio)) {
        continue;
      }
      final Radio fromRadio = noiseRadio;
      NoiseSourceRadio radio = (NoiseSourceRadio) noiseRadio;
      int signalStrength = radio.getNoiseLevel();
      if (signalStrength == Integer.MIN_VALUE) {
        continue;
      }

      /* Calculate how noise source affects surrounding radios */
      for (Radio affectedRadio : getRegisteredRadios()) {
        if (noiseRadio == affectedRadio) {
          continue;
        }

        /* Update noise levels */
        final Radio toRadio = affectedRadio;
        TxPair txPair = new RadioPair() {
          public Radio getFromRadio() {
            return fromRadio;
          }
          public Radio getToRadio() {
View Full Code Here

      return sb.toString();
    }
  }

  private MoteTracker createMoteTracker(Mote mote) {
    final Radio moteRadio = mote.getInterfaces().getRadio();
    if (moteRadio == null) {
      return null;
    }

    /* Radio observer */
 
View Full Code Here

      for (int i=0; i < currentRadioMedium.getRegisteredRadioCount(); i++) {
        g2d.setStroke(new BasicStroke((float) 0.0));
        g2d.setTransform(realWorldTransform);

        // Translate to real world radio position
        Radio radio = currentRadioMedium.getRegisteredRadio(i);
        Position radioPosition = radio.getPosition();
        g2d.translate(
            radioPosition.getXCoordinate(),
            radioPosition.getYCoordinate()
        );
View Full Code Here

    double realIconHalfHeight = antennaImage.getHeight(this) / (currentZoomY*2.0);
    double realClickedX = clickedPoint.x / currentZoomX - currentPanX;
    double realClickedY = clickedPoint.y / currentZoomY - currentPanY;

    for (int i=0; i < currentRadioMedium.getRegisteredRadioCount(); i++) {
      Radio testRadio = currentRadioMedium.getRegisteredRadio(i);
      Position testPosition = testRadio.getPosition();

      if (realClickedX > testPosition.getXCoordinate() - realIconHalfWidth &&
          realClickedX < testPosition.getXCoordinate() + realIconHalfWidth &&
          realClickedY > testPosition.getYCoordinate() - realIconHalfHeight &&
          realClickedY < testPosition.getYCoordinate() + realIconHalfHeight) {
View Full Code Here

TOP

Related Classes of se.sics.cooja.interfaces.Radio

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.