public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
    super.setConfigXML(configXML, visAvailable);

    random = simulation.getRandomGenerator();

    /* Wait until simulation has been loaded */
    delayedConfiguration = configXML;
    return true;
  }
  public void unregisterRadioInterface(Radio radio, Simulation sim) {
    super.unregisterRadioInterface(radio, sim);

    for (Edge edge : getEdges()) {
      if (edge.source == radio || edge.superDest.radio == radio) {
        removeEdge(edge);
        requestEdgeAnalysis();
      }
    }
  }
 public void removed() {
   super.removed();
 }
  public void simulationFinishedLoading() {
    if (delayedConfiguration == null) {
      return;
    }

    super.simulationFinishedLoading();

    boolean oldConfig = false;
    for (Element element : delayedConfiguration) {
      if (element.getName().equals("edge")) {
        @SuppressWarnings("unchecked")
        Collection<Element> edgeConfig = element.getChildren();
        Radio source = null;
        DGRMDestinationRadio dest = null;
        for (Element edgeElement : edgeConfig) {
          if (edgeElement.getName().equals("src")) {
            oldConfig = true;

            /* Old config: lookup source mote */
            for (Mote m : simulation.getMotes()) {
              if (m.toString().equals(edgeElement.getText())) {
                logger.info(
                    "Old config: mapping '" + edgeElement.getText() + "' to node " + m.getID());
                source = m.getInterfaces().getRadio();
                break;
              }
            }
          } else if (edgeElement.getName().equals("source")) {
            source =
                simulation
                    .getMoteWithID(Integer.parseInt(edgeElement.getText()))
                    .getInterfaces()
                    .getRadio();
          } else if (oldConfig && edgeElement.getName().equals("ratio")) {
            /* Old config: parse link ratio */
            double ratio = Double.parseDouble(edgeElement.getText());
            dest.ratio = ratio;
          } else if (edgeElement.getName().equals("dest")) {
            if (oldConfig) {
              /* Old config: create simple destination link */
              Radio destRadio = null;
              for (Mote m : simulation.getMotes()) {
                if (m.toString().equals(edgeElement.getText())) {
                  logger.info(
                      "Old config: mapping '" + edgeElement.getText() + "' to node " + m.getID());
                  destRadio = m.getInterfaces().getRadio();
                  break;
                }
              }
              dest = new DGRMDestinationRadio(destRadio);
            } else {
              String destClassName = edgeElement.getText().trim();
              if (destClassName == null || destClassName.isEmpty()) {
                continue;
              }
              /* Backwards compatibility: se.sics -> org.contikios */
              destClassName = destClassName.replaceFirst("^se\\.sics", "org.contikios");

              Class<? extends DGRMDestinationRadio> destClass =
                  simulation
                      .getCooja()
                      .tryLoadClass(this, DGRMDestinationRadio.class, destClassName);
              if (destClass == null) {
                throw new RuntimeException("Could not load class: " + destClassName);
              }
              try {
                dest = destClass.newInstance();
                @SuppressWarnings("unchecked")
                List<Element> children = edgeElement.getChildren();
                dest.setConfigXML(children, simulation);
              } catch (Exception e) {
                throw (RuntimeException)
                    new RuntimeException("Unknown class: " + destClassName).initCause(e);
              }
            }
          }
        }
        if (source == null || dest == null) {
          logger.fatal("Failed loading DGRM links, aborting");
          return;
        } else {
          addEdge(new Edge(source, dest));
        }
      }
    }
    requestEdgeAnalysis();
    delayedConfiguration = null;
  }