Class Plan

    • Field Detail

      • rplan

        protected jadex.bdiv3.runtime.impl.RPlan rplan
        The rplan.
    • Constructor Detail

      • Plan

        public Plan()
    • Method Detail

      • body

        public abstract void body()
        The body method is called on the instantiated plan instance from the scheduler.
      • passed

        public void passed()
        The passed method is called on plan success.
      • failed

        public void failed()
        The failed method is called on plan failure/abort.
      • aborted

        public void aborted()
        The plan was aborted (because of conditional goal success or termination from outside).
      • waitFor

        public void waitFor​(long timeout)
        Wait for a some time.
        Parameters:
        duration - The duration.
      • waitForTick

        public void waitForTick()
        Wait for next tick.
      • createGoal

        public IGoal createGoal​(java.lang.String type)
        Create a goal from a template goal. To be processed, the goal has to be dispatched as subgoal or adopted as top-level goal.
        Parameters:
        type - The template goal name as specified in the ADF.
        Returns:
        The created goal.
      • dispatchSubgoalAndWait

        public void dispatchSubgoalAndWait​(IGoal goal)
        Dispatch a new top-level goal.
        Parameters:
        goal - The new goal.
      • dispatchSubgoalAndWait

        public void dispatchSubgoalAndWait​(IGoal goal,
                                           long timeout)
        Dispatch a new top-level goal.
        Parameters:
        goal - The new goal.
      • waitForGoalFinished

        public IGoal waitForGoalFinished​(java.lang.String type)
        Wait for a goal.
        Parameters:
        type - The goal type.
      • waitForGoalFinished

        public IGoal waitForGoalFinished​(java.lang.String type,
                                         long timeout)
        Wait for a goal.
        Parameters:
        type - The goal type.
        timeout - The timeout.
      • waitForGoalFinished

        public void waitForGoalFinished​(IGoal goal)
        Wait for a goal to be finished.
        Parameters:
        goal - The goal.
      • waitForGoalFinished

        public void waitForGoalFinished​(IGoal goal,
                                        long timeout)
        Wait for a goal to be finished.
        Parameters:
        goal - The goal.
      • waitForMessageEvent

        public IMessageEvent waitForMessageEvent​(java.lang.String type)
        Wait for a message event.
        Parameters:
        type - The message event type.
      • waitForMessageEvent

        public IMessageEvent waitForMessageEvent​(java.lang.String type,
                                                 long timeout)
        Wait for a message event.
        Parameters:
        type - The message event type.
        timeout - The timeout.
      • waitForReply

        public IMessageEvent waitForReply​(IMessageEvent event)
        Wait for a reply to a message event.
        Parameters:
        event - The message event.
      • waitForReply

        public IMessageEvent waitForReply​(IMessageEvent event,
                                          long timeout)
        Wait for a reply to a message event.
        Parameters:
        event - The message event.
        timeout - The timeout.
      • waitForReply

        public IMessageEvent waitForReply​(IMessageEvent event,
                                          java.lang.String type)
        Wait for a reply to a message event.
        Parameters:
        event - The message event.
        type - The reply.
      • waitForReply

        public IMessageEvent waitForReply​(IMessageEvent event,
                                          java.lang.String type,
                                          long timeout)
        Wait for a reply to a message event.
        Parameters:
        event - The message event.
        type - The reply.
        timeout - The timeout.
      • waitForInternalEvent

        public IInternalEvent waitForInternalEvent​(java.lang.String type)
        Wait for an internal event.
        Parameters:
        type - The internal event type.
      • waitForInternalEvent

        public IInternalEvent waitForInternalEvent​(java.lang.String type,
                                                   long timeout)
        Wait for an internal event.
        Parameters:
        type - The internal event type.
        timeout - The timeout.
      • killAgent

        public void killAgent()
        Kill this agent.
      • getLogger

        public java.util.logging.Logger getLogger()
        Get the logger.
        Returns:
        The logger.
      • getBeliefbase

        public IBeliefbase getBeliefbase()
        Get the beliefbase.
        Returns:
        The beliefbase.
      • getRPlan

        public IPlan getRPlan()
        Get the rplan.
        Returns:
        The rplan
      • getReason

        public java.lang.Object getReason()
        Get the reason this plan was created for.
        Returns:
        The reason.
      • getDispatchedElement

        public java.lang.Object getDispatchedElement()
        Get the reason this plan was created for.
        Returns:
        The reason.
      • getParameter

        public IParameter getParameter​(java.lang.String name)
        Get a parameter.
        Parameters:
        name - The name.
        Returns:
        The parameter.
      • getParameterSet

        public IParameterSet getParameterSet​(java.lang.String name)
        Get a parameter.
        Parameters:
        name - The name.
        Returns:
        The parameter.
      • getExpression

        public IExpression getExpression​(java.lang.String name)
        Get an expression by name.
        Returns:
        The expression.
      • createExpression

        public IExpression createExpression​(java.lang.String exp)
        Get an expression by name.
        Returns:
        The expression.
      • sendMessageAndWait

        public <T> IMessageEvent<T> sendMessageAndWait​(IMessageEvent<T> me)
        Send a message and wait for the answer.
        Parameters:
        me - The message event.
        Returns:
        The result event.
      • sendMessageAndWait

        public <T> IMessageEvent<T> sendMessageAndWait​(IMessageEvent<T> me,
                                                       long timeout)
        Send a message and wait for the answer. Adds a reply_with entry if not present, for tracking the conversation.
        Parameters:
        me - The message event.
        timeout - The timeout.
        Returns:
        The result event.
      • fail

        public void fail()
        Let the plan fail.
      • fail

        public void fail​(java.lang.Throwable cause)
        Let a plan fail.
        Parameters:
        cause - The cause.
      • fail

        public void fail​(java.lang.String message,
                         java.lang.Throwable cause)
        Let a plan fail.
        Parameters:
        message - The message.
        cause - The cause.
      • getScope

        public ICapability getScope()
        Get the scope.
        Returns:
        The scope.
      • startAtomic

        public void startAtomic()
        Start an atomic transaction. All possible side-effects (i.e. triggered conditions) of internal changes (e.g. belief changes) will be delayed and evaluated after endAtomic() has been called.
        See Also:
        endAtomic()
      • endAtomic

        public void endAtomic()
        End an atomic transaction. Side-effects (i.e. triggered conditions) of all internal changes (e.g. belief changes) performed after the last call to startAtomic() will now be evaluated and performed.
        See Also:
        startAtomic()
      • dispatchSubgoal

        public IFuture<java.lang.Void> dispatchSubgoal​(IGoal subgoal)
        Dispatch a new subgoal.
        Parameters:
        subgoal - The new subgoal. Note: plan step is interrupted after call.
      • toString

        public java.lang.String toString()
        Get the string representation.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The string representation.
      • getComponentName

        public java.lang.String getComponentName()
        Get the agent name.
        Returns:
        The agent name.
      • getComponentIdentifier

        public IComponentIdentifier getComponentIdentifier()
        Get the agent identifier.
        Returns:
        The agent identifier.
      • getComponentDescription

        public IComponentDescription getComponentDescription()
        Get the agent description.
        Returns:
        The agent description.
      • getException

        public java.lang.Exception getException()
        Get the uncatched exception that occurred in the body (if any). Method should only be called when in failed() method.
        Returns:
        The exception.
      • getGoalbase

        public IGoalbase getGoalbase()
        Get the goal base.
        Returns:
        The goal base.
      • getPlanbase

        public IPlanbase getPlanbase()
        Get the plan base.
        Returns:
        The plan base.
      • getEventbase

        public IEventbase getEventbase()
        Get the event base.
        Returns:
        The event base.
      • getExpressionbase

        public IExpressionbase getExpressionbase()
        Get the expression base.
        Returns:
        The expression base.
      • getClock

        public IClockService getClock()
        Get the clock.
        Returns:
        The clock.
      • getTime

        public long getTime()
        Get the current time. The time unit depends on the currently running clock implementation. For the default system clock, the time value adheres to the time representation as used by 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.
        Returns:
        The current time.
      • dispatchTopLevelGoal

        public void dispatchTopLevelGoal​(IGoal goal)
        Dispatch a new top-level goal.
        Parameters:
        goal - The new goal. Note: plan step is interrupted after call.
      • sendMessage

        public IFuture<java.lang.Void> sendMessage​(IMessageEvent<?> me)
        Send a message.
        Parameters:
        me - The message event.
      • dispatchInternalEvent

        public void dispatchInternalEvent​(IInternalEvent event)
        Dispatch an internal event.
        Parameters:
        event - The event. Note: plan step is interrupted after call.
      • createMessageEvent

        public <T> IMessageEvent<T> createMessageEvent​(java.lang.String type)
        Create a new message event.
        Returns:
        The new message event.
      • createInternalEvent

        public IInternalEvent createInternalEvent​(java.lang.String type)
        Create a new intenal event.
        Returns:
        The new intenal event.
      • getExternalAccess

        public IExternalAccess getExternalAccess()
        Get the scope.
        Returns:
        The scope.
      • getParameters

        public IParameter[] getParameters()
        Get all parameters.
        Returns:
        All parameters.
      • getParameterSets

        public IParameterSet[] getParameterSets()
        Get all parameter sets.
        Returns:
        All parameter sets.
      • hasParameter

        public boolean hasParameter​(java.lang.String name)
        Has the element a parameter element.
        Parameters:
        name - The name.
        Returns:
        True, if it has the parameter.
      • hasParameterSet

        public boolean hasParameterSet​(java.lang.String name)
        Has the element a parameter set element.
        Parameters:
        name - The name.
        Returns:
        True, if it has the parameter set.
      • getAgent

        public IInternalAccess getAgent()
        Get the agent.
        Returns:
        The agent
      • waitForFactChanged

        public java.lang.Object waitForFactChanged​(java.lang.String belname)
        Wait for a fact change of a belief.
      • waitForFactChanged

        public java.lang.Object waitForFactChanged​(java.lang.String belname,
                                                   long timeout)
        Wait for a fact change of a belief.
      • waitForFactAdded

        public java.lang.Object waitForFactAdded​(java.lang.String belname)
        Wait for a fact added.
      • waitForFactAdded

        public java.lang.Object waitForFactAdded​(java.lang.String belname,
                                                 long timeout)
        Wait for a fact added.
      • waitForFactRemoved

        public java.lang.Object waitForFactRemoved​(java.lang.String belname)
        Wait for a fact added.
      • waitForFactRemoved

        public java.lang.Object waitForFactRemoved​(java.lang.String belname,
                                                   long timeout)
        Wait for a fact added.
      • waitForCondition

        public void waitForCondition​(java.lang.String name)
        Wait for a condition.
        Parameters:
        name - The name of the condition.
      • waitForCondition

        public void waitForCondition​(java.lang.String name,
                                     long timeout)
        Wait for a condition.
        Parameters:
        name - The name of the condition.
        timeout - The wait timeout.
      • waitForCondition

        public void waitForCondition​(java.lang.String name,
                                     long timeout,
                                     java.util.Map<java.lang.String,​java.lang.Object> values)
        Wait for a condition.
        Parameters:
        name - The name of the condition.
        timeout - The wait timeout.
        values - Extra parameter values for the condition, if any.
      • waitForConditionInline

        public void waitForConditionInline​(java.lang.String expr)
        Wait for a condition.
        Parameters:
        name - The name of the condition.
      • waitForConditionInline

        public void waitForConditionInline​(java.lang.String expr,
                                           long timeout)
        Wait for a condition.
        Parameters:
        name - The name of the condition.
      • waitForEver

        public void waitForEver()
        Wait for ever (is aborted on goal success/failure).
      • getPlanElement

        public IPlan getPlanElement()
        Get the plan interface.
      • checkNotInAtomic

        protected void checkNotInAtomic()
        Check if wait is called in atomic mode.
        Throws:
        java.lang.RuntimeException - in case is in atomic block.