fixed interference in app radio

This commit is contained in:
joxe 2010-01-24 23:16:17 +00:00
parent c0e7eb21bc
commit 940a2903f2

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ApplicationRadio.java,v 1.10 2009/10/28 14:38:02 fros4943 Exp $
* $Id: ApplicationRadio.java,v 1.11 2010/01/24 23:16:17 joxe Exp $
*/
package se.sics.cooja.interfaces;
@ -83,6 +83,8 @@ public class ApplicationRadio extends Radio {
private double outputPower = 0;
private int outputPowerIndicator = 100;
private int interfered;
public ApplicationRadio(Mote mote) {
this.mote = mote;
this.simulation = mote.getSimulation();
@ -117,10 +119,17 @@ public class ApplicationRadio extends Radio {
}
public void signalReceptionEnd() {
//System.out.println("SignalReceptionEnded for node: " + mote.getID() + " intf:" + interfered);
if (isInterfered() || packetToMote == null) {
isInterfered = false;
interfered--;
if (interfered == 0) isInterfered = false;
if (interfered < 0) {
isInterfered = false;
//logger.warn("Interfered got lower than 0!!!");
interfered = 0;
}
packetToMote = null;
return;
if (interfered > 0) return;
}
isReceiving = false;
@ -154,7 +163,9 @@ public class ApplicationRadio extends Radio {
return lastEvent;
}
/* Note: this must be called exactly as many times as the reception ended */
public void interfereAnyReception() {
interfered++;
if (!isInterfered()) {
isInterfered = true;