Package se.sics.cooja

Examples of se.sics.cooja.Mote


        return createErrorMessage("No mote ID specified");
      int moteNr = Integer.parseInt(mote);
      if (moteNr < 0 || simulation.getMotesCount() <= moteNr) {
        return createErrorMessage("Bad mote ID specified: " + moteNr);
      }
      Mote moteObject = simulation.getMote(moteNr);

      MoteMemory memory = simulation.getMote(moteNr).getMemory();
     
      if (!(memory instanceof AddressMemory))
        return createErrorMessage("Can't write mote memory variables (not address memory)");
     
      if (!((AddressMemory) memory).variableExists(variable)) {
        return createErrorMessage("Variable does not exist: " + variable);
      }

      Eventpoint newEventpoint = new IntegerWatchpoint(moteObject, variable);
      myEvaluator.addEventpoint(newEventpoint);
      return createOkMessage(newEventpoint, simulation.getSimulationTime());
    }

    // Variable watchpoint
    if (type.equals(XML_WATCHPOINT_VARIABLE)) {
      if (variable == null)
        return createErrorMessage("No variable name specified");
      if (variable.contains(" "))
        return createErrorMessage("Variable name must not contain spaces: " + variable);
      if (mote == null)
        return createErrorMessage("No mote ID specified");
      if (size == null)
        return createErrorMessage("No size specified");
      int sizeParsed = Integer.parseInt(size);
      if (sizeParsed < 0) {
        return createErrorMessage("Bad size specified: " + sizeParsed);
      }
      int moteNr = Integer.parseInt(mote);
      if (moteNr < 0 || simulation.getMotesCount() <= moteNr) {
        return createErrorMessage("Bad mote ID specified: " + moteNr);
      }
      Mote moteObject = simulation.getMote(moteNr);

      MoteMemory memory = simulation.getMote(moteNr).getMemory();
     
      if (!(memory instanceof AddressMemory))
        return createErrorMessage("Can't write mote memory variables (not address memory)");
     
      if (!((AddressMemory) memory).variableExists(variable)) {
        return createErrorMessage("Variable does not exist: " + variable);
      }

      Eventpoint newEventpoint = new VariableWatchpoint(moteObject, variable, sizeParsed);
      myEvaluator.addEventpoint(newEventpoint);
      return createOkMessage(newEventpoint, simulation.getSimulationTime());
    }


    // Memory area watchpoint
    if (type.equals(XML_WATCHPOINT_ADDRESS)) {
      if (mote == null)
        return createErrorMessage("No mote ID specified");
      if (size == null)
        return createErrorMessage("No size specified");
      int sizeParsed = Integer.parseInt(size);
      if (sizeParsed < 0) {
        return createErrorMessage("Bad size specified: " + sizeParsed);
      }
      int addressParsed = Integer.parseInt(address);
      if (addressParsed < 0) {
        return createErrorMessage("Bad start address specified: " + addressParsed);
      }
      int moteNr = Integer.parseInt(mote);
      if (moteNr < 0 || simulation.getMotesCount() <= moteNr) {
        return createErrorMessage("Bad mote ID specified: " + moteNr);
      }
      Mote moteObject = simulation.getMote(moteNr);
      MoteMemory memory = simulation.getMote(moteNr).getMemory();
     
      Eventpoint newEventpoint = new Watchpoint(moteObject, addressParsed, sizeParsed);
      myEvaluator.addEventpoint(newEventpoint);
      return createOkMessage(newEventpoint, simulation.getSimulationTime());
View Full Code Here


     
    if (myGUI.getSimulation().getMotesCount() < highIdInt)
      return createErrorMessage("Bad mote interval specified: Only " + myGUI.getSimulation().getMotesCount() + " motes exist");

    for (int pos=lowIdInt; pos <= highIdInt; pos++) {
      Mote mote = myGUI.getSimulation().getMote(pos);
      mote.setState(State.DEAD);
    }
    return XML_OK;
  }
View Full Code Here

        return createErrorMessage("No mote ID specified");
      int moteNr = Integer.parseInt(mote);
      if (moteNr < 0 || simulation.getMotesCount() <= moteNr) {
        return createErrorMessage("Bad mote ID specified: " + moteNr);
      }
      Mote moteObject = simulation.getMote(moteNr);
      MoteMemory memory = simulation.getMote(moteNr).getMemory();
       
      if (!(memory instanceof AddressMemory))
        return createErrorMessage("Can't read mote memory variable address (not address memory)");
View Full Code Here

        return createErrorMessage("No mote ID specified");
      int moteNr = Integer.parseInt(mote);
      if (moteNr < 0 || simulation.getMotesCount() <= moteNr) {
        return createErrorMessage("Bad mote ID specified: " + moteNr);
      }
      Mote moteObject = simulation.getMote(moteNr);

      MoteMemory memory = simulation.getMote(moteNr).getMemory();
     
      if (!(memory instanceof AddressMemory))
        return createErrorMessage("Can't write mote memory variables (not address memory)");
     
      if (!((AddressMemory) memory).variableExists(variable)) {
        return createErrorMessage("Variable does not exist: " + variable);
      }

      Eventpoint newEventpoint = new IntegerWatchpoint(moteObject, variable);
      myEvaluator.addEventpoint(newEventpoint);
      return createOkMessage(newEventpoint, simulation.getSimulationTime());
    }

    // Variable watchpoint
    if (type.equals(XML_WATCHPOINT_VARIABLE)) {
      if (variable == null)
        return createErrorMessage("No variable name specified");
      if (variable.contains(" "))
        return createErrorMessage("Variable name must not contain spaces: " + variable);
      if (mote == null)
        return createErrorMessage("No mote ID specified");
      if (size == null)
        return createErrorMessage("No size specified");
      int sizeParsed = Integer.parseInt(size);
      if (sizeParsed < 0) {
        return createErrorMessage("Bad size specified: " + sizeParsed);
      }
      int moteNr = Integer.parseInt(mote);
      if (moteNr < 0 || simulation.getMotesCount() <= moteNr) {
        return createErrorMessage("Bad mote ID specified: " + moteNr);
      }
      Mote moteObject = simulation.getMote(moteNr);

      MoteMemory memory = simulation.getMote(moteNr).getMemory();
     
      if (!(memory instanceof AddressMemory))
        return createErrorMessage("Can't write mote memory variables (not address memory)");
     
      if (!((AddressMemory) memory).variableExists(variable)) {
        return createErrorMessage("Variable does not exist: " + variable);
      }

      Eventpoint newEventpoint = new VariableWatchpoint(moteObject, variable, sizeParsed);
      myEvaluator.addEventpoint(newEventpoint);
      return createOkMessage(newEventpoint, simulation.getSimulationTime());
    }


    // Memory area watchpoint
    if (type.equals(XML_WATCHPOINT_ADDRESS)) {
      if (mote == null)
        return createErrorMessage("No mote ID specified");
      if (size == null)
        return createErrorMessage("No size specified");
      int sizeParsed = Integer.parseInt(size);
      if (sizeParsed < 0) {
        return createErrorMessage("Bad size specified: " + sizeParsed);
      }
      int addressParsed = Integer.parseInt(address);
      if (addressParsed < 0) {
        return createErrorMessage("Bad start address specified: " + addressParsed);
      }
      int moteNr = Integer.parseInt(mote);
      if (moteNr < 0 || simulation.getMotesCount() <= moteNr) {
        return createErrorMessage("Bad mote ID specified: " + moteNr);
      }
      Mote moteObject = simulation.getMote(moteNr);
      MoteMemory memory = simulation.getMote(moteNr).getMemory();
     
      Eventpoint newEventpoint = new Watchpoint(moteObject, addressParsed, sizeParsed);
      myEvaluator.addEventpoint(newEventpoint);
      return createOkMessage(newEventpoint, simulation.getSimulationTime());
View Full Code Here

     
    if (myGUI.getSimulation().getMotesCount() < highIdInt)
      return createErrorMessage("Bad mote interval specified: Only " + myGUI.getSimulation().getMotesCount() + " motes exist");

    for (int pos=lowIdInt; pos <= highIdInt; pos++) {
      Mote mote = myGUI.getSimulation().getMote(pos);
      mote.setState(State.DEAD);
    }
    return XML_OK;
  }
View Full Code Here

        return createErrorMessage("No mote ID specified");
      int moteNr = Integer.parseInt(mote);
      if (moteNr < 0 || simulation.getMotesCount() <= moteNr) {
        return createErrorMessage("Bad mote ID specified: " + moteNr);
      }
      Mote moteObject = simulation.getMote(moteNr);
      MoteMemory memory = simulation.getMote(moteNr).getMemory();
       
      if (!(memory instanceof AddressMemory))
        return createErrorMessage("Can't read mote memory variable address (not address memory)");
View Full Code Here

      return;
    }
  }

  public Color[] getColorOf(Mote mote) {
    Mote selectedMote = visualizer.getSelectedMote();
    if (mote == selectedMote) {
      return new Color[] { Color.CYAN };
    }
    return null;
  }
View Full Code Here

    }
    return null;
  }

  public void paintBeforeMotes(Graphics g) {
    final Mote selectedMote = visualizer.getSelectedMote();
    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;

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

    MRM radioMedium = (MRM) simulation.getRadioMedium();

    /* Print transmission success probabilities */
    Mote[] dests = simulation.getMotes();
    if (dests == null || dests.length == 0) {
      String msg = "No edges";
      int msgWidth = fm.stringWidth(msg);
      g.setColor(Color.BLACK);
      g.drawString(msg, x - msgWidth/2, y + 2*Visualizer.MOTE_RADIUS + 3);
      return;
    }
    g.setColor(Color.BLACK);
    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() {
          return dRadio;
        }
      };
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() {
          public void actionPerformed(ActionEvent e) {
            /* Count down */
            if (timer.getDelay() < 90) {
              timer.stop();
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() {
          public void actionPerformed(ActionEvent e) {
            /* Count down */
            if (timer.getDelay() < 90) {
              timer.stop();
View Full Code Here

TOP

Related Classes of se.sics.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.