public class PlanInstance extends java.lang.Object implements GoalListener
| Modifier and Type | Class and Description |
|---|---|
static class |
PlanInstance.EndState
This enumuration represents the possible end states of a plan execution.
|
| Constructor and Description |
|---|
PlanInstance(Plan plan,
Intention intention)
Creates a new plan instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispatchGoal(Goal goal)
Dispatches a goal to be achieved.
|
void |
dispatchProtectedGoal(Goal goal)
Dispatches a goal to be achieved, using the capability (or its children
capabilities) associated with the plan.
|
void |
dispatchProtectedSubgoal(Goal subgoal)
Dispatches a subgoal to be achieved, using the capability (or its
children capabilities) associated with the plan.
|
void |
dispatchProtectedSubgoalAndListen(Goal subgoal)
Dispatches a subgoal to be achieved, using the capability (or its
children capabilities) associated with the plan, and registers itself as
a listener to receive a notification of the end of execution of the goal.
|
void |
dispatchSubgoal(Goal subgoal)
Dispatches a subgoal to be achieved.
|
void |
dispatchSubgoalAndListen(Goal subgoal)
Dispatches a subgoal to be achieved and registers itself as a listener to
receive a notification of the end of execution of the goal.
|
BeliefBase |
getBeliefBase()
Returns the belief base of the capability.
|
PlanInstance.EndState |
getEndState()
Returns the end state of plan.
|
Goal |
getGoal()
Returns the goal to be achieved by this plan instance.
|
GoalFinishedEvent |
getGoalEvent()
Returns a goal event from the queue.
|
GoalFinishedEvent |
getGoalEvent(boolean block)
Returns a goal event from the queue.
|
GoalFinishedEvent |
getGoalEvent(long ms)
Returns a goal event from the queue.
|
Plan |
getPlan()
Returns the
Plan that is associated with this plan instance. |
void |
goalPerformed(GoalEvent event)
Notifies the listener that the goal was performed.
|
void |
startPlan()
Starts the plan body, a
Behaviour, associated with this plan. |
void |
stopPlan()
Stops the plan body, a
Behaviour, associated with this plan. |
public PlanInstance(Plan plan, Intention intention) throws PlanInstantiationException
Plan) and an Intention. It creates an instance of the
plan body defined in the plan and throws an exception if an error occurs
in this process.plan - the plan associated this this plan instance.intention - the intention that this plan instance have to achieve.PlanBodyInstantiationException - in an error occurred during the instantiation.PlanInstantiationExceptionpublic void dispatchProtectedGoal(Goal goal)
goal - the goal to be dispatched.public void dispatchProtectedSubgoal(Goal subgoal)
subgoal - the subgoal to be dispatched.public void dispatchProtectedSubgoalAndListen(Goal subgoal)
subgoal - the subgoal to be dispatched.public void dispatchGoal(Goal goal)
goal - the goal to be dispatched.public void dispatchSubgoal(Goal subgoal)
subgoal - the subgoal to be dispatched.public void dispatchSubgoalAndListen(Goal subgoal)
subgoal - the subgoal to be dispatched.public BeliefBase getBeliefBase()
public PlanInstance.EndState getEndState()
OutputPlanBody interface (this is invoked only
once). If the plan body has come to a failed state, it sets all of its
subgoals as no longer desired.public Goal getGoal()
public GoalFinishedEvent getGoalEvent()
public GoalFinishedEvent getGoalEvent(boolean block)
block - true if the behavior must be blocked if the queue is empty.public GoalFinishedEvent getGoalEvent(long ms)
ms - the maximum amount of time that the behavior must be blocked.public Plan getPlan()
Plan that is associated with this plan instance.public void goalPerformed(GoalEvent event)
GoalListenergoalPerformed in interface GoalListenerevent - the performed goal event.GoalListener.goalPerformed(bdi4jade.event.GoalEvent)public void startPlan()
Behaviour, associated with this plan.public void stopPlan()
Behaviour, associated with this plan. If
the body implements the DisposablePlanBody, it invokes the method
to about the plan body, so it can perform finalizations.