Package jason.stdlib
Class wait
java.lang.Object
jason.asSemantics.DefaultInternalAction
jason.stdlib.wait
- All Implemented Interfaces:
InternalAction
,Serializable
@Manual(literal=".wait([event,expression,timeout][,elapsed_time])",
hint="suspend the intention for the time specified, until some event happens or some condition is true",
argsHint={"the event to wait for enclosed by { and } [optional]","the expression (as used on plans context) to wait [optional]","how many miliseconds should be waited [optional]","the amount of time the intention was suspended waiting [optional]"},
argsType={"trigger term","logical expression","number","variable"},
examples={".wait(1000)</code>: suspend the intention for 1 second",".wait({+b(1)})</code>: suspend the intention until the belief b(1) is added in the belief base",".wait(b(X) & X > 10): suspend the intention until the agent believes b(X) with X greater than 10",".wait({+!g}, 2000): suspend the intention until the goal g is triggered or 2 seconds have passed, whatever happens first. In case the event does not happens in two seconds, the internal action fails.wait({+!g}, 2000, EventTime): suspend the intention until the goal g is triggered or 2 seconds have passed, whatever happens first. In case the event does not happen in two seconds, the internal action does not fail. The third argument will be unified to the elapsed time (in milliseconds) from the start of .wait until the event or timeout."},
seeAlso="jason.stdlib.at")
public class wait
extends DefaultInternalAction
Internal action: .wait(E,T)
.
Description: suspend the intention for the time specified by T (in
milliseconds) or until some event E happens. The events follow the
AgentSpeak syntax but are enclosed by { and }, e.g. {+bel(33)}
,
{+!go(X,Y)}
.
Parameters:
- + event (trigger term [optional]): the event to wait for.
- + logical expression ([optional]): the expression (as used on plans context) to wait to holds.
- + timeout (number [optional]): how many milliseconds should be waited.
- - elapse time (var [optional]): the amount of time the intention was suspended waiting.
Examples:
-
.wait(1000)
: suspend the intention for 1 second. -
.wait({+b(1)})
: suspend the intention until the beliefb(1)
is added in the belief base. -
.wait(b(X) invalid input: '&' X > 10)
: suspend the intention until the agent believesb(X)
with X greater than 10. -
.wait({+!g}, 2000)
: suspend the intention until the goalg
is triggered or 2 seconds have passed, whatever happens first. In case the event does not happens in two seconds, the internal action fails. -
.wait({+!g}, 2000, EventTime)
: suspend the intention until the goalg
is triggered or 2 seconds have passed, whatever happens first. As this use of .wait has three arguments, in case the event does not happen in two seconds, the internal action does not fail (as in the previous example). The third argument will be unified to the elapsed time (in milliseconds) from the start of .wait until the event or timeout.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Return true if the internal action can be used in plans' contextexecute
(TransitionSystem ts, Unifier un, Term[] args) Executes the internal action.int
int
boolean
Returns true if the internal action (IA) should suspend the intention where the IA is calledMethods inherited from class jason.asSemantics.DefaultInternalAction
checkArguments, destroy, prepareArguments
-
Field Details
-
waitAtom
- See Also:
-
-
Constructor Details
-
wait
public wait()
-
-
Method Details
-
canBeUsedInContext
public boolean canBeUsedInContext()Description copied from interface:InternalAction
Return true if the internal action can be used in plans' context- Specified by:
canBeUsedInContext
in interfaceInternalAction
- Overrides:
canBeUsedInContext
in classDefaultInternalAction
-
suspendIntention
public boolean suspendIntention()Description copied from interface:InternalAction
Returns true if the internal action (IA) should suspend the intention where the IA is called- Specified by:
suspendIntention
in interfaceInternalAction
- Overrides:
suspendIntention
in classDefaultInternalAction
-
getMinArgs
public int getMinArgs()- Overrides:
getMinArgs
in classDefaultInternalAction
-
getMaxArgs
public int getMaxArgs()- Overrides:
getMaxArgs
in classDefaultInternalAction
-
execute
Description copied from interface:InternalAction
Executes the internal action. It should return a Boolean or an Iterator. A true boolean return means that the IA was successfully executed. An Iterator result means that there is more than one answer for this IA (e.g. see member internal action). - Specified by:
execute
in interfaceInternalAction
- Overrides:
execute
in classDefaultInternalAction
- Throws:
Exception
-