public boolean setConfigXML( Simulation simulation, Collection<Element> configXML, boolean visAvailable) { for (Element element : configXML) { String name = element.getName(); if (name.equals("motetype_identifier")) { setSimulation(simulation); myMoteType = (MspMoteType) simulation.getMoteType(element.getText()); getType().setIdentifier(element.getText()); initEmulator(myMoteType.getContikiFirmwareFile()); myMoteInterfaceHandler = createMoteInterfaceHandler(); } else if (name.equals("interface_config")) { String intfClass = element.getText().trim(); if (intfClass.equals("se.sics.cooja.mspmote.interfaces.MspIPAddress")) { intfClass = IPAddress.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); } } return true; }
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; }
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; }
public Collection<Element> getConfigXML() { Vector<Element> config = new Vector<Element>(); Element element; // Mote type identifier element = new Element("motetype_identifier"); element.setText(getType().getIdentifier()); 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; }