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

jadex.bdi.benchmarks.MessageReceiverPlan 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.benchmarks;

import jadex.bdi.runtime.Plan;


/**
 *  Plan for receiving messages.
 */
public class MessageReceiverPlan extends Plan
{
	/**
	 *  Create a new plan body.
	 */
	public void body()
	{
		int msgcnt = ((Integer)getBeliefbase().getBelief("msg_cnt").getFact()).intValue();
		int received = ((Integer)getBeliefbase().getBelief("received").getFact()).intValue();
		received++;
		getBeliefbase().getBelief("received").setFact(new Integer(received));
		
		if(received==msgcnt)
		{
			long starttime = ((Long)getBeliefbase().getBelief("starttime").getFact()).longValue();
			long dur = getTime() - starttime;
			System.out.println("Sending/receiving " + msgcnt + " messages took: " + dur + " milliseconds.");
			killAgent();
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy