From 609ae94b147fa0ffb1eac8644644a209a3e6746f Mon Sep 17 00:00:00 2001 From: fros4943 Date: Wed, 3 Dec 2008 16:37:06 +0000 Subject: [PATCH] only notify tick observers when simulation time changes, not for every handled event --- tools/cooja/java/se/sics/cooja/Simulation.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/Simulation.java b/tools/cooja/java/se/sics/cooja/Simulation.java index 3d7edc9f9..79c204ed7 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.30 2008/12/03 15:38:01 fros4943 Exp $ + * $Id: Simulation.java,v 1.31 2008/12/03 16:37:06 fros4943 Exp $ */ package se.sics.cooja; @@ -198,6 +198,7 @@ public class Simulation extends Observable implements Runnable { mspMoteArray = mspMotes.toArray(new Mote[mspMotes.size()]); moteArray = contikiMotes.toArray(new Mote[contikiMotes.size()]); + boolean increasedTime; try { while (isRunning) { @@ -206,11 +207,14 @@ public class Simulation extends Observable implements Runnable { throw new RuntimeException("No more events"); } + increasedTime = nextEvent.time > currentSimulationTime; currentSimulationTime = nextEvent.time; nextEvent.execute(currentSimulationTime); /* Notify tick observers */ - tickObservable.allTicksPerformed(); + if (increasedTime) { + tickObservable.allTicksPerformed(); + } if (stopSimulation) { isRunning = false;