implementing custom data objects

This commit is contained in:
fros4943 2008-03-18 15:48:00 +00:00
parent 6e6857c6a6
commit 32b5f206b1

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: SkyRadio.java,v 1.2 2008/03/18 13:34:20 fros4943 Exp $ * $Id: SkyRadio.java,v 1.3 2008/03/18 15:48:00 fros4943 Exp $
*/ */
package se.sics.cooja.mspmote.interfaces; package se.sics.cooja.mspmote.interfaces;
@ -41,6 +41,7 @@ import org.apache.log4j.Logger;
import org.jdom.Element; import org.jdom.Element;
import se.sics.cooja.*; import se.sics.cooja.*;
import se.sics.cooja.interfaces.CustomDataRadio;
import se.sics.cooja.interfaces.Position; import se.sics.cooja.interfaces.Position;
import se.sics.cooja.interfaces.Radio; import se.sics.cooja.interfaces.Radio;
import se.sics.cooja.mspmote.SkyMote; import se.sics.cooja.mspmote.SkyMote;
@ -53,7 +54,7 @@ import se.sics.mspsim.chip.PacketListener;
* @author Fredrik Osterlind * @author Fredrik Osterlind
*/ */
@ClassDescription("CC2420") @ClassDescription("CC2420")
public class SkyRadio extends Radio { public class SkyRadio extends Radio implements CustomDataRadio {
private static Logger logger = Logger.getLogger(SkyRadio.class); private static Logger logger = Logger.getLogger(SkyRadio.class);
private int lastEventTime = 0; private int lastEventTime = 0;
@ -90,6 +91,7 @@ public class SkyRadio extends Radio {
public void transmissionStarted() { public void transmissionStarted() {
lastEventTime = myMote.getSimulation().getSimulationTime(); lastEventTime = myMote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.TRANSMISSION_STARTED; lastEvent = RadioEvent.TRANSMISSION_STARTED;
/*logger.debug("----- SKY TRANSMISSION STARTED -----");*/
setChanged(); setChanged();
notifyObservers(); notifyObservers();
} }
@ -104,6 +106,7 @@ public class SkyRadio extends Radio {
lastEventTime = myMote.getSimulation().getSimulationTime(); lastEventTime = myMote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.CUSTOM_DATA_TRANSMITTED; lastEvent = RadioEvent.CUSTOM_DATA_TRANSMITTED;
/*logger.debug("----- SKY CUSTOM DATA TRANSMITTED -----");*/
setChanged(); setChanged();
notifyObservers(); notifyObservers();
@ -111,10 +114,12 @@ public class SkyRadio extends Radio {
lastEventTime = myMote.getSimulation().getSimulationTime(); lastEventTime = myMote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.PACKET_TRANSMITTED; lastEvent = RadioEvent.PACKET_TRANSMITTED;
/*logger.debug("----- SKY PACKET TRANSMITTED -----");*/
setChanged(); setChanged();
notifyObservers(); notifyObservers();
lastEventTime = myMote.getSimulation().getSimulationTime(); lastEventTime = myMote.getSimulation().getSimulationTime();
/*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
lastEvent = RadioEvent.TRANSMISSION_FINISHED; lastEvent = RadioEvent.TRANSMISSION_FINISHED;
setChanged(); setChanged();
notifyObservers(); notifyObservers();
@ -136,6 +141,21 @@ public class SkyRadio extends Radio {
lastIncomingCC2420Packet = CC2420RadioPacketConverter.fromCoojaToCC24240(packet); lastIncomingCC2420Packet = CC2420RadioPacketConverter.fromCoojaToCC24240(packet);
} }
/* Custom data radio support */
public Object getLastCustomDataTransmitted() {
return lastOutgoingCC2420Packet;
}
public Object getLastCustomDataReceived() {
return lastIncomingCC2420Packet;
}
public void receiveCustomData(Object data) {
if (data instanceof CC2420RadioPacket) {
lastIncomingCC2420Packet = (CC2420RadioPacket) data;
}
}
/* General radio support */ /* General radio support */
public boolean isTransmitting() { public boolean isTransmitting() {
return isTransmitting; return isTransmitting;
@ -164,6 +184,7 @@ public class SkyRadio extends Radio {
lastEventTime = myMote.getSimulation().getSimulationTime(); lastEventTime = myMote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_STARTED; lastEvent = RadioEvent.RECEPTION_STARTED;
/*logger.debug("----- SKY RECEPTION STARTED -----");*/
setChanged(); setChanged();
notifyObservers(); notifyObservers();
} }
@ -186,6 +207,7 @@ public class SkyRadio extends Radio {
lastEventTime = myMote.getSimulation().getSimulationTime(); lastEventTime = myMote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_FINISHED; lastEvent = RadioEvent.RECEPTION_FINISHED;
/*logger.debug("----- SKY RECEPTION FINISHED -----");*/
setChanged(); setChanged();
notifyObservers(); notifyObservers();
} }
@ -203,6 +225,7 @@ public class SkyRadio extends Radio {
lastEventTime = myMote.getSimulation().getSimulationTime(); lastEventTime = myMote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_INTERFERED; lastEvent = RadioEvent.RECEPTION_INTERFERED;
/*logger.debug("----- SKY RECEPTION INTERFERED -----");*/
setChanged(); setChanged();
notifyObservers(); notifyObservers();
} }