Package jason.stdlib
Class send
java.lang.Object
jason.asSemantics.DefaultInternalAction
jason.stdlib.send
- All Implemented Interfaces:
InternalAction,Serializable
@Manual(literal=".send(receiver,performative,content[,answer,timeout])",
hint="used to send messages to other agents",
argsHint={"the name of the agent(s) that will receive the message","the performative (tell, achieve, askOne,...)","the message content","the answer of an ask message (for performatives askOne, askAll, and askHow) [optional]","timeout (in milliseconds) when waiting for an ask answer [optional]"},
argsType={"atom or string or list of atoms","atom","literal","term","number"},
examples={".send(rafael,tell,value(10)): adds the literal value(10)[source(jomi)] in the rafael\'s belief base.",".send(rafael,achieve,go(10,30): sends go(10,30) to the agent named rafael what creates an event <+!go(10,30)[source(jomi)],T> in rafael\'s event queue",".send(rafael,askOne,value(beer,X)): sends value(beer,X) to the agent named rafael. This askOne is an asynchronous ask since it does not suspend jomi\'s intention. If rafael has, for instance, the literal value(beer,2) in its belief base, this belief is automatically sent back to jomi. Otherwise an event like +?value(beer,X)[source(self)] is generated in rafael\'s side and the result of this query is then sent to jomi. In the jomi\'s side, the rafael\'s answer is added in the jomi\'s belief base and an event like +value(beer,10)[source(rafael)] is generated",".send(rafael,askOne,value(beer,X),A): sends value(beer,X) to the agent named rafael. This askOne is a synchronous ask, it suspends jomi\'s intention until rafael\'s answer is received. The answer (something like value(beer,10) unifies with A",".send(rafael,askOne,value(beer,X),A,2000)</code>: as in the previous example, but agent jomi waits for 2 seconds. If no message is received by then, A unifies with timeout"},
seeAlso={"jason.stdlib.broadcast","jason.stdlib.my_name"})
public class send
extends DefaultInternalAction
Internal action: .send.
Description: sends a message to an agent.
Parameters:
- + receiver (atom, string, or list): the receiver of the
message. It is the unique name of the agent that will receive the
message (or list of names).
- + ilf (atom): the illocutionary force of the message (tell,
achieve, ...).
- + message (literal): the content of the message.
- + answer (any term [optional]): the answer of an ask
message (for performatives askOne, askAll, and askHow).
- + timeout (number [optional]): timeout (in milliseconds)
when waiting for an ask answer.
Messages with an ask illocutionary force can optionally have
arguments 3 and 4. In case they are given, .send suspends the
intention until an answer is received and unified with arg[3],
or the message request times out as specified by
arg[4]. Otherwise, the intention is not suspended and the
answer (which is a tell message) produces a belief addition event as usual.
Examples (suppose that agent jomi is sending the
messages):
-
.send(rafael,tell,value(10)): sendsvalue(10)to the agent namedrafael. The literalvalue(10)[source(jomi)]will be added as a belief inrafael's belief base. -
.send(rafael,achieve,go(10,30): sendsgo(10,30)to the agent namedrafael. Whenrafaelreceives this message, an event<+!go(10,30)[source(jomi)],T>will be added inrafael's event queue. -
.send(rafael,askOne,value(beer,X)): sendsvalue(beer,X)to the agent named rafael. This askOne is an asynchronous ask since it does not suspend jomi's intention. If rafael has, for instance, the literalvalue(beer,2)in its belief base, this belief is automatically sent back to jomi. Otherwise an event like+?value(beer,X)[source(self)]is generated in rafael's side and the result of this query is then sent to jomi. In the jomi's side, the rafael's answer is added in the jomi's belief base and an event like+value(beer,10)[source(rafael)]is generated. -
.send(rafael,askOne,value(beer,X),A): sendsvalue(beer,X)to the agent namedrafael. This askOne is a synchronous ask, it suspendsjomi's intention untilrafael's answer is received. The answer (something likevalue(beer,10)) unifies withA. -
.send(rafael,askOne,value(beer,X),A,2000): as in the previous example, but agentjomiwaits for 2 seconds. If no message is received by then,Aunifies withtimeout.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturn true if the internal action can be used in plans' contextprotected voidcheckArguments(Term[] args) execute(TransitionSystem ts, Unifier un, Term[] args) Executes the internal action.intintbooleanReturns true if the internal action (IA) should suspend the intention where the IA is calledMethods inherited from class jason.asSemantics.DefaultInternalAction
destroy, prepareArguments
-
Constructor Details
-
send
public send()
-
-
Method Details
-
canBeUsedInContext
public boolean canBeUsedInContext()Description copied from interface:InternalActionReturn true if the internal action can be used in plans' context- Specified by:
canBeUsedInContextin interfaceInternalAction- Overrides:
canBeUsedInContextin classDefaultInternalAction
-
getMinArgs
public int getMinArgs()- Overrides:
getMinArgsin classDefaultInternalAction
-
getMaxArgs
public int getMaxArgs()- Overrides:
getMaxArgsin classDefaultInternalAction
-
checkArguments
- Overrides:
checkArgumentsin classDefaultInternalAction- Throws:
JasonException
-
execute
Description copied from interface:InternalActionExecutes 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:
executein interfaceInternalAction- Overrides:
executein classDefaultInternalAction- Throws:
Exception
-
suspendIntention
public boolean suspendIntention()Description copied from interface:InternalActionReturns true if the internal action (IA) should suspend the intention where the IA is called- Specified by:
suspendIntentionin interfaceInternalAction- Overrides:
suspendIntentionin classDefaultInternalAction
-