From e238d84a75e785245a4b8395f15bef57ea0a9003 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 26 May 2009 14:34:30 +0000 Subject: [PATCH] milliseconds -> microseconds update + removed dependency of radio interface --- .../src/se/sics/cooja/mspmote/MspMote.java | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 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 2024e5b48..5ca66319b 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.28 2009/04/29 20:04:56 fros4943 Exp $ + * $Id: MspMote.java,v 1.29 2009/05/26 14:34:30 fros4943 Exp $ */ package se.sics.cooja.mspmote; @@ -71,7 +71,7 @@ public abstract class MspMote implements Mote { /* Cycle counter */ public long cycleCounter = 0; - public long cycleDrift = 0; + public long usDrift = 0; /* us */ private Simulation mySimulation = null; private CommandHandler commandHandler; @@ -300,22 +300,17 @@ public abstract class MspMote implements Mote { private int[] pcHistory = new int[5]; /* return false when done - e.g. true means more work to do before finished with this tick */ - private boolean firstTick = true; public boolean tick(long simTime) { if (stopNextInstruction) { stopNextInstruction = false; throw new RuntimeException("MSPSim requested simulation stop"); + } + + if (simTime + usDrift < 0) { + return false; } - - /* Nodes may be added in an ongoing simulation: - * Update cycle drift to current simulation time */ - if (firstTick) { - firstTick = false; - cycleDrift += (-NR_CYCLES_PER_MSEC*simTime); - } - - long maxSimTimeCycles = NR_CYCLES_PER_MSEC * (simTime + 1) + cycleDrift; - + + long maxSimTimeCycles = (long)(NR_CYCLES_PER_MSEC * ((simTime+usDrift+Simulation.MILLISECOND)/(double)Simulation.MILLISECOND)); if (maxSimTimeCycles <= cycleCounter) { return false; } @@ -330,7 +325,7 @@ public abstract class MspMote implements Mote { } myMoteInterfaceHandler.doActiveActionsBeforeTick(); - /* Experimental program counter history */ + /* Log recent program counter (PC) history */ for (int i=pcHistory.length-1; i > 0; i--) { pcHistory[i] = pcHistory[i-1]; } @@ -359,11 +354,6 @@ public abstract class MspMote implements Mote { new RuntimeException("Emulated exception: " + e.getMessage()).initCause(e); } - /* Check if radio has pending incoming bytes */ - if (myRadio != null && myRadio.hasPendingBytes()) { - myRadio.tryDeliverNextByte(cpu.cycles); - } - if (monitorStackUsage) { int newStack = cpu.reg[MSP430.SP]; if (newStack < stackPointerLow && newStack > 0) {