*cleaned up some code

*updated signal strengths to those stated in cooja core interface
This commit is contained in:
fros4943 2006-12-07 14:28:54 +00:00
parent d59ef75617
commit 37bbf515f2

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: StandardRadioMedium.java,v 1.8 2006/10/11 15:14:10 fros4943 Exp $
* $Id: StandardRadioMedium.java,v 1.9 2006/12/07 14:28:54 fros4943 Exp $
*/
package se.sics.cooja.radiomediums;
@ -76,9 +76,9 @@ public class StandardRadioMedium extends RadioMedium {
public static final double SS_NOTHING = -200;
public static final double SS_BAD = -110;
public static final double SS_BAD = -60;
public static final double SS_OK = -100;
public static final double SS_OK = 0;
/**
* Visualizes radio traffic in the current radio medium. Allows a user to
@ -375,27 +375,28 @@ public class StandardRadioMedium extends RadioMedium {
pendingConnections.add(newConnection);
newConnection.setSource(sendingRadio, sendingPosition, dataToSend);
// Fetch current output power indicator (scale with as percent)
// TODO Probably not the best way to use indicator
double moteInterferenceRange = INTERFERENCE_RANGE
* (0.01 * (double) sendingRadio.getCurrentOutputPowerIndicator());
double moteTransmissionRange = TRANSMITTING_RANGE
* (0.01 * (double) sendingRadio.getCurrentOutputPowerIndicator());
// Loop through all radios that are listening
for (int listenNr = 0; listenNr < registeredPositions.size(); listenNr++) {
Radio listeningRadio = registeredRadios.get(listenNr);
// If not the sending radio..
if (sendingRadio != listeningRadio) {
if (sendingRadio == listeningRadio)
continue;
if (sendingRadio.getChannel() != listeningRadio.getChannel())
continue;
// If not the sending radio..
double distance = sendingPosition.getDistanceTo(registeredPositions
.get(listenNr));
// Fetch current output power indicator (scale with as percent)
// TODO Probably not the best way to use indicator
double moteInterferenceRange = INTERFERENCE_RANGE
* (0.01 * (double) sendingRadio
.getCurrentOutputPowerIndicator());
double moteTransmissionRange = TRANSMITTING_RANGE
* (0.01 * (double) sendingRadio
.getCurrentOutputPowerIndicator());
if (distance <= moteTransmissionRange
&& sendingRadio.getChannel() == listeningRadio.getChannel()) {
if (distance <= moteTransmissionRange) {
newConnection.addDestination(registeredRadios.get(listenNr),
registeredPositions.get(listenNr), dataToSend);
@ -411,8 +412,7 @@ public class StandardRadioMedium extends RadioMedium {
.getTransmissionEndTime());
listeningRadio.setCurrentSignalStrength(SS_OK);
}
} else if (distance <= moteInterferenceRange
&& sendingRadio.getChannel() == listeningRadio.getChannel()) {
} else if (distance <= moteInterferenceRange) {
// If close enough to sabotage other transmissions..
listeningRadio.interferReception(sendingRadio
.getTransmissionEndTime());
@ -421,7 +421,6 @@ public class StandardRadioMedium extends RadioMedium {
// else too far away
}
}
}
if (((Radio) radio).getLastEvent() == Radio.RadioEvent.TRANSMISSION_FINISHED) {
transmissionEndedRadios.add((Radio) radio);