IIMUEventDispatcher.h
Go to the documentation of this file.
1/*
2 * IIMUEventDispatcher.h
3 *
4 * Created on: Mar 16, 2014
5 * Author: Dr.-Ing. David Israel González Aguirre
6 * Mail: david.gonzalez@kit.edu
7 */
8
9#pragma once
10
11#include "IMUEvent.h"
12#include "IMUHelpers.h"
13#include "Includes.h"
14
15namespace IMU
16{
17 class CIMUDevice;
18
20 {
21 public:
27
30
31 virtual ~IIMUEventDispatcher();
32
33 void SetIMU(CIMUDevice* pIMUDevice);
34
35 uint32_t GetEventFlags();
36
37 void SetDispatchingMode(const DispatchingMode Mode);
39
40 void SetMaximalPendingEvents(const uint32_t MaximalPendingEvents);
41 uint32_t GetMaximalPendingEvents();
42
43 void SetEventHandling(const CIMUEvent::EventType Type, const bool Enabled);
44 uint32_t GetEventHandlingFlags();
45
46 void ReceiveEvent(const CIMUEvent& Event);
47
48 inline uint32_t
50 {
51 return uint32_t(m_EventsQueue.size());
52 }
53
54 inline bool
56 {
57 return m_EventsQueue.size();
58 }
59
61
62 void SetReferenceTimeStamps(const timeval& Reference);
63
64 timeval GetLastStartTimeStamp();
65 timeval GetLastStopTimeStamp();
70
71 virtual void OnIMUEvent(const CIMUEvent& Event) = 0;
72
73 private:
74 void PurgeEvents();
75
76 DispatchingMode m_DispatchingMode;
77 pthread_mutex_t m_DispatchingModeMutex;
78 uint32_t m_MaximalPendingEvents;
79 pthread_mutex_t m_MaximalPendingEventsMutex;
80 uint32_t m_EventFlags;
81 pthread_mutex_t m_EventFlagsMutex;
82 CIMUDevice* m_pIMUDevice;
83 pthread_mutex_t m_IMUDeviceMutex;
84 std::list<CIMUEvent> m_EventsQueue;
85 pthread_mutex_t m_EventsQueueMutex;
86 timeval m_LastStartTimeStamp;
87 pthread_mutex_t m_LastStartTimeStampMutex;
88 timeval m_LastStopTimeStamp;
89 pthread_mutex_t m_LastStopTimeStampMutex;
90 timeval m_LastCycleReferenceTimeStamp;
91 pthread_mutex_t m_LastCycleReferenceTimeStampMutex;
92 timeval m_LastFusedCycleReferenceTimeStamp;
93 pthread_mutex_t m_LastFusedCycleReferenceTimeStampMutex;
94 timeval m_LastIntegratedStateReferenceTimeStamp;
95 pthread_mutex_t m_LastIntegratedStateReferenceTimeStampMutex;
96 timeval m_LastCustomEventReferenceTimeStamp;
97 pthread_mutex_t m_LastCustomEventReferenceTimeStampMutex;
98 };
99} // namespace IMU
This class contains the the devices module and the thread for read the measurements.
Definition IMUDevice.h:42
void SetReferenceTimeStamps(const timeval &Reference)
void SetEventHandling(const CIMUEvent::EventType Type, const bool Enabled)
void SetIMU(CIMUDevice *pIMUDevice)
void ReceiveEvent(const CIMUEvent &Event)
IIMUEventDispatcher(CIMUDevice *pIMUDevice)
void SetMaximalPendingEvents(const uint32_t MaximalPendingEvents)
void SetDispatchingMode(const DispatchingMode Mode)
virtual void OnIMUEvent(const CIMUEvent &Event)=0