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 #include "IMUDevice.h"
11 
12 namespace IMU
13 {
14  uint32_t CIMUEvent::s_IdCounter = 0;
15  pthread_mutex_t CIMUEvent::s_IdCounterMutex = PTHREAD_MUTEX_INITIALIZER;
16 
17  CIMUEvent::CIMUEvent(const timeval& TimeStamp, const EventType EventType, const CIMUDevice* pIMUDevice, const IMUState& EventState) :
18  m_Id(CreatId()),
19  m_TimeStamp(TimeStamp), m_EventType(EventType), m_pIMUDevice(pIMUDevice), m_IMUState(EventState)
20  {
21  }
22 
23  CIMUEvent::CIMUEvent(const timeval& TimeStamp, const EventType EventType, const CIMUDevice* pIMUDevice) :
24  m_Id(CreatId()), m_TimeStamp(TimeStamp), m_EventType(EventType), m_pIMUDevice(pIMUDevice), m_IMUState(pIMUDevice->GetIMUState())
25  {
26  }
27 
28  CIMUEvent::CIMUEvent(const EventType EventType, const CIMUDevice* pIMUDevice) :
29  m_Id(CreatId()), m_TimeStamp(CTimeStamp::GetCurrentTimeStamp()), m_EventType(EventType), m_pIMUDevice(pIMUDevice), m_IMUState(pIMUDevice->GetIMUState())
30  {
31  }
32 
34  m_Id(CreatId()), m_TimeStamp(Event.m_TimeStamp), m_EventType(Event.m_EventType), m_pIMUDevice(Event.m_pIMUDevice), m_IMUState(Event.m_IMUState)
35  {
36  }
37 
39  m_Id(CreatId()), m_TimeStamp(CTimeStamp::s_Zero), m_EventType(EventType(0x0)), m_pIMUDevice(nullptr), m_IMUState()
40  {
41  }
42 
44  = default;
45 
46  uint32_t CIMUEvent::CreatId()
47  {
48  pthread_mutex_lock(&s_IdCounterMutex);
49  uint32_t Id = CIMUEvent::s_IdCounter++;
50  pthread_mutex_unlock(&s_IdCounterMutex);
51  return Id;
52  }
53 }
IMU::CIMUEvent::EventType
EventType
Definition: IMUEvent.h:21
IMU::CIMUEvent::CIMUEvent
CIMUEvent()
Definition: IMUEvent.cpp:38
IMU::CIMUEvent::~CIMUEvent
virtual ~CIMUEvent()
IMUDevice.h
IMU::CIMUEvent
Definition: IMUEvent.h:17
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:12
IMUEvent.h