osd-contiki/tools/cooja/contiki_tests/sky_collect.js

53 lines
1.4 KiB
JavaScript
Raw Normal View History

TIMEOUT(300000, log.log("received/node: " + count[1] + " " + count[2] + " " + count[3] + " " + count[4] + " " + count[5] + " " + count[6] + " " + count[7] + "\n"));
2009-01-08 18:11:06 +01:00
/* Conf. */
booted = new Array();
count = new Array();
nrNodes = 7;
nodes_starting = true;
for (i = 1; i <= nrNodes; i++) {
booted[i] = false;
count[i] = 0;
2008-11-05 20:22:18 +01:00
}
2009-01-08 18:11:06 +01:00
/* Wait until all nodes have started */
while (nodes_starting) {
YIELD_THEN_WAIT_UNTIL(msg.startsWith('Starting'));
2009-01-08 18:11:06 +01:00
log.log("Node " + id + " booted\n");
booted[id] = true;
for (i = 1; i <= nrNodes; i++) {
if (!booted[i]) break;
if (i == nrNodes) nodes_starting = false;
2008-11-05 20:22:18 +01:00
}
}
/* Create sink */
2009-01-08 18:11:06 +01:00
log.log("All nodes booted, creating sink at node " + id + "\n");
mote.getInterfaces().getButton().clickButton()
2008-11-05 20:22:18 +01:00
2009-01-08 18:11:06 +01:00
while (true) {
YIELD();
/* Count sensor data packets */
source = msg.split(" ")[0];
count[source]++;
log.log("Got data from node " + source + ": tot=" + count[source] + "\n");
2009-01-08 18:11:06 +01:00
/* Fail if any node has transmitted more than 20 packets */
for (i = 1; i <= nrNodes; i++) {
if (count[i] > 20) {
log.log("received/node: " + count[1] + " " + count[2] + " " + count[3] + " " + count[4] + " " + count[5] + " " + count[6] + " " + count[7] + "\n");
log.testFailed(); /* We are done! */
}
}
2009-01-08 18:11:06 +01:00
/* Wait until we have received data from all nodes */
for (i = 1; i <= nrNodes; i++) {
if (count[i] < 5) break;
if (i == nrNodes) log.testOK();
2008-11-05 20:22:18 +01:00
}
2009-01-08 18:11:06 +01:00
}