From 66e562f2c0510ef7d554500d83675d3c902c4a25 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 19 Jun 2007 09:59:19 +0000 Subject: [PATCH] added method for setting timedrift --- .../cooja/contikimote/interfaces/ContikiClock.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiClock.java b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiClock.java index 9b01ab51a..1922e7d52 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiClock.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiClock.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ContikiClock.java,v 1.2 2007/01/09 10:05:19 fros4943 Exp $ + * $Id: ContikiClock.java,v 1.3 2007/06/19 09:59:19 fros4943 Exp $ */ package se.sics.cooja.contikimote.interfaces; @@ -83,13 +83,20 @@ public class ContikiClock extends Clock implements ContikiMoteInterface { moteMem.setIntValueOf("simCurrentTime", newTime); } + public void setDrift(int timeDrift) { + this.timeDrift = timeDrift; + } + public int getTime() { return moteMem.getIntValueOf("simCurrentTime"); } public void doActionsBeforeTick() { // Update core time to correspond with the simulation time - setTime((int) mote.getSimulation().getSimulationTime() + timeDrift); + int moteTime = mote.getSimulation().getSimulationTime() + timeDrift; + + if (moteTime > 0) + setTime(moteTime); } public void doActionsAfterTick() {