Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
timer_based_debouncer.h
1#ifndef TIMER_BASED_DEBOUNCER_H
2#define TIMER_BASED_DEBOUNCER_H
3
4#include <stdint.h>
5#include <thread>
6#include <condition_variable>
7#include <atomic>
8#include "./debouncer.h"
9
10namespace ara
11{
12 namespace diag
13 {
15 struct TimeBased
16 {
18 uint32_t passedMs;
20 uint32_t failedMs;
21 };
22
23 namespace debouncing
24 {
26 {
27 private:
28 const TimeBased mDefaultValues;
29
30 std::mutex mMutex;
31 std::unique_lock<std::mutex> mLock;
32 std::condition_variable mConditionVariable;
33 std::thread mThread;
34 std::atomic_uint32_t mElapsedMs;
35 bool mIsPassing;
36
37 void tick(std::chrono::milliseconds duration, bool passing);
38 void start(uint32_t threshold);
39
40 public:
45 std::function<void(bool)> callback,
46 TimeBased defaultValues);
47
48 virtual ~TimerBasedDebouncer() override;
49
50 virtual void ReportPrepassed() override;
51
52 virtual void ReportPassed() override;
53
54 virtual void ReportPrefailed() override;
55
56 virtual void ReportFailed() override;
57
58 virtual void Freeze() override;
59
60 virtual void Reset() override;
61 };
62 }
63 }
64}
65
66#endif
Debouncing mechanism interface.
Definition: debouncer.h:24
Definition: timer_based_debouncer.h:26
virtual void Freeze() override
Freeze the debouncing mechanism.
Definition: timer_based_debouncer.cpp:114
virtual void ReportPassed() override
Report finally passed of the monitored event.
Definition: timer_based_debouncer.cpp:86
virtual void Reset() override
Reset the debouncing mechanism.
Definition: timer_based_debouncer.cpp:123
virtual void ReportPrepassed() override
Report pre-passed of the monitored event.
Definition: timer_based_debouncer.cpp:74
virtual void ReportPrefailed() override
Report pre-failed of the monitored event.
Definition: timer_based_debouncer.cpp:94
TimerBasedDebouncer(std::function< void(bool)> callback, TimeBased defaultValues)
Constructor.
Definition: timer_based_debouncer.cpp:10
virtual void ReportFailed() override
Report finally failed of the monitored event.
Definition: timer_based_debouncer.cpp:106
Time-based debouncing parameters.
Definition: timer_based_debouncer.h:16
uint32_t failedMs
Time threshold in milliseconds to report failure.
Definition: timer_based_debouncer.h:20
uint32_t passedMs
Time threshold in milliseconds to report passing.
Definition: timer_based_debouncer.h:18