mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
added simple example demonstrating user-defined timeout function
This commit is contained in:
parent
59768e7bc7
commit
bdc42d8e64
@ -7,14 +7,26 @@
|
|||||||
|
|
||||||
/* Started plugins are available from the GUI object */
|
/* Started plugins are available from the GUI object */
|
||||||
|
|
||||||
while (true) {
|
TIMEOUT(60000);
|
||||||
|
|
||||||
|
counter=0;
|
||||||
|
plugins=0;
|
||||||
|
|
||||||
|
timeout_function = function my_fun() {
|
||||||
|
log.log("Script timed out.\n");
|
||||||
|
log.log(plugins + " plugins were referenced\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
while (counter<10) {
|
||||||
|
counter++;
|
||||||
|
|
||||||
GENERATE_MSG(1000, "wait");
|
GENERATE_MSG(1000, "wait");
|
||||||
YIELD_THEN_WAIT_UNTIL(msg.equals("wait"));
|
YIELD_THEN_WAIT_UNTIL(msg.equals("wait"));
|
||||||
|
|
||||||
/* Toggle Log Listener filter */
|
/* Toggle Log Listener filter */
|
||||||
plugin = mote.getSimulation().getGUI().getStartedPlugin("se.sics.cooja.plugins.LogListener");
|
plugin = mote.getSimulation().getGUI().getStartedPlugin("se.sics.cooja.plugins.LogListener");
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
|
plugins++;
|
||||||
log.log("LogListener: Setting filter: " + plugin.getFilter() + "\n");
|
log.log("LogListener: Setting filter: " + plugin.getFilter() + "\n");
|
||||||
if (plugin.getFilter() == null || !plugin.getFilter().equals("Contiki")) {
|
if (plugin.getFilter() == null || !plugin.getFilter().equals("Contiki")) {
|
||||||
plugin.setFilter("Contiki");
|
plugin.setFilter("Contiki");
|
||||||
@ -29,6 +41,7 @@ while (true) {
|
|||||||
/* Extract Timeline statistics */
|
/* Extract Timeline statistics */
|
||||||
plugin = mote.getSimulation().getGUI().getStartedPlugin("se.sics.cooja.plugins.TimeLine");
|
plugin = mote.getSimulation().getGUI().getStartedPlugin("se.sics.cooja.plugins.TimeLine");
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
|
plugins++;
|
||||||
stats = plugin.extractStatistics();
|
stats = plugin.extractStatistics();
|
||||||
if (stats.length() > 40) {
|
if (stats.length() > 40) {
|
||||||
/* Stripping */
|
/* Stripping */
|
||||||
@ -43,6 +56,7 @@ while (true) {
|
|||||||
/* Select time in Radio Logger */
|
/* Select time in Radio Logger */
|
||||||
plugin = mote.getSimulation().getGUI().getStartedPlugin("se.sics.cooja.plugins.RadioLogger");
|
plugin = mote.getSimulation().getGUI().getStartedPlugin("se.sics.cooja.plugins.RadioLogger");
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
|
plugins++;
|
||||||
log.log("RadioLogger: Showing logged radio packet at mid simulation\n");
|
log.log("RadioLogger: Showing logged radio packet at mid simulation\n");
|
||||||
plugin.trySelectTime(time/2);
|
plugin.trySelectTime(time/2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user