added method for turning off radio receiver of application motes
This commit is contained in:
parent
f4d19560fc
commit
8ec88e2fcb
|
@ -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: ApplicationRadio.java,v 1.12 2010/02/05 09:07:58 fros4943 Exp $
|
* $Id: ApplicationRadio.java,v 1.13 2010/02/08 16:00:46 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.interfaces;
|
package se.sics.cooja.interfaces;
|
||||||
|
@ -83,7 +83,7 @@ public class ApplicationRadio extends Radio {
|
||||||
private double outputPower = 0;
|
private double outputPower = 0;
|
||||||
private int outputPowerIndicator = 100;
|
private int outputPowerIndicator = 100;
|
||||||
|
|
||||||
private int interfered;
|
private int interfered;
|
||||||
|
|
||||||
public ApplicationRadio(Mote mote) {
|
public ApplicationRadio(Mote mote) {
|
||||||
this.mote = mote;
|
this.mote = mote;
|
||||||
|
@ -119,14 +119,14 @@ private int interfered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void signalReceptionEnd() {
|
public void signalReceptionEnd() {
|
||||||
//System.out.println("SignalReceptionEnded for node: " + mote.getID() + " intf:" + interfered);
|
//System.out.println("SignalReceptionEnded for node: " + mote.getID() + " intf:" + interfered);
|
||||||
if (isInterfered() || packetToMote == null) {
|
if (isInterfered() || packetToMote == null) {
|
||||||
interfered--;
|
interfered--;
|
||||||
if (interfered == 0) isInterfered = false;
|
if (interfered == 0) isInterfered = false;
|
||||||
if (interfered < 0) {
|
if (interfered < 0) {
|
||||||
isInterfered = false;
|
isInterfered = false;
|
||||||
//logger.warn("Interfered got lower than 0!!!");
|
//logger.warn("Interfered got lower than 0!!!");
|
||||||
interfered = 0;
|
interfered = 0;
|
||||||
}
|
}
|
||||||
packetToMote = null;
|
packetToMote = null;
|
||||||
if (interfered > 0) return;
|
if (interfered > 0) return;
|
||||||
|
@ -346,7 +346,19 @@ private int interfered;
|
||||||
return mote;
|
return mote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean radioOn = true;
|
||||||
|
public void setReceiverOn(boolean radioOn) {
|
||||||
|
if (this.radioOn == radioOn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.radioOn = radioOn;
|
||||||
|
lastEvent = radioOn?RadioEvent.HW_ON:RadioEvent.HW_OFF;
|
||||||
|
lastEventTime = simulation.getSimulationTime();
|
||||||
|
this.setChanged();
|
||||||
|
this.notifyObservers();
|
||||||
|
}
|
||||||
public boolean isReceiverOn() {
|
public boolean isReceiverOn() {
|
||||||
return true;
|
return radioOn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue