From b13e9dde90f9114ae2a65b5472e38f9a555d2352 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Wed, 4 Jul 2007 16:13:17 +0000 Subject: [PATCH] saving random seed with simconfig --- tools/cooja/java/se/sics/cooja/Simulation.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/Simulation.java b/tools/cooja/java/se/sics/cooja/Simulation.java index 0a45086ce..ec03fdece 100644 --- a/tools/cooja/java/se/sics/cooja/Simulation.java +++ b/tools/cooja/java/se/sics/cooja/Simulation.java @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: Simulation.java,v 1.14 2007/07/04 07:44:13 fros4943 Exp $ + * $Id: Simulation.java,v 1.15 2007/07/04 16:13:17 fros4943 Exp $ */ package se.sics.cooja; @@ -304,6 +304,11 @@ public class Simulation extends Observable implements Runnable { element.setText(Integer.toString(tickTime)); config.add(element); + // Random seed + element = new Element("randomseed"); + element.setText(Long.toString(randomSeed)); + config.add(element); + // Radio Medium element = new Element("radiomedium"); element.setText(currentRadioMedium.getClass().getName()); @@ -372,6 +377,12 @@ public class Simulation extends Observable implements Runnable { tickTime = Integer.parseInt(element.getText()); } + // Random seed + if (element.getName().equals("randomseed")) { + randomSeed = Long.parseLong(element.getText()); + delayMotesRandom.setSeed(randomSeed); + } + // Radio medium if (element.getName().equals("radiomedium")) { String radioMediumClassName = element.getText().trim(); @@ -492,7 +503,6 @@ public class Simulation extends Observable implements Runnable { } else motes.add(mote); - tickListRandom.setSeed(randomSeed); if (maxDelayedStartupTime > 0 && mote instanceof ContikiMote) { ((ContikiClock) mote.getInterfaces().getClock()).setDrift(-delayMotesRandom.nextInt(maxDelayedStartupTime)); }