如何在另一个Gui中开始JADE Gui?

时间:2013-07-15 02:52:39

标签: java agents-jade

如何在另一个Gui中开始JADE Gui?假设我的Gui上有一个按钮。点击该按钮后,JADE Gui将启动。

这可能吗?如果是,怎么样?

提前致谢。

此致

1 个答案:

答案 0 :(得分:6)

我假设JADE Gui你的意思是JADE RMA

由于RMA本身就是一个代理,显示RMA gui只是创建和启动RMA代理的问题。

如果您是通过代码执行此操作(即,不是通过命令行或gui),则必须引用容器控制器以获取要启动它的容器,并且您将只需在其上调用createAgent()方法。

import jade.wrapper.AgentController;
import jade.wrapper.ContainerController;

...

ContainerController myContainer;

// .. load a container into the above variable ..

try {
    AgentController rma = myContainer.createNewAgent("rma", "jade.tools.rma.rma", null);
    rma.start();
} catch(StaleProxyException e) {
    e.printStackTrace();
}

您可以使用此类代码启动主容器

import jade.core.Runtime;
import jade.core.Profile;
import jade.core.ProfileImpl;

...

Runtime myRuntime = Runtime.instance();

// prepare the settings for the platform that we're going to start
Profile myProfile = new ProfileImpl();

// create the main container
myContainer = myRuntime.createMainContainer(myProfile);

或者你可以启动一个普通的代理容器并连接到这样的外部容器

import jade.core.Runtime;
import jade.core.Profile;
import jade.core.ProfileImpl;

...

Runtime myRuntime = Runtime.instance();

// prepare the settings for the platform that we're going to connect to
Profile myProfile = new ProfileImpl();
myProfile.setParameter(Profile.MAIN_HOST, "myhost");
myProfile.setParameter(Profile.MAIN_PORT, "1099");

// create the agent container
myContainer = myRuntime.createAgentContainer(myProfile);

参考:使用JADE开发多代理系统,Fabio Luigi Bellifemine,Giovanni Caire,Dominic Greenwood。

相关问题