public class RPlan extends RParameterElement implements IPlan, IInternalPlan
Modifier and Type | Class and Description |
---|---|
class |
RPlan.BDIFuture<E>
Future that overrides addResultListener to keep track
of current rplan in RPLANS variable.
|
static class |
RPlan.PlanLifecycleState |
static class |
RPlan.PlanProcessingState |
class |
RPlan.ResumeCommand<T> |
class |
RPlan.Waitqueue
Waitque holds events for later processing.
|
RParameterElement.RParameter, RParameterElement.RParameterSet
Modifier and Type | Field and Description |
---|---|
protected boolean |
atomic
The atomic flag.
|
protected IPlanBody |
body
The plan body.
|
protected java.lang.Object |
candidate
The candidate from which this plan was created.
|
protected int |
cnt
The wait cnt for rule names.
|
protected java.lang.Object |
dispatchedelement
The plan has a dispatched element (current goal/event).
|
protected java.lang.Exception |
exception
The plan has exception attribute.
|
jadex.commons.future.Future<java.lang.Void> |
finished
The finished future (if finishing or finished).
|
protected RPlan.PlanLifecycleState |
lifecyclestate
The plan has lifecycle state attribute.
|
protected java.util.List<jadex.commons.future.IResultListener<java.lang.Object>> |
listeners
The plan listeners.
|
protected RPlan.PlanProcessingState |
processingstate
The plan has processing state attribute (ready or waiting).
|
protected java.lang.Object |
reason
The plan has a reason.
|
protected java.lang.Object |
result
The result.
|
protected jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>> |
resumecommand
The blocking resume.
|
protected java.util.List<jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>>> |
resumecommands
The non-blocking resumes.
|
protected java.util.List<RGoal> |
subgoals
The plan has subgoals attribute (hack!!! redundancy to goal_has_parentplan).
|
protected WaitAbstraction |
waitabstraction
The plan has a wait abstraction attribute.
|
protected RPlan.Waitqueue |
waitqueue
The waitqueue.
|
protected WaitAbstraction |
waitqueuewa
The plan has a waitqueue wait abstraction attribute.
|
parameters, parametersets
agent, id, modelelement
Constructor and Description |
---|
RPlan(MPlan mplan,
java.lang.Object candidate,
java.lang.Object reason,
jadex.bridge.IInternalAccess agent,
java.util.Map<java.lang.String,java.lang.Object> mappingvals,
MConfigParameterElement config)
Create a new plan.
|
Modifier and Type | Method and Description |
---|---|
jadex.commons.future.IFuture<java.lang.Void> |
abort()
Abort the plan.
|
void |
addListener(jadex.commons.future.IResultListener<java.lang.Object> listener)
Add a new listener to get notified when the goal is finished.
|
void |
addResumeCommand(jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>> rescom) |
void |
addSubgoal(RGoal subgoal) |
protected void |
addToWaitqueue(java.lang.Object obj) |
void |
afterBlock()
Called after unblocking the component thread.
|
void |
beforeBlock()
Called before blocking the component thread.
|
static RPlan |
createRPlan(MPlan mplan,
java.lang.Object candidate,
java.lang.Object reason,
jadex.bridge.IInternalAccess ia,
java.util.Map<java.lang.String,java.lang.Object> binding,
MConfigParameterElement config)
Create a new rplan based on an mplan.
|
jadex.commons.future.IFuture<jadex.bridge.service.types.clock.ITimer> |
createTimer(long timeout,
jadex.bridge.IInternalAccess ia,
jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>> rescom) |
<T,E> jadex.commons.future.IFuture<E> |
dispatchSubgoal(T goal)
Dispatch a goal wait for its result.
|
<T,E> jadex.commons.future.IFuture<E> |
dispatchSubgoal(T goal,
long timeout)
Dispatch a goal wait for its result.
|
static jadex.commons.future.IFuture<java.lang.Object> |
executePlan(RPlan rplan,
jadex.bridge.IInternalAccess ia)
Execute a plan.
|
IPlanBody |
getBody()
Get the body.
|
java.lang.Object |
getCandidate()
Get the candidate.
|
java.lang.Object |
getDispatchedElement()
Get the dispatchedelement.
|
java.lang.Exception |
getException()
Get the exception.
|
java.lang.String |
getFetcherName()
Get the name of the element in the fetcher (e.g.
|
java.lang.Object |
getFromWaitqueue(WaitAbstraction wa) |
RPlan.PlanLifecycleState |
getLifecycleState()
Get the lifecycleState.
|
java.util.List<jadex.commons.future.IResultListener<java.lang.Object>> |
getListeners()
Get the listeners.
|
WaitAbstraction |
getOrCreateWaitqueueWaitAbstraction()
Get the waitabstraction.
|
java.lang.Object |
getPojoPlan()
Get the pojo plan of a plan.
|
RPlan.PlanProcessingState |
getProcessingState()
Get the processingState.
|
java.lang.Object |
getReason()
Get the reason.
|
java.lang.Object |
getResult()
Get the result.
|
jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>> |
getResumeCommand()
Get the resumecommand.
|
java.util.List<jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>>> |
getResumeCommands()
Get the resumecommands.
|
protected java.lang.String |
getRuleName() |
WaitAbstraction |
getWaitAbstraction()
Get the waitabstraction.
|
RPlan.Waitqueue |
getWaitqueue()
Get the waitqueue.
|
void |
initParameters(java.util.Map<java.lang.String,java.lang.Object> vals,
MConfigParameterElement config)
Create the parameters from model spec.
|
void |
internalSetupEventsRule(java.util.List<jadex.rules.eca.EventType> events)
Set up a rule for the waitqueue to signal to what kinds of events this plan
in principle reacts to.
|
boolean |
isAborted()
Test if plan is aborted.
|
boolean |
isAtomic()
Get the atomic.
|
boolean |
isFailed()
Test if element is failed.
|
boolean |
isFinished()
Test if goal is finished.
|
boolean |
isFinishing()
Test, if the plan end state (passed/failed/aborted) is started or done.
|
boolean |
isPassed()
Test if plan is passed.
|
boolean |
isSucceeded()
Test if element is succeeded.
|
boolean |
isWaitingFor(java.lang.Object procelem)
Test if the plan is waiting for a process element.
|
boolean |
isWaitqueueWaitingFor(java.lang.Object procelem)
Test if the plan is always waiting for a process element (waitqueue wait).
|
void |
notifyListeners()
Notify the listeners.
|
void |
publishToolPlanEvent(java.lang.String evtype)
Publish a tool event.
|
void |
removeListener(jadex.commons.future.IResultListener<java.lang.Object> listener)
Remove a listener.
|
void |
removeResumeCommand(jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>> rescom) |
void |
removeSubgoal(RGoal subgoal) |
void |
setAtomic(boolean atomic)
The atomic to set.
|
void |
setBody(IPlanBody body)
Set the body.
|
void |
setCandidate(java.lang.Object candidate)
Set the candidate.
|
void |
setDispatchedElement(java.lang.Object dispatchedelement)
Set the dispatchedelement.
|
void |
setException(java.lang.Exception exception)
Set the exception.
|
void |
setFinishing()
Start the finishing of the plan.
|
void |
setLifecycleState(RPlan.PlanLifecycleState lifecyclestate)
Set the lifecycleState.
|
void |
setProcessingState(RPlan.PlanProcessingState processingstate)
Set the processingState.
|
void |
setResult(java.lang.Object result)
Set the result.
|
void |
setupEventsRule(java.util.Collection<java.lang.String> events)
Set up a rule for the waitque to signal to what kinds of events this plan
in principle reacts to.
|
void |
setWaitAbstraction(WaitAbstraction waitabstraction)
Set the waitabstraction.
|
protected void |
testBodyAborted()
Check if plan is already aborted.
|
jadex.commons.future.IFuture<java.lang.Void> |
waitFor(long delay)
Wait for a delay.
|
<T> jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<T>> |
waitForCollectionChange(java.lang.String belname,
long timeout,
jadex.commons.IFilter<jadex.rules.eca.ChangeInfo<T>> filter)
Wait for a collection change.
|
<T> jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<T>> |
waitForCollectionChange(java.lang.String belname,
long timeout,
java.lang.Object id)
Wait for a collection change.
|
jadex.commons.future.IFuture<java.lang.Void> |
waitForCondition(jadex.rules.eca.ICondition cond,
java.lang.String[] events)
Wait for a condition.
|
jadex.commons.future.IFuture<java.lang.Void> |
waitForCondition(jadex.rules.eca.ICondition cond,
java.lang.String[] events,
long timeout)
Wait for a condition.
|
jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> |
waitForFactAdded(java.lang.String belname)
Wait for a fact being added to a belief.
|
jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> |
waitForFactAdded(java.lang.String belname,
long timeout)
Wait for a fact being added to a belief.
|
jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> |
waitForFactAddedOrRemoved(java.lang.String belname)
Wait for a fact being added or removed to a belief.
|
jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> |
waitForFactAddedOrRemoved(java.lang.String belname,
long timeout)
Wait for a fact being added or removed to a belief.
|
jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> |
waitForFactChanged(java.lang.String belname)
Wait for a fact change of a belief.
|
jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> |
waitForFactChanged(java.lang.String belname,
long timeout)
Wait for a fact change of a belief.
|
jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> |
waitForFactRemoved(java.lang.String belname)
Wait for a fact being removed from a belief.
|
jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> |
waitForFactRemoved(java.lang.String belname,
long timeout)
Wait for a fact being removed from a belief.
|
jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> |
waitForFactX(java.lang.String belname,
java.lang.String[] evtypes,
long timeout,
jadex.commons.IFilter<jadex.rules.eca.ChangeInfo<?>> filter)
Wait for a fact being added to a belief..
|
jadex.javaparser.SimpleValueFetcher |
wrapFetcher(jadex.commons.IValueFetcher fetcher)
Add reason to fetcher.
|
addParameter, addParameterSet, createParameter, createParameter, createParameterSet, createParameterSet, get, getParameter, getParameters, getParameterSet, getParameterSets, getType, hasParameter, hasParameterSet, testWriteOK
getAgent, getCapability, getId, getMCapability, getModelElement, getRuleSystem, setId, setModelElement, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getParameter, getParameters, getParameterSet, getParameterSets, getType, hasParameter, hasParameterSet
getModelElement
protected java.lang.Object reason
protected java.lang.Object dispatchedelement
protected java.util.List<RGoal> subgoals
protected WaitAbstraction waitabstraction
protected WaitAbstraction waitqueuewa
protected RPlan.Waitqueue waitqueue
protected jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>> resumecommand
protected java.util.List<jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>>> resumecommands
protected java.lang.Exception exception
protected java.lang.Object result
protected RPlan.PlanLifecycleState lifecyclestate
protected RPlan.PlanProcessingState processingstate
protected IPlanBody body
protected java.lang.Object candidate
protected java.util.List<jadex.commons.future.IResultListener<java.lang.Object>> listeners
protected int cnt
protected boolean atomic
public jadex.commons.future.Future<java.lang.Void> finished
public RPlan(MPlan mplan, java.lang.Object candidate, java.lang.Object reason, jadex.bridge.IInternalAccess agent, java.util.Map<java.lang.String,java.lang.Object> mappingvals, MConfigParameterElement config)
public static RPlan createRPlan(MPlan mplan, java.lang.Object candidate, java.lang.Object reason, jadex.bridge.IInternalAccess ia, java.util.Map<java.lang.String,java.lang.Object> binding, MConfigParameterElement config)
public jadex.javaparser.SimpleValueFetcher wrapFetcher(jadex.commons.IValueFetcher fetcher)
wrapFetcher
in class RParameterElement
public java.lang.Object getPojoPlan()
public static jadex.commons.future.IFuture<java.lang.Object> executePlan(RPlan rplan, jadex.bridge.IInternalAccess ia)
public void initParameters(java.util.Map<java.lang.String,java.lang.Object> vals, MConfigParameterElement config)
initParameters
in class RParameterElement
public java.lang.String getFetcherName()
getFetcherName
in class RParameterElement
public RPlan.PlanProcessingState getProcessingState()
public void setProcessingState(RPlan.PlanProcessingState processingstate)
processingState
- The processingState to set.public RPlan.PlanLifecycleState getLifecycleState()
public void setLifecycleState(RPlan.PlanLifecycleState lifecyclestate)
lifecycleState
- The lifecycleState to set.public void notifyListeners()
public void addListener(jadex.commons.future.IResultListener<java.lang.Object> listener)
addListener
in interface IFinishableElement<java.lang.Object>
listener
- The listener.public void removeListener(jadex.commons.future.IResultListener<java.lang.Object> listener)
removeListener
in interface IFinishableElement<java.lang.Object>
listener
- The listener.public java.util.List<jadex.commons.future.IResultListener<java.lang.Object>> getListeners()
public java.lang.Object getReason()
public java.lang.Object getDispatchedElement()
getDispatchedElement
in interface IPlan
public void setDispatchedElement(java.lang.Object dispatchedelement)
dispatchedelement
- The dispatchedelement to set.public java.lang.Exception getException()
getException
in interface IInternalPlan
getException
in interface IFinishableElement<java.lang.Object>
public void setException(java.lang.Exception exception)
exception
- The exception to set.public IPlanBody getBody()
public void setBody(IPlanBody body)
body
- The body to set.public java.lang.Object getCandidate()
getCandidate
in interface IInternalPlan
public void setCandidate(java.lang.Object candidate)
candidate
- The candidate to set.public boolean isWaitingFor(java.lang.Object procelem)
public WaitAbstraction getWaitAbstraction()
public void setWaitAbstraction(WaitAbstraction waitabstraction)
waitabstraction
- The waitabstraction to set.public boolean isWaitqueueWaitingFor(java.lang.Object procelem)
public WaitAbstraction getOrCreateWaitqueueWaitAbstraction()
protected void addToWaitqueue(java.lang.Object obj)
public java.lang.Object getFromWaitqueue(WaitAbstraction wa)
public boolean isPassed()
IPlan
isPassed
in interface IInternalPlan
isPassed
in interface IPlan
public boolean isFailed()
IFinishableElement
isFailed
in interface IInternalPlan
isFailed
in interface IFinishableElement<java.lang.Object>
public boolean isAborted()
IPlan
isAborted
in interface IInternalPlan
isAborted
in interface IPlan
public void setFinishing()
public boolean isFinishing()
public boolean isFinished()
IFinishableElement
isFinished
in interface IFinishableElement<java.lang.Object>
public void addSubgoal(RGoal subgoal)
public void removeSubgoal(RGoal subgoal)
public jadex.commons.future.IFuture<java.lang.Void> abort()
IPlan
public RPlan.Waitqueue getWaitqueue()
public jadex.commons.future.IFuture<java.lang.Void> waitFor(long delay)
public <T,E> jadex.commons.future.IFuture<E> dispatchSubgoal(T goal)
dispatchSubgoal
in interface IPlan
public <T,E> jadex.commons.future.IFuture<E> dispatchSubgoal(T goal, long timeout)
dispatchSubgoal
in interface IPlan
public jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> waitForFactChanged(java.lang.String belname)
waitForFactChanged
in interface IPlan
public jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> waitForFactChanged(java.lang.String belname, long timeout)
waitForFactChanged
in interface IPlan
public jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> waitForFactAdded(java.lang.String belname)
waitForFactAdded
in interface IPlan
public jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> waitForFactAdded(java.lang.String belname, long timeout)
waitForFactAdded
in interface IPlan
public jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> waitForFactRemoved(java.lang.String belname)
waitForFactRemoved
in interface IPlan
public jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> waitForFactRemoved(java.lang.String belname, long timeout)
waitForFactRemoved
in interface IPlan
public jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> waitForFactX(java.lang.String belname, java.lang.String[] evtypes, long timeout, jadex.commons.IFilter<jadex.rules.eca.ChangeInfo<?>> filter)
public jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> waitForFactAddedOrRemoved(java.lang.String belname)
waitForFactAddedOrRemoved
in interface IPlan
public jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<?>> waitForFactAddedOrRemoved(java.lang.String belname, long timeout)
waitForFactAddedOrRemoved
in interface IPlan
public <T> jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<T>> waitForCollectionChange(java.lang.String belname, long timeout, jadex.commons.IFilter<jadex.rules.eca.ChangeInfo<T>> filter)
waitForCollectionChange
in interface IPlan
public <T> jadex.commons.future.IFuture<jadex.rules.eca.ChangeInfo<T>> waitForCollectionChange(java.lang.String belname, long timeout, java.lang.Object id)
waitForCollectionChange
in interface IPlan
public jadex.commons.future.IFuture<java.lang.Void> waitForCondition(jadex.rules.eca.ICondition cond, java.lang.String[] events)
waitForCondition
in interface IPlan
public jadex.commons.future.IFuture<java.lang.Void> waitForCondition(jadex.rules.eca.ICondition cond, java.lang.String[] events, long timeout)
waitForCondition
in interface IPlan
public jadex.commons.future.IFuture<jadex.bridge.service.types.clock.ITimer> createTimer(long timeout, jadex.bridge.IInternalAccess ia, jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>> rescom)
protected java.lang.String getRuleName()
public void beforeBlock()
public void afterBlock()
protected void testBodyAborted()
public void addResumeCommand(jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>> rescom)
public void removeResumeCommand(jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>> rescom)
public java.util.List<jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>>> getResumeCommands()
public jadex.commons.ICommand<jadex.commons.Tuple2<java.lang.Boolean,java.lang.Boolean>> getResumeCommand()
public java.lang.Object getResult()
public void setResult(java.lang.Object result)
result
- The result to set.public boolean isAtomic()
public void setAtomic(boolean atomic)
atomic
- The atomic to setpublic void publishToolPlanEvent(java.lang.String evtype)
public void setupEventsRule(java.util.Collection<java.lang.String> events)
public void internalSetupEventsRule(java.util.List<jadex.rules.eca.EventType> events)
public boolean isSucceeded()
isSucceeded
in interface IFinishableElement<java.lang.Object>