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 TickerBehaviour
java.lang.Object
  sajas.core.behaviours.Behaviour
      sajas.core.behaviours.SimpleBehaviour
          sajas.core.behaviours.TickerBehaviour
All Implemented Interfaces:
jade.util.leap.Serializable, Serializable

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

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
TickerBehaviour(Agent a, long period)
          Construct a TickerBehaviour that call its onTick() method every period ms.
Method Summary
void
action()
          Runs the behaviour.
boolean
done()
          Check if this behaviour is done.
protected long
getPeriod()
int
getTickCount()
          Retrieve how many ticks were done (i.e.
void
onStart()
          This method is just an empty placeholders for subclasses.
protected abstract void
onTick()
          This method is invoked periodically with the period defined in the constructor.
void
reset()
          This method must be called to reset the behaviour and starts again
void
reset(long period)
          This method must be called to reset the behaviour and starts again
void
setFixedPeriod(boolean fixedPeriod)
          Turn on/off the "fixed period" mode.
void
stop()
          Make this TickerBehaviour terminate.
Methods inherited from class sajas.core.behaviours.Behaviour
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, handle, handleBlockEvent, handleRestartEvent, isRunnable, onEnd, 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
TickerBehaviour
public TickerBehaviour(Agent a,
                       long period)
Construct a TickerBehaviour that call its onTick() method every period ms.
Parameters:
a - is the pointer to the agent
period - the tick period in ms
Method Detail
onStart
public void onStart()
Description copied from class: Behaviour
This method is just an empty placeholders for subclasses. It is executed just once before starting behaviour execution. Therefore, it acts as a prolog to the task represented by this Behaviour.
Overrides:
onStart in class Behaviour

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

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.

onTick
protected abstract void onTick()
This method is invoked periodically with the period defined in the constructor. Subclasses are expected to define this method specifying the action that must be performed at every tick.

setFixedPeriod
public void setFixedPeriod(boolean fixedPeriod)
Turn on/off the "fixed period" mode. Given a period P, when fixed period mode is off (default), this behaviour will wait for P milliseconds from the end of the n-th execution of the onTick() method to the beginning of the n+1-th execution. When fixed period is on, this behaviour will execute the onTick() method exactly every P milliseconds.
Parameters:
fixedPeriod - A boolean value indicating whether the fixed period mode must be turned on or off.

reset
public void reset(long period)
This method must be called to reset the behaviour and starts again
Parameters:
period - the new tick time

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 TickerBehaviour terminate. Calling stop() has the same effect as removing this TickerBehaviour, but is Thread safe

getTickCount
public final int getTickCount()
Retrieve how many ticks were done (i.e. how many times this behaviour was executed) since the last reset.
Returns:
The number of ticks since the last reset

getPeriod
protected long getPeriod()

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