only notify tick observers when simulation time changes, not for every handled event

This commit is contained in:
fros4943 2008-12-03 16:37:06 +00:00
parent b55b825a60
commit 609ae94b14

View file

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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; package se.sics.cooja;
@ -198,6 +198,7 @@ public class Simulation extends Observable implements Runnable {
mspMoteArray = mspMotes.toArray(new Mote[mspMotes.size()]); mspMoteArray = mspMotes.toArray(new Mote[mspMotes.size()]);
moteArray = contikiMotes.toArray(new Mote[contikiMotes.size()]); moteArray = contikiMotes.toArray(new Mote[contikiMotes.size()]);
boolean increasedTime;
try { try {
while (isRunning) { while (isRunning) {
@ -206,11 +207,14 @@ public class Simulation extends Observable implements Runnable {
throw new RuntimeException("No more events"); throw new RuntimeException("No more events");
} }
increasedTime = nextEvent.time > currentSimulationTime;
currentSimulationTime = nextEvent.time; currentSimulationTime = nextEvent.time;
nextEvent.execute(currentSimulationTime); nextEvent.execute(currentSimulationTime);
/* Notify tick observers */ /* Notify tick observers */
if (increasedTime) {
tickObservable.allTicksPerformed(); tickObservable.allTicksPerformed();
}
if (stopSimulation) { if (stopSimulation) {
isRunning = false; isRunning = false;