Timer
Summary
Represents a project timer object.
- Methods
- Properties
- Events
Structure
- class Timer
- get_running_time() float
Method that returns the current duration since timer started.
- Returns
Timer execution duration.
- Return type
- get_state() TIMERSTATE
Method that returns the current state of the timer.
- Returns
Timer State
- Return type
- get_timeout() float
Method that returns the Timeout value of the timer.
- Returns
Timer timeout value
- Return type
- pause()
Pauses the timer.
- reset()
Sets the timer’s time to zero.
- resume()
Resumes the timer.
- start()
Starts the timer, raising during the execution the on_time_elapsed and on_time_out events. It can be stopped at any time by calling stop.
- start(timeout: float)
Starts the timer, raising during the execution the on_time_elapsed and on_time_out events. It can be stopped at any time by calling stop.
- Parameters
timeout (
float
) – (optional) the time that the timer will run is in milliseconds. In this case, there is no need to use stop because the timer will stop automatically when the defined time is over.
- stop()
Stops the timer.
- @on_state_changed(arg: TimerStateChangedEventArg)
Event is triggered when the state of the timer changes, e.g. from running to stop. The Callback parameters are a Timer object that generated the event and the current_date, timestamp when the event is triggered. See Microsoft’s DateTime class for further information.
- Parameters
arg (
TimerStateChangedEventArg
) – Timer monitored.
- @on_time_elapsed(source: object, e: TimerElapsedEventArgs)
Event is triggered every time when the interval elapses, e.g. every second if the interval is set to
1000
milliseconds. The Callback parameters are a Timer object that generated the event and the current_date, timestamp when the event is triggered. See Microsoft’s DateTime class for further information.- Parameters
source (
object
) – Source of the event.e (
TimerElapsedEventArgs
) – Timer to monitor.
- @on_time_out(source: object, e: TimerElapsedEventArgs)
Event is triggered when the timeout is over, i.e. when the timer stops. The Callback parameters are a Timer object that generated the event, and the current_date, timestamp when the event is triggered. See Microsoft’s DateTime class for further information.
- Parameters
source (
object
) – Source of the event.e (
TimerElapsedEventArgs
) – Timer to monitor.