added default methods for saving and restoring the mote id

This commit is contained in:
fros4943 2009-10-28 14:35:10 +00:00
parent 831f16cf61
commit cb04423a57

View file

@ -26,11 +26,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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; 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.*; import se.sics.cooja.*;
/** /**
@ -49,8 +55,23 @@ public abstract class MoteID extends MoteInterface {
/** /**
* Sets mote ID to given number. * 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<Element> getConfigXML() {
ArrayList<Element> config = new ArrayList<Element>();
Element element = new Element("id");
element.setText(Integer.toString(getMoteID()));
config.add(element);
return config;
}
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
for (Element element : configXML) {
if (element.getName().equals("id")) {
setMoteID(Integer.parseInt(element.getText()));
}
}
}
} }