using timeout event instead of slower tick observer

This commit is contained in:
fros4943 2008-12-03 16:23:26 +00:00
parent c6d6bb4a14
commit 0083cc2080

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: ScriptRunnerNoGUI.java,v 1.4 2008/11/05 18:18:16 fros4943 Exp $ * $Id: ScriptRunnerNoGUI.java,v 1.5 2008/12/03 16:23:26 fros4943 Exp $
*/ */
package se.sics.cooja.plugins; package se.sics.cooja.plugins;
@ -154,10 +154,9 @@ public class ScriptRunnerNoGUI implements Plugin {
} }
}); });
/* Create timeout watch */ /* Create timeout event */
sim.addTickObserver(new Observer() { sim.scheduleEvent(new TimeEvent(0) {
public void update(Observable obs, Object obj) { public void execute(int t) {
if (sim.getSimulationTime() > TIMEOUT) {
try { try {
logWriter.write("TEST TIMEOUT"); logWriter.write("TEST TIMEOUT");
logWriter.flush(); logWriter.flush();
@ -165,8 +164,7 @@ public class ScriptRunnerNoGUI implements Plugin {
} }
gui.doQuit(false); gui.doQuit(false);
} }
} }, TIMEOUT);
});
/* Start simulation and leave control to script */ /* Start simulation and leave control to script */
sim.startSimulation(); sim.startSimulation();