mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-08-14 09:28:59 +00:00
only notify tick observers when simulation time changes, not for every handled event
This commit is contained in:
parent
b55b825a60
commit
609ae94b14
@ -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 */
|
||||||
tickObservable.allTicksPerformed();
|
if (increasedTime) {
|
||||||
|
tickObservable.allTicksPerformed();
|
||||||
|
}
|
||||||
|
|
||||||
if (stopSimulation) {
|
if (stopSimulation) {
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user