Overview  Package   Class  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

sajas.core.behaviours
Class WakerBehaviour
java.lang.Object
  sajas.core.behaviours.Behaviour
      sajas.core.behaviours.SimpleBehaviour
          sajas.core.behaviours.WakerBehaviour
All Implemented Interfaces:
jade.util.leap.Serializable, Serializable

public abstract class WakerBehaviour
extends SimpleBehaviour
Author:
hlc
See Also:
jade.core.behaviours.WakerBehaviour

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
WakerBehaviour(Agent a, 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.
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(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.
Methods inherited from class sajas.core.behaviours.Behaviour
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, handle, handleBlockEvent, handleRestartEvent, isRunnable, onEnd, 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
Constructor Detail
WakerBehaviour
public WakerBehaviour(Agent a,
                      Date wakeupDate)
This method constructs the behaviour.
Parameters:
a - is the pointer to the agent
wakeupDate - is the date when the task must be executed

WakerBehaviour
public WakerBehaviour(Agent a,
                      long timeout)
This method constructs the behaviour.
Parameters:
a - is the pointer to the agent
timeout - indicates the number of milliseconds after which the task must be executed
Method Detail
action
public final void action()
Description copied from class: Behaviour
Runs the behaviour. This abstract method must be implemented by Behavioursubclasses 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.
Overrides:
action in class Behaviour

onWake
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). Subclasses are expected to define this method specifying the action that must be performed at that time.

handleElapsedTimeout
protected void handleElapsedTimeout()
Deprecated. Use onWake() instead

reset
public void reset(Date wakeupDate)
This method must be called to reset the behaviour and starts again
Parameters:
wakeupDate - is the new time when the task must be executed again

reset
public void reset(long timeout)
This method must be called to reset the behaviour and starts again
Parameters:
timeout - indicates in how many milliseconds from now the behaviour must be waken up again.

reset
public void reset()
This method must be called to reset the behaviour and starts again
Overrides:
reset in class SimpleBehaviour

stop
public void stop()
Make this WakerBehaviour terminate without calling the onWake() method. Calling stop() has the same effect as removing this WakerBehaviour, but is Thread safe

done
public final boolean done()
Description copied from class: Behaviour
Check if this behaviour is done. The agent scheduler calls this method to see whether a 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.
Overrides:
done in class Behaviour
Returns:
true if the behaviour has completely executed.

getWakeupTime
public final long getWakeupTime()

Overview  Package   Class  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

Java API documentation generated with DocFlex/Doclet 1.6.1 using JavadocPro template set.
DocFlex/Doclet is both a multi-format Javadoc doclet and a free edition of DocFlex/Javadoc, which is a template-driven programming tool for rapid development of any Javadoc-based Java API documentation generators (i.e. doclets). If you need to customize your Javadoc without writing a full-blown doclet from scratch, DocFlex/Javadoc may be the only tool able to help you! Find out more at www.docflex.com