From cb04423a57806b8b9f69dfe547195cc602d7c2d9 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Wed, 28 Oct 2009 14:35:10 +0000 Subject: [PATCH] added default methods for saving and restoring the mote id --- .../java/se/sics/cooja/interfaces/MoteID.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/interfaces/MoteID.java b/tools/cooja/java/se/sics/cooja/interfaces/MoteID.java index bc94c5136..05ab4f33d 100644 --- a/tools/cooja/java/se/sics/cooja/interfaces/MoteID.java +++ b/tools/cooja/java/se/sics/cooja/interfaces/MoteID.java @@ -26,11 +26,17 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MoteID.java,v 1.1 2006/08/21 12:12:58 fros4943 Exp $ + * $Id: MoteID.java,v 1.2 2009/10/28 14:35:10 fros4943 Exp $ */ package se.sics.cooja.interfaces; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Vector; + +import org.jdom.Element; + import se.sics.cooja.*; /** @@ -49,8 +55,23 @@ public abstract class MoteID extends MoteInterface { /** * Sets mote ID to given number. - * @param newID New mote ID number + * @param id New mote ID number */ - public abstract void setMoteID(int newID); + public abstract void setMoteID(int id); + public Collection getConfigXML() { + ArrayList config = new ArrayList(); + Element element = new Element("id"); + element.setText(Integer.toString(getMoteID())); + config.add(element); + return config; + } + + public void setConfigXML(Collection configXML, boolean visAvailable) { + for (Element element : configXML) { + if (element.getName().equals("id")) { + setMoteID(Integer.parseInt(element.getText())); + } + } + } }