main random generator must not be used for setup tasks such as node positioning

This commit is contained in:
fros4943 2009-02-18 11:49:54 +00:00
parent fbb09061c8
commit cc56325300
2 changed files with 9 additions and 7 deletions

View file

@ -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: ESBMote.java,v 1.5 2008/10/28 17:02:13 fros4943 Exp $ * $Id: ESBMote.java,v 1.6 2009/02/18 11:50:11 fros4943 Exp $
*/ */
package se.sics.cooja.mspmote; package se.sics.cooja.mspmote;
@ -73,7 +73,7 @@ public class ESBMote 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);

View file

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: DisturberMote.java,v 1.5 2008/12/04 14:03:42 joxe Exp $ * $Id: DisturberMote.java,v 1.6 2009/02/18 11:49:54 fros4943 Exp $
*/ */
package se.sics.cooja.motes; package se.sics.cooja.motes;
@ -57,8 +57,6 @@ public class DisturberMote implements Mote {
private Simulation mySim = null; private Simulation mySim = null;
private Random myRandom = new Random();
private DisturberRadio myDisturberRadio; private DisturberRadio myDisturberRadio;
/** /**
@ -79,6 +77,7 @@ public class DisturberMote implements Mote {
public DisturberMote(MoteType moteType, Simulation sim) { public DisturberMote(MoteType moteType, Simulation sim) {
mySim = sim; mySim = sim;
myType = moteType; myType = moteType;
Random random = new Random(); /* Do not use main random generator for positioning */
// Create memory // Create memory
myMemory = new SectionMoteMemory(new Properties()); myMemory = new SectionMoteMemory(new Properties());
@ -86,8 +85,11 @@ public class DisturberMote implements Mote {
// Create interface handler // Create interface handler
myInterfaceHandler = new MoteInterfaceHandler(); myInterfaceHandler = new MoteInterfaceHandler();
Position myPosition = new Position(this); Position myPosition = new Position(this);
myPosition.setCoordinates(myRandom.nextDouble() * 100, myRandom myPosition.setCoordinates(
.nextDouble() * 100, myRandom.nextDouble() * 100); random.nextDouble() * 100,
random.nextDouble() * 100,
random.nextDouble() * 100
);
myInterfaceHandler.addInterface(myPosition); myInterfaceHandler.addInterface(myPosition);
// create interface handler for radio // create interface handler for radio