Cooja: Give access to uninitialized motes

This commit is contained in:
Moritz 'Morty' Strübe 2012-10-30 11:41:56 +01:00
parent becd2d4e15
commit a3eb42387f

View File

@ -59,6 +59,7 @@ public class Simulation extends Observable implements Runnable {
/*private static long EVENT_COUNTER = 0;*/
private Vector<Mote> motes = new Vector<Mote>();
private Vector<Mote> motesUninit = new Vector<Mote>();
private Vector<MoteType> moteTypes = new Vector<MoteType>();
@ -819,6 +820,7 @@ public class Simulation extends Observable implements Runnable {
}
motes.add(mote);
motesUninit.remove(mote);
currentRadioMedium.registerMote(mote, Simulation.this);
/* Notify mote interfaces that node was added */
@ -838,6 +840,9 @@ public class Simulation extends Observable implements Runnable {
/* Add mote from simulation thread */
invokeSimulationThread(addMote);
}
//Add to list of uninitialized motes
motesUninit.add(mote);
}
/**
@ -868,6 +873,24 @@ public class Simulation extends Observable implements Runnable {
return null;
}
/**
* Returns uninitialised simulation mote with with given ID.
*
* @param id ID
* @return Mote or null
* @see Mote#getID()
*/
public Mote getMoteWithIDUninit(int id) {
for (Mote m: motesUninit) {
if (m.getID() == id) {
return m;
}
}
return null;
}
/**
* Returns number of motes in this simulation.
*
@ -888,6 +911,16 @@ public class Simulation extends Observable implements Runnable {
return arr;
}
/**
* Returns uninitialised motes
*
* @return Motes
*/
public Mote[] getMotesUninit() {
return motesUninit.toArray(new Mote[motesUninit.size()]);
}
/**
* Returns all mote types in simulation.
*