OS  v1.7.5
Documentation
Loading...
Searching...
No Matches
timer.hpp
1#ifndef QOS_CPP_TIMER
2#define QOS_CPP_TIMER
3
4#include "include/types.hpp"
5#include "include/clock.hpp"
6
7namespace qOS {
8
26 class timer {
27 private:
28 qOS::clock_t tStart{ 0U };
29 qOS::clock_t tv{ 0U };
30 public:
33 virtual ~timer() {}
43 explicit timer( const qOS::duration_t tTime )
44 {
45 (void)set( tTime );
46 }
56 bool set( const qOS::duration_t tTime ) noexcept;
60 void disarm( void ) noexcept;
65 void reload( void ) noexcept;
70 bool status( void ) const noexcept;
88 bool freeRun( const qOS::duration_t tTime ) noexcept;
93 qOS::clock_t remaining( void ) const noexcept;
98 qOS::clock_t elapsed( void ) const noexcept;
104 bool expired( void ) const noexcept;
109 bool deadLineCheck( void ) const noexcept;
114 qOS::clock_t getInterval( void ) const noexcept;
130 timer& operator=( const bool en );
136 bool operator()( void ) const;
144 bool operator()( const qOS::duration_t tTime );
152 void operator()( const bool en );
154 static const bool ARMED;
156 static const bool DISARMED;
163 };
164
166}
167
168bool operator==( const qOS::timer& obj, bool value );
169
170#endif /*QOS_CPP_TIMER*/
171
A non-blocking Timer object.
Definition timer.hpp:26
bool operator()(const qOS::duration_t tTime)
Set the expiration time for a timer and gets armed immediately.
void reload(void) noexcept
Reload the timer with the previous specified time.
static const bool DISARMED
Constant that defines the status of a disarmed timer.
Definition timer.hpp:156
qOS::clock_t elapsed(void) const noexcept
Retrieve the elapsed time in epochs.
bool set(const qOS::duration_t tTime) noexcept
Set the expiration time for a timer. On success, the timer gets armed immediately.
timer(const qOS::duration_t tTime)
Initializes the instance of the timer with the specified expiration time. Timer will start armed.
Definition timer.hpp:43
timer & operator=(const qOS::duration_t tTime)
Set the expiration time for a timer and gets armed immediately.
bool deadLineCheck(void) const noexcept
Check if the specified deadline for has been reached.
void operator()(const bool en)
Disarm or reload the timer.
bool status(void) const noexcept
Get the current status of the Timer (Armed or Disarmed)
qOS::clock_t getInterval(void) const noexcept
Retrieve the timer interval value.
static const qOS::clock_t DISARM_VALUE
Constant that defines the value of a disarmed timer.
Definition timer.hpp:158
bool expired(void) const noexcept
Non-Blocking timer check.
bool operator()(void) const
Non-Blocking timer check.
void disarm(void) noexcept
Disarms the timer object.
static const qOS::clock_t REMAINING_IN_DISARMED_STATE
Constant that defines the value that a disarmed timer returns when the remaining time is requested.
Definition timer.hpp:162
static const bool ARMED
Constant that defines the status of an armed timer.
Definition timer.hpp:154
bool freeRun(const qOS::duration_t tTime) noexcept
Non-Blocking timer check with automatic arming.
timer & operator=(const bool en)
Disarm or reload the timer.
qOS::clock_t remaining(void) const noexcept
Retrieve the remaining time in epochs.
timeCount_t duration_t
The typedef that specified an time quantity, usually expressed in milliseconds.
Definition clock.hpp:18
timeCount_t clock_t
A unsigned integer to hold ticks count. Epochs counter.
Definition clock.hpp:15
OS/Kernel interfaces.
Definition bytebuffer.hpp:7