IMUEvent.cpp
Go to the documentation of this file.
1 /*
2  * IMUEvent.cpp
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 #include "IMUEvent.h"
10 
11 #include "IMUDevice.h"
12 
13 namespace IMU
14 {
15  uint32_t CIMUEvent::s_IdCounter = 0;
16  pthread_mutex_t CIMUEvent::s_IdCounterMutex = PTHREAD_MUTEX_INITIALIZER;
17 
18  CIMUEvent::CIMUEvent(const timeval& TimeStamp,
19  const EventType EventType,
20  const CIMUDevice* pIMUDevice,
21  const IMUState& EventState) :
22  m_Id(CreatId()),
23  m_TimeStamp(TimeStamp),
24  m_EventType(EventType),
25  m_pIMUDevice(pIMUDevice),
26  m_IMUState(EventState)
27  {
28  }
29 
30  CIMUEvent::CIMUEvent(const timeval& TimeStamp,
31  const EventType EventType,
32  const CIMUDevice* pIMUDevice) :
33  m_Id(CreatId()),
34  m_TimeStamp(TimeStamp),
35  m_EventType(EventType),
36  m_pIMUDevice(pIMUDevice),
37  m_IMUState(pIMUDevice->GetIMUState())
38  {
39  }
40 
41  CIMUEvent::CIMUEvent(const EventType EventType, const CIMUDevice* pIMUDevice) :
42  m_Id(CreatId()),
43  m_TimeStamp(CTimeStamp::GetCurrentTimeStamp()),
44  m_EventType(EventType),
45  m_pIMUDevice(pIMUDevice),
46  m_IMUState(pIMUDevice->GetIMUState())
47  {
48  }
49 
51  m_Id(CreatId()),
52  m_TimeStamp(Event.m_TimeStamp),
53  m_EventType(Event.m_EventType),
54  m_pIMUDevice(Event.m_pIMUDevice),
55  m_IMUState(Event.m_IMUState)
56  {
57  }
58 
60  m_Id(CreatId()),
61  m_TimeStamp(CTimeStamp::s_Zero),
62  m_EventType(EventType(0x0)),
63  m_pIMUDevice(nullptr),
64  m_IMUState()
65  {
66  }
67 
68  CIMUEvent::~CIMUEvent() = default;
69 
70  uint32_t
71  CIMUEvent::CreatId()
72  {
73  pthread_mutex_lock(&s_IdCounterMutex);
74  uint32_t Id = CIMUEvent::s_IdCounter++;
75  pthread_mutex_unlock(&s_IdCounterMutex);
76  return Id;
77  }
78 } // namespace IMU
IMU::CIMUEvent::EventType
EventType
Definition: IMUEvent.h:21
IMU::CIMUEvent::CIMUEvent
CIMUEvent()
Definition: IMUEvent.cpp:59
IMU::CIMUEvent::~CIMUEvent
virtual ~CIMUEvent()
IMUDevice.h
IMU::CIMUEvent
Definition: IMUEvent.h:18
IMU::CIMUDevice
This class contains the the devices module and the thread for read the measurements.
Definition: IMUDevice.h:41
IMU::IMUState
Definition: IMUState.h:15
IMU::CTimeStamp
Definition: IMUHelpers.h:18
IMU
Definition: IIMUEventDispatcher.cpp:13
IMUEvent.h