From 37b40f99c7251f850023b21d657212fc595b7a96 Mon Sep 17 00:00:00 2001 From: joxe Date: Thu, 4 Dec 2008 14:03:41 +0000 Subject: [PATCH] changed simulation time from int to long to support very long simulations --- .../mspsim/src/se/sics/cooja/mspmote/MspMote.java | 6 +++--- .../se/sics/cooja/mspmote/interfaces/MspClock.java | 6 +++--- .../cooja/mspmote/interfaces/MspIPAddress.java | 4 ++-- .../sics/cooja/mspmote/interfaces/MspMoteID.java | 4 ++-- .../cooja/mspmote/interfaces/SkyByteRadio.java | 6 +++--- .../sics/cooja/mspmote/interfaces/SkySerial.java | 5 +++-- .../sics/cooja/mspmote/interfaces/TR1001Radio.java | 6 +++--- .../cooja/mspmote/plugins/MspStackWatcher.java | 4 ++-- tools/cooja/java/se/sics/cooja/EventQueue.java | 6 +++--- tools/cooja/java/se/sics/cooja/Mote.java | 4 ++-- tools/cooja/java/se/sics/cooja/Simulation.java | 14 +++++++------- tools/cooja/java/se/sics/cooja/TimeEvent.java | 12 ++++++------ .../se/sics/cooja/contikimote/ContikiMote.java | 4 ++-- .../contikimote/interfaces/ContikiBeeper.java | 6 +++--- .../contikimote/interfaces/ContikiButton.java | 4 ++-- .../cooja/contikimote/interfaces/ContikiCFS.java | 6 +++--- .../cooja/contikimote/interfaces/ContikiClock.java | 11 ++++++----- .../cooja/contikimote/interfaces/ContikiRadio.java | 6 +++--- .../se/sics/cooja/dialogs/CreateSimDialog.java | 4 ++-- .../se/sics/cooja/interfaces/ApplicationRadio.java | 10 +++++----- .../cooja/java/se/sics/cooja/interfaces/Clock.java | 6 +++--- .../java/se/sics/cooja/motes/DisturberMote.java | 4 ++-- .../java/se/sics/cooja/motes/DisturberRadio.java | 10 +++++----- .../cooja/java/se/sics/cooja/motes/DummyMote.java | 4 ++-- .../java/se/sics/cooja/plugins/RadioLogger.java | 4 ++-- .../se/sics/cooja/plugins/ScriptRunnerNoGUI.java | 4 ++-- 26 files changed, 81 insertions(+), 79 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 964c302ec..84ef7c94c 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.17 2008/12/04 13:14:34 fros4943 Exp $ + * $Id: MspMote.java,v 1.18 2008/12/04 14:03:41 joxe Exp $ */ package se.sics.cooja.mspmote; @@ -296,7 +296,7 @@ public abstract class MspMote implements Mote { /* return false when done - e.g. true means more work to do before finished with this tick */ private boolean firstTick = true; - public boolean tick(int simTime) { + public boolean tick(long simTime) { if (stopNextInstruction) { stopNextInstruction = false; throw new RuntimeException("MSPSim requested simulation stop"); @@ -309,7 +309,7 @@ public abstract class MspMote implements Mote { cycleDrift += (-NR_CYCLES_PER_MSEC*simTime); } - long maxSimTimeCycles = NR_CYCLES_PER_MSEC*(simTime+1) + cycleDrift; + long maxSimTimeCycles = NR_CYCLES_PER_MSEC * (simTime + 1) + cycleDrift; if (maxSimTimeCycles <= cycleCounter) { return false; diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspClock.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspClock.java index fea6aed2b..ea1690359 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspClock.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspClock.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspClock.java,v 1.5 2008/12/04 13:08:55 fros4943 Exp $ + * $Id: MspClock.java,v 1.6 2008/12/04 14:03:41 joxe Exp $ */ package se.sics.cooja.mspmote.interfaces; @@ -56,11 +56,11 @@ public class MspClock extends Clock { cpu = myMote.getCPU(); } - public void setTime(int newTime) { + public void setTime(long newTime) { logger.fatal("Can't change emulated CPU time"); } - public int getTime() { + public long getTime() { int time = (int) ((cpu.cycles + myMote.cycleDrift) / MspMote.NR_CYCLES_PER_MSEC); return time > 0 ? time : 0; } diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspIPAddress.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspIPAddress.java index 42cdbf90a..354b961c3 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspIPAddress.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspIPAddress.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspIPAddress.java,v 1.1 2008/12/03 13:11:20 fros4943 Exp $ + * $Id: MspIPAddress.java,v 1.2 2008/12/04 14:03:41 joxe Exp $ */ package se.sics.cooja.mspmote.interfaces; @@ -57,7 +57,7 @@ public class MspIPAddress extends IPAddress { this.moteMem = (MspMoteMemory) mote.getMemory(); TimeEvent updateWhenAddressReady = new TimeEvent(0) { - public void execute(int t) { + public void execute(long t) { if (getIPString().equals("0.0.0.0")) { MspIPAddress.this.mote.getSimulation().scheduleEvent( this, diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java index 375d2722a..6748dcccc 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspMoteID.java,v 1.8 2008/10/29 08:35:38 fros4943 Exp $ + * $Id: MspMoteID.java,v 1.9 2008/12/04 14:03:41 joxe Exp $ */ package se.sics.cooja.mspmote.interfaces; @@ -123,7 +123,7 @@ public class MspMoteID extends MoteID { } private TimeEvent persistentSetIDEvent = new TimeEvent(0) { - public void execute(int t) { + public void execute(long t) { if (persistentSetIDCounter-- > 0) { diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java index 6ddfc5752..5672c3b34 100755 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkyByteRadio.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: SkyByteRadio.java,v 1.4 2008/11/03 12:31:33 fros4943 Exp $ + * $Id: SkyByteRadio.java,v 1.5 2008/12/04 14:03:41 joxe Exp $ */ package se.sics.cooja.mspmote.interfaces; @@ -59,7 +59,7 @@ import se.sics.mspsim.chip.CC2420.StateListener; public class SkyByteRadio extends Radio implements CustomDataRadio { private static Logger logger = Logger.getLogger(SkyByteRadio.class); - private int lastEventTime = 0; + private long lastEventTime = 0; private RadioEvent lastEvent = RadioEvent.UNKNOWN; @@ -155,7 +155,7 @@ public class SkyByteRadio extends Radio implements CustomDataRadio { private byte[] crossBufferedData = null; private TimeEvent receiveCrosslevelDataEvent = new TimeEvent(0) { - public void execute(int t) { + public void execute(long t) { if (crossBufferedData == null) { return; diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkySerial.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkySerial.java index e700b2be9..44abfaf19 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkySerial.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/SkySerial.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: SkySerial.java,v 1.7 2008/12/04 13:09:27 fros4943 Exp $ + * $Id: SkySerial.java,v 1.8 2008/12/04 14:03:41 joxe Exp $ */ package se.sics.cooja.mspmote.interfaces; @@ -151,7 +151,8 @@ public class SkySerial extends Log implements SerialPort, USARTListener { } private TimeEvent writeDataEvent = new TimeEvent(0) { - public void execute(int t) { + public void execute(long t) { + /* TODO Implement MSPSim callback - better timing */ tryWriteNextByte(); if (!incomingData.isEmpty()) { mote.getSimulation().scheduleEvent(this, t+1); diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/TR1001Radio.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/TR1001Radio.java index e75e1c8de..c8783f690 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/TR1001Radio.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/TR1001Radio.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: TR1001Radio.java,v 1.8 2008/12/03 13:14:07 fros4943 Exp $ + * $Id: TR1001Radio.java,v 1.9 2008/12/04 14:03:41 joxe Exp $ */ package se.sics.cooja.mspmote.interfaces; @@ -70,7 +70,7 @@ public class TR1001Radio extends Radio implements USARTListener, CustomDataRadio private RadioEvent lastEvent = RadioEvent.UNKNOWN; - private int lastEventTime = 0; + private long lastEventTime = 0; private USART radioUSART = null; @@ -379,7 +379,7 @@ public class TR1001Radio extends Radio implements USARTListener, CustomDataRadio } private TimeEvent followupTransmissionEvent = new TimeEvent(0) { - public void execute(int t) { + public void execute(long t) { if (isTransmitting()) { ticksSinceLastSend++; diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspStackWatcher.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspStackWatcher.java index efaf686c5..a58f5d8ae 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspStackWatcher.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspStackWatcher.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: MspStackWatcher.java,v 1.4 2008/10/03 15:18:48 fros4943 Exp $ + * $Id: MspStackWatcher.java,v 1.5 2008/12/04 14:03:41 joxe Exp $ */ package se.sics.cooja.mspmote.plugins; @@ -103,7 +103,7 @@ public class MspStackWatcher extends VisPlugin { }); // Create nfi's stack viewer - final StackUI stackUI = new StackUI(cpu, MspMote.NR_CYCLES_PER_MSEC); + final StackUI stackUI = new StackUI(cpu, (int)MspMote.NR_CYCLES_PER_MSEC); // Register as log listener /*if (logObserver == null && mspMote.getInterfaces().getLog() != null) { diff --git a/tools/cooja/java/se/sics/cooja/EventQueue.java b/tools/cooja/java/se/sics/cooja/EventQueue.java index 05cede965..c47a4858b 100644 --- a/tools/cooja/java/se/sics/cooja/EventQueue.java +++ b/tools/cooja/java/se/sics/cooja/EventQueue.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: EventQueue.java,v 1.1 2008/10/28 12:52:24 fros4943 Exp $ + * $Id: EventQueue.java,v 1.2 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja; @@ -37,13 +37,13 @@ package se.sics.cooja; public class EventQueue { private TimeEvent first; - private int nextTime; + private long nextTime; private int eventCount = 0; public EventQueue() { } - public void addEvent(TimeEvent event, int time) { + public void addEvent(TimeEvent event, long time) { event.time = time; addEvent(event); } diff --git a/tools/cooja/java/se/sics/cooja/Mote.java b/tools/cooja/java/se/sics/cooja/Mote.java index afcf47e0d..37e427d67 100644 --- a/tools/cooja/java/se/sics/cooja/Mote.java +++ b/tools/cooja/java/se/sics/cooja/Mote.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: Mote.java,v 1.5 2008/03/31 15:22:42 fros4943 Exp $ + * $Id: Mote.java,v 1.6 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja; @@ -179,7 +179,7 @@ public interface Mote { * New simulation time * @return True is mote accepts another immediate tick */ - public boolean tick(int simTime); + public boolean tick(long simTime); /** * Returns XML elements representing the current config of this mote. This is diff --git a/tools/cooja/java/se/sics/cooja/Simulation.java b/tools/cooja/java/se/sics/cooja/Simulation.java index fae8cb581..d45e835bc 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.33 2008/12/04 13:04:26 fros4943 Exp $ + * $Id: Simulation.java,v 1.34 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja; @@ -54,7 +54,7 @@ public class Simulation extends Observable implements Runnable { private int delayTime = 5; - private int currentSimulationTime = 0; + private long currentSimulationTime = 0; private int tickTime = 1; @@ -117,7 +117,7 @@ public class Simulation extends Observable implements Runnable { * @param e Event * @param time Simulated time */ - public void scheduleEvent(TimeEvent e, int time) { + public void scheduleEvent(TimeEvent e, long time) { eventQueue.addEvent(e, time); } @@ -125,7 +125,7 @@ public class Simulation extends Observable implements Runnable { private Mote[] mspMoteArray; private TimeEvent tickMspMotesEvent = new TimeEvent(0) { - public void execute(int t) { + public void execute(long t) { /*logger.info("MSP motes tick at: " + t);*/ /* Tick MSP motes */ @@ -147,7 +147,7 @@ public class Simulation extends Observable implements Runnable { private Mote[] moteArray; private TimeEvent tickMotesEvent = new TimeEvent(0) { - public void execute(int t) { + public void execute(long t) { /*logger.info("Contiki motes tick at: " + t);*/ /* Tick Contiki motes */ @@ -161,7 +161,7 @@ public class Simulation extends Observable implements Runnable { }; private TimeEvent delayEvent = new TimeEvent(0) { - public void execute(int t) { + public void execute(long t) { /*logger.info("Delay at: " + t);*/ if (delayTime > 0) { @@ -685,7 +685,7 @@ public class Simulation extends Observable implements Runnable { * * @return Simulation time (ms) */ - public int getSimulationTime() { + public long getSimulationTime() { return currentSimulationTime; } diff --git a/tools/cooja/java/se/sics/cooja/TimeEvent.java b/tools/cooja/java/se/sics/cooja/TimeEvent.java index 1c3fae107..662353c5e 100644 --- a/tools/cooja/java/se/sics/cooja/TimeEvent.java +++ b/tools/cooja/java/se/sics/cooja/TimeEvent.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: TimeEvent.java,v 1.1 2008/10/28 12:51:22 fros4943 Exp $ + * $Id: TimeEvent.java,v 1.2 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja; @@ -43,18 +43,18 @@ public abstract class TimeEvent { EventQueue scheduledIn = null; String name; - protected int time; + protected long time; - public TimeEvent(int time) { + public TimeEvent(long time) { this.time = time; } - public TimeEvent(int time, String name) { + public TimeEvent(long time, String name) { this.time = time; this.name = name; } - public final int getTime() { + public final long getTime() { return time; } @@ -69,7 +69,7 @@ public abstract class TimeEvent { return false; } - public abstract void execute(int t); + public abstract void execute(long t); public String getShort() { return "" + time + (name != null ? ": " + name : ""); diff --git a/tools/cooja/java/se/sics/cooja/contikimote/ContikiMote.java b/tools/cooja/java/se/sics/cooja/contikimote/ContikiMote.java index 3d49ed22c..9bb2b012c 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/ContikiMote.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/ContikiMote.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ContikiMote.java,v 1.8 2008/10/28 12:05:30 fros4943 Exp $ + * $Id: ContikiMote.java,v 1.9 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.contikimote; @@ -176,7 +176,7 @@ public class ContikiMote implements Mote { * * @param simTime Current simulation time */ - public boolean tick(int simTime) { + public boolean tick(long simTime) { State currentState = getState(); // If mote is dead, do nothing at all diff --git a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiBeeper.java b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiBeeper.java index ab14ce111..67979aa0a 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiBeeper.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiBeeper.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ContikiBeeper.java,v 1.7 2008/10/28 13:37:11 fros4943 Exp $ + * $Id: ContikiBeeper.java,v 1.8 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.contikimote.interfaces; @@ -102,7 +102,7 @@ public class ContikiBeeper extends Beeper implements ContikiMoteInterface, Polle } private TimeEvent stopBeepEvent = new TimeEvent(0) { - public void execute(int t) { + public void execute(long t) { myEnergyConsumption = 0.0; } }; @@ -135,7 +135,7 @@ public class ContikiBeeper extends Beeper implements ContikiMoteInterface, Polle return; } - int currentTime = mote.getSimulation().getSimulationTime(); + long currentTime = mote.getSimulation().getSimulationTime(); statusLabel.setText("Last beep at time: " + currentTime); /* Beep on speakers */ diff --git a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiButton.java b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiButton.java index 8227eb01a..b5a67a295 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiButton.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiButton.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ContikiButton.java,v 1.9 2008/10/28 13:37:11 fros4943 Exp $ + * $Id: ContikiButton.java,v 1.10 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.contikimote.interfaces; @@ -85,7 +85,7 @@ public class ContikiButton extends Button implements ContikiMoteInterface { } private TimeEvent releaseButtonEvent = new TimeEvent(0) { - public void execute(int t) { + public void execute(long t) { /* Force mote awake when button is down */ mote.setState(Mote.State.ACTIVE); diff --git a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiCFS.java b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiCFS.java index 9f03f9095..eb97ef94e 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiCFS.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiCFS.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ContikiCFS.java,v 1.7 2008/10/28 13:37:11 fros4943 Exp $ + * $Id: ContikiCFS.java,v 1.8 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.contikimote.interfaces; @@ -110,7 +110,7 @@ public class ContikiCFS extends MoteInterface implements ContikiMoteInterface, P } private TimeEvent doneEvent = new TimeEvent(0) { - public void execute(int t) { + public void execute(long t) { myEnergyConsumption = 0.0; } }; @@ -203,7 +203,7 @@ public class ContikiCFS extends MoteInterface implements ContikiMoteInterface, P Observer observer; this.addObserver(observer = new Observer() { public void update(Observable obs, Object obj) { - int currentTime = mote.getSimulation().getSimulationTime(); + long currentTime = mote.getSimulation().getSimulationTime(); lastTimeLabel.setText("Last change at time: " + currentTime); lastReadLabel.setText("Last change read bytes: " + getLastReadCount()); lastWrittenLabel.setText("Last change wrote bytes: " + getLastWrittenCount()); 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 9639a9f0f..12e420d30 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.6 2008/10/29 08:36:40 fros4943 Exp $ + * $Id: ContikiClock.java,v 1.7 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.contikimote.interfaces; @@ -80,8 +80,9 @@ public class ContikiClock extends Clock implements ContikiMoteInterface, PolledB return new String[]{"clock_interface"}; } - public void setTime(int newTime) { - moteMem.setIntValueOf("simCurrentTime", newTime); + public void setTime(long newTime) { + /* TODO: check if this is correct even if newTime > MAX_INT */ + moteMem.setIntValueOf("simCurrentTime", (int)newTime); } public void setDrift(int timeDrift) { @@ -92,13 +93,13 @@ public class ContikiClock extends Clock implements ContikiMoteInterface, PolledB return timeDrift; } - public int getTime() { + public long getTime() { return moteMem.getIntValueOf("simCurrentTime"); } public void doActionsBeforeTick() { /* Update time */ - int moteTime = mote.getSimulation().getSimulationTime() + timeDrift; + long moteTime = mote.getSimulation().getSimulationTime() + timeDrift; if (moteTime > 0) { setTime(moteTime); diff --git a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiRadio.java b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiRadio.java index 514f51ff4..e675fce2d 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiRadio.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiRadio.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ContikiRadio.java,v 1.23 2008/10/28 15:31:51 fros4943 Exp $ + * $Id: ContikiRadio.java,v 1.24 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.contikimote.interfaces; @@ -121,11 +121,11 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA private boolean isInterfered = false; - private int transmissionEndTime = -1; + private long transmissionEndTime = -1; private RadioEvent lastEvent = RadioEvent.UNKNOWN; - private int lastEventTime = 0; + private long lastEventTime = 0; private int oldOutputPowerIndicator = -1; diff --git a/tools/cooja/java/se/sics/cooja/dialogs/CreateSimDialog.java b/tools/cooja/java/se/sics/cooja/dialogs/CreateSimDialog.java index e21bf767a..f50e87594 100644 --- a/tools/cooja/java/se/sics/cooja/dialogs/CreateSimDialog.java +++ b/tools/cooja/java/se/sics/cooja/dialogs/CreateSimDialog.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: CreateSimDialog.java,v 1.13 2008/10/29 10:36:58 fros4943 Exp $ + * $Id: CreateSimDialog.java,v 1.14 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.dialogs; @@ -127,7 +127,7 @@ public class CreateSimDialog extends JDialog { myDialog.delayTime.setValue(new Integer(simulationToConfigure.getDelayTime())); // Set simulation time - myDialog.simulationTime.setValue(new Integer(simulationToConfigure.getSimulationTime())); + myDialog.simulationTime.setValue(new Long(simulationToConfigure.getSimulationTime())); // Select radio medium if (simulationToConfigure.getRadioMedium() != null) { diff --git a/tools/cooja/java/se/sics/cooja/interfaces/ApplicationRadio.java b/tools/cooja/java/se/sics/cooja/interfaces/ApplicationRadio.java index fc91ee3ea..8c06a8601 100644 --- a/tools/cooja/java/se/sics/cooja/interfaces/ApplicationRadio.java +++ b/tools/cooja/java/se/sics/cooja/interfaces/ApplicationRadio.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ApplicationRadio.java,v 1.6 2008/10/28 12:59:30 fros4943 Exp $ + * $Id: ApplicationRadio.java,v 1.7 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.interfaces; @@ -59,10 +59,10 @@ public class ApplicationRadio extends Radio implements PolledBeforeActiveTicks { private boolean isReceiving = false; private boolean isInterfered = false; - private int transmissionEndTime = 0; + private long transmissionEndTime = 0; private RadioEvent lastEvent = RadioEvent.UNKNOWN; - private int lastEventTime = 0; + private long lastEventTime = 0; private boolean outPacketExists = false; private RadioPacket outPacket = null; @@ -126,7 +126,7 @@ public class ApplicationRadio extends Radio implements PolledBeforeActiveTicks { return isTransmitting; } - public int getTransmissionEndTime() { + public long getTransmissionEndTime() { return transmissionEndTime; } @@ -217,7 +217,7 @@ public class ApplicationRadio extends Radio implements PolledBeforeActiveTicks { } public void doActionsBeforeTick() { - int currentTime = myMote.getSimulation().getSimulationTime(); + long currentTime = myMote.getSimulation().getSimulationTime(); if (outPacketExists) { outPacketExists = false; diff --git a/tools/cooja/java/se/sics/cooja/interfaces/Clock.java b/tools/cooja/java/se/sics/cooja/interfaces/Clock.java index b71b558cc..47ad6a75c 100644 --- a/tools/cooja/java/se/sics/cooja/interfaces/Clock.java +++ b/tools/cooja/java/se/sics/cooja/interfaces/Clock.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: Clock.java,v 1.3 2008/10/29 08:37:42 fros4943 Exp $ + * $Id: Clock.java,v 1.4 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.interfaces; @@ -49,12 +49,12 @@ public abstract class Clock extends MoteInterface { * * @param newTime Time */ - public abstract void setTime(int newTime); + public abstract void setTime(long newTime); /** * @return Current time */ - public abstract int getTime(); + public abstract long getTime(); /** * Set time drift. diff --git a/tools/cooja/java/se/sics/cooja/motes/DisturberMote.java b/tools/cooja/java/se/sics/cooja/motes/DisturberMote.java index 60a4c9a7d..649665672 100644 --- a/tools/cooja/java/se/sics/cooja/motes/DisturberMote.java +++ b/tools/cooja/java/se/sics/cooja/motes/DisturberMote.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: DisturberMote.java,v 1.4 2008/10/28 13:39:24 fros4943 Exp $ + * $Id: DisturberMote.java,v 1.5 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.motes; @@ -141,7 +141,7 @@ public class DisturberMote implements Mote { this.mySim = simulation; } - public boolean tick(int simTime) { + public boolean tick(long simTime) { myInterfaceHandler.doPassiveActionsBeforeTick(); myInterfaceHandler.doActiveActionsBeforeTick(); myInterfaceHandler.doActiveActionsAfterTick(); diff --git a/tools/cooja/java/se/sics/cooja/motes/DisturberRadio.java b/tools/cooja/java/se/sics/cooja/motes/DisturberRadio.java index 66c72b439..bba9db13e 100644 --- a/tools/cooja/java/se/sics/cooja/motes/DisturberRadio.java +++ b/tools/cooja/java/se/sics/cooja/motes/DisturberRadio.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: DisturberRadio.java,v 1.8 2008/10/28 13:39:24 fros4943 Exp $ + * $Id: DisturberRadio.java,v 1.9 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.motes; @@ -58,11 +58,11 @@ public class DisturberRadio extends Radio { private int distChannel = -1; // channel mote is disturbing - private int transEndTime = 0; + private long transEndTime = 0; private RadioEvent lastEvent = RadioEvent.UNKNOWN; - private int lastEventTime = 0; + private long lastEventTime = 0; public static int TRANSMISSION_INTERVAL = 100; public static int TRANSMISSION_DURATION = 98; @@ -103,7 +103,7 @@ public class DisturberRadio extends Radio { return transmitting; } - public int getTransmissionEndTime() { + public long getTransmissionEndTime() { return transEndTime; } @@ -152,7 +152,7 @@ public class DisturberRadio extends Radio { } public void doActionsBeforeTick() { - int currentTime = myMote.getSimulation().getSimulationTime(); + long currentTime = myMote.getSimulation().getSimulationTime(); if (!transmitting && currentTime % TRANSMISSION_INTERVAL == 0) { transmitting = true; diff --git a/tools/cooja/java/se/sics/cooja/motes/DummyMote.java b/tools/cooja/java/se/sics/cooja/motes/DummyMote.java index 45072e9df..fbbe2a0cb 100644 --- a/tools/cooja/java/se/sics/cooja/motes/DummyMote.java +++ b/tools/cooja/java/se/sics/cooja/motes/DummyMote.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: DummyMote.java,v 1.5 2008/10/28 13:39:24 fros4943 Exp $ + * $Id: DummyMote.java,v 1.6 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.motes; @@ -146,7 +146,7 @@ public class DummyMote implements Mote { this.mySim = simulation; } - public boolean tick(int simTime) { + public boolean tick(long simTime) { // Perform some dummy task if (myRandom.nextDouble() > 0.9) { diff --git a/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java b/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java index 30ae0da0f..e08bcb3be 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java +++ b/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: RadioLogger.java,v 1.13 2008/03/18 15:42:35 fros4943 Exp $ + * $Id: RadioLogger.java,v 1.14 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.plugins; @@ -258,7 +258,7 @@ public class RadioLogger extends VisPlugin { for (RadioConnection newConnection: newConnections) { Object[] data = new Object[3]; - data[DATAPOS_TIME] = new Integer(simulation.getSimulationTime()); + data[DATAPOS_TIME] = new Long(simulation.getSimulationTime()); data[DATAPOS_CONNECTION] = newConnection; data[DATAPOS_PACKET] = newConnection.getSource().getLastPacketTransmitted(); diff --git a/tools/cooja/java/se/sics/cooja/plugins/ScriptRunnerNoGUI.java b/tools/cooja/java/se/sics/cooja/plugins/ScriptRunnerNoGUI.java index b1acf689a..d0786f8e6 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/ScriptRunnerNoGUI.java +++ b/tools/cooja/java/se/sics/cooja/plugins/ScriptRunnerNoGUI.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ScriptRunnerNoGUI.java,v 1.5 2008/12/03 16:23:26 fros4943 Exp $ + * $Id: ScriptRunnerNoGUI.java,v 1.6 2008/12/04 14:03:42 joxe Exp $ */ package se.sics.cooja.plugins; @@ -156,7 +156,7 @@ public class ScriptRunnerNoGUI implements Plugin { /* Create timeout event */ sim.scheduleEvent(new TimeEvent(0) { - public void execute(int t) { + public void execute(long t) { try { logWriter.write("TEST TIMEOUT"); logWriter.flush();