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
13namespace 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),
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),
36 m_pIMUDevice(pIMUDevice),
37 m_IMUState(pIMUDevice->GetIMUState())
38 {
39 }
40
42 m_Id(CreatId()),
43 m_TimeStamp(CTimeStamp::GetCurrentTimeStamp()),
45 m_pIMUDevice(pIMUDevice),
46 m_IMUState(pIMUDevice->GetIMUState())
47 {
48 }
49
51 m_Id(CreatId()),
56 {
57 }
58
60 m_Id(CreatId()),
61 m_TimeStamp(CTimeStamp::s_Zero),
63 m_pIMUDevice(nullptr),
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
This class contains the the devices module and the thread for read the measurements.
Definition IMUDevice.h:42
uint32_t m_Id
Definition IMUEvent.h:69
CIMUEvent(const timeval &TimeStamp, const EventType EventType, const CIMUDevice *pIMUDevice, const IMUState &EventState)
Definition IMUEvent.cpp:18
const EventType m_EventType
Definition IMUEvent.h:71
const timeval m_TimeStamp
Definition IMUEvent.h:70
virtual ~CIMUEvent()
const CIMUDevice * m_pIMUDevice
Definition IMUEvent.h:72
const IMUState m_IMUState
Definition IMUEvent.h:73