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

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

import jadex.bdi.runtime.Plan;

/**
 *  Add a value to a belief set.
 */
public class BeliefSetAddPlan extends Plan
{
	//-------- attributes --------

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

	/** The new value. */
	protected Object value;
	
	/** The wait time (if any). */
	protected long wait;

	//-------- constructors --------

	/**
	 *  Create a new plan.
	 */
	public BeliefSetAddPlan()
	{
		this.belsetname = (String)getParameter("beliefsetname").getValue();
		if(belsetname==null)
			throw new RuntimeException("Beliefsetname must not null.");

		this.value = getParameter("value").getValue();
		
		if(hasParameter("wait"))
			this.wait	= ((Number)getParameter("wait").getValue()).longValue();
		else
			this.wait	= -1;
	}

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

	/**
	 * The body method.
	 */
	public void body()
	{
		getLogger().info("waiting for: "+wait);
		if(wait!=-1)
			waitFor(wait);
		
		getLogger().info("Adding to beliefset: "+belsetname+" value :"+value);
		getBeliefbase().getBeliefSet(belsetname).addFact(value);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy