added new mote type method that returns the by default used mote interfaces, as opposed to all compatible mote

interfaces

this allows a user to override default settings in the create-new-mote-type dialogs
This commit is contained in:
Fredrik Osterlind 2013-08-14 13:30:15 +02:00
parent 8e264badb7
commit 9929cc2a10
5 changed files with 39 additions and 11 deletions

View file

@ -32,16 +32,17 @@ package se.sics.cooja.avrmote.interfaces;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import se.sics.cooja.ClassDescription;
import se.sics.cooja.Mote;
import se.sics.cooja.avrmote.MicaZMote;
import se.sics.cooja.emulatedmote.Radio802154;
import se.sics.cooja.interfaces.CustomDataRadio;
import avrora.sim.FiniteStateMachine; import avrora.sim.FiniteStateMachine;
import avrora.sim.FiniteStateMachine.Probe; import avrora.sim.FiniteStateMachine.Probe;
import avrora.sim.platform.MicaZ; import avrora.sim.platform.MicaZ;
import avrora.sim.radio.CC2420Radio; import avrora.sim.radio.CC2420Radio;
import avrora.sim.radio.Medium; import avrora.sim.radio.Medium;
import se.sics.cooja.*;
import se.sics.cooja.avrmote.MicaZMote;
import se.sics.cooja.emulatedmote.Radio802154;
/** /**
* CC2420 to COOJA wrapper. * CC2420 to COOJA wrapper.
* *
@ -152,4 +153,11 @@ public class MicaZRadio extends Radio802154 {
//System.out.println("MicaZ: Received: " + (b &0xff)); //System.out.println("MicaZ: Received: " + (b &0xff));
recv.nextByte(true, (byte)b); recv.nextByte(true, (byte)b);
} }
public boolean canReceiveFrom(CustomDataRadio radio) {
if (radio.getClass().equals(this.getClass())) {
return true;
}
return false;
}
} }

View file

@ -423,4 +423,11 @@ public class Msp802154Radio extends Radio implements CustomDataRadio {
} }
return true; return true;
} }
public boolean canReceiveFrom(CustomDataRadio radio) {
if (radio.getClass().equals(this.getClass())) {
return true;
}
return false;
}
} }

View file

@ -357,4 +357,12 @@ public class TR1001Radio extends Radio implements USARTListener, CustomDataRadio
/* TODO Implement me */ /* TODO Implement me */
return true; return true;
} }
public boolean canReceiveFrom(CustomDataRadio radio) {
if (radio.getClass().equals(this.getClass())) {
return true;
}
return false;
}
} }

View file

@ -39,6 +39,8 @@ package se.sics.cooja.interfaces;
*/ */
public interface CustomDataRadio { public interface CustomDataRadio {
public boolean canReceiveFrom(CustomDataRadio radio);
public void receiveCustomData(Object data); public void receiveCustomData(Object data);
public Object getLastCustomDataTransmitted(); public Object getLastCustomDataTransmitted();

View file

@ -341,8 +341,8 @@ public abstract class AbstractRadioMedium extends RadioMedium {
} }
for (Radio dstRadio : connection.getAllDestinations()) { for (Radio dstRadio : connection.getAllDestinations()) {
if (!(dstRadio instanceof CustomDataRadio) ||
if (!radio.getClass().equals(dstRadio.getClass()) || !(radio instanceof CustomDataRadio)) { !((CustomDataRadio) dstRadio).canReceiveFrom((CustomDataRadio)radio)) {
/* Radios communicate via radio packets */ /* Radios communicate via radio packets */
continue; continue;
} }
@ -384,11 +384,14 @@ public abstract class AbstractRadioMedium extends RadioMedium {
for (Radio dstRadio : connection.getAllDestinations()) { for (Radio dstRadio : connection.getAllDestinations()) {
if (radio.getClass().equals(dstRadio.getClass()) && radio instanceof CustomDataRadio) { if ((radio instanceof CustomDataRadio) &&
(dstRadio instanceof CustomDataRadio) &&
((CustomDataRadio) dstRadio).canReceiveFrom((CustomDataRadio)radio)) {
/* Radios instead communicate via custom data objects */ /* Radios instead communicate via custom data objects */
continue; continue;
} }
/* Forward radio packet */ /* Forward radio packet */
if (connection.getDestinationDelay(dstRadio) == 0) { if (connection.getDestinationDelay(dstRadio) == 0) {
dstRadio.setReceivedPacket(packet); dstRadio.setReceivedPacket(packet);