public abstract class WakerBehaviour extends SimpleBehaviour
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.
Constructor and Description |
---|
WakerBehaviour(Agent a,
java.util.Date wakeupDate)
This method constructs the behaviour.
|
WakerBehaviour(Agent a,
long timeout)
This method constructs the behaviour.
|
Modifier and Type | Method and Description |
---|---|
void |
action()
Runs the behaviour.
|
boolean |
done()
Check if this behaviour is done.
|
long |
getWakeupTime() |
protected void |
handleElapsedTimeout()
Deprecated.
Use onWake() instead
|
protected void |
onWake()
This method is invoked when the deadline defined in the
constructor is reached (or when the timeout specified in the
constructor expires).
|
void |
reset()
This method must be called to reset the behaviour and starts again
|
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
|
void |
stop()
Make this WakerBehaviour terminate without calling the onWake() method.
|
block, block, getAgent, getBehaviourName, getDataStore, getParent, isRunnable, onEnd, onStart, restart, root, setAgent, setBehaviourName, setDataStore
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 executedpublic 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 void onWake()
protected void handleElapsedTimeout()
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 void reset()
reset
in class SimpleBehaviour
public void stop()
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.public final long getWakeupTime()