ch.aplu.util
Class BaseAlarmTimer

java.lang.Object
  |
  +--ch.aplu.util.BaseAlarmTimer
Direct Known Subclasses:
HiResAlarmTimer, LoResAlarmTimer

public abstract class BaseAlarmTimer
extends java.lang.Object

Abstract base class for HiResAlarmTimer and LoResAlarmTimer. See HiResAlarmTimer or LoResAlarmTimer for more details.


Method Summary
 void addTimerListener(TimerListener timerListener)
          Create a new thread with high priority for the AlarmTimer and start the timer.
 long getTime()
          Return the current timer's value in microseconds (us).
 boolean isRunning()
          Return true if the timer is running.
 void resume()
          Restart the timer from its current value.
 void start()
          Set the timer to the preset value and start it.
 void start(long alarmTime)
          Set the timer to the give preset value and start it.
 void stop()
          Stop the timer and store the current value.
 void stopEvents()
          Force to stop the callback calls by terminating the timer's thread
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTime

public long getTime()
Return the current timer's value in microseconds (us).


start

public void start()
Set the timer to the preset value and start it. (If the timer is running, it is stopped first.)


start

public void start(long alarmTime)
Set the timer to the give preset value and start it. The timer runs backwards. (If the timer is running, it is stopped first.)


stop

public void stop()
Stop the timer and store the current value.


resume

public void resume()
Restart the timer from its current value. The timer runs backwards.


isRunning

public boolean isRunning()
Return true if the timer is running.


addTimerListener

public void addTimerListener(TimerListener timerListener)
Create a new thread with high priority for the AlarmTimer and start the timer. Register a TimerListener to fire callbacks when the time interval expires. The accuracy of the event is about 1 ms, but may vary due to multitasking/multithreading of the operation system and Java. The preset time of the AlarmTimer must not be smaller than 10 ms. Be aware that the callback method must return before the preset time has elapsed.


stopEvents

public void stopEvents()
Force to stop the callback calls by terminating the timer's thread