-
Notifications
You must be signed in to change notification settings - Fork 1
/
canDataProvider.cpp
90 lines (74 loc) · 2.68 KB
/
canDataProvider.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "canDataProvider.h"
CanDataProvider* CanDataProvider::canDataProvider = NULL;
CanDataProvider::CanDataProvider(QObject *parent) :
QObject(parent), mutexStreaming(), mutexMotorDataSet1(), mutexMotorDataSet2(), mutexJointDataSet()
{
this->streaming = false;
}
CanDataProvider::~CanDataProvider()
{
}
CanDataProvider* CanDataProvider::getInstance()
{
if(canDataProvider == NULL)
canDataProvider = new CanDataProvider();
return canDataProvider;
}
bool CanDataProvider::isStreaming()
{
QMutexLocker locker(&mutexStreaming);
return this->streaming;
}
std::array<motorDataSet1,MAX_DRIVERS_AND_JOINTS> CanDataProvider::getLatestMotorDataSet1()
{
QMutexLocker locker(&mutexMotorDataSet1);
return this->latestMotorDataSet1;
}
std::array<motorDataSet2,MAX_DRIVERS_AND_JOINTS> CanDataProvider::getLatestMotorDataSet2()
{
QMutexLocker locker(&mutexMotorDataSet2);
return this->latestMotorDataSet2;
}
std::array<jointDataSet,MAX_DRIVERS_AND_JOINTS> CanDataProvider::getLatestJointDataSet()
{
QMutexLocker locker(&mutexJointDataSet);
return this->latestJointDataSet;
}
unsigned long CanDataProvider::getLatestMotorDataSet1TimeMicroSec()
{
QMutexLocker locker(&mutexMotorDataSet1);
return this->latestMotorDataSet1TimeMicroSec;
}
unsigned long CanDataProvider::getLatestMotorDataSet2TimeMicroSec()
{
QMutexLocker locker(&mutexMotorDataSet2);
return this->latestMotorDataSet2TimeMicroSec;
}
unsigned long CanDataProvider::getLatestJointDataSetTimeMicroSec()
{
QMutexLocker locker(&mutexJointDataSet);
return this->latestJointDataSetTimeMicroSec;
}
void CanDataProvider::setStreaming(bool newStreaming)
{
QMutexLocker locker(&mutexStreaming);
this->streaming = newStreaming;
}
void CanDataProvider::setMotorDataSet1(std::array<motorDataSet1,MAX_DRIVERS_AND_JOINTS>* newMotorDataSet1, unsigned long newMotorDataSet1TimeMicroSec)
{
QMutexLocker locker(&mutexMotorDataSet1);
this->latestMotorDataSet1 = *newMotorDataSet1;
this->latestMotorDataSet1TimeMicroSec = newMotorDataSet1TimeMicroSec;
}
void CanDataProvider::setMotorDataSet2(std::array<motorDataSet2,MAX_DRIVERS_AND_JOINTS>* newMotorDataSet2, unsigned long newMotorDataSet2TimeMicroSec)
{
QMutexLocker locker(&mutexMotorDataSet2);
this->latestMotorDataSet2 = *newMotorDataSet2;
this->latestMotorDataSet2TimeMicroSec = newMotorDataSet2TimeMicroSec;
}
void CanDataProvider::setJointDataSet(std::array<jointDataSet,MAX_DRIVERS_AND_JOINTS>* newJointDataSet, unsigned long newJointDataSetTimeMicroSec)
{
QMutexLocker locker(&mutexJointDataSet);
this->latestJointDataSet = *newJointDataSet;
this->latestJointDataSetTimeMicroSec = newJointDataSetTimeMicroSec;
}