mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-01 02:29:03 +00:00
better example test script
This commit is contained in:
parent
15738c9fe3
commit
c74687ee48
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ScriptRunner.java,v 1.4 2008/09/29 13:03:29 fros4943 Exp $
|
||||
* $Id: ScriptRunner.java,v 1.5 2008/09/29 13:24:41 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.plugins;
|
||||
@ -86,13 +86,17 @@ public class ScriptRunner extends VisPlugin {
|
||||
"log.log('TIME=' + mote.getSimulation().getSimulationTime() + '\\n');\n" +
|
||||
"log.log('MSG=' + msg + '\\n');\n" +
|
||||
"\n" +
|
||||
"/* Hashtable global may be used to store state across script invokes */\n" +
|
||||
"log.log('STORED VAR=' + global.get('storedVar') + '\\n');\n" +
|
||||
"global.put('storedVar', msg);\n" +
|
||||
"\n" +
|
||||
"/* Contiki test script example */\n" +
|
||||
"if (msg.startsWith('Hello, world')) {\n" +
|
||||
" log.log('TEST OK\\n'); /* Report test success */\n" +
|
||||
" \n" +
|
||||
" /* To increase test run speed, close the simulator when done */\n" +
|
||||
" //mote.getSimulation().getGUI().doQuit(false); /* Quit simulator (to end test run)*/\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"//mote.getSimulation().getGUI().reloadCurrentSimulation(true); /* Reload simulation */\n";
|
||||
|
||||
@ -183,6 +187,8 @@ public class ScriptRunner extends VisPlugin {
|
||||
}
|
||||
|
||||
private void importContikiTest() {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
Simulation simulation = ScriptRunner.this.gui.getSimulation();
|
||||
|
||||
/* Load config from test directory */
|
||||
@ -192,8 +198,9 @@ public class ScriptRunner extends VisPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
scriptTextArea.setText("");
|
||||
logTextArea.setText("");
|
||||
|
||||
gui.doLoadConfig(false, true, proposedDir);
|
||||
Vector<File> history = gui.getFileHistory();
|
||||
|
||||
@ -217,7 +224,6 @@ public class ScriptRunner extends VisPlugin {
|
||||
|
||||
/* Import .js */
|
||||
try {
|
||||
scriptTextArea.setText("");
|
||||
BufferedReader reader =
|
||||
new BufferedReader(new InputStreamReader(new FileInputStream(jsFile)));
|
||||
String line;
|
||||
|
Loading…
Reference in New Issue
Block a user