From: Fredrik Ãs. <fro...@us...> - 2008-10-29 09:13:27
|
Update of /cvsroot/contiki/contiki-2.x/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13787/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces Modified Files: TR1001Radio.java Log Message: using time events for following up on ongoing transmissions Index: TR1001Radio.java =================================================================== RCS file: /cvsroot/contiki/contiki-2.x/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/TR1001Radio.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TR1001Radio.java 18 Mar 2008 16:47:17 -0000 1.6 --- TR1001Radio.java 29 Oct 2008 09:13:12 -0000 1.7 *************** *** 42,45 **** --- 42,46 ---- import se.sics.mspsim.core.*; import se.sics.cooja.*; + import se.sics.cooja.TimeEvent; import se.sics.cooja.interfaces.*; import se.sics.cooja.mspmote.ESBMote; *************** *** 49,53 **** * preambles, synchbytes, GCR coding, CRC16. * ! * @author Fredrik Osterlind */ @ClassDescription("TR1001 Radio") --- 50,54 ---- * preambles, synchbytes, GCR coding, CRC16. * ! * @author Fredrik Österlind */ @ClassDescription("TR1001 Radio") *************** *** 60,64 **** public static final long CYCLES_BETWEEN_BYTES = 1200; /* ~19.200 bps */ ! private ESBMote mspMote; private boolean radioOn = true; --- 61,65 ---- public static final long CYCLES_BETWEEN_BYTES = 1200; /* ~19.200 bps */ ! private ESBMote mote; private boolean radioOn = true; *************** *** 117,121 **** */ public TR1001Radio(ESBMote mote) { ! mspMote = mote; /* Start listening to CPU's USART */ --- 118,122 ---- */ public TR1001Radio(ESBMote mote) { ! this.mote = mote; /* Start listening to CPU's USART */ *************** *** 239,247 **** transmitting = true; ! transmissionStartCycles = mspMote.getCPU().cycles; lastDeliveredByteTimestamp = transmissionStartCycles; lastEvent = RadioEvent.TRANSMISSION_STARTED; ! lastEventTime = mspMote.getSimulation().getSimulationTime(); this.setChanged(); this.notifyObservers(); --- 240,248 ---- transmitting = true; ! transmissionStartCycles = mote.getCPU().cycles; lastDeliveredByteTimestamp = transmissionStartCycles; lastEvent = RadioEvent.TRANSMISSION_STARTED; ! lastEventTime = mote.getSimulation().getSimulationTime(); this.setChanged(); this.notifyObservers(); *************** *** 250,253 **** --- 251,255 ---- // Remember recent radio activity ticksSinceLastSend = 0; + mote.getSimulation().scheduleEvent(followupTransmissionEvent, mote.getSimulation().getSimulationTime()+1); if (outgoingDataLength >= outgoingData.length) { *************** *** 259,267 **** /*logger.debug("----- TR1001 DELIVERED BYTE -----");*/ lastEvent = RadioEvent.CUSTOM_DATA_TRANSMITTED; ! tr1001ByteFromMote = new TR1001RadioByte((byte) data, mspMote.getCPU().cycles - lastDeliveredByteTimestamp); this.setChanged(); this.notifyObservers(); ! lastDeliveredByteTimestamp = mspMote.getCPU().cycles; outgoingData[outgoingDataLength++] = tr1001ByteFromMote; --- 261,269 ---- /*logger.debug("----- TR1001 DELIVERED BYTE -----");*/ lastEvent = RadioEvent.CUSTOM_DATA_TRANSMITTED; ! tr1001ByteFromMote = new TR1001RadioByte((byte) data, mote.getCPU().cycles - lastDeliveredByteTimestamp); this.setChanged(); this.notifyObservers(); ! lastDeliveredByteTimestamp = mote.getCPU().cycles; outgoingData[outgoingDataLength++] = tr1001ByteFromMote; *************** *** 342,346 **** lastEvent = RadioEvent.RECEPTION_INTERFERED; ! lastEventTime = mspMote.getSimulation().getSimulationTime(); this.setChanged(); this.notifyObservers(); --- 344,348 ---- lastEvent = RadioEvent.RECEPTION_INTERFERED; ! lastEventTime = mote.getSimulation().getSimulationTime(); this.setChanged(); this.notifyObservers(); *************** *** 371,402 **** public Position getPosition() { ! return mspMote.getInterfaces().getPosition(); } ! public void doActionsBeforeTick() { ! } ! public void doActionsAfterTick() { ! // Detect transmission end due to inactivity ! if (isTransmitting() && ticksSinceLastSend > 4) { ! /* Dropping packet due to inactivity */ ! packetFromMote = null; ! // Reset counters and wait for next packet ! outgoingDataLength = 0; ! ticksSinceLastSend = -1; ! // Signal we are done transmitting ! transmitting = false; ! lastEvent = RadioEvent.TRANSMISSION_FINISHED; ! this.setChanged(); ! this.notifyObservers(); ! //logger.debug("----- NULL TRANSMISSION ENDED -----"); ! } else if (isTransmitting() && ticksSinceLastSend >= 0) { ! // Increase counter to detect when transmission ends ! ticksSinceLastSend++; } ! } public JPanel getInterfaceVisualizer() { --- 373,408 ---- public Position getPosition() { ! return mote.getInterfaces().getPosition(); } ! private TimeEvent followupTransmissionEvent = new TimeEvent(0) { ! public void execute(int t) { ! if (isTransmitting()) { ! ticksSinceLastSend++; ! // Detect transmission end due to inactivity ! if (ticksSinceLastSend > 4) { ! /* Dropping packet due to inactivity */ ! packetFromMote = null; ! /* Reset counters and wait for next packet */ ! outgoingDataLength = 0; ! ticksSinceLastSend = -1; ! /* Signal we are done transmitting */ ! transmitting = false; ! lastEvent = RadioEvent.TRANSMISSION_FINISHED; ! TR1001Radio.this.setChanged(); ! TR1001Radio.this.notifyObservers(); ! ! /*logger.debug("----- NULL TRANSMISSION ENDED -----");*/ ! } ! ! /* Reschedule as long as node is transmitting */ ! mote.getSimulation().scheduleEvent(this, t+1); ! } } ! }; public JPanel getInterfaceVisualizer() { *************** *** 476,480 **** } ! public double energyConsumptionPerTick() { return 0; } --- 482,486 ---- } ! public double energyConsumption() { return 0; } *************** *** 488,492 **** public Mote getMote() { ! return mspMote; } } --- 494,498 ---- public Mote getMote() { ! return mote; } } |