Critical Link MityCam SoC Firmware
1.0
Critical Link MityCam SoC Firmware
Timer.h
Go to the documentation of this file.
1
/*
2
* To use this class, inherit from tcTimedObject. Contain a tcTimer and start it.
3
* When the timer expires, it will call "TimerTicked" with a pointer to itself to compare against in case there are multiple timed events.
4
*/
5
6
#ifndef TCTIMER_H_
7
#define TCTIMER_H_
8
9
class
tcTimer
;
10
11
#include <time.h>
12
#include <signal.h>
13
#include <sys/time.h>
14
#include <stdint.h>
15
#include <chrono>
16
17
class
tcTimedObject
{
18
public
:
19
tcTimedObject
() {};
20
virtual
~tcTimedObject
() {};
21
22
virtual
void
timerTicked
(
tcTimer
*) = 0;
23
};
24
25
class
tcTimer
{
26
public
:
27
tcTimer
();
28
virtual
~tcTimer
();
29
34
bool
initializeTimer
();
35
44
bool
startTimer
(
tcTimedObject
* apTimedObject, uint32_t anSeconds, uint32_t anNanoseconds,
bool
abSingleShot =
false
);
45
53
bool
startTimer
(
tcTimedObject
* apTimedObject, std::chrono::microseconds acDuration,
bool
abSingleShot =
false
);
54
59
bool
isStarted
();
60
64
void
stopTimer
();
65
66
private
:
67
static
void
timerExpired(
union
sigval auSig);
68
69
struct
itimerspec msTimerInterval;
70
struct
sigevent msSigevent;
71
timer_t mhTimerId;
72
tcTimedObject
*mpObject;
73
bool
mbInitialized;
74
bool
mbStarted;
75
};
76
77
#endif
/* TCTIMER_H_ */
tcTimer::stopTimer
void stopTimer()
Definition:
Timer.cpp:64
tcTimer::tcTimer
tcTimer()
Definition:
Timer.cpp:12
tcTimer
Definition:
Timer.h:25
tcTimer::isStarted
bool isStarted()
Definition:
Timer.cpp:59
tcTimer::~tcTimer
virtual ~tcTimer()
Definition:
Timer.cpp:16
tcTimedObject::tcTimedObject
tcTimedObject()
Definition:
Timer.h:19
tcTimedObject
Definition:
Timer.h:17
tcTimer::startTimer
bool startTimer(tcTimedObject *apTimedObject, uint32_t anSeconds, uint32_t anNanoseconds, bool abSingleShot=false)
Definition:
Timer.cpp:21
tcTimedObject::~tcTimedObject
virtual ~tcTimedObject()
Definition:
Timer.h:20
tcTimer::initializeTimer
bool initializeTimer()
Definition:
Timer.cpp:73
tcTimedObject::timerTicked
virtual void timerTicked(tcTimer *)=0
src
Utility
Timer.h
Generated on Wed Mar 23 2022 10:59:09 for Critical Link MityCam SoC Firmware by
1.8.17