From c1520a7134038a1de78c3a7138d0acd232b0a939 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Mon, 7 Dec 2009 11:06:08 +0000 Subject: [PATCH] added support for multiple log mote interfaces / mote --- .../java/se/sics/cooja/SimEventCentral.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/SimEventCentral.java b/tools/cooja/java/se/sics/cooja/SimEventCentral.java index c572d0c65..92d46247d 100644 --- a/tools/cooja/java/se/sics/cooja/SimEventCentral.java +++ b/tools/cooja/java/se/sics/cooja/SimEventCentral.java @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: SimEventCentral.java,v 1.2 2009/07/03 13:37:41 fros4943 Exp $ + * $Id: SimEventCentral.java,v 1.3 2009/12/07 11:06:08 fros4943 Exp $ */ package se.sics.cooja; @@ -240,9 +240,10 @@ public class SimEventCentral { /* Start observing all log interfaces */ Mote[] motes = simulation.getMotes(); for (Mote m: motes) { - Log log = m.getInterfaces().getLog(); - if (log != null) { - moteObservations.add(new MoteObservation(m, log, logOutputObserver)); + for (MoteInterface mi: m.getInterfaces().getInterfaces()) { + if (mi instanceof Log) { + moteObservations.add(new MoteObservation(m, mi, logOutputObserver)); + } } } } @@ -303,10 +304,12 @@ public class SimEventCentral { /* HELP METHODS: MAINTAIN OBSERVERS */ private void moteWasAdded(Mote mote) { if (logOutputListeners.length > 0) { - /* Add another log output observation */ - Log log = mote.getInterfaces().getLog(); - if (log != null) { - moteObservations.add(new MoteObservation(mote, log, logOutputObserver)); + /* Add another log output observation. + * (Supports multiple log interfaces per mote) */ + for (MoteInterface mi: mote.getInterfaces().getInterfaces()) { + if (mi instanceof Log) { + moteObservations.add(new MoteObservation(mote, mi, logOutputObserver)); + } } }