added output power indicator max value + remade signal strength calculation per distance
This commit is contained in:
parent
660bc5e991
commit
7cf49fb57a
1 changed files with 23 additions and 22 deletions
|
@ -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: UDGM.java,v 1.14 2008/02/23 10:10:42 fros4943 Exp $
|
* $Id: UDGM.java,v 1.15 2008/03/17 09:49:44 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.radiomediums;
|
package se.sics.cooja.radiomediums;
|
||||||
|
@ -60,9 +60,8 @@ import se.sics.cooja.plugins.Visualizer2D;
|
||||||
* The radio output power indicator (0-100) is used in a very simple way; the
|
* The radio output power indicator (0-100) is used in a very simple way; the
|
||||||
* total transmission (and interfering) range is multiplied with [power_ind]%.
|
* total transmission (and interfering) range is multiplied with [power_ind]%.
|
||||||
*
|
*
|
||||||
* @see #SS_OK_BEST
|
* @see #SS_STRONG
|
||||||
* @see #SS_OK_WORST
|
* @see #SS_WEAK
|
||||||
* @see #SS_NOISE
|
|
||||||
* @see #SS_NOTHING
|
* @see #SS_NOTHING
|
||||||
*
|
*
|
||||||
* @see VisUDGM
|
* @see VisUDGM
|
||||||
|
@ -74,13 +73,13 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
|
|
||||||
private static RadioMedium myRadioMedium;
|
private static RadioMedium myRadioMedium;
|
||||||
|
|
||||||
public static final double SS_NOTHING = -200;
|
/* Signal strengths in dBm.
|
||||||
|
* Approx. values measured on TmoteSky */
|
||||||
|
public static final double SS_NOTHING = -100;
|
||||||
|
|
||||||
public static final double SS_NOISE = -60;
|
public static final double SS_STRONG = -10;
|
||||||
|
|
||||||
public static final double SS_OK_BEST = 0;
|
public static final double SS_WEAK = -95;
|
||||||
|
|
||||||
public static final double SS_OK_WORST = -30;
|
|
||||||
|
|
||||||
private static double SUCCESS_RATIO_TX = 1.0;
|
private static double SUCCESS_RATIO_TX = 1.0;
|
||||||
|
|
||||||
|
@ -358,12 +357,11 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
|
|
||||||
// Fetch current output power indicator (scale with as percent)
|
// Fetch current output power indicator (scale with as percent)
|
||||||
if (selectedMote.getInterfaces().getRadio() != null) {
|
if (selectedMote.getInterfaces().getRadio() != null) {
|
||||||
|
Radio selectedRadio = selectedMote.getInterfaces().getRadio();
|
||||||
double moteInterferenceRange = INTERFERENCE_RANGE
|
double moteInterferenceRange = INTERFERENCE_RANGE
|
||||||
* (0.01 * selectedMote.getInterfaces().getRadio()
|
* (selectedRadio.getCurrentOutputPowerIndicator() / selectedRadio.getOutputPowerIndicatorMax());
|
||||||
.getCurrentOutputPowerIndicator());
|
|
||||||
double moteTransmissionRange = TRANSMITTING_RANGE
|
double moteTransmissionRange = TRANSMITTING_RANGE
|
||||||
* (0.01 * selectedMote.getInterfaces().getRadio()
|
* (selectedRadio.getCurrentOutputPowerIndicator() / selectedRadio.getOutputPowerIndicatorMax());
|
||||||
.getCurrentOutputPowerIndicator());
|
|
||||||
|
|
||||||
Point translatedZero = transformPositionToPixel(0.0, 0.0, 0.0);
|
Point translatedZero = transformPositionToPixel(0.0, 0.0, 0.0);
|
||||||
Point translatedInterference = transformPositionToPixel(
|
Point translatedInterference = transformPositionToPixel(
|
||||||
|
@ -441,9 +439,9 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
|
|
||||||
// Fetch current output power indicator (scale with as percent)
|
// Fetch current output power indicator (scale with as percent)
|
||||||
double moteTransmissionRange = TRANSMITTING_RANGE
|
double moteTransmissionRange = TRANSMITTING_RANGE
|
||||||
* (0.01 * sendingRadio.getCurrentOutputPowerIndicator());
|
* (sendingRadio.getCurrentOutputPowerIndicator() / sendingRadio.getOutputPowerIndicatorMax());
|
||||||
double moteInterferenceRange = INTERFERENCE_RANGE
|
double moteInterferenceRange = INTERFERENCE_RANGE
|
||||||
* (0.01 * sendingRadio.getCurrentOutputPowerIndicator());
|
* (sendingRadio.getCurrentOutputPowerIndicator() / sendingRadio.getOutputPowerIndicatorMax());
|
||||||
|
|
||||||
/* Fail transmission randomly (affects all receiving nodes) */
|
/* Fail transmission randomly (affects all receiving nodes) */
|
||||||
if (SUCCESS_RATIO_TX < 1.0 && random.nextDouble() > SUCCESS_RATIO_TX) {
|
if (SUCCESS_RATIO_TX < 1.0 && random.nextDouble() > SUCCESS_RATIO_TX) {
|
||||||
|
@ -524,23 +522,26 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
|
|
||||||
// Set signal strength on all OK transmissions
|
// Set signal strength on all OK transmissions
|
||||||
for (RadioConnection conn : getActiveConnections()) {
|
for (RadioConnection conn : getActiveConnections()) {
|
||||||
conn.getSource().setCurrentSignalStrength(SS_OK_BEST);
|
conn.getSource().setCurrentSignalStrength(SS_STRONG);
|
||||||
for (Radio dstRadio : conn.getDestinations()) {
|
for (Radio dstRadio : conn.getDestinations()) {
|
||||||
double dist = conn.getSource().getPosition().getDistanceTo(dstRadio.getPosition());
|
double dist = conn.getSource().getPosition().getDistanceTo(dstRadio.getPosition());
|
||||||
double distFactor = dist/TRANSMITTING_RANGE;
|
double distFactor = dist/TRANSMITTING_RANGE;
|
||||||
distFactor = distFactor*distFactor;
|
double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG);
|
||||||
double signalStrength = SS_OK_BEST + distFactor*(SS_OK_WORST - SS_OK_BEST);
|
|
||||||
dstRadio.setCurrentSignalStrength(signalStrength);
|
dstRadio.setCurrentSignalStrength(signalStrength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set signal strength on all interferences
|
// Set signal strength on all interferences
|
||||||
for (RadioConnection conn : getActiveConnections()) {
|
for (RadioConnection conn : getActiveConnections()) {
|
||||||
for (Radio dstRadio : conn.getInterfered()) {
|
for (Radio intfRadio : conn.getInterfered()) {
|
||||||
dstRadio.setCurrentSignalStrength(SS_NOISE);
|
double dist = conn.getSource().getPosition().getDistanceTo(intfRadio.getPosition());
|
||||||
if (!dstRadio.isInterfered()) {
|
double distFactor = dist/TRANSMITTING_RANGE;
|
||||||
|
double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG);
|
||||||
|
intfRadio.setCurrentSignalStrength(signalStrength);
|
||||||
|
|
||||||
|
if (!intfRadio.isInterfered()) {
|
||||||
// Set to interfered again
|
// Set to interfered again
|
||||||
dstRadio.interfereAnyReception();
|
intfRadio.interfereAnyReception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue