minor changes and documentation regarding using random generators in Cooja
This commit is contained in:
parent
cc56325300
commit
00273dce75
7 changed files with 373 additions and 334 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: AreaViewer.java,v 1.4 2008/02/15 13:20:23 fros4943 Exp $
|
* $Id: AreaViewer.java,v 1.5 2009/02/18 12:08:10 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.mrm;
|
package se.sics.mrm;
|
||||||
|
@ -2128,7 +2128,7 @@ public class AreaViewer extends VisPlugin {
|
||||||
g2d.setTransform(realWorldTransformScaled);
|
g2d.setTransform(realWorldTransformScaled);
|
||||||
g2d.setStroke(new BasicStroke((float) 0.0));
|
g2d.setStroke(new BasicStroke((float) 0.0));
|
||||||
|
|
||||||
Random random = new Random();
|
Random random = new Random(); /* Do not use main random generator */
|
||||||
for (int i=0; i < trackedComponents.size(); i++) {
|
for (int i=0; i < trackedComponents.size(); i++) {
|
||||||
g2d.setColor(new Color(255, random.nextInt(255), random.nextInt(255), 255));
|
g2d.setColor(new Color(255, random.nextInt(255), random.nextInt(255), 255));
|
||||||
Line2D originalLine = trackedComponents.get(i);
|
Line2D originalLine = trackedComponents.get(i);
|
||||||
|
|
|
@ -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: ChannelModel.java,v 1.3 2007/03/23 21:13:43 fros4943 Exp $
|
* $Id: ChannelModel.java,v 1.4 2009/02/18 12:08:10 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.mrm;
|
package se.sics.mrm;
|
||||||
|
@ -85,9 +85,6 @@ public class ChannelModel {
|
||||||
}
|
}
|
||||||
private SettingsObservable settingsObservable = new SettingsObservable();
|
private SettingsObservable settingsObservable = new SettingsObservable();
|
||||||
|
|
||||||
// A random number generator
|
|
||||||
private Random random = new Random();
|
|
||||||
|
|
||||||
public ChannelModel() {
|
public ChannelModel() {
|
||||||
// - Set initial parameter values -
|
// - Set initial parameter values -
|
||||||
|
|
||||||
|
@ -243,9 +240,10 @@ public class ChannelModel {
|
||||||
public void addRectObstacle(double startX, double startY, double width, double height, boolean notify) {
|
public void addRectObstacle(double startX, double startY, double width, double height, boolean notify) {
|
||||||
myObstacleWorld.addObstacle(startX, startY, width, height);
|
myObstacleWorld.addObstacle(startX, startY, width, height);
|
||||||
|
|
||||||
if (notify)
|
if (notify) {
|
||||||
settingsObservable.notifySettingsChanged();
|
settingsObservable.notifySettingsChanged();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Number of registered obstacles
|
* @return Number of registered obstacles
|
||||||
|
@ -405,17 +403,21 @@ public class ChannelModel {
|
||||||
// Check which sides of the rectangle the test line passes through
|
// Check which sides of the rectangle the test line passes through
|
||||||
Vector<Line2D> intersectedSides = new Vector<Line2D>();
|
Vector<Line2D> intersectedSides = new Vector<Line2D>();
|
||||||
|
|
||||||
if (rectangleLower.intersectsLine(testLine))
|
if (rectangleLower.intersectsLine(testLine)) {
|
||||||
intersectedSides.add(rectangleLower);
|
intersectedSides.add(rectangleLower);
|
||||||
|
}
|
||||||
|
|
||||||
if (rectangleUpper.intersectsLine(testLine))
|
if (rectangleUpper.intersectsLine(testLine)) {
|
||||||
intersectedSides.add(rectangleUpper);
|
intersectedSides.add(rectangleUpper);
|
||||||
|
}
|
||||||
|
|
||||||
if (rectangleLeft.intersectsLine(testLine))
|
if (rectangleLeft.intersectsLine(testLine)) {
|
||||||
intersectedSides.add(rectangleLeft);
|
intersectedSides.add(rectangleLeft);
|
||||||
|
}
|
||||||
|
|
||||||
if (rectangleRight.intersectsLine(testLine))
|
if (rectangleRight.intersectsLine(testLine)) {
|
||||||
intersectedSides.add(rectangleRight);
|
intersectedSides.add(rectangleRight);
|
||||||
|
}
|
||||||
|
|
||||||
// If no sides are intersected, return null (no intersection)
|
// If no sides are intersected, return null (no intersection)
|
||||||
if (intersectedSides.isEmpty()) {
|
if (intersectedSides.isEmpty()) {
|
||||||
|
@ -449,8 +451,9 @@ public class ChannelModel {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intersectingLinePoints.get(0).distance(intersectingLinePoints.get(1)) < 0.001)
|
if (intersectingLinePoints.get(0).distance(intersectingLinePoints.get(1)) < 0.001) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new Line2D.Double(
|
return new Line2D.Double(
|
||||||
intersectingLinePoints.get(0),
|
intersectingLinePoints.get(0),
|
||||||
|
@ -472,9 +475,10 @@ public class ChannelModel {
|
||||||
double dy2 = secondLine.getY2() - secondLine.getY1();
|
double dy2 = secondLine.getY2() - secondLine.getY1();
|
||||||
double det = (dx2*dy1-dy2*dx1);
|
double det = (dx2*dy1-dy2*dx1);
|
||||||
|
|
||||||
if (det == 0.0)
|
if (det == 0.0) {
|
||||||
// Lines parallell, not intersecting
|
// Lines parallell, not intersecting
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
double mu = ((firstLine.getX1() - secondLine.getX1())*dy1 - (firstLine.getY1() - secondLine.getY1())*dx1)/det;
|
double mu = ((firstLine.getX1() - secondLine.getX1())*dy1 - (firstLine.getY1() - secondLine.getY1())*dx1)/det;
|
||||||
if (mu >= 0.0 && mu <= 1.0) {
|
if (mu >= 0.0 && mu <= 1.0) {
|
||||||
|
@ -502,9 +506,10 @@ public class ChannelModel {
|
||||||
double dy2 = secondLine.getY2() - secondLine.getY1();
|
double dy2 = secondLine.getY2() - secondLine.getY1();
|
||||||
double det = (dx2*dy1-dy2*dx1);
|
double det = (dx2*dy1-dy2*dx1);
|
||||||
|
|
||||||
if (det == 0.0)
|
if (det == 0.0) {
|
||||||
// Lines parallell, not intersecting
|
// Lines parallell, not intersecting
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
double mu = ((firstLine.getX1() - secondLine.getX1())*dy1 - (firstLine.getY1() - secondLine.getY1())*dx1)/det;
|
double mu = ((firstLine.getX1() - secondLine.getX1())*dy1 - (firstLine.getY1() - secondLine.getY1())*dx1)/det;
|
||||||
Point2D.Double intersectionPoint = new Point2D.Double((secondLine.getX1() + mu*dx2),
|
Point2D.Double intersectionPoint = new Point2D.Double((secondLine.getX1() + mu*dx2),
|
||||||
|
@ -577,10 +582,11 @@ public class ChannelModel {
|
||||||
Rectangle2D bounds = reflectingSide.getBounds2D();
|
Rectangle2D bounds = reflectingSide.getBounds2D();
|
||||||
double newPsuedoSourceX = source.getX();
|
double newPsuedoSourceX = source.getX();
|
||||||
double newPsuedoSourceY = source.getY();
|
double newPsuedoSourceY = source.getY();
|
||||||
if (bounds.getHeight() > bounds.getWidth())
|
if (bounds.getHeight() > bounds.getWidth()) {
|
||||||
newPsuedoSourceX = 2*reflectingSide.getX1() - newPsuedoSourceX;
|
newPsuedoSourceX = 2*reflectingSide.getX1() - newPsuedoSourceX;
|
||||||
else
|
} else {
|
||||||
newPsuedoSourceY = 2*reflectingSide.getY1() - newPsuedoSourceY;
|
newPsuedoSourceY = 2*reflectingSide.getY1() - newPsuedoSourceY;
|
||||||
|
}
|
||||||
|
|
||||||
// Recursively build and add subtrees
|
// Recursively build and add subtrees
|
||||||
RayData newRayData = new RayData(
|
RayData newRayData = new RayData(
|
||||||
|
@ -663,10 +669,11 @@ public class ChannelModel {
|
||||||
// Check if direct path exists
|
// Check if direct path exists
|
||||||
justBeforeDestination = sourcePoint;
|
justBeforeDestination = sourcePoint;
|
||||||
|
|
||||||
if (!getParameterBooleanValue("rt_disallow_direct_path"))
|
if (!getParameterBooleanValue("rt_disallow_direct_path")) {
|
||||||
directPathExists = isDirectPath(justBeforeDestination, dest);
|
directPathExists = isDirectPath(justBeforeDestination, dest);
|
||||||
else
|
} else {
|
||||||
directPathExists = false;
|
directPathExists = false;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (type == RayData.RayType.REFRACTION && pseudoSourceToDest.intersectsLine(line)) {
|
} else if (type == RayData.RayType.REFRACTION && pseudoSourceToDest.intersectsLine(line)) {
|
||||||
|
|
||||||
|
@ -742,8 +749,9 @@ public class ChannelModel {
|
||||||
currentPath.addPoint(newestPoint, currentlyTracedNodeType);
|
currentPath.addPoint(newestPoint, currentlyTracedNodeType);
|
||||||
|
|
||||||
// Check that this ray subpath is long enough to be considered
|
// Check that this ray subpath is long enough to be considered
|
||||||
if (newestPoint.distance(lastPoint) < 0.01)
|
if (newestPoint.distance(lastPoint) < 0.01) {
|
||||||
pathBroken = true;
|
pathBroken = true;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Trace further up in the tree
|
// Trace further up in the tree
|
||||||
|
@ -764,18 +772,20 @@ public class ChannelModel {
|
||||||
currentPath.addPoint(newestPoint, currentlyTracedNodeType);
|
currentPath.addPoint(newestPoint, currentlyTracedNodeType);
|
||||||
|
|
||||||
// Check that this ray subpath is long enough to be considered
|
// Check that this ray subpath is long enough to be considered
|
||||||
if (newestPoint == null || lastPoint == null || newestPoint.distance(lastPoint) < 0.01)
|
if (newestPoint == null || lastPoint == null || newestPoint.distance(lastPoint) < 0.01) {
|
||||||
pathBroken = true;
|
pathBroken = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Subpath must be double-direct if from diffraction
|
// Subpath must be double-direct if from diffraction
|
||||||
if (currentlyTracedNodeType == RayData.RayType.DIFFRACTION && !isDirectPath(lastPoint, newestPoint)) {
|
if (currentlyTracedNodeType == RayData.RayType.DIFFRACTION && !isDirectPath(lastPoint, newestPoint)) {
|
||||||
pathBroken = true;
|
pathBroken = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pathBroken)
|
if (pathBroken) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Save ray path
|
// Save ray path
|
||||||
if (!pathBroken) {
|
if (!pathBroken) {
|
||||||
|
@ -827,11 +837,12 @@ public class ChannelModel {
|
||||||
if (visibleSides.get(i).intersectsLine(sourceToDest)) {
|
if (visibleSides.get(i).intersectsLine(sourceToDest)) {
|
||||||
// Check that intersection point is not destination
|
// Check that intersection point is not destination
|
||||||
Point2D intersectionPoint = getIntersectionPointInfinite(visibleSides.get(i), sourceToDest);
|
Point2D intersectionPoint = getIntersectionPointInfinite(visibleSides.get(i), sourceToDest);
|
||||||
if (dest.distance(intersectionPoint) > 0.01)
|
if (dest.distance(intersectionPoint) > 0.01) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -942,16 +953,18 @@ public class ChannelModel {
|
||||||
Vector<AngleInterval> unhandledAngles = new Vector<AngleInterval>();
|
Vector<AngleInterval> unhandledAngles = new Vector<AngleInterval>();
|
||||||
|
|
||||||
if (lookThrough != null) {
|
if (lookThrough != null) {
|
||||||
if (angleInterval == null)
|
if (angleInterval == null) {
|
||||||
unhandledAngles.add(AngleInterval.getAngleIntervalOfLine(source, lookThrough));
|
unhandledAngles.add(AngleInterval.getAngleIntervalOfLine(source, lookThrough));
|
||||||
else
|
|
||||||
unhandledAngles.add(AngleInterval.getAngleIntervalOfLine(source, lookThrough).intersectWith(angleInterval));
|
|
||||||
} else {
|
} else {
|
||||||
if (angleInterval == null)
|
unhandledAngles.add(AngleInterval.getAngleIntervalOfLine(source, lookThrough).intersectWith(angleInterval));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (angleInterval == null) {
|
||||||
unhandledAngles.add(new AngleInterval(0, 2*Math.PI));
|
unhandledAngles.add(new AngleInterval(0, 2*Math.PI));
|
||||||
else
|
} else {
|
||||||
unhandledAngles.add(angleInterval);
|
unhandledAngles.add(angleInterval);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do forever (will break when no more unhandled angles exist)
|
// Do forever (will break when no more unhandled angles exist)
|
||||||
while (!unhandledAngles.isEmpty()) {
|
while (!unhandledAngles.isEmpty()) {
|
||||||
|
@ -985,22 +998,26 @@ public class ChannelModel {
|
||||||
Rectangle2D obstacle = visibleObstacleCandidates.get(i);
|
Rectangle2D obstacle = visibleObstacleCandidates.get(i);
|
||||||
int outcode = obstacle.outcode(source);
|
int outcode = obstacle.outcode(source);
|
||||||
|
|
||||||
if ((outcode & Rectangle2D.OUT_BOTTOM) != 0)
|
if ((outcode & Rectangle2D.OUT_BOTTOM) != 0) {
|
||||||
visibleLineCandidates.add(
|
visibleLineCandidates.add(
|
||||||
new Line2D.Double(obstacle.getMinX(), obstacle.getMaxY(), obstacle.getMaxX(), obstacle.getMaxY()));
|
new Line2D.Double(obstacle.getMinX(), obstacle.getMaxY(), obstacle.getMaxX(), obstacle.getMaxY()));
|
||||||
|
}
|
||||||
|
|
||||||
if ((outcode & Rectangle2D.OUT_TOP) != 0)
|
if ((outcode & Rectangle2D.OUT_TOP) != 0) {
|
||||||
visibleLineCandidates.add(
|
visibleLineCandidates.add(
|
||||||
new Line2D.Double(obstacle.getMinX(), obstacle.getMinY(), obstacle.getMaxX(), obstacle.getMinY()));
|
new Line2D.Double(obstacle.getMinX(), obstacle.getMinY(), obstacle.getMaxX(), obstacle.getMinY()));
|
||||||
|
}
|
||||||
|
|
||||||
if ((outcode & Rectangle2D.OUT_LEFT) != 0)
|
if ((outcode & Rectangle2D.OUT_LEFT) != 0) {
|
||||||
visibleLineCandidates.add(
|
visibleLineCandidates.add(
|
||||||
new Line2D.Double(obstacle.getMinX(), obstacle.getMinY(), obstacle.getMinX(), obstacle.getMaxY()));
|
new Line2D.Double(obstacle.getMinX(), obstacle.getMinY(), obstacle.getMinX(), obstacle.getMaxY()));
|
||||||
|
}
|
||||||
|
|
||||||
if ((outcode & Rectangle2D.OUT_RIGHT) != 0)
|
if ((outcode & Rectangle2D.OUT_RIGHT) != 0) {
|
||||||
visibleLineCandidates.add(
|
visibleLineCandidates.add(
|
||||||
new Line2D.Double(obstacle.getMaxX(), obstacle.getMinY(), obstacle.getMaxX(), obstacle.getMaxY()));
|
new Line2D.Double(obstacle.getMaxX(), obstacle.getMinY(), obstacle.getMaxX(), obstacle.getMaxY()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//logger.info("Line candidates count = " + visibleLineCandidates.size());
|
//logger.info("Line candidates count = " + visibleLineCandidates.size());
|
||||||
if (visibleLineCandidates.isEmpty()) {
|
if (visibleLineCandidates.isEmpty()) {
|
||||||
//logger.info("Visible line candidates empty");
|
//logger.info("Visible line candidates empty");
|
||||||
|
@ -1039,7 +1056,9 @@ public class ChannelModel {
|
||||||
).intersectsLine(lookThrough)) {
|
).intersectsLine(lookThrough)) {
|
||||||
croppedVisibleLineCandidates.add(lineCandidate);
|
croppedVisibleLineCandidates.add(lineCandidate);
|
||||||
} // else Skip line
|
} // else Skip line
|
||||||
} else croppedVisibleLineCandidates.add(lineCandidate);
|
} else {
|
||||||
|
croppedVisibleLineCandidates.add(lineCandidate);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,7 +1113,9 @@ public class ChannelModel {
|
||||||
).intersectsLine(lookThrough)) {
|
).intersectsLine(lookThrough)) {
|
||||||
croppedVisibleLineCandidates.add(newCropped);
|
croppedVisibleLineCandidates.add(newCropped);
|
||||||
} // else Skip line
|
} // else Skip line
|
||||||
} else croppedVisibleLineCandidates.add(newCropped);
|
} else {
|
||||||
|
croppedVisibleLineCandidates.add(newCropped);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1197,20 +1218,25 @@ public class ChannelModel {
|
||||||
Vector<AngleInterval> tempVector1 =
|
Vector<AngleInterval> tempVector1 =
|
||||||
AngleInterval.intersect(unhandledAngles, intersectedInterval);
|
AngleInterval.intersect(unhandledAngles, intersectedInterval);
|
||||||
|
|
||||||
if (tempVector1 != null)
|
if (tempVector1 != null) {
|
||||||
for (int k=0; k < tempVector1.size(); k++)
|
for (int k=0; k < tempVector1.size(); k++) {
|
||||||
if (tempVector1.get(k) != null && !tempVector1.get(k).isEmpty()) {
|
if (tempVector1.get(k) != null && !tempVector1.get(k).isEmpty()) {
|
||||||
newIntervalsToAdd.add(tempVector1.get(k));
|
newIntervalsToAdd.add(tempVector1.get(k));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add angle interval of visible candidate without shadow candidate
|
// Add angle interval of visible candidate without shadow candidate
|
||||||
Vector<AngleInterval> tempVector2 =
|
Vector<AngleInterval> tempVector2 =
|
||||||
visibleLineCandidateAngleInterval.subtract(shadowLineCandidateAngleInterval);
|
visibleLineCandidateAngleInterval.subtract(shadowLineCandidateAngleInterval);
|
||||||
if (tempVector2 != null)
|
if (tempVector2 != null) {
|
||||||
for (int k=0; k < tempVector2.size(); k++)
|
for (int k=0; k < tempVector2.size(); k++) {
|
||||||
if (tempVector2.get(k) != null && !tempVector2.get(k).isEmpty())
|
if (tempVector2.get(k) != null && !tempVector2.get(k).isEmpty()) {
|
||||||
newIntervalsToAdd.addAll(AngleInterval.intersect(unhandledAngles, tempVector2.get(k)));
|
newIntervalsToAdd.addAll(AngleInterval.intersect(unhandledAngles, tempVector2.get(k)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Subtract angle interval of visible candidate
|
// Subtract angle interval of visible candidate
|
||||||
unhandledAngles = AngleInterval.subtract(unhandledAngles, visibleLineCandidateAngleInterval);
|
unhandledAngles = AngleInterval.subtract(unhandledAngles, visibleLineCandidateAngleInterval);
|
||||||
|
@ -1233,9 +1259,10 @@ public class ChannelModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!unshadowed)
|
if (!unshadowed) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (unhandledAnglesChanged) {
|
if (unhandledAnglesChanged) {
|
||||||
//logger.info("Unhandled angles changed, restarting..");
|
//logger.info("Unhandled angles changed, restarting..");
|
||||||
|
@ -1438,8 +1465,9 @@ public class ChannelModel {
|
||||||
double pathLengthDiff = Math.abs(pathLengths[i] - pathLengths[bestSignalNr]);
|
double pathLengthDiff = Math.abs(pathLengths[i] - pathLengths[bestSignalNr]);
|
||||||
|
|
||||||
// Update delay spread TODO Now considering best signal, should be first or mean?
|
// Update delay spread TODO Now considering best signal, should be first or mean?
|
||||||
if (pathLengthDiff > delaySpread)
|
if (pathLengthDiff > delaySpread) {
|
||||||
delaySpread = pathLengthDiff;
|
delaySpread = pathLengthDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update root-mean-square delay spread TODO Now considering best signal time, should be mean delay?
|
// Update root-mean-square delay spread TODO Now considering best signal time, should be mean delay?
|
||||||
|
@ -1481,10 +1509,10 @@ public class ChannelModel {
|
||||||
// Using formula (dB)
|
// Using formula (dB)
|
||||||
// Received power = Output power + System gain + Transmitter gain + Path Loss + Receiver gain
|
// Received power = Output power + System gain + Transmitter gain + Path Loss + Receiver gain
|
||||||
// TODO Update formulas
|
// TODO Update formulas
|
||||||
Random random = new Random();
|
|
||||||
double outputPower = getParameterDoubleValue("tx_power");
|
double outputPower = getParameterDoubleValue("tx_power");
|
||||||
double systemGain = getParameterDoubleValue("system_gain_mean");
|
double systemGain = getParameterDoubleValue("system_gain_mean");
|
||||||
if (getParameterBooleanValue("apply_random")) {
|
if (getParameterBooleanValue("apply_random")) {
|
||||||
|
Random random = new Random(); /* TODO Use main random generator? */
|
||||||
systemGain += Math.sqrt(getParameterDoubleValue("system_gain_var")) * random.nextGaussian();
|
systemGain += Math.sqrt(getParameterDoubleValue("system_gain_var")) * random.nextGaussian();
|
||||||
} else {
|
} else {
|
||||||
accumulatedVariance += getParameterDoubleValue("system_gain_var");
|
accumulatedVariance += getParameterDoubleValue("system_gain_var");
|
||||||
|
@ -1496,8 +1524,9 @@ public class ChannelModel {
|
||||||
logger.info("Resulting received signal strength:\t" + receivedPower + " (" + accumulatedVariance + ")");
|
logger.info("Resulting received signal strength:\t" + receivedPower + " (" + accumulatedVariance + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataType == TransmissionData.DELAY_SPREAD || dataType == TransmissionData.DELAY_SPREAD_RMS)
|
if (dataType == TransmissionData.DELAY_SPREAD || dataType == TransmissionData.DELAY_SPREAD_RMS) {
|
||||||
return new double[] {delaySpread, delaySpreadRMS};
|
return new double[] {delaySpread, delaySpreadRMS};
|
||||||
|
}
|
||||||
|
|
||||||
return new double[] {receivedPower, accumulatedVariance};
|
return new double[] {receivedPower, accumulatedVariance};
|
||||||
}
|
}
|
||||||
|
@ -1558,10 +1587,12 @@ public class ChannelModel {
|
||||||
double noiseVariance = getParameterDoubleValue("bg_noise_var");
|
double noiseVariance = getParameterDoubleValue("bg_noise_var");
|
||||||
double noiseMean = getParameterDoubleValue("bg_noise_mean");
|
double noiseMean = getParameterDoubleValue("bg_noise_mean");
|
||||||
|
|
||||||
if (interference > noiseMean)
|
if (interference > noiseMean) {
|
||||||
noiseMean = interference;
|
noiseMean = interference;
|
||||||
|
}
|
||||||
|
|
||||||
if (getParameterBooleanValue("apply_random")) {
|
if (getParameterBooleanValue("apply_random")) {
|
||||||
|
Random random = new Random(); /* TODO Use main random generator? */
|
||||||
noiseMean += Math.sqrt(noiseVariance) * random.nextGaussian();
|
noiseMean += Math.sqrt(noiseVariance) * random.nextGaussian();
|
||||||
noiseVariance = 0;
|
noiseVariance = 0;
|
||||||
}
|
}
|
||||||
|
@ -1613,10 +1644,11 @@ public class ChannelModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not random varianble, probability is either 1 or 0
|
// If not random varianble, probability is either 1 or 0
|
||||||
if (snrVariance == 0)
|
if (snrVariance == 0) {
|
||||||
return new double[] {
|
return new double[] {
|
||||||
threshold - snrMean > 0 ? 0:1, signalStrength
|
threshold - snrMean > 0 ? 0:1, signalStrength
|
||||||
};
|
};
|
||||||
|
}
|
||||||
double snrStdDev = Math.sqrt(snrVariance);
|
double snrStdDev = Math.sqrt(snrVariance);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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: MRM.java,v 1.7 2008/03/18 16:37:35 fros4943 Exp $
|
* $Id: MRM.java,v 1.8 2009/02/18 12:08:10 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.mrm;
|
package se.sics.mrm;
|
||||||
|
@ -63,7 +63,7 @@ public class MRM extends AbstractRadioMedium {
|
||||||
private ChannelModel currentChannelModel = null;
|
private ChannelModel currentChannelModel = null;
|
||||||
private Simulation mySimulation = null;
|
private Simulation mySimulation = null;
|
||||||
|
|
||||||
private Random random = new Random();
|
private Random random = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies observers when this radio medium has changed settings.
|
* Notifies observers when this radio medium has changed settings.
|
||||||
|
@ -75,6 +75,7 @@ public class MRM extends AbstractRadioMedium {
|
||||||
*/
|
*/
|
||||||
public MRM(Simulation simulation) {
|
public MRM(Simulation simulation) {
|
||||||
super(simulation);
|
super(simulation);
|
||||||
|
random = simulation.getRandomGenerator();
|
||||||
|
|
||||||
// Create the channel model
|
// Create the channel model
|
||||||
currentChannelModel = new ChannelModel();
|
currentChannelModel = new ChannelModel();
|
||||||
|
|
|
@ -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: SkyMote.java,v 1.10 2009/02/07 16:38:51 joxe Exp $
|
* $Id: SkyMote.java,v 1.11 2009/02/18 12:08:37 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote;
|
package se.sics.cooja.mspmote;
|
||||||
|
@ -74,7 +74,7 @@ public class SkyMote extends MspMote {
|
||||||
|
|
||||||
// Add position interface
|
// Add position interface
|
||||||
Position motePosition = new Position(this);
|
Position motePosition = new Position(this);
|
||||||
Random random = new Random();
|
Random random = new Random(); /* Do not use main random generator for positioning */
|
||||||
motePosition.setCoordinates(random.nextDouble()*100, random.nextDouble()*100, random.nextDouble()*100);
|
motePosition.setCoordinates(random.nextDouble()*100, random.nextDouble()*100, random.nextDouble()*100);
|
||||||
moteInterfaceHandler.addInterface(motePosition);
|
moteInterfaceHandler.addInterface(motePosition);
|
||||||
|
|
||||||
|
|
|
@ -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: DummyVisualizer.java,v 1.1 2008/10/28 16:56:59 fros4943 Exp $
|
* $Id: DummyVisualizer.java,v 1.2 2009/02/18 12:07:42 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
@ -50,8 +50,6 @@ public class DummyVisualizer extends Visualizer2D {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static Logger logger = Logger.getLogger(DummyVisualizer.class);
|
private static Logger logger = Logger.getLogger(DummyVisualizer.class);
|
||||||
|
|
||||||
private Random random = new Random();
|
|
||||||
|
|
||||||
public DummyVisualizer(Simulation simulationToVisualize, GUI gui) {
|
public DummyVisualizer(Simulation simulationToVisualize, GUI gui) {
|
||||||
super(simulationToVisualize, gui);
|
super(simulationToVisualize, gui);
|
||||||
setTitle("Dummy Visualizer");
|
setTitle("Dummy Visualizer");
|
||||||
|
@ -60,6 +58,7 @@ public class DummyVisualizer extends Visualizer2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color[] getColorOf(Mote m) {
|
public Color[] getColorOf(Mote m) {
|
||||||
|
Random random = new Random(); /* Do not use main random generator */
|
||||||
Color moteColors[] = new Color[2];
|
Color moteColors[] = new Color[2];
|
||||||
|
|
||||||
/* Outer color */
|
/* Outer color */
|
||||||
|
@ -76,6 +75,7 @@ public class DummyVisualizer extends Visualizer2D {
|
||||||
|
|
||||||
/* TODO Analyze data - determine color */
|
/* TODO Analyze data - determine color */
|
||||||
|
|
||||||
|
Random random = new Random(); /* Do not use main random generator */
|
||||||
return new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256));
|
return new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,11 @@
|
||||||
* 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: RandomIPDistributor.java,v 1.1 2006/08/21 12:13:06 fros4943 Exp $
|
* $Id: RandomIPDistributor.java,v 1.2 2009/02/18 12:07:19 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.ipdistributors;
|
package se.sics.cooja.ipdistributors;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import se.sics.cooja.*;
|
import se.sics.cooja.*;
|
||||||
|
|
||||||
|
@ -42,16 +43,17 @@ import se.sics.cooja.*;
|
||||||
@ClassDescription("Random (10.10.?.?)")
|
@ClassDescription("Random (10.10.?.?)")
|
||||||
public class RandomIPDistributor extends IPDistributor {
|
public class RandomIPDistributor extends IPDistributor {
|
||||||
|
|
||||||
|
private Random random = new Random(); /* Do not use main random generator for setup */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a random IP distributor.
|
* Creates a random IP distributor.
|
||||||
* @param newMotes All motes which later will be assigned IP numbers.
|
* @param newMotes All motes which later will be assigned IP numbers.
|
||||||
*/
|
*/
|
||||||
public RandomIPDistributor(Vector<Mote> newMotes) {
|
public RandomIPDistributor(Vector<Mote> newMotes) {
|
||||||
// NOP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNextIPAddress() {
|
public String getNextIPAddress() {
|
||||||
return "" + 10 + "." + 10 + "." + (Math.round(Math.random()*20) + 1) + "." + (Math.round(Math.random()*20) + 1);
|
return "" + 10 + "." + 10 + "." + (1+random.nextInt(20)) + "." + (1+random.nextInt(20));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,12 @@
|
||||||
* 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: RandomPositioner.java,v 1.1 2006/08/21 12:13:11 fros4943 Exp $
|
* $Id: RandomPositioner.java,v 1.2 2009/02/18 12:07:19 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.positioners;
|
package se.sics.cooja.positioners;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import se.sics.cooja.*;
|
import se.sics.cooja.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,6 +43,8 @@ import se.sics.cooja.*;
|
||||||
public class RandomPositioner extends Positioner {
|
public class RandomPositioner extends Positioner {
|
||||||
double startX, endX, startY, endY, startZ, endZ;
|
double startX, endX, startY, endY, startZ, endZ;
|
||||||
|
|
||||||
|
private Random random = new Random(); /* Do not use main random generator for setup */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a random positioner.
|
* Creates a random positioner.
|
||||||
* @param totalNumberOfMotes Total number of motes
|
* @param totalNumberOfMotes Total number of motes
|
||||||
|
@ -65,9 +69,9 @@ public class RandomPositioner extends Positioner {
|
||||||
|
|
||||||
public double[] getNextPosition() {
|
public double[] getNextPosition() {
|
||||||
return new double[] {
|
return new double[] {
|
||||||
startX + Math.random()*(endX - startX),
|
startX + random.nextDouble()*(endX - startX),
|
||||||
startY + Math.random()*(endY - startY),
|
startY + random.nextDouble()*(endY - startY),
|
||||||
startZ + Math.random()*(endZ - startZ)
|
startZ + random.nextDouble()*(endZ - startZ)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue