|
done()
method of an existing behaviour object to print on the standard output a proper message when the behaviour
is completing.
Behaviour b = // get the behaviour object addBehaviour(new WrapperBehaviour(b) { public boolean done() { boolean ret = super.done(); if (ret) { System.out.println("done() method returned true --> The behaviour is completing!"); } return ret; } });
Nested classes/interfaces inherited from class sajas.core.behaviours.Behaviour |
Behaviour.RunnableChangedEvent |
Fields inherited from class sajas.core.behaviours.Behaviour |
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING |
Constructor Summary | ||
WrapperBehaviour(Behaviour wrapped) |
Method Summary | ||
void |
action() Runs the behaviour. |
|
boolean |
done() Check if this behaviour is done. |
|
getDataStore() Return the private data store of this Behaviour . |
||
getWrappedBehaviour() | ||
protected void |
handle(Behaviour.RunnableChangedEvent rce) Handler for block/restart events. |
|
protected void |
handleBlockEvent() This method is used internally by the framework. |
|
void |
handleRestartEvent() This method is used internally by the framework. |
|
int |
onEnd() This method is just an empty placeholder for subclasses. |
|
void |
onStart() This method is just an empty placeholders for subclasses. |
|
void |
reset() Restores behaviour initial state. |
|
void |
setAgent(Agent a) Associates this behaviour with the agent it belongs to. |
|
void |
setDataStore(DataStore ds) Set the private data store of this Behaviour |
Methods inherited from class sajas.core.behaviours.Behaviour |
actionWrapper, block, block, getAgent, getBehaviourName, getExecutionState, getParent, getRestartCounter, isRunnable, restart, root, setBehaviourName, setExecutionState |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
addBehaviour()
call takes care of the association
transparently.Behaviour
DataStore
that this Behaviour
will use as its private data storeBehaviour
.
If it was null, a new DataStore is created and returned.Behaviour
reset()
on a behaviour object is equivalent to
destroying it and recreating it back. The main purpose for this
method is to realize multistep cyclic behaviours without needing
expensive constructions an deletion of objects at each loop
iteration.
Remind to call super.reset() from the sub-classes.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.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
.
|