Package se.sics.cooja.interfaces

Examples of se.sics.cooja.interfaces.Position


      LED leds = mote.getInterfaces().getLED();
      if (leds == null) {
        continue;
      }

      Position pos = mote.getInterfaces().getPosition();
      Point pixel = visualizer.transformPositionToPixel(pos);

      int x = pixel.x - 2*Visualizer.MOTE_RADIUS;
     
      int y = pixel.y - Visualizer.MOTE_RADIUS;
View Full Code Here


      String msg = log.getLastLogMessage();
      if (msg == null) {
        continue;
      }

      Position pos = mote.getInterfaces().getPosition();
      Point pixel = visualizer.transformPositionToPixel(pos);

      int msgWidth = fm.stringWidth(msg);
      g.drawString(msg, pixel.x - msgWidth/2, pixel.y - Visualizer.MOTE_RADIUS);
    }
View Full Code Here

     
      if (msg == null) {
        continue;
      }
     
      Position pos = mote.getInterfaces().getPosition();
      Point pixel = visualizer.transformPositionToPixel(pos);

      int msgWidth = fm.stringWidth(msg);
      g.drawString(msg, pixel.x - msgWidth/2, pixel.y + 2*Visualizer.MOTE_RADIUS + 3);
    }
View Full Code Here

    }

    /* Paint transmission and interference range for select mote */
    if (selectedMote != null) {
      Graphics2D g2 = (Graphics2D) g;
      Position motePos = selectedMote.getInterfaces().getPosition();

      Point pixelCoord = visualizer.transformPositionToPixel(motePos);
      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);

          /* Draw arrows */
          if (DRAW_ARROWS) {
View Full Code Here

  public boolean tick(long simTime) {

    /* Dummy task: move randomly */
    if (random.nextDouble() > 0.9) {
      Position pos = getInterfaces().getPosition();
      pos.setCoordinates(
          pos.getXCoordinate() + random.nextDouble() - 0.5,
          pos.getYCoordinate() + random.nextDouble() - 0.5,
          pos.getZCoordinate() + random.nextDouble() - 0.5
      );
    }

    return false;
  }
View Full Code Here

  private MoteInterfaceHandler createMoteInterfaceHandler() {
    System.out.println("Creating mote interface handler....");
    MoteInterfaceHandler moteInterfaceHandler = new MoteInterfaceHandler();

      // Add position interface
      Position motePosition = new Position(this);
      Random random = new Random(); /* Do not use main random generator for positioning */
      motePosition.setCoordinates(random.nextDouble()*100, random.nextDouble()*100, random.nextDouble()*100);
      moteInterfaceHandler.addInterface(motePosition);

      // Add LED interface
      moteInterfaceHandler.addInterface(new MicaZLED(micaZ));
      // Add Radio interface
View Full Code Here

    if (simulation == null
        || selectedMote == null
        || selectedMote.getInterfaces().getRadio() == null) {
      return;
    }
    final Position sPos = selectedMote.getInterfaces().getPosition();

    /* Paint transmission and interference range for selected mote */
    Position motePos = selectedMote.getInterfaces().getPosition();

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

View Full Code Here

        }
  }
 
  public MRMRadioConnection createConnections(final Radio sender) {
    MRMRadioConnection newConnection = new MRMRadioConnection(sender);
    final Position senderPos = sender.getPosition();

    /* TODO Cache potential destination in DGRM */
    /* Loop through all potential destinations */
    for (Radio recv: getRegisteredRadios()) {
      if (sender == recv) {
View Full Code Here

        final double startY = -currentPanY;
        final double width = canvas.getWidth() / currentZoomX;
        final double height = canvas.getHeight() / currentZoomY;

        // Get sending radio position
        Position radioPosition = selectedRadio.getPosition();
        final double radioX = radioPosition.getXCoordinate();
        final double radioY = radioPosition.getYCoordinate();

        // Create temporary image
        final BufferedImage tempChannelImage = new BufferedImage(resolution.width, resolution.height, BufferedImage.TYPE_INT_ARGB);

        // Save time for later analysis
View Full Code Here

        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()
        );

        // Fetch current translation
        double xPos = g2d.getTransform().getTranslateX();
        double yPos = g2d.getTransform().getTranslateY();
View Full Code Here

TOP

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

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.