get[Started]Plugin method returns plugins that end with argument + added sim and gui variables accessible from test scripts

This commit is contained in:
Fredrik Osterlind 2011-03-14 19:54:58 +01:00
parent bdc42d8e64
commit 0829e50f4b
2 changed files with 16 additions and 3 deletions

View File

@ -1882,19 +1882,30 @@ public class GUI extends Observable {
} }
/** /**
* Returns started plugin with given class name, if any. * Returns started plugin that ends with given class name, if any.
* *
* @param classname Class name * @param classname Class name
* @return Plugin instance * @return Plugin instance
*/ */
public Plugin getStartedPlugin(String classname) { public Plugin getPlugin(String classname) {
for (Plugin p: startedPlugins) { for (Plugin p: startedPlugins) {
if (p.getClass().getName().equals(classname)) { if (p.getClass().getName().endsWith(classname)) {
return p; return p;
} }
} }
return null; return null;
} }
/**
* Returns started plugin with given class name, if any.
*
* @param classname Class name
* @return Plugin instance
* @deprecated
*/
public Plugin getStartedPlugin(String classname) {
return getPlugin(classname);
}
public Plugin[] getStartedPlugins() { public Plugin[] getStartedPlugins() {
return startedPlugins.toArray(new Plugin[0]); return startedPlugins.toArray(new Plugin[0]);

View File

@ -434,6 +434,8 @@ public class LogScriptEngine {
Hashtable<Object, Object> hash = new Hashtable<Object, Object>(); Hashtable<Object, Object> hash = new Hashtable<Object, Object>();
engine.put("global", hash); engine.put("global", hash);
engine.put("sim", simulation);
engine.put("gui", simulation.getGUI());
scriptMote = new ScriptMote(); scriptMote = new ScriptMote();
engine.put("node", scriptMote); engine.put("node", scriptMote);