Reference for the Mosaic class Core::Timer
The class Core::Timer provides a mechanism to trigger periodical operations in predetermined intervals. The intervals are defined by the properties Begin und Period. After an interval is elapsed, the timer sends a signal to the method stored in the property OnTrigger. Optionally, the method Trigger() can be overridden and implemented in classes derived from Core::Timer.
Whether the timer is running or not is controlled by its property Enabled. It can be used to start and stop the timer. The timer can also be controlled by sending signals to its StartTimer and StopTimer slot methods.
property int32 Begin = 0;
The property 'Begin' stores the interval in milliseconds for the first timer expiration. If this value is less or equal to zero, the timer will expire only in intervals specified in the property Period.
property bool Enabled = false;
The property 'Enabled' determines whether the timer is currently running.
Assigning the value 'true' to this property re-starts the timer. The timer will start then the interval specified in Begin. After the interval is elapsed, the timer continue running with the interval defined in Period.
method uint32 GetCurrentTime();
The method 'GetCurrentTime()' returns the current time expressed in milliseconds. The value can be used e.g. to calculate the time span elapsed since the timer was expired (see Time).
property slot OnTrigger = null;
property int32 Period = 1000;
The property 'Period' stores an interval in milliseconds to expire periodically after the start interval Begin is elapsed. If Period is less or equal to zero the timer will expire only once after the interval specified in Begin.
The slot method 'StartTimer' will re-start the timer if a signal is sent to this slot method. The timer will start with the interval specified in Begin. After the interval is elapsed, the timer continue running with the interval defined in Period.
The slot method 'StopTimer' will stop the running timer if a signal is sent to this slot method.
var uint32 Time;
The variable 'Time' stores the time in milliseconds when the timer is expired for the last time.
method void Trigger();
The method Trigger() will be invoked when the timer is expired (when the interval defined in Begin or Period is elapsed). The method can be overridden and implemented in derived classes. The default implementation of this method sends a signal to the slot method stored in the OnTrigger property.