From a3eb42387fa9752a3f2d171cb9177d4ef98432b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20=27Morty=27=20Str=C3=BCbe?= Date: Tue, 30 Oct 2012 11:41:56 +0100 Subject: [PATCH] Cooja: Give access to uninitialized motes --- .../cooja/java/se/sics/cooja/Simulation.java | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tools/cooja/java/se/sics/cooja/Simulation.java b/tools/cooja/java/se/sics/cooja/Simulation.java index 3e76cbde7..125e907d5 100644 --- a/tools/cooja/java/se/sics/cooja/Simulation.java +++ b/tools/cooja/java/se/sics/cooja/Simulation.java @@ -59,7 +59,8 @@ public class Simulation extends Observable implements Runnable { /*private static long EVENT_COUNTER = 0;*/ private Vector motes = new Vector(); - + private Vector motesUninit = new Vector(); + private Vector moteTypes = new Vector(); /* If true, run simulation at full speed */ @@ -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. *