bugfix: do not activate script engine according to simulation config in test mode (without GUI), instead, always keep it activated
+ more debugging output
This commit is contained in:
parent
4c4cdeb546
commit
a45e2382b2
2 changed files with 32 additions and 34 deletions
|
@ -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: LogScriptEngine.java,v 1.14 2009/06/09 09:47:04 fros4943 Exp $
|
* $Id: LogScriptEngine.java,v 1.15 2009/06/15 15:41:32 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.plugins;
|
package se.sics.cooja.plugins;
|
||||||
|
@ -276,11 +276,11 @@ public class LogScriptEngine {
|
||||||
timeoutEvent,
|
timeoutEvent,
|
||||||
simulation.getSimulationTime() + timeoutTime);
|
simulation.getSimulationTime() + timeoutTime);
|
||||||
} else {
|
} else {
|
||||||
logger.info("No timeout defined, using default: " +
|
logger.info("No timeout defined, using default (us): " +
|
||||||
simulation.getSimulationTime() + DEFAULT_TIMEOUT);
|
(simulation.getSimulationTime() + DEFAULT_TIMEOUT));
|
||||||
simulation.scheduleEvent(
|
simulation.scheduleEvent(
|
||||||
timeoutEvent,
|
timeoutEvent,
|
||||||
simulation.getSimulationTime() + DEFAULT_TIMEOUT);
|
(simulation.getSimulationTime() + DEFAULT_TIMEOUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
engine.eval(jsCode);
|
engine.eval(jsCode);
|
||||||
|
@ -296,7 +296,7 @@ public class LogScriptEngine {
|
||||||
try {
|
try {
|
||||||
semaphoreScript.acquire();
|
semaphoreScript.acquire();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
logger.fatal("Error when creating engine: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
ThreadGroup group = new ThreadGroup("script") {
|
ThreadGroup group = new ThreadGroup("script") {
|
||||||
public void uncaughtException(Thread t, Throwable e) {
|
public void uncaughtException(Thread t, Throwable e) {
|
||||||
|
|
|
@ -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: ScriptRunner.java,v 1.19 2009/06/09 09:47:04 fros4943 Exp $
|
* $Id: ScriptRunner.java,v 1.20 2009/06/15 15:41:32 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.plugins;
|
package se.sics.cooja.plugins;
|
||||||
|
@ -37,6 +37,7 @@ import java.awt.Insets;
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.awt.event.WindowListener;
|
import java.awt.event.WindowListener;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
@ -74,6 +75,9 @@ public class ScriptRunner extends VisPlugin {
|
||||||
|
|
||||||
private LogScriptEngine engine = null;
|
private LogScriptEngine engine = null;
|
||||||
|
|
||||||
|
private File coojaBuild;
|
||||||
|
private File coojaJAR;
|
||||||
|
private final File logFile;
|
||||||
private static BufferedWriter logWriter = null; /* For non-GUI tests */
|
private static BufferedWriter logWriter = null; /* For non-GUI tests */
|
||||||
|
|
||||||
private JTextArea scriptTextArea = null;
|
private JTextArea scriptTextArea = null;
|
||||||
|
@ -88,6 +92,17 @@ public class ScriptRunner extends VisPlugin {
|
||||||
super("Contiki Test Editor", gui, false);
|
super("Contiki Test Editor", gui, false);
|
||||||
this.simulation = simulation;
|
this.simulation = simulation;
|
||||||
|
|
||||||
|
try {
|
||||||
|
coojaBuild = new File(GUI.getExternalToolsSetting("PATH_CONTIKI"), "tools/cooja/build");
|
||||||
|
coojaJAR = new File(GUI.getExternalToolsSetting("PATH_CONTIKI"), "tools/cooja/dist/cooja.jar");
|
||||||
|
coojaBuild = coojaBuild.getCanonicalFile();
|
||||||
|
coojaJAR = coojaJAR.getCanonicalFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
coojaBuild = new File(GUI.getExternalToolsSetting("PATH_CONTIKI"), "tools/cooja/build");
|
||||||
|
coojaJAR = new File(GUI.getExternalToolsSetting("PATH_CONTIKI"), "tools/cooja/dist/cooja.jar");
|
||||||
|
}
|
||||||
|
logFile = new File(coojaBuild, "COOJA.testlog");
|
||||||
|
|
||||||
final JTextArea lineTextArea = new JTextArea();
|
final JTextArea lineTextArea = new JTextArea();
|
||||||
lineTextArea.setEnabled(false);
|
lineTextArea.setEnabled(false);
|
||||||
lineTextArea.setMargin(new Insets(5,0,5,0));
|
lineTextArea.setMargin(new Insets(5,0,5,0));
|
||||||
|
@ -261,9 +276,11 @@ public class ScriptRunner extends VisPlugin {
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
/* Continously write test output to file */
|
/* Continously write test output to file */
|
||||||
File logFile = new File("COOJA.testlog");
|
|
||||||
if (logWriter == null) {
|
if (logWriter == null) {
|
||||||
/* Warning: static variable, used by all active plugins */
|
/* Warning: static variable, used by all active test editor plugins */
|
||||||
|
if (logFile.exists()) {
|
||||||
|
logFile.delete();
|
||||||
|
}
|
||||||
logWriter = new BufferedWriter(new FileWriter(logFile));
|
logWriter = new BufferedWriter(new FileWriter(logFile));
|
||||||
}
|
}
|
||||||
engine.setScriptLogObserver(new Observer() {
|
engine.setScriptLogObserver(new Observer() {
|
||||||
|
@ -276,11 +293,12 @@ public class ScriptRunner extends VisPlugin {
|
||||||
logger.fatal("No log writer: " + obj);
|
logger.fatal("No log writer: " + obj);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.fatal("Error when writing to test log file: " + obj);
|
logger.fatal("Error when writing to test log file: " + obj, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
logger.fatal("Create log writer error: ", e);
|
||||||
setScriptActive(false);
|
setScriptActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,16 +371,6 @@ public class ScriptRunner extends VisPlugin {
|
||||||
final JDialog progressDialog = new JDialog((Window)GUI.getTopParentContainer(), (String) null);
|
final JDialog progressDialog = new JDialog((Window)GUI.getTopParentContainer(), (String) null);
|
||||||
progressDialog.setTitle("Running test...");
|
progressDialog.setTitle("Running test...");
|
||||||
|
|
||||||
File coojaBuild = new File(GUI.getExternalToolsSetting("PATH_CONTIKI"), "tools/cooja/build");
|
|
||||||
File coojaJAR = new File(GUI.getExternalToolsSetting("PATH_CONTIKI"), "tools/cooja/dist/cooja.jar");
|
|
||||||
coojaBuild = coojaBuild.getCanonicalFile();
|
|
||||||
coojaJAR = coojaJAR.getCanonicalFile();
|
|
||||||
|
|
||||||
final File logFile = new File(coojaBuild, "COOJA.testlog");
|
|
||||||
if (logFile.exists()) {
|
|
||||||
logFile.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!coojaJAR.exists()) {
|
if (!coojaJAR.exists()) {
|
||||||
JOptionPane.showMessageDialog(GUI.getTopParentContainer(),
|
JOptionPane.showMessageDialog(GUI.getTopParentContainer(),
|
||||||
"Can't start COOJA, cooja.jar not found:" +
|
"Can't start COOJA, cooja.jar not found:" +
|
||||||
|
@ -418,24 +426,12 @@ public class ScriptRunner extends VisPlugin {
|
||||||
progressDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
progressDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
progressDialog.getRootPane().setDefaultButton(button);
|
progressDialog.getRootPane().setDefaultButton(button);
|
||||||
progressDialog.setSize(500, 300);
|
progressDialog.setSize(800, 300);
|
||||||
progressDialog.setLocationRelativeTo(ScriptRunner.this);
|
progressDialog.setLocationRelativeTo(ScriptRunner.this);
|
||||||
progressDialog.addWindowListener(new WindowListener() {
|
progressDialog.addWindowListener(new WindowAdapter() {
|
||||||
public void windowActivated(WindowEvent e) {
|
|
||||||
}
|
|
||||||
public void windowClosed(WindowEvent e) {
|
public void windowClosed(WindowEvent e) {
|
||||||
abort.actionPerformed(null);
|
abort.actionPerformed(null);
|
||||||
}
|
}
|
||||||
public void windowClosing(WindowEvent e) {
|
|
||||||
}
|
|
||||||
public void windowDeactivated(WindowEvent e) {
|
|
||||||
}
|
|
||||||
public void windowDeiconified(WindowEvent e) {
|
|
||||||
}
|
|
||||||
public void windowIconified(WindowEvent e) {
|
|
||||||
}
|
|
||||||
public void windowOpened(WindowEvent e) {
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
progressDialog.setVisible(true);
|
progressDialog.setVisible(true);
|
||||||
|
|
||||||
|
@ -553,7 +549,9 @@ public class ScriptRunner extends VisPlugin {
|
||||||
}
|
}
|
||||||
} else if ("active".equals(name)) {
|
} else if ("active".equals(name)) {
|
||||||
boolean active = Boolean.parseBoolean(element.getText());
|
boolean active = Boolean.parseBoolean(element.getText());
|
||||||
setScriptActive(active);
|
if (GUI.isVisualized()) {
|
||||||
|
setScriptActive(active);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue