Package org.contikios.cooja.interfaces

Examples of org.contikios.cooja.interfaces.Radio


          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 source = Integer.parseInt(arr[INDEX_SRC]);
      m = simulation.getMoteWithID(source);
      if (m == null) {
        throw new RuntimeException("No simulation mote with ID " + source);
      }
      Radio sourceRadio = m.getInterfaces().getRadio();
      int dst = Integer.parseInt(arr[INDEX_DST]);
      m = simulation.getMoteWithID(dst);
      if (m == null) {
        throw new RuntimeException("No simulation mote with ID " + dst);
      }
View Full Code Here

      return;
    }
    for (RadioConnectionArrow connArrow : historyCopy) {
      float colorHistoryIndex = (float)connArrow.getAge() / (float)connArrow.getMaxAge();
      g.setColor(new Color(colorHistoryIndex, colorHistoryIndex, 1.0f));
      Radio source = connArrow.getConnection().getSource();
      Point sourcePoint = visualizer.transformPositionToPixel(source.getPosition());
      for (Radio destRadio : connArrow.getConnection().getDestinations()) {
        Position destPos = destRadio.getPosition();
        Point destPoint = visualizer.transformPositionToPixel(destPos);
        drawArrow(g, sourcePoint.x, sourcePoint.y, destPoint.x, destPoint.y, 8);
      }
View Full Code Here

      Position motePos = selectedMote.getInterfaces().getPosition();

      Point pixelCoord = visualizer.transformPositionToPixel(motePos);
      int x = pixelCoord.x;
      int y = pixelCoord.y;
      Radio selectedRadio = selectedMote.getInterfaces().getRadio();

      FontMetrics fm = g.getFontMetrics();
      g.setColor(Color.BLACK);

      DirectedGraphMedium radioMedium = (DirectedGraphMedium) simulation.getRadioMedium();
View Full Code Here

      Point pixelCoord = visualizer.transformPositionToPixel(motePos);
      int x = pixelCoord.x;
      int y = pixelCoord.y;

      // Fetch current output power indicator (scale with as percent)
      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);
      Point translatedInterferenceMax
              = visualizer.transformPositionToPixel(radioMedium.INTERFERENCE_RANGE, radioMedium.INTERFERENCE_RANGE, 0.0);
      Point translatedTransmissionMax
              = visualizer.transformPositionToPixel(radioMedium.TRANSMITTING_RANGE, radioMedium.TRANSMITTING_RANGE, 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);
      translatedInterferenceMax.x = Math.abs(translatedInterferenceMax.x - translatedZero.x);
      translatedInterferenceMax.y = Math.abs(translatedInterferenceMax.y - translatedZero.y);
      translatedTransmissionMax.x = Math.abs(translatedTransmissionMax.x - translatedZero.x);
      translatedTransmissionMax.y = Math.abs(translatedTransmissionMax.y - translatedZero.y);

      /* Interference range */
      intRangeArea.add(new Area(new Ellipse2D.Double(
              x - translatedInterference.x,
              y - translatedInterference.y,
              2 * translatedInterference.x,
              2 * translatedInterference.y)));

      /* Interference range (MAX) */
      trxRangeArea.add(new Area(new Ellipse2D.Double(
              x - translatedTransmission.x,
              y - translatedTransmission.y,
              2 * translatedTransmission.x,
              2 * translatedTransmission.y)));

      intRangeMaxArea.add(new Area(new Ellipse2D.Double(
              x - translatedInterferenceMax.x,
              y - translatedInterferenceMax.y,
              2 * translatedInterferenceMax.x,
              2 * translatedInterferenceMax.y)));

      /* Transmission range (MAX) */
      trxRangeMaxArea.add(new Area(new Ellipse2D.Double(
              x - translatedTransmissionMax.x,
              y - translatedTransmissionMax.y,
              2 * translatedTransmissionMax.x,
              2 * translatedTransmissionMax.y)));

    }

    Graphics2D g2d = (Graphics2D) g;

    g2d.setColor(COLOR_INT);
    g2d.fill(intRangeArea);
    g.setColor(Color.GRAY);
    g2d.draw(intRangeMaxArea);

    g.setColor(COLOR_TX);
    g2d.fill(trxRangeArea);
    g.setColor(Color.GRAY);
    g2d.draw(trxRangeMaxArea);

    FontMetrics fm = g.getFontMetrics();
    g.setColor(Color.BLACK);

    /* Print transmission success probabilities only if single mote is selected */
    if (selectedMotes.size() == 1) {
      Mote selectedMote = selectedMotes.toArray(new Mote[0])[0];
      Radio selectedRadio = selectedMote.getInterfaces().getRadio();
      for (Mote m : simulation.getMotes()) {
        if (m == selectedMote) {
          continue;
        }
        double prob
View Full Code Here

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

    /* Radio OnOff, RXTX, and channels */
    final Radio moteRadio = mote.getInterfaces().getRadio();
    if (moteRadio != null) {
      RadioChannelEvent startupChannel = new RadioChannelEvent(
          simulation.getSimulationTime(), moteRadio.getChannel(), moteRadio.isRadioOn());
      moteEvents.addRadioChannel(startupChannel);
      RadioHWEvent startupHW = new RadioHWEvent(
          simulation.getSimulationTime(), moteRadio.isRadioOn());
      moteEvents.addRadioHW(startupHW);
      RadioRXTXEvent startupRXTX = new RadioRXTXEvent(
          simulation.getSimulationTime(), RXTXRadioEvent.IDLE);
      moteEvents.addRadioRXTX(startupRXTX);
      Observer observer = new Observer() {
        int lastChannel = -1;
        public void update(Observable o, Object arg) {
          RadioEvent radioEv = moteRadio.getLastEvent();

          String details = null;
          if (executionDetails && mote instanceof AbstractEmulatedMote) {
            details = ((AbstractEmulatedMote) mote).getExecutionDetails();
            if (details != null) {
              details = "<br>" + details.replace("\n", "<br>");
            }
          }

          /* Radio channel */
          int nowChannel = moteRadio.getChannel();
          if (nowChannel != lastChannel) {
            lastChannel = nowChannel;
            RadioChannelEvent ev = new RadioChannelEvent(
                simulation.getSimulationTime(), nowChannel, moteRadio.isRadioOn());
            moteEvents.addRadioChannel(ev);

            ev.details = details;
          }
         
          if (radioEv == RadioEvent.HW_ON ||
              radioEv == RadioEvent.HW_OFF) {
            RadioHWEvent ev = new RadioHWEvent(
                simulation.getSimulationTime(), moteRadio.isRadioOn());
            moteEvents.addRadioHW(ev);

            ev.details = details;

            /* Also create another channel event here */
            lastChannel = nowChannel;
            RadioChannelEvent ev2 = new RadioChannelEvent(
                simulation.getSimulationTime(), nowChannel, moteRadio.isRadioOn());
            ev2.details = details;
            moteEvents.addRadioChannel(ev2);
          }

          /* Radio RXTX events */
          if (radioEv == RadioEvent.TRANSMISSION_STARTED ||
              radioEv == RadioEvent.TRANSMISSION_FINISHED ||
              radioEv == RadioEvent.RECEPTION_STARTED ||
              radioEv == RadioEvent.RECEPTION_INTERFERED ||
              radioEv == RadioEvent.RECEPTION_FINISHED) {

            RadioRXTXEvent ev;
            /* Override events, instead show state */
            if (moteRadio.isTransmitting()) {
              ev = new RadioRXTXEvent(
                  simulation.getSimulationTime(), RXTXRadioEvent.TRANSMITTING);
            } else if (!moteRadio.isRadioOn()) {
              ev = new RadioRXTXEvent(
                  simulation.getSimulationTime(), RXTXRadioEvent.IDLE);
            } else if (moteRadio.isInterfered()) {
              ev = new RadioRXTXEvent(
                  simulation.getSimulationTime(), RXTXRadioEvent.INTERFERED);
            } else if (moteRadio.isReceiving()) {
              ev = new RadioRXTXEvent(
                  simulation.getSimulationTime(), RXTXRadioEvent.RECEIVING);
            } else {
              ev = new RadioRXTXEvent(
                  simulation.getSimulationTime(), RXTXRadioEvent.IDLE);
            }

            moteEvents.addRadioRXTX(ev);

            ev.details = details;
          }

        }
      };

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

    /* Watchpoints */
    if (mote instanceof WatchpointMote) {
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

      Point pixelCoord = visualizer.transformPositionToPixel(motePos);
      int x = pixelCoord.x;
      int y = pixelCoord.y;

      // Fetch current output power indicator (scale with as percent)
      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);
      Point translatedInterferenceMax
              = visualizer.transformPositionToPixel(radioMedium.INTERFERENCE_RANGE, radioMedium.INTERFERENCE_RANGE, 0.0);
      Point translatedTransmissionMax
              = visualizer.transformPositionToPixel(radioMedium.TRANSMITTING_RANGE, radioMedium.TRANSMITTING_RANGE, 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);
      translatedInterferenceMax.x = Math.abs(translatedInterferenceMax.x - translatedZero.x);
      translatedInterferenceMax.y = Math.abs(translatedInterferenceMax.y - translatedZero.y);
      translatedTransmissionMax.x = Math.abs(translatedTransmissionMax.x - translatedZero.x);
      translatedTransmissionMax.y = Math.abs(translatedTransmissionMax.y - translatedZero.y);

      /* Interference range */
      intRangeArea.add(new Area(new Ellipse2D.Double(
              x - translatedInterference.x,
              y - translatedInterference.y,
              2 * translatedInterference.x,
              2 * translatedInterference.y)));

      /* Interference range (MAX) */
      trxRangeArea.add(new Area(new Ellipse2D.Double(
              x - translatedTransmission.x,
              y - translatedTransmission.y,
              2 * translatedTransmission.x,
              2 * translatedTransmission.y)));

      intRangeMaxArea.add(new Area(new Ellipse2D.Double(
              x - translatedInterferenceMax.x,
              y - translatedInterferenceMax.y,
              2 * translatedInterferenceMax.x,
              2 * translatedInterferenceMax.y)));

      /* Transmission range (MAX) */
      trxRangeMaxArea.add(new Area(new Ellipse2D.Double(
              x - translatedTransmissionMax.x,
              y - translatedTransmissionMax.y,
              2 * translatedTransmissionMax.x,
              2 * translatedTransmissionMax.y)));

    }

    Graphics2D g2d = (Graphics2D) g;

    g2d.setColor(COLOR_INT);
    g2d.fill(intRangeArea);
    g.setColor(Color.GRAY);
    g2d.draw(intRangeMaxArea);

    g.setColor(COLOR_TX);
    g2d.fill(trxRangeArea);
    g.setColor(Color.GRAY);
    g2d.draw(trxRangeMaxArea);

    FontMetrics fm = g.getFontMetrics();
    g.setColor(Color.BLACK);

    /* Print transmission success probabilities only if single mote is selected */
    if (selectedMotes.size() == 1) {
      Mote selectedMote = selectedMotes.toArray(new Mote[0])[0];
      Radio selectedRadio = selectedMote.getInterfaces().getRadio();
      for (Mote m : simulation.getMotes()) {
        if (m == selectedMote) {
          continue;
        }
        double prob
View Full Code Here

  @Override
  public void paintBeforeMotes(Graphics g) {
    synchronized (historyList) {
      for (RadioConnectionArrow connArrow : historyList) {
        float colorHistoryIndex = 1.0f - connArrow.getAge();
        Radio source = connArrow.getConnection().getSource();
        Point sourcePoint = visualizer.transformPositionToPixel(source.getPosition());
        /* If there is no destination, paint red circles to indicate untransmitted message */
        if (connArrow.getConnection().getDestinations().length == 0) {
          g.setColor(new Color(UNTRANSMITTED_COLOR_RGB[0], UNTRANSMITTED_COLOR_RGB[1], UNTRANSMITTED_COLOR_RGB[2], colorHistoryIndex));
          g.drawOval(sourcePoint.x - 20, sourcePoint.y - 20, 40, 40);
          g.drawOval(sourcePoint.x - 30, sourcePoint.y - 30, 60, 60);
View Full Code Here

TOP

Related Classes of org.contikios.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.