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 "Includes.h"
12 #include "IMUEvent.h"
13 #include "IMUHelpers.h"
14 
15 namespace IMU
16 {
17  class CIMUDevice;
19  {
20  public:
21 
23  {
25  };
26 
27  IIMUEventDispatcher(CIMUDevice* pIMUDevice);
29 
30  virtual ~IIMUEventDispatcher();
31 
32  void SetIMU(CIMUDevice* pIMUDevice);
33 
34  uint32_t GetEventFlags();
35 
36  void SetDispatchingMode(const DispatchingMode Mode);
38 
39  void SetMaximalPendingEvents(const uint32_t MaximalPendingEvents);
40  uint32_t GetMaximalPendingEvents();
41 
42  void SetEventHandling(const CIMUEvent::EventType Type, const bool Enabled);
43  uint32_t GetEventHandlingFlags();
44 
45  void ReceiveEvent(const CIMUEvent& Event);
46 
47  inline uint32_t GetTotalPendingEvents()
48  {
49  return uint32_t(m_EventsQueue.size());
50  }
51 
52  inline bool HasPendingEvents()
53  {
54  return m_EventsQueue.size();
55  }
56 
57  bool ProcessPendingEvent();
58 
59  void SetReferenceTimeStamps(const timeval& Reference);
60 
61  timeval GetLastStartTimeStamp();
62  timeval GetLastStopTimeStamp();
67 
68  virtual void OnIMUEvent(const CIMUEvent& Event) = 0;
69 
70  private:
71 
72  void PurgeEvents();
73 
74  DispatchingMode m_DispatchingMode;
75  pthread_mutex_t m_DispatchingModeMutex;
76  uint32_t m_MaximalPendingEvents;
77  pthread_mutex_t m_MaximalPendingEventsMutex;
78  uint32_t m_EventFlags;
79  pthread_mutex_t m_EventFlagsMutex;
80  CIMUDevice* m_pIMUDevice;
81  pthread_mutex_t m_IMUDeviceMutex;
82  std::list<CIMUEvent> m_EventsQueue;
83  pthread_mutex_t m_EventsQueueMutex;
84  timeval m_LastStartTimeStamp;
85  pthread_mutex_t m_LastStartTimeStampMutex;
86  timeval m_LastStopTimeStamp;
87  pthread_mutex_t m_LastStopTimeStampMutex;
88  timeval m_LastCycleReferenceTimeStamp;
89  pthread_mutex_t m_LastCycleReferenceTimeStampMutex;
90  timeval m_LastFusedCycleReferenceTimeStamp;
91  pthread_mutex_t m_LastFusedCycleReferenceTimeStampMutex;
92  timeval m_LastIntegratedStateReferenceTimeStamp;
93  pthread_mutex_t m_LastIntegratedStateReferenceTimeStampMutex;
94  timeval m_LastCustomEventReferenceTimeStamp;
95  pthread_mutex_t m_LastCustomEventReferenceTimeStampMutex;
96  };
97 }
98 
IMU::IIMUEventDispatcher::SetDispatchingMode
void SetDispatchingMode(const DispatchingMode Mode)
Definition: IIMUEventDispatcher.cpp:69
IMU::CIMUEvent::EventType
EventType
Definition: IMUEvent.h:21
IMU::IIMUEventDispatcher::eDecoupled
@ eDecoupled
Definition: IIMUEventDispatcher.h:24
IMU::IIMUEventDispatcher::GetMaximalPendingEvents
uint32_t GetMaximalPendingEvents()
Definition: IIMUEventDispatcher.cpp:99
IMU::IIMUEventDispatcher::~IIMUEventDispatcher
virtual ~IIMUEventDispatcher()
Definition: IIMUEventDispatcher.cpp:46
IMU::IIMUEventDispatcher::DispatchingMode
DispatchingMode
Definition: IIMUEventDispatcher.h:22
IMU::IIMUEventDispatcher::SetMaximalPendingEvents
void SetMaximalPendingEvents(const uint32_t MaximalPendingEvents)
Definition: IIMUEventDispatcher.cpp:84
IMU::IIMUEventDispatcher::HasPendingEvents
bool HasPendingEvents()
Definition: IIMUEventDispatcher.h:52
IMU::IIMUEventDispatcher::SetEventHandling
void SetEventHandling(const CIMUEvent::EventType Type, const bool Enabled)
Definition: IIMUEventDispatcher.cpp:107
Includes.h
IMU::IIMUEventDispatcher::SetReferenceTimeStamps
void SetReferenceTimeStamps(const timeval &Reference)
Definition: IIMUEventDispatcher.cpp:206
IMU::IIMUEventDispatcher::GetLastStartTimeStamp
timeval GetLastStartTimeStamp()
Definition: IIMUEventDispatcher.cpp:233
IMU::IIMUEventDispatcher::SetIMU
void SetIMU(CIMUDevice *pIMUDevice)
Definition: IIMUEventDispatcher.cpp:54
IMU::CIMUEvent
Definition: IMUEvent.h:17
IMU::IIMUEventDispatcher
Definition: IIMUEventDispatcher.h:18
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:249
IMU::IIMUEventDispatcher::ProcessPendingEvent
bool ProcessPendingEvent()
Definition: IIMUEventDispatcher.cpp:188
IMU::IIMUEventDispatcher::eCoupled
@ eCoupled
Definition: IIMUEventDispatcher.h:24
IMU::IIMUEventDispatcher::GetDispatchingMode
DispatchingMode GetDispatchingMode()
Definition: IIMUEventDispatcher.cpp:76
IMU::IIMUEventDispatcher::GetLastCustomEventReferenceTimeStamp
timeval GetLastCustomEventReferenceTimeStamp()
Definition: IIMUEventDispatcher.cpp:273
armarx::aron::similarity::FloatSimilarity::Type
Type
The Type enum.
Definition: FloatSimilarity.h:8
IMU::IIMUEventDispatcher::ReceiveEvent
void ReceiveEvent(const CIMUEvent &Event)
Definition: IIMUEventDispatcher.cpp:122
IMU::IIMUEventDispatcher::IIMUEventDispatcher
IIMUEventDispatcher()
Definition: IIMUEventDispatcher.cpp:30
IMU::IIMUEventDispatcher::OnIMUEvent
virtual void OnIMUEvent(const CIMUEvent &Event)=0
IMU
Definition: IIMUEventDispatcher.cpp:12
IMUHelpers.h
IMUEvent.h
IMU::IIMUEventDispatcher::GetLastStopTimeStamp
timeval GetLastStopTimeStamp()
Definition: IIMUEventDispatcher.cpp:241
IMU::IIMUEventDispatcher::GetTotalPendingEvents
uint32_t GetTotalPendingEvents()
Definition: IIMUEventDispatcher.h:47
IMU::IIMUEventDispatcher::GetEventFlags
uint32_t GetEventFlags()
Definition: IIMUEventDispatcher.cpp:61
IMU::IIMUEventDispatcher::GetEventHandlingFlags
uint32_t GetEventHandlingFlags()
Definition: IIMUEventDispatcher.cpp:114
IMU::IIMUEventDispatcher::GetLastFusedCycleReferenceTimeStamp
timeval GetLastFusedCycleReferenceTimeStamp()
Definition: IIMUEventDispatcher.cpp:257
IMU::IIMUEventDispatcher::GetLastIntegratedStateReferenceTimeStamp
timeval GetLastIntegratedStateReferenceTimeStamp()
Definition: IIMUEventDispatcher.cpp:265