|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jade.core.behaviours.Behaviour | +--jade.core.behaviours.SimpleBehaviour | +--jade.core.behaviours.WakerBehaviour
This abstract class implements a OneShot task that must be executed only one just after a given timeout is elapsed.
The task is simply the call to the method
handleElapsedTimeout()
that must be implemented by
all subclasses. Notice that the best practice in JADE is when
this method just adds a behaviour to the agent class.
All subclasses have available the protected variable
myAgent
that points to the agent class.
The programmer must use this abstract class in this simple way:
handleElapsedTimeout
.
addBehaviour()
method.
handleElapsedTimeout
must implement the
task that will be executed after the timeout is elapsed.
Field Summary |
Fields inherited from class jade.core.behaviours.Behaviour |
myAgent, parent |
Constructor Summary | |
WakerBehaviour(Agent a,
java.util.Date wakeupDate)
This method constructs the behaviour. |
|
WakerBehaviour(Agent a,
long timeout)
This method constructs the behaviour. |
Method Summary | |
void |
action()
Runs the behaviour. |
boolean |
done()
Check if this behaviour is done. |
protected abstract void |
handleElapsedTimeout()
This method is called by this subclass only after the given timeout is elapsed. |
void |
reset(java.util.Date wakeupDate)
This method must be called to reset the behaviour and starts again |
void |
reset(long timeout)
This method must be called to reset the behaviour and starts again |
Methods inherited from class jade.core.behaviours.SimpleBehaviour |
reset |
Methods inherited from class jade.core.behaviours.Behaviour |
block, block, getBehaviourName, getDataStore, isRunnable, onEnd, onStart, restart, root, setAgent, setBehaviourName, setDataStore |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WakerBehaviour(Agent a, java.util.Date wakeupDate)
a
- is the pointer to the agentwakeupDate
- is the date when the task must be executedpublic WakerBehaviour(Agent a, long timeout)
a
- is the pointer to the agenttimeout
- indicates the number of milliseconds after which the
task must be executedMethod Detail |
public final void action()
Behaviour
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.
action
in class Behaviour
CompositeBehaviour
protected abstract void handleElapsedTimeout()
myAgent
that
points to the agent class.
public void reset(java.util.Date wakeupDate)
wakeupDate
- is the new time when the task must be executed againpublic void reset(long timeout)
timeout
- indicates in how many milliseconds from now the behaviour
must be waken up again.public final boolean done()
Behaviour
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.
done
in class Behaviour
true
if the behaviour has completely executed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |