aicas logoJamaica 6.1 release 1

javax.realtime
Class Timer

java.lang.Object
  extended by javax.realtime.AsyncEvent
      extended by javax.realtime.Timer
Direct Known Subclasses:
OneShotTimer, PeriodicTimer

public abstract class Timer
extends AsyncEvent

Jamaica Real-Time Specification for Java class Timer.

abstract super class of PeriodicTimer or OneShotTimer. These timers are asynchronous events that fire at a given time.


Constructor Summary
protected Timer(HighResolutionTime time, Clock clock, AsyncEventHandler handler)
          Constructor to create a timer with the given time, clock and handler.
 
Method Summary
 ReleaseParameters createReleaseParameters()
           createReleaseParameters creates the default release parameters for this event.
 void destroy()
          destroy destroys this timer, i.e., stops it from counting.
 void disable()
          disable disables firing of this timer.
 void enable()
          enable re-enables firing of this timer if it was disabled by a previous call to disable().
 void fire()
          The fire method inherited from AsyncEvent must not be called, it will throw an exception.
 Clock getClock()
          getClock returns the clock this timer was based on.
 AbsoluteTime getFireTime()
          getFireTime returns the time at which this timer is expected to fire or skip firing (because it is disabled) next.
 AbsoluteTime getFireTime(AbsoluteTime dest)
          getFireTime returns the time at which this timer is expected to fire or skip firing (because it is disabled) next.
 boolean isRunning()
          isRunning returns true if this timer has been started (it is active) and it has not been disabled.
 void reschedule(HighResolutionTime time)
          reschedule changes the time for this event.
 void start()
          start this timer, i.e., make it active and enabled
 void start(boolean disabled)
          start this timer, i.e., make it active.
 boolean stop()
          stop stops this active timer changing its state to not-active and disabled.
 
Methods inherited from class javax.realtime.AsyncEvent
addHandler, bindTo, handledBy, removeHandler, setHandler, unbindTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timer

protected Timer(HighResolutionTime time,
                Clock clock,
                AsyncEventHandler handler)
Constructor to create a timer with the given time, clock and handler.

Parameters:
time - The time when this timer should fire. May be null, in this case this is equal to new RelativeTime(0,0) and the firing will occur immediately after a call to start().
clock - the clock this timer should be based upon. May be null to use the default System.getRealtimeClock().
handler - The handler that will be released when this timer fires. May be null to have no handler until one will be added via addHandler.
Throws:
java.lang.IllegalArgumentException - if time is a negative RelativeTime.
Method Detail

isRunning

public boolean isRunning()
isRunning returns true if this timer has been started (it is active) and it has not been disabled.

Returns:
true if this timer expects to fire.

start

public void start()
start this timer, i.e., make it active and enabled


start

public void start(boolean disabled)
start this timer, i.e., make it active.

Parameters:
disabled - true to make this timer active but disabled.
Throws:
java.lang.IllegalStateException - if this timer is destroyed.

stop

public boolean stop()
stop stops this active timer changing its state to not-active and disabled.

Returns:
true if this timer was active before the call, false if it was not.
Throws:
java.lang.IllegalStateException - if this timer is destroyed.

createReleaseParameters

public ReleaseParameters createReleaseParameters()

createReleaseParameters creates the default release parameters for this event. The default implementation creates AperiodicParemters without cost/deadline and without overrun or miss handler.

Overrides:
createReleaseParameters in class AsyncEvent
Returns:
An instance of ReleaseParameters appropriate for handlers for this event.
Throws:
java.lang.IllegalStateException - if this timer is destroyed.

enable

public void enable()

enable re-enables firing of this timer if it was disabled by a previous call to disable().

Throws:
java.lang.IllegalStateException - if this timer has been destroyed.

disable

public void disable()

disable disables firing of this timer. The timer will continue execution like before, only it will not fire() when the given time is reached.

Throws:
java.lang.IllegalStateException - if this timer has been destroyed.

destroy

public void destroy()
destroy destroys this timer, i.e., stops it from counting. This will release important resources that were allocated for this timer, it may free a thread that was generated for this counter.

Throws:
java.lang.IllegalStateException - if this timer has been destroyed.

fire

public void fire()
          throws java.lang.UnsupportedOperationException
The fire method inherited from AsyncEvent must not be called, it will throw an exception.

Overrides:
fire in class AsyncEvent
Throws:
java.lang.UnsupportedOperationException - always thrown.
Since:
RTSJ V1.0.1 redefines fire() inherited from AsyncEvent to prevent calls to fire() from outside this class.

getClock

public Clock getClock()
getClock returns the clock this timer was based on.

Returns:
the clock of this timer.
Throws:
java.lang.IllegalStateException - if this timer has been destroyed.

getFireTime

public AbsoluteTime getFireTime()
getFireTime returns the time at which this timer is expected to fire or skip firing (because it is disabled) next.

Returns:
a new instance of AbsoluteTime that holds the next firing time.
Throws:
java.lang.IllegalStateException - if this timer has been destroyed or it is not active.

getFireTime

public AbsoluteTime getFireTime(AbsoluteTime dest)
getFireTime returns the time at which this timer is expected to fire or skip firing (because it is disabled) next.

Parameters:
dest - the AbsoluteTime which will be updated and returned if not null. If dest is null, a new instance of AbsoluteTime will be returned.
Returns:
the updated given AbsoluteTime or a new instance that holds the next firing time.
Throws:
java.lang.IllegalStateException - if this timer has been destroyed or it is not active.

reschedule

public void reschedule(HighResolutionTime time)
reschedule changes the time for this event. This changes the first time a timer fires.

Parameters:
time - the new time parameter.
Throws:
java.lang.IllegalStateException - if this timer has been destroyed.

aicas logoJamaica 6.1 release 1

aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2012 aicas GmbH. All Rights Reserved.