All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.bdi.examples.ping.EchoPlan Maven / Gradle / Ivy

Go to download

The Jadex BDI applications package contain several example applications, benchmarks and testcases using BDI agents.

There is a newer version: 2.4
Show newest version
package jadex.bdi.examples.ping;

import jadex.bdi.runtime.IMessageEvent;
import jadex.bdi.runtime.Plan;
import jadex.bridge.fipa.SFipa;


/**
 *  The echo plan reacts on every message
 *  with the same message.
 */
public class EchoPlan extends Plan
{
	//-------- methods --------

	/**
	 *  Handle the ping request.
	 */
	public void body()
	{
		// Get the initial event.
		IMessageEvent me = (IMessageEvent)getReason();
	
//		System.out.println("Echo plan invoked: "+me.getParameter(SFipa.CONTENT).getValue());
		
		// Create the reply.
		IMessageEvent re = getEventbase().createReply(me, "any_message");
		re.getParameter(SFipa.PERFORMATIVE).setValue(me.getParameter(
			SFipa.PERFORMATIVE).getValue());
		re.getParameter(SFipa.CONTENT).setValue(me.getParameter(
				SFipa.CONTENT).getValue());
	
		// Send back the reply and terminate.
		sendMessage(re);
	}
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy