org.aitools.programd.util
Class Heart

java.lang.Object
  extended by org.aitools.programd.util.Heart

public class Heart
extends java.lang.Object

A Heart beats. At a configurable interval, it calls pulse() methods on some objects (currently only the parent static Multiplexor) in order to provide assurance that the bot server is alive.

Author:
Noel Bush

Nested Class Summary
(package private)  class Heart.HeartBeat
           
 
Field Summary
private  int pulserate
          The pulse rate.
private  java.util.ArrayList<Pulse> pulses
          Will hold a set of Pulses.
private  java.util.Timer timer
          The Timer object used to beat the heart.
 
Constructor Summary
Heart(int pulserateToUse)
          Creates a new Heart with the given pulse rate.
 
Method Summary
 void addPulse(Pulse pulse)
          Adds a Pulse to the registered list.
 void pulse()
          Emits any registered pulses.
 void start()
          Starts the heart (if the pulse is greater than zero).
private  void startBeating(int pulse)
          Starts the heart beating with a specified pulse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timer

private java.util.Timer timer
The Timer object used to beat the heart.


pulserate

private int pulserate
The pulse rate.


pulses

private java.util.ArrayList<Pulse> pulses
Will hold a set of Pulses.

Constructor Detail

Heart

public Heart(int pulserateToUse)
Creates a new Heart with the given pulse rate.

Parameters:
pulserateToUse - the pulse rate to use
Method Detail

start

public void start()
Starts the heart (if the pulse is greater than zero).


startBeating

private void startBeating(int pulse)
Starts the heart beating with a specified pulse.

Parameters:
pulse - the period in milliseconds

addPulse

public void addPulse(Pulse pulse)
Adds a Pulse to the registered list.

Parameters:
pulse - the Pulse to be added

pulse

public void pulse()
Emits any registered pulses.