我想将自己的插件添加到Cooja。我想扩展Visualizer.class,以便在Cooja中有两个。
答案 0 :(得分:1)
此视频向您展示如何将自己的插件添加到Cooja,扩展Visualizer.java
我解释了视频。您需要修改文件Gui.java
/home/user/contiki-2.x/tools/cooja/java/se/sics/cooja/Gui.java
添加以下代码:
// Register My Own plugins
Class<? extends Plugin> pluginClass1 = tryLoadClass(this, Plugin.class,
"se.sics.cooja.plugins.Tree");
if (pluginClass1 != null) {
registerPlugin(pluginClass1);
logger.info("Loaded plugin class: " + pluginClass1);
} else {
logger.warn("Could not load plugin class: se.sics.cooja.plugins.Tree" );
}
此外,您必须创建自己的名为Tree.java的插件,扩展Visualizer.java。以下是创建插件Tree.java
的代码package se.sics.cooja.plugins;
import se.sics.cooja.GUI;
import se.sics.cooja.Simulation;
import se.sics.cooja.plugins.Visualizer;
import se.sics.cooja.PluginType;
import se.sics.cooja.ClassDescription;
@ClassDescription("NetworkTree")
@PluginType(PluginType.SIM_STANDARD_PLUGIN)
public class Tree extends Visualizer{
public Tree(Simulation simulation, GUI gui) {
super(simulation, gui);
this.setLocation(1, 401);
this.setSize(400, 400);
}
}
Tree.java位于
/home/user/contiki-2.x/tools/cooja/java/se/sics/cooja/plugins/Tree.java
然后,你编译Cooja
ant clean
ant run
现在你在Cooja中有自己的插件,它扩展了Visualizer.java
:)