RTJ in Embedded Systems (english)
RTJ i apparater (danish)
Implementation of Timers

Periodic Timer

This example with a periodic timer is implemented so that it looks, on the whole, as if it is implemented by means of the classes from the "Real Time Specification for Java" (RTSJ).

After each period the periodic timer generates a trigger event.
A TriggerEventListener object is added as listener, and its triggerEvent() method is activated each time the trigger event is generated.


Program: Periodic timer

An Ordinary One-shot Timer

This example shows a simple OneShotTimer with a TriggerEventListener as eventhandler.

After the OneShotTimer object has started, it sends a trigger event after a preset time period.
The triggerEvent() method in the TriggerEventListener class is now activated.


Program: Ordinary one-shot timer

A One-shot Timer which starts on a fixed Calendar Time

This example shows how to start a one-shot timer on a fixed calendar time, for example on January 19th 2003, at 9.30.00.

Here we use the class CallbackTimer, because the method setIntervalMillis(int value) in class OneShotTimer only has value of type int (31 bits to positive mSec =
24.86 days and nights, - in danish:døgn), while the method callback(long timeMillis, ..) in CallbackTimer has timeMillis of type long (63 bits to positive mSec = 2.9 * 10^8 years).

In the aJile Systems Java-doc for the class Configuration you can read how to configure the aJile's base time.


Program: One-shot timer which starts on a fixed calendar time

One-shot Timer as a Time-out Watchdog

In this example a OneShotTimer object, called watchdog, acts as a time-out watchdog.
A thread is running:

  while (true)
  {
    readValue ();
    reschedule (watchdog);
  }

If the method readValue() has returned before the time-out interval has expired, the watchdog will be rescheduled and a new value can be read, else a time-out happens, and a triggerEvent() method will cause a call of System.exit(0).


Program: One-shot timer as a time-out watchdog

One-shot Timer as a Time-out Watchdog with Time-out Handling

This example is like the time-out watchdog example above, but with the following difference:
If timeout happens, the method triggerEvent() will cause the following actions:

    make timeout-handling
    restart the time-out watchdog.


Program: One-shot timer as a time-out watchdog with time-out handling

Maintained by Hans Sondergaard, hso@vitusbering.dk


print denne side
Activities
JAOO 2003
Working Group 1
Working Group 2
Working Group 3
HowTo
How to start programming the aJile-100 on the SaJe board
Implementation of different programs to the aJile-100 on the SaJe board
Implementation of Timers
Implementation of Periodic Threads
Implementation of the RS-232 Serial Port
Implementation of the GPIO Port
Implementation of the Dallas 1-Wire Connection
Implementation of the Ethernet 10BaseT Connection
Implementation of Synchronization for the two JVM
Literature
Web
Pictures