net.tinyos.sim.script.reflect
Class Radio

java.lang.Object
  |
  +--net.tinyos.sim.script.reflect.SimReflect
        |
        +--net.tinyos.sim.script.reflect.Radio

public class Radio
extends net.tinyos.sim.script.reflect.SimReflect

Interface class to the radio model.

The class is bound into the simcore module as the radio global instance.


Constructor Summary
Radio(net.tinyos.sim.script.ScriptInterpreter interp, net.tinyos.sim.SimDriver driver)
           
 
Method Summary
 void disable()
          Disables the radio model plugin altogether.
 double distanceToPacketLoss(double distance)
          Convert a distance into a packet loss probability according to the current radio model.
 double distanceToPacketLoss(double distance, java.lang.String model)
          Convert a distance into a packet loss probability according to the specified radio model.
 void enable()
          Re-enables the radio model plugin.
 java.lang.String getCurModel()
          Return the name of the current radio model.
 double getLossRate(int senderID, int receiverID)
          Get the packet loss rate between two motes.
 double getScalingFactor()
          Return the radio model scaling factor.
 double packetLossToBitError(double packetLoss)
          Convert a requested packet loss probability into a bit error rate, according to the current radio model.
 double packetLossToBitError(double packetLoss, java.lang.String model)
          Convert a requested packet loss probability into a bit error rate, according to the specified radio model.
 void printLossRates()
          Dump the current loss rate table to the console.
 void publishModel()
          Publishes all the current radio model values to the simulator.
 void setAutoPublish(boolean autoPublish)
          Set the auto publish flag in the radio model.
 void setCurModel(java.lang.String modelname)
          Set the radio model.
 void setLossRate(int senderID, int receiverID, double prob)
          Set the packet loss rate between two motes.
 void setScalingFactor(double scalingFactor)
          Set the radio model scaling factor.
 void updateModel()
          Forces a recalculation of the radio loss model by iterating over all pairs of motes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Radio

public Radio(net.tinyos.sim.script.ScriptInterpreter interp,
             net.tinyos.sim.SimDriver driver)
Method Detail

getCurModel

public java.lang.String getCurModel()
Return the name of the current radio model.


setCurModel

public void setCurModel(java.lang.String modelname)
Set the radio model.

Parameters:
modelname - the name of the new model (e.g. "empirical")

getScalingFactor

public double getScalingFactor()
Return the radio model scaling factor.

Returns:
the current scaling factor

setScalingFactor

public void setScalingFactor(double scalingFactor)
Set the radio model scaling factor.

Parameters:
scalingFactor - the new scaling factor

getLossRate

public double getLossRate(int senderID,
                          int receiverID)
Get the packet loss rate between two motes.

Parameters:
senderID - id of the sender mote
receiverID - id of the receiver mote

setLossRate

public void setLossRate(int senderID,
                        int receiverID,
                        double prob)
Set the packet loss rate between two motes.

Parameters:
senderID - id of the sender mote
receiverID - id of the receiver mote
prob - new loss probability

printLossRates

public void printLossRates()
Dump the current loss rate table to the console.


packetLossToBitError

public double packetLossToBitError(double packetLoss)
Convert a requested packet loss probability into a bit error rate, according to the current radio model.

Parameters:
packetLoss - requested packet loss probability

packetLossToBitError

public double packetLossToBitError(double packetLoss,
                                   java.lang.String model)
Convert a requested packet loss probability into a bit error rate, according to the specified radio model.

Parameters:
packetLoss - requested packet loss probability
model - name of the radio model to use

distanceToPacketLoss

public double distanceToPacketLoss(double distance)
Convert a distance into a packet loss probability according to the current radio model.

Parameters:
distance - the distance between two motes

distanceToPacketLoss

public double distanceToPacketLoss(double distance,
                                   java.lang.String model)
Convert a distance into a packet loss probability according to the specified radio model.

Parameters:
distance - the distance between two motes
model - name of the radio model to use

setAutoPublish

public void setAutoPublish(boolean autoPublish)
Set the auto publish flag in the radio model. With this flag enabled, all changes, either due to mote movement or due to programmatic settings, are propagated to the simulator. When auto publish is turned off, the updateModel() function must be called to propagate settings from the simdriver to the simulator.

Parameters:
autoPublish - value of the autoPublish feature

updateModel

public void updateModel()
Forces a recalculation of the radio loss model by iterating over all pairs of motes.


publishModel

public void publishModel()
Publishes all the current radio model values to the simulator. See setAutoPublish() for more information.


disable

public void disable()
Disables the radio model plugin altogether.


enable

public void enable()
Re-enables the radio model plugin.