added support for multiple log mote interfaces / mote

This commit is contained in:
fros4943 2009-12-07 11:06:08 +00:00
parent 5e251b837a
commit c1520a7134

View file

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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; package se.sics.cooja;
@ -240,9 +240,10 @@ public class SimEventCentral {
/* Start observing all log interfaces */ /* Start observing all log interfaces */
Mote[] motes = simulation.getMotes(); Mote[] motes = simulation.getMotes();
for (Mote m: motes) { for (Mote m: motes) {
Log log = m.getInterfaces().getLog(); for (MoteInterface mi: m.getInterfaces().getInterfaces()) {
if (log != null) { if (mi instanceof Log) {
moteObservations.add(new MoteObservation(m, log, logOutputObserver)); moteObservations.add(new MoteObservation(m, mi, logOutputObserver));
}
} }
} }
} }
@ -303,10 +304,12 @@ public class SimEventCentral {
/* HELP METHODS: MAINTAIN OBSERVERS */ /* HELP METHODS: MAINTAIN OBSERVERS */
private void moteWasAdded(Mote mote) { private void moteWasAdded(Mote mote) {
if (logOutputListeners.length > 0) { if (logOutputListeners.length > 0) {
/* Add another log output observation */ /* Add another log output observation.
Log log = mote.getInterfaces().getLog(); * (Supports multiple log interfaces per mote) */
if (log != null) { for (MoteInterface mi: mote.getInterfaces().getInterfaces()) {
moteObservations.add(new MoteObservation(mote, log, logOutputObserver)); if (mi instanceof Log) {
moteObservations.add(new MoteObservation(mote, mi, logOutputObserver));
}
} }
} }