-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhandInterface.cpp
60 lines (47 loc) · 1.02 KB
/
handInterface.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
#include "handInterface.h"
#include "hand.h"
#include "consts.h"
HandInterface::HandInterface() :
mHand(new Hand)
{
}
HandInterface::~HandInterface()
{
if (isHardwareHandSet()) {
QObject::disconnect(mHand, SIGNAL(dataIsRead()), this, SIGNAL(dataIsRead()));
}
delete mHand;
}
void HandInterface::setHardwareHand(const QString &portName)
{
mHand->connectHardwareHand(portName);
if (isHardwareHandSet()) {
QObject::connect(mHand, SIGNAL(dataIsRead()), this, SIGNAL(dataIsRead()));
}
}
bool HandInterface::isHardwareHandSet()
{
return mHand->isPortSet();
}
void HandInterface::startSendingDatas()
{
mHand->startSendingData();
}
void HandInterface::stopSendingDatas()
{
mHand->stopSendingData();
}
void HandInterface::moveMotor(const int &num, const int &value)
{
mHand->moveMotor(num, value);
}
void HandInterface::moveMotors(const QList<int> &data)
{
for (int i = 0; i < HandConsts::numberOfMotors; i++) {
moveMotor(i, data.at(i));
}
}
QList<int> HandInterface::motorsDatas()
{
return mHand->currentPosition();
}