Package org.contikios.cooja

Examples of org.contikios.cooja.Mote


    }
    String state = args[2];

    /* Locate destination mote */
    /* TODO Use Rime address interface instead of mote ID? */
    Mote destinationMote = mote.getSimulation().getMoteWithID(destID);
    if (destinationMote == null) {
      logger.warn("No destination mote with ID: " + destID);
      return;
    }
    if (destinationMote == mote) {
View Full Code Here


        if (!(obj instanceof Mote)) {
          return;
        }

        final Timer timer = new Timer(100, null);
        final Mote mote = (Mote) obj;
        timer.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            /* Count down */
            if (timer.getDelay() < 90) {
View Full Code Here

      l = l.trim();
      if (l.startsWith("#")) {
        continue;
      }

      Mote m;
      String[] arr = l.split(" ");
      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);
      }
      DGRMDestinationRadio destRadio = new DGRMDestinationRadio(m.getInterfaces().getRadio());
      double prr = Double.parseDouble(arr[INDEX_PRR]);
      /*double prrConfidence = Double.parseDouble(arr[INDEX_PRR_CI]);*/
      /*int numTX <- INDEX_NUM_TX;*/
      /*int numRX <- INDEX_NUM_RX;*/
      double rssi = Double.parseDouble(arr[INDEX_RSSI_MEDIAN]);
View Full Code Here

    // Create new motes
          newMotes = new Vector<Mote>();
          int motesToAdd = ((Number) numberOfMotesField.getValue()).intValue();
          while (newMotes.size() < motesToAdd) {
            Mote newMote = moteType.generateMote(simulation);
            newMotes.add(newMote);
          }

          // Position new motes
          Class<? extends Positioner> positionerClass = null;
View Full Code Here

    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

      keepMoteOnlyItem.setText("Remove all motes from timeline but");
      popupMenu.add(keepMoteOnlyItem);

      addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
          Mote m = getMote(e.getPoint());
          if (m == null) {
            return;
          }
          simulation.getCooja().signalMoteHighlight(m);
View Full Code Here

      }
    }

    public String getToolTipText(MouseEvent event) {
      Point p = event.getPoint();
      Mote m = getMote(p);
      if (m == null)
        return null;

      return "<html>" + m + "<br>Click mote for options</html>";
    }
View Full Code Here

      }
      public void removedLogOutput(LogOutputEvent ev) {
      }
      public void newLogOutput(LogOutputEvent ev) {
        /* Log output */
        Mote mote = ev.getMote();
        LogEvent logEvent = new LogEvent(ev);
       
        /* TODO Optimize */
        for (MoteEvents moteEvents: allMoteEvents) {
          if (moteEvents.mote == mote) {
            moteEvents.addLog(logEvent);
            break;
          }
        }
      }
    });
    for (Mote m: simulation.getMotes()) {
      addMote(m);
    }

    /* Update timeline for the duration of the plugin */
    repaintTimelineTimer.start();

    gui.addMoteHighlightObserver(moteHighlightObserver = new Observer() {
      public void update(Observable obs, Object obj) {
        if (!(obj instanceof Mote)) {
          return;
        }

        final Timer timer = new Timer(100, null);
        final Mote mote = (Mote) obj;
        timer.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            /* Count down */
            if (timer.getDelay() < 90) {
              timer.stop();
View Full Code Here

    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

        if (!(obj instanceof Mote)) {
          return;
        }

        final Timer timer = new Timer(100, null);
        final Mote mote = (Mote) obj;
        timer.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            /* Count down */
            if (timer.getDelay() < 90) {
              timer.stop();
              highlightedMotes.remove(mote);
              repaint();
              return;
            }

            /* Toggle highlight state */
            if (highlightedMotes.contains(mote)) {
              highlightedMotes.remove(mote);
            }
            else {
              highlightedMotes.add(mote);
            }
            timer.setDelay(timer.getDelay() - 1);
            repaint();
          }
        });
        timer.start();
      }
    });

    /* Observe mote relations */
    gui.addMoteRelationsObserver(moteRelationsObserver = new Observer() {
      @Override
      public void update(Observable obs, Object obj) {
        repaint();
      }
    });

    canvas.getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"), "abort_action");
    canvas.getInputMap().put(KeyStroke.getKeyStroke("DELETE"), "delete_motes");

    canvas.getActionMap().put("abort_action", new AbstractAction() {

      @Override
      public void actionPerformed(ActionEvent e) {
        if (mouseActionState == MotesActionState.MOVING) {
          /* Reset positions to those of move start */
          for (Mote m : Visualizer.this.getSelectedMotes()) {
            double rstPos[] = Visualizer.this.moveStartPositions.get(m);
            m.getInterfaces().getPosition().setCoordinates(rstPos[0], rstPos[1], rstPos[2]);
          }
          mouseActionState = MotesActionState.NONE;
        }
        /* Always deselect all */
        Visualizer.this.getSelectedMotes().clear();
        repaint();
      }
    });

    canvas.getActionMap().put("delete_motes", new AbstractAction() {

      @Override
      public void actionPerformed(ActionEvent e) {
        Iterator<Mote> iter = Visualizer.this.getSelectedMotes().iterator();
        while (iter.hasNext()) {
          Mote m = iter.next();
          m.getSimulation().removeMote(m);
          iter.remove();
        }
      }
    });

View Full Code Here

TOP

Related Classes of org.contikios.cooja.Mote

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.