|
Nested classes/interfaces inherited from class sajas.core.behaviours.Behaviour |
Behaviour.RunnableChangedEvent |
Field Summary | ||
protected long |
deadline | |
static int |
INFINITE A numeric constant to mean that the deadline for the receive operation will never expire. |
|
static int |
INTERRUPTED A numeric constant to mean that the receive operation was interrupted. |
|
protected Object |
receivedMsgKey | |
protected jade.lang.acl.MessageTemplate |
template | |
static int |
TIMEOUT_EXPIRED A numeric constant to mean that a timeout expired. |
Fields inherited from class sajas.core.behaviours.Behaviour |
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING |
Constructor Summary | |||
protected |
MsgReceiver() | ||
MsgReceiver(Agent a, jade.lang.acl.MessageTemplate mt, long deadline, DataStore s, Object msgKey) Constructor. |
Method Summary | ||
void |
action() Runs the behaviour. |
|
boolean |
done() Check if this behaviour is done. |
|
protected void |
handleMessage(jade.lang.acl.ACLMessage msg) This is invoked when a message matching the specified template is received or the timeout has expired (the msg parameter is null in this case). |
|
void |
interrupt() Signal an interruption to this receiver, and cause the ongoing receive operation to abort. |
|
int |
onEnd() This method is just an empty placeholder for subclasses. |
|
void |
reset(jade.lang.acl.MessageTemplate mt, long deadline, DataStore s, Object msgKey) Reset this behaviour, possibly replacing the receive templatt and other data. |
|
void |
setDeadline(long deadline) This method allows modifying the deadline |
|
void |
setReceivedKey(Object key) This method allows modifying the key in the DS where to put the received message |
|
void |
setTemplate(jade.lang.acl.MessageTemplate mt) This method allows modifying the template |
Methods inherited from class sajas.core.behaviours.SimpleBehaviour |
reset |
Methods inherited from class sajas.core.behaviours.Behaviour |
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, handle, handleBlockEvent, handleRestartEvent, isRunnable, onStart, restart, root, setAgent, setBehaviourName, setDataStore, setExecutionState |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
System.currentTimeMillisec()
Behaviour
subclasses to perform ordinary behaviour
duty. An agent schedules its behaviours calling their
action()
method; since all the behaviours belonging
to the same agent are scheduled cooperatively, this method
must not enter in an endless loop and should return as
soon as possible to preserve agent responsiveness. To split a
long and slow task into smaller section, recursive behaviour
aggregation may be used.Behaviour
still need to be
run or it has completed its task. Concrete behaviours must
implement this method to return their completion state. Finished
behaviours are removed from the scheduling queue, while others
are kept within to be run again when their turn comes again.true
if the behaviour has completely executed.Behaviour
.
onEnd
is called after the behaviour has been
removed from the pool of behaviours to be executed by an agent.
Therefore calling
reset()
is not sufficient to cyclically repeat the task
represented by this Behaviour
. In order to achieve that,
this Behaviour
must be added again to the agent
(using myAgent.addBehaviour(this)
). The same applies to
in the case of a Behaviour
that is a child of a
ParallelBehaviour
.TIMEOUT_EXPIRED
if the timeout expired or
INTERRUPTED
if this MsgReceiver
was interrupted calling the interrupt()
method.msg
parameter is null in this case). Users may redefine this method
to react to this event. The default implementation of does nothing.INFINITE
constant is used, then
no deadline is set and the operation will wait until a matching
ACL message arrives.
|