Table of Contents

ITimer

Namespace
ZCore
Extends
Inherited Properties
Inherited Methods
INTERFACE ITimer EXTENDS ZCore.IObject, ZCore.IError

Interface for timers. Timers are Objects that may be Started and then appear Busy for the time that has been passed to the start method. It also contains some convenient properites like checking if the timer has been started or if it just elapsed and other useful methods for timing.

By extending from the IObject timers implementing this interface may be used with Await methods of Sequences.

Properties

Busy

PROPERTY Busy : BOOL

This property returns TRUE if the timer is still running. If this property is called after the duration, that has been specified with the WaitAsync method, has been elapsed, this proeprty returns FALSE.

Property Value

BOOL

Done

PROPERTY Done : BOOL

This property returns TRUE if the timer got started and the requested time has elapsed or it has never been started.

Property Value

BOOL

Duration

PROPERTY Duration : LREAL

Returns the duration of the last time that the timer got started with WaitAsync. The unit of the returned value is seconds.

Property Value

LREAL

Started

PROPERTY Started : BOOL

This property returns TRUE if the timer is currently running or it has just been started. The is started flag is only reset by explicitly calling the stop method or calling WaitAsync(duration:=0).

Property Value

BOOL

Methods

ElapsedTimeNormalized

METHOD ElapsedTimeNormalized () : LREAL

Time that has been passed since WaitAsync was called. The return value is scaled to the interval [0, 1] and if the timer has elapsed, this method returns 1. If it has just been started, it returns 0.

For the special case that the timer has been started with duration=0 this method returns 1, which is in agreement to the returned value of Done and other methods in this case.

Returns

LREAL

OnDone

METHOD OnDone () : BOOL

This method returns TRUE for the first time that it is called and the timer is elapsed. Internally it is a rising trigger on the Done property.

Returns

BOOL

RemainingTimeNormalized

METHOD RemainingTimeNormalized () : LREAL

Remaining time for the timer to be elapsed. The return value is scaled to the interval [0, 1] such that 1 means the timer has just been started and 0 means that the timer is elapsed.

For the special case that the timer has been started with duration=0 this method returns 1, which is in aggrement to the returned value of Done and other methods & properties in this case.

Returns

LREAL

Stop

METHOD Stop ()

This method stops the Timer and sets its state to Idle. Notably, this method also resets the Started flag.

WaitAsync

METHOD WaitAsync (
 [input] duration : LREAL)

This method starts the Timer and sets the state to Busy. After doing so, the object can be polled for completion by calling Busy or Timer.Done. The timer has completed after duration has elapsed, where duration is given in seconds.

If duration <=0 the stop method is called internally, which in turn resets the Started flag.

Inputs

duration LREAL

in seconds