From 3786f2f5fb18aa3203ea7093cdf7715e47ee072e Mon Sep 17 00:00:00 2001 From: fros4943 Date: Wed, 3 Feb 2010 19:08:40 +0000 Subject: [PATCH] introduced execute method with duration argument --- .../mspsim/src/se/sics/cooja/mspmote/MspMote.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java index 1fdedecd9..f0a690399 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspMote.java,v 1.40 2010/02/03 16:04:44 fros4943 Exp $ + * $Id: MspMote.java,v 1.41 2010/02/03 19:08:40 fros4943 Exp $ */ package se.sics.cooja.mspmote; @@ -310,7 +310,10 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc private long lastExecute = -1; /* Last time mote executed */ private long nextExecute; - public void execute(long t) { + public void execute(long time) { + execute(time, EXECUTE_DURATION_US); + } + public void execute(long t, int duration) { /* Wait until mote boots */ if (myMoteInterfaceHandler.getClock().getTime() < 0) { scheduleNextWakeup(t - myMoteInterfaceHandler.getClock().getTime()); @@ -336,8 +339,8 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc /* TODO Try-catch overhead */ try { nextExecute = - t + EXECUTE_DURATION_US + - myCpu.stepMicros(t - lastExecute, EXECUTE_DURATION_US); + t + duration + + myCpu.stepMicros(t - lastExecute, duration); lastExecute = t; } catch (EmulationException e) { if (e.getMessage().startsWith("Bad operation")) { @@ -350,7 +353,7 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc } /* Schedule wakeup */ - if (nextExecute <= t) { + if (nextExecute < t) { throw new RuntimeException(t + ": MSPSim requested early wakeup: " + nextExecute); } /*logger.debug(t + ": Schedule next wakeup at " + nextExecute);*/