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 
15 namespace IMU
16 {
17  class CIMUDevice;
18 
20  {
21  public:
23  {
26  };
27 
28  IIMUEventDispatcher(CIMUDevice* pIMUDevice);
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 
60  bool ProcessPendingEvent();
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
IMU::IIMUEventDispatcher::SetDispatchingMode
void SetDispatchingMode(const DispatchingMode Mode)
Definition: IIMUEventDispatcher.cpp:92
IMU::CIMUEvent::EventType
EventType
Definition: IMUEvent.h:21
IMU::IIMUEventDispatcher::eDecoupled
@ eDecoupled
Definition: IIMUEventDispatcher.h:25
IMU::IIMUEventDispatcher::GetMaximalPendingEvents
uint32_t GetMaximalPendingEvents()
Definition: IIMUEventDispatcher.cpp:125
IMU::IIMUEventDispatcher::~IIMUEventDispatcher
virtual ~IIMUEventDispatcher()
Definition: IIMUEventDispatcher.cpp:66
IMU::IIMUEventDispatcher::DispatchingMode
DispatchingMode
Definition: IIMUEventDispatcher.h:22
IMU::IIMUEventDispatcher::SetMaximalPendingEvents
void SetMaximalPendingEvents(const uint32_t MaximalPendingEvents)
Definition: IIMUEventDispatcher.cpp:109
IMU::IIMUEventDispatcher::HasPendingEvents
bool HasPendingEvents()
Definition: IIMUEventDispatcher.h:55
IMU::IIMUEventDispatcher::SetEventHandling
void SetEventHandling(const CIMUEvent::EventType Type, const bool Enabled)
Definition: IIMUEventDispatcher.cpp:134
Includes.h
IMU::IIMUEventDispatcher::SetReferenceTimeStamps
void SetReferenceTimeStamps(const timeval &Reference)
Definition: IIMUEventDispatcher.cpp:237
IMU::IIMUEventDispatcher::GetLastStartTimeStamp
timeval GetLastStartTimeStamp()
Definition: IIMUEventDispatcher.cpp:265
IMU::IIMUEventDispatcher::SetIMU
void SetIMU(CIMUDevice *pIMUDevice)
Definition: IIMUEventDispatcher.cpp:75
IMU::CIMUEvent
Definition: IMUEvent.h:18
IMU::IIMUEventDispatcher
Definition: IIMUEventDispatcher.h:19
IMU::CIMUDevice
This class contains the the devices module and the thread for read the measurements.
Definition: IMUDevice.h:41
IMU::IIMUEventDispatcher::GetLastCycleReferenceTimeStamp
timeval GetLastCycleReferenceTimeStamp()
Definition: IIMUEventDispatcher.cpp:283
IMU::IIMUEventDispatcher::ProcessPendingEvent
bool ProcessPendingEvent()
Definition: IIMUEventDispatcher.cpp:218
IMU::IIMUEventDispatcher::eCoupled
@ eCoupled
Definition: IIMUEventDispatcher.h:24
IMU::IIMUEventDispatcher::GetDispatchingMode
DispatchingMode GetDispatchingMode()
Definition: IIMUEventDispatcher.cpp:100
IMU::IIMUEventDispatcher::GetLastCustomEventReferenceTimeStamp
timeval GetLastCustomEventReferenceTimeStamp()
Definition: IIMUEventDispatcher.cpp:310
armarx::aron::similarity::FloatSimilarity::Type
Type
The Type enum.
Definition: FloatSimilarity.h:10
IMU::IIMUEventDispatcher::ReceiveEvent
void ReceiveEvent(const CIMUEvent &Event)
Definition: IIMUEventDispatcher.cpp:151
IMU::IIMUEventDispatcher::IIMUEventDispatcher
IIMUEventDispatcher()
Definition: IIMUEventDispatcher.cpp:40
IMU::IIMUEventDispatcher::OnIMUEvent
virtual void OnIMUEvent(const CIMUEvent &Event)=0
IMU
Definition: IIMUEventDispatcher.cpp:13
IMUHelpers.h
IMUEvent.h
IMU::IIMUEventDispatcher::GetLastStopTimeStamp
timeval GetLastStopTimeStamp()
Definition: IIMUEventDispatcher.cpp:274
IMU::IIMUEventDispatcher::GetTotalPendingEvents
uint32_t GetTotalPendingEvents()
Definition: IIMUEventDispatcher.h:49
IMU::IIMUEventDispatcher::GetEventFlags
uint32_t GetEventFlags()
Definition: IIMUEventDispatcher.cpp:83
IMU::IIMUEventDispatcher::GetEventHandlingFlags
uint32_t GetEventHandlingFlags()
Definition: IIMUEventDispatcher.cpp:142
IMU::IIMUEventDispatcher::GetLastFusedCycleReferenceTimeStamp
timeval GetLastFusedCycleReferenceTimeStamp()
Definition: IIMUEventDispatcher.cpp:292
IMU::IIMUEventDispatcher::GetLastIntegratedStateReferenceTimeStamp
timeval GetLastIntegratedStateReferenceTimeStamp()
Definition: IIMUEventDispatcher.cpp:301