示例#1
0
  public boolean setConfigXML(
      Simulation simulation, Collection<Element> configXML, boolean visAvailable) {
    setSimulation(simulation);
    myMoteInterfaceHandler = createMoteInterfaceHandler();

    /* Create watchpoint container */
    try {
      breakpointsContainer =
          new MspBreakpointContainer(this, ((MspMoteType) getType()).getFirmwareDebugInfo());
    } catch (IOException e) {
      throw (RuntimeException) new RuntimeException("Error: " + e.getMessage()).initCause(e);
    }

    for (Element element : configXML) {
      String name = element.getName();

      if (name.equals("motetype_identifier")) {
        /* Ignored: handled by simulation */
      } else if ("breakpoints".equals(element.getName())) {
        breakpointsContainer.setConfigXML(element.getChildren(), visAvailable);
      } else if (name.equals("interface_config")) {
        String intfClass = element.getText().trim();
        if (intfClass.equals("se.sics.cooja.mspmote.interfaces.MspIPAddress")) {
          intfClass = IPAddress.class.getName();
        }
        if (intfClass.equals("se.sics.cooja.mspmote.interfaces.ESBLog")) {
          intfClass = MspSerial.class.getName();
        }
        if (intfClass.equals("se.sics.cooja.mspmote.interfaces.SkySerial")) {
          intfClass = MspSerial.class.getName();
        }
        Class<? extends MoteInterface> moteInterfaceClass =
            simulation.getGUI().tryLoadClass(this, MoteInterface.class, intfClass);

        if (moteInterfaceClass == null) {
          logger.fatal("Could not load mote interface class: " + intfClass);
          return false;
        }

        MoteInterface moteInterface = getInterfaces().getInterfaceOfType(moteInterfaceClass);
        moteInterface.setConfigXML(element.getChildren(), visAvailable);
      }
    }

    /* Schedule us immediately */
    requestImmediateWakeup();
    return true;
  }
示例#2
0
  public Collection<Element> getConfigXML() {
    ArrayList<Element> config = new ArrayList<Element>();
    Element element;

    /* Breakpoints */
    element = new Element("breakpoints");
    element.addContent(breakpointsContainer.getConfigXML());
    config.add(element);

    // Mote interfaces
    for (MoteInterface moteInterface : getInterfaces().getInterfaces()) {
      element = new Element("interface_config");
      element.setText(moteInterface.getClass().getName());

      Collection<Element> interfaceXML = moteInterface.getConfigXML();
      if (interfaceXML != null) {
        element.addContent(interfaceXML);
        config.add(element);
      }
    }

    return config;
  }
示例#3
0
 public void removeWatchpointListener(ActionListener listener) {
   breakpointsContainer.removeWatchpointListener(listener);
 }
示例#4
0
 public ActionListener[] getWatchpointListeners() {
   return breakpointsContainer.getWatchpointListeners();
 }
示例#5
0
 public Mote getMote() {
   return breakpointsContainer.getMote();
 }
示例#6
0
 public Watchpoint getLastWatchpoint() {
   return breakpointsContainer.getLastWatchpoint();
 }
示例#7
0
 /* Watchpoints: Forward to breakpoint container */
 public void addWatchpointListener(ActionListener listener) {
   breakpointsContainer.addWatchpointListener(listener);
 }