
jadex.bdi.examples.marsworld_classic.sentry.AddTargetPlan Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-bdi Show documentation
Show all versions of jadex-applications-bdi Show documentation
The Jadex BDI applications package contain
several example applications, benchmarks and
testcases using BDI agents.
The newest version!
package jadex.bdi.examples.marsworld_classic.sentry;
import jadex.bdi.examples.marsworld_classic.Environment;
import jadex.bdi.examples.marsworld_classic.Target;
import jadex.bdi.runtime.IMessageEvent;
import jadex.bdi.runtime.Plan;
import jadex.bridge.fipa.SFipa;
/**
* Add a new unknown target to test.
*/
public class AddTargetPlan extends Plan
{
//-------- constructors --------
/**
* Create a new plan.
*/
public AddTargetPlan()
{
getLogger().info("Created: "+this);
}
//-------- methods --------
/**
* The plan body.
*/
public void body()
{
//System.out.println("AddPlan found");
Environment env = (Environment)getBeliefbase().getBelief("move.environment").getFact();
IMessageEvent req = (IMessageEvent)getReason();
Target ot = (Target)req.getParameter(SFipa.CONTENT).getValue();
Target target = env.getTarget(ot.getId());
//if(ts.length>0)
// System.out.println("Sees: "+SUtil.arrayToString(ts));
if(target!=null)
{
if(!getBeliefbase().getBeliefSet("my_targets").containsFact(target)
&& !getBeliefbase().getBeliefSet("analysed_targets").containsFact(target))
{
//System.out.println("Found a new target: "+target);
getBeliefbase().getBeliefSet("my_targets").addFact(target);
}
}
}
//-------- static part --------
/**
* Get the filter.
* /
public static IFilter getEventFilter()
{
MessageTemplate temp = MessageTemplate.MatchPerformative(ACLMessage.INFORM);
MessageFilter filt = new MessageFilter(temp, null, OInformTarget.class);
return filt;
}*/
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy