From b96b3ae8c6e6e24d0f4ab9e1a3ede68cd50343a6 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Mon, 17 Mar 2008 10:10:17 +0000 Subject: [PATCH] only using distance when calculating received signal strength for nodes closer than transmitting range --- tools/cooja/java/se/sics/cooja/radiomediums/UDGM.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/radiomediums/UDGM.java b/tools/cooja/java/se/sics/cooja/radiomediums/UDGM.java index e4cee91e2..57bbb7f69 100644 --- a/tools/cooja/java/se/sics/cooja/radiomediums/UDGM.java +++ b/tools/cooja/java/se/sics/cooja/radiomediums/UDGM.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: UDGM.java,v 1.15 2008/03/17 09:49:44 fros4943 Exp $ + * $Id: UDGM.java,v 1.16 2008/03/17 10:10:17 fros4943 Exp $ */ package se.sics.cooja.radiomediums; @@ -536,8 +536,12 @@ public class UDGM extends AbstractRadioMedium { for (Radio intfRadio : conn.getInterfered()) { double dist = conn.getSource().getPosition().getDistanceTo(intfRadio.getPosition()); double distFactor = dist/TRANSMITTING_RANGE; - double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG); - intfRadio.setCurrentSignalStrength(signalStrength); + if (distFactor < 1) { + double signalStrength = SS_STRONG + distFactor*(SS_WEAK - SS_STRONG); + intfRadio.setCurrentSignalStrength(signalStrength); + } else { + intfRadio.setCurrentSignalStrength(SS_WEAK); + } if (!intfRadio.isInterfered()) { // Set to interfered again