public abstract class Plan
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
Plan.PlanWaitAbstraction
The plan wait abstraction extends wait abstraction with convenience methods.
|
Modifier and Type | Field and Description |
---|---|
protected IInternalAccess |
agent
The internal access.
|
protected RPlan |
rplan
The rplan.
|
Constructor and Description |
---|
Plan() |
Modifier and Type | Method and Description |
---|---|
void |
aborted()
The plan was aborted (because of conditional goal
success or termination from outside).
|
abstract void |
body()
The body method is called on the
instantiated plan instance from the scheduler.
|
protected void |
checkNotInAtomic()
Check if wait is called in atomic mode.
|
IExpression |
createExpression(java.lang.String exp)
Get an expression by name.
|
IGoal |
createGoal(java.lang.String type)
Create a goal from a template goal.
|
IInternalEvent |
createInternalEvent(java.lang.String type)
Create a new intenal event.
|
<T> IMessageEvent<T> |
createMessageEvent(java.lang.String type)
Create a new message event.
|
void |
dispatchInternalEvent(IInternalEvent event)
Dispatch an internal event.
|
IFuture<java.lang.Void> |
dispatchSubgoal(IGoal subgoal)
Dispatch a new subgoal.
|
void |
dispatchSubgoalAndWait(IGoal goal)
Dispatch a new top-level goal.
|
void |
dispatchSubgoalAndWait(IGoal goal,
long timeout)
Dispatch a new top-level goal.
|
void |
dispatchTopLevelGoal(IGoal goal)
Dispatch a new top-level goal.
|
void |
endAtomic()
End an atomic transaction.
|
void |
fail()
Let the plan fail.
|
void |
fail(java.lang.String message,
java.lang.Throwable cause)
Let a plan fail.
|
void |
fail(java.lang.Throwable cause)
Let a plan fail.
|
void |
failed()
The failed method is called on plan failure/abort.
|
IInternalAccess |
getAgent()
Get the agent.
|
IBeliefbase |
getBeliefbase()
Get the beliefbase.
|
IClockService |
getClock()
Get the clock.
|
IComponentDescription |
getComponentDescription()
Get the agent description.
|
IComponentIdentifier |
getComponentIdentifier()
Get the agent identifier.
|
java.lang.String |
getComponentName()
Get the agent name.
|
java.lang.Object |
getDispatchedElement()
Get the reason this plan was created for.
|
IEventbase |
getEventbase()
Get the event base.
|
java.lang.Exception |
getException()
Get the uncatched exception that occurred in the body (if any).
|
IExpression |
getExpression(java.lang.String name)
Get an expression by name.
|
IExpressionbase |
getExpressionbase()
Get the expression base.
|
IExternalAccess |
getExternalAccess()
Get the scope.
|
IGoalbase |
getGoalbase()
Get the goal base.
|
java.util.logging.Logger |
getLogger()
Get the logger.
|
IParameter |
getParameter(java.lang.String name)
Get a parameter.
|
IParameter[] |
getParameters()
Get all parameters.
|
IParameterSet |
getParameterSet(java.lang.String name)
Get a parameter.
|
IParameterSet[] |
getParameterSets()
Get all parameter sets.
|
IPlanbase |
getPlanbase()
Get the plan base.
|
IPlan |
getPlanElement()
Get the plan interface.
|
java.lang.Object |
getReason()
Get the reason this plan was created for.
|
IPlan |
getRPlan()
Get the rplan.
|
ICapability |
getScope()
Get the scope.
|
long |
getTime()
Get the current time.
|
Plan.PlanWaitAbstraction |
getWaitqueue()
Get the waitqueue.
|
boolean |
hasParameter(java.lang.String name)
Has the element a parameter element.
|
boolean |
hasParameterSet(java.lang.String name)
Has the element a parameter set element.
|
void |
killAgent()
Kill this agent.
|
void |
passed()
The passed method is called on plan success.
|
IFuture<java.lang.Void> |
sendMessage(IMessageEvent<?> me)
Send a message.
|
<T> IMessageEvent<T> |
sendMessageAndWait(IMessageEvent<T> me)
Send a message and wait for the answer.
|
<T> IMessageEvent<T> |
sendMessageAndWait(IMessageEvent<T> me,
long timeout)
Send a message and wait for the answer.
|
void |
startAtomic()
Start an atomic transaction.
|
java.lang.String |
toString()
Get the string representation.
|
void |
waitFor(long timeout)
Wait for a some time.
|
void |
waitForCondition(java.lang.String name)
Wait for a condition.
|
void |
waitForCondition(java.lang.String name,
long timeout)
Wait for a condition.
|
void |
waitForCondition(java.lang.String name,
long timeout,
java.util.Map<java.lang.String,java.lang.Object> values)
Wait for a condition.
|
void |
waitForConditionInline(java.lang.String expr)
Wait for a condition.
|
void |
waitForConditionInline(java.lang.String expr,
long timeout)
Wait for a condition.
|
void |
waitForEver()
Wait for ever (is aborted on goal success/failure).
|
java.lang.Object |
waitForFactAdded(java.lang.String belname)
Wait for a fact added.
|
java.lang.Object |
waitForFactAdded(java.lang.String belname,
long timeout)
Wait for a fact added.
|
java.lang.Object |
waitForFactChanged(java.lang.String belname)
Wait for a fact change of a belief.
|
java.lang.Object |
waitForFactChanged(java.lang.String belname,
long timeout)
Wait for a fact change of a belief.
|
java.lang.Object |
waitForFactRemoved(java.lang.String belname)
Wait for a fact added.
|
java.lang.Object |
waitForFactRemoved(java.lang.String belname,
long timeout)
Wait for a fact added.
|
void |
waitForGoalFinished(IGoal goal)
Wait for a goal to be finished.
|
void |
waitForGoalFinished(IGoal goal,
long timeout)
Wait for a goal to be finished.
|
IGoal |
waitForGoalFinished(java.lang.String type)
Wait for a goal.
|
IGoal |
waitForGoalFinished(java.lang.String type,
long timeout)
Wait for a goal.
|
IInternalEvent |
waitForInternalEvent(java.lang.String type)
Wait for an internal event.
|
IInternalEvent |
waitForInternalEvent(java.lang.String type,
long timeout)
Wait for an internal event.
|
IMessageEvent |
waitForMessageEvent(java.lang.String type)
Wait for a message event.
|
IMessageEvent |
waitForMessageEvent(java.lang.String type,
long timeout)
Wait for a message event.
|
IMessageEvent |
waitForReply(IMessageEvent event)
Wait for a reply to a message event.
|
IMessageEvent |
waitForReply(IMessageEvent event,
long timeout)
Wait for a reply to a message event.
|
IMessageEvent |
waitForReply(IMessageEvent event,
java.lang.String type)
Wait for a reply to a message event.
|
IMessageEvent |
waitForReply(IMessageEvent event,
java.lang.String type,
long timeout)
Wait for a reply to a message event.
|
void |
waitForTick()
Wait for next tick.
|
protected IInternalAccess agent
protected RPlan rplan
public abstract void body()
public void passed()
public void failed()
public void aborted()
public void waitFor(long timeout)
duration
- The duration.public void waitForTick()
public IGoal createGoal(java.lang.String type)
type
- The template goal name as specified in the ADF.public void dispatchSubgoalAndWait(IGoal goal)
goal
- The new goal.public void dispatchSubgoalAndWait(IGoal goal, long timeout)
goal
- The new goal.public IGoal waitForGoalFinished(java.lang.String type)
type
- The goal type.public IGoal waitForGoalFinished(java.lang.String type, long timeout)
type
- The goal type.timeout
- The timeout.public void waitForGoalFinished(IGoal goal)
goal
- The goal.public void waitForGoalFinished(IGoal goal, long timeout)
goal
- The goal.public IMessageEvent waitForMessageEvent(java.lang.String type)
type
- The message event type.public IMessageEvent waitForMessageEvent(java.lang.String type, long timeout)
type
- The message event type.timeout
- The timeout.public IMessageEvent waitForReply(IMessageEvent event)
event
- The message event.public IMessageEvent waitForReply(IMessageEvent event, long timeout)
event
- The message event.timeout
- The timeout.public IMessageEvent waitForReply(IMessageEvent event, java.lang.String type)
event
- The message event.type
- The reply.public IMessageEvent waitForReply(IMessageEvent event, java.lang.String type, long timeout)
event
- The message event.type
- The reply.timeout
- The timeout.public IInternalEvent waitForInternalEvent(java.lang.String type)
type
- The internal event type.public IInternalEvent waitForInternalEvent(java.lang.String type, long timeout)
type
- The internal event type.timeout
- The timeout.public void killAgent()
public java.util.logging.Logger getLogger()
public IBeliefbase getBeliefbase()
public IPlan getRPlan()
public java.lang.Object getReason()
public java.lang.Object getDispatchedElement()
public IParameter getParameter(java.lang.String name)
name
- The name.public IParameterSet getParameterSet(java.lang.String name)
name
- The name.public IExpression getExpression(java.lang.String name)
public IExpression createExpression(java.lang.String exp)
public <T> IMessageEvent<T> sendMessageAndWait(IMessageEvent<T> me)
me
- The message event.public <T> IMessageEvent<T> sendMessageAndWait(IMessageEvent<T> me, long timeout)
me
- The message event.timeout
- The timeout.public void fail()
public void fail(java.lang.Throwable cause)
cause
- The cause.public void fail(java.lang.String message, java.lang.Throwable cause)
message
- The message.cause
- The cause.public ICapability getScope()
public void startAtomic()
endAtomic()
public void endAtomic()
startAtomic()
public IFuture<java.lang.Void> dispatchSubgoal(IGoal subgoal)
subgoal
- The new subgoal.
Note: plan step is interrupted after call.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getComponentName()
public IComponentIdentifier getComponentIdentifier()
public IComponentDescription getComponentDescription()
public java.lang.Exception getException()
public IGoalbase getGoalbase()
public IPlanbase getPlanbase()
public IEventbase getEventbase()
public IExpressionbase getExpressionbase()
public IClockService getClock()
public long getTime()
System.currentTimeMillis()
, i.e.,
the value of milliseconds passed since 0:00 'o clock, January 1st, 1970, UTC.
For custom simulation clocks, arbitrary representations can be used.public void dispatchTopLevelGoal(IGoal goal)
goal
- The new goal.
Note: plan step is interrupted after call.public IFuture<java.lang.Void> sendMessage(IMessageEvent<?> me)
me
- The message event.public void dispatchInternalEvent(IInternalEvent event)
event
- The event.
Note: plan step is interrupted after call.public <T> IMessageEvent<T> createMessageEvent(java.lang.String type)
public IInternalEvent createInternalEvent(java.lang.String type)
public IExternalAccess getExternalAccess()
public IParameter[] getParameters()
public IParameterSet[] getParameterSets()
public boolean hasParameter(java.lang.String name)
name
- The name.public boolean hasParameterSet(java.lang.String name)
name
- The name.public IInternalAccess getAgent()
public Plan.PlanWaitAbstraction getWaitqueue()
public java.lang.Object waitForFactChanged(java.lang.String belname)
public java.lang.Object waitForFactChanged(java.lang.String belname, long timeout)
public java.lang.Object waitForFactAdded(java.lang.String belname)
public java.lang.Object waitForFactAdded(java.lang.String belname, long timeout)
public java.lang.Object waitForFactRemoved(java.lang.String belname)
public java.lang.Object waitForFactRemoved(java.lang.String belname, long timeout)
public void waitForCondition(java.lang.String name)
name
- The name of the condition.public void waitForCondition(java.lang.String name, long timeout)
name
- The name of the condition.timeout
- The wait timeout.public void waitForCondition(java.lang.String name, long timeout, java.util.Map<java.lang.String,java.lang.Object> values)
name
- The name of the condition.timeout
- The wait timeout.values
- Extra parameter values for the condition, if any.public void waitForConditionInline(java.lang.String expr)
name
- The name of the condition.public void waitForConditionInline(java.lang.String expr, long timeout)
name
- The name of the condition.public void waitForEver()
public IPlan getPlanElement()
protected void checkNotInAtomic()
java.lang.RuntimeException
- in case is in atomic block.