顯示具有 JADE 標籤的文章。 顯示所有文章
顯示具有 JADE 標籤的文章。 顯示所有文章

2009年5月12日 星期二

JADE/JMS integration Part I- User Scenario

JADE (Java Agent Development Environment) is a mature agent platform. It receives a lots of attention in software agent development paradigm. In this post I will discuss a scenario that using JADE as a basic platform to develop Tel-Gate application. The Tel-Gate is equipped with multiple RFID readers and IP based cameras. The agents in JADE have to communicate with the RFID reader middleware and surveillance system. Then, a fusion process will be execute when the agent receives any signal from both systems.
I list the agent's responsibilities as following:

  1. communicate the surveillance system to get the meta-data which is produced when something appear in the front of the camera. The meta-data from the surveillance is a text message in XML format delivered by JMS.
  2. communicate with RFID middleware (JMS application) to get the RFID signal.
  3. fuse the signal from different devices.
  4. report a situation to backend.
The challenges I have to overcome is list as following:
  1. In JADE how to cooperator with the JMS to get the message from other sub-system.
  2. How to simulate a time domain to fuse the data from difference sub-system.
This project is a benchmark project to compare the capability with SystemJ (which is language the use to perform GALS). I will try to make this program as small as possible.

What will be devliered in this project:
  1. a development project under eclipse.
  2. an ant script that used to execute the build process and execution.
  3. several agents based on JADE will be developed.
  4. a performance result will be reported.
Next post, I will introduce the system architecture of this system.

2008年10月21日 星期二

JADE/SWT Integaration

JADE is a platform to develop agent based application based on Java language.
I used this package in my dissertation. In this post I would like record the integration between JADE and SWT user interface package.
In my agent application, the agent have to catch the user's eye when the agent wants to notify the user who is working arround a PC station.
So, Here is two questions that I have to deal with. The first one is to know the packages that I have to include in my application, the second one is how could I activate the user interface in my agent process.

The first question is easy to solve by using the plugin inspector and plugin depency user interface from eclipse platform.

  1. Find JFace plug-in in the list
  2. Double click on the plug-in then it will show the whole dependencies. We need all this package in the class path.
So, I added the following jar files into my class path
  • org.eclipse.core.commands_3.4.0.I20080509-2000.jar
  • org.eclipse.equinox.common_3.4.0.v20080421-2006.jar
  • org.eclipse.jface_3.4.0.I20080606-1300.jar
  • org.eclipse.osgi_3.4.0.v20080605-1900.jar
  • org.eclipse.swt_3.4.0.v3448f.jar
Then, I have to deal the activation question. In JADE programming, programers have to code their logic in the Behaviour class. Also, an agent can have more than one behaviour class at the same time.
I created a CyclicBehaviour class to linsten the incoming message from other agent. Once a specific message is caught by the agent then a user interface will be activate.
However, I encounter a problem when using the normal Behaviour to activate the SWT/JFace ApplicationWindow like the following code.

The behaviour class is list as following:

private class WorkerReactionBehaviour extends CyclicBehaviour
{


@Override
public void action() {
System.out.println("from worker agent: message collect");
ACLMessage msg = myAgent.receive();
if (msg != null) {
System.out.println("from agent:" + msg.getSender().getName());
String content =msg.getContent();
if(bGuiShow == false)
{
myAgent.addBehaviour(new GuiBehaviour());
gui.notifyUser(content);
}
}
else
System.out.println("worker agent: no message");
//test
//System.out.println("notified user ...");
//gui.notifyUser("test");
block(2000);

}

}

The user interface activate code is list as following:

public class WorkerGuiImpl extends ApplicationWindow implements WorkerGui {
public void show()
{
if(bShowed == true)
return;
bShowed = true;
this.setBlockOnOpen(true);
this.open();
Display.getCurrent().dispose();
}
}//show

The consequence is the agent behaviour will be block when the user interface shows up.
Hence, I have to make the user interface behaviour execute as a dedicated Java thread.
There is a ThreadedBehaviourFactory supported by JADE plateform to wrap the normal JADE behaviour into dedicated Java thread.
Just using the following code to solve the behaviour blocking problem.

ThreadedBehaviourFactory tbf = new
ThreadedBehaviourFactory();
myAgent.addBehaviour(tbf.wrap(new GuiBehaviour()));


Reference
  1. http://www.nabble.com/JADE-SWT-problem-to20093283.html