From d13f47a64f1c6e7bda4e660a3812d8d93656e1d4 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Thu, 20 Aug 2009 13:10:35 +0000 Subject: [PATCH] bugfix: clock drift must be set even when the random startup delay is zero --- tools/cooja/java/se/sics/cooja/Simulation.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/Simulation.java b/tools/cooja/java/se/sics/cooja/Simulation.java index beb9503e9..f845f24f9 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.51 2009/07/06 12:29:57 fros4943 Exp $ + * $Id: Simulation.java,v 1.52 2009/08/20 13:10:35 fros4943 Exp $ */ package se.sics.cooja; @@ -688,11 +688,15 @@ public class Simulation extends Observable implements Runnable { * Mote to add */ public void addMote(final Mote mote) { - if (maxMoteStartupDelay > 0 && mote.getInterfaces().getClock() != null) { - mote.getInterfaces().getClock().setDrift( - - getSimulationTime() - - randomGenerator.nextInt((int)maxMoteStartupDelay) - ); + if (mote.getInterfaces().getClock() != null) { + if (maxMoteStartupDelay > 0) { + mote.getInterfaces().getClock().setDrift( + - getSimulationTime() + - randomGenerator.nextInt((int)maxMoteStartupDelay) + ); + } else { + mote.getInterfaces().getClock().setDrift(-getSimulationTime()); + } } if (!isRunning()) {