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

jadex.bdi.testcases.misc.BeliefSetAddPlan 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.testcases.misc;

import jadex.bdi.runtime.Plan;

/**
 *  Modify a beliefset continuously by adding values.
 */
public class BeliefSetAddPlan extends Plan
{
	//-------- attributes --------

	/** The belief name. */
	protected String belsetname;

	/** The values. */
	protected Object[] values;
	
	/** The wait time. */
	protected long time;
	
	/** The flag for adding values over and over again. */
	protected boolean loop = true;
	
	//-------- constructors --------

	/**
	 *  Create a new plan.
	 */
	public BeliefSetAddPlan()
	{
		if(hasParameter("beliefsetname"))
			this.belsetname = (String)getParameter("beliefsetname").getValue();
		else
			throw new RuntimeException("Parameter value 'beliefsetname' required.");
		
		if(hasParameterSet("values"))
			this.values = getParameterSet("values").getValues();
		if(hasParameter("time"))
			this.time = ((Long)getParameter("time").getValue()).longValue();
		if(hasParameter("loop"))
			this.loop = ((Boolean)getParameter("loop").getValue()).booleanValue();
	}

	//-------- methods --------

	/**
	 * The body method is called on the
	 * instatiated plan instance from the scheduler.
	 */
	public void body()
	{
		long cnt = 0;
		do
		{
			if(values!=null)
			{
				for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy