Repository navigation
Expand file tree
/
Copy pathtranslator.h
More file actions
110 lines (85 loc) · 2.66 KB
/
Copy pathtranslator.h
File metadata and controls
110 lines (85 loc) · 2.66 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef TRANSLATOR_H
#define TRANSLATOR_H
#include <QObject>
#include <QList>
/**
* @file translator.h
*
* Implementation of the class Translator.
* It is the main class of the programm.
* It is connects all the components of the program.
*/
class FileActionPerformer;
class GloveInterface;
class HandInterface;
class User;
class GloveCalibrator;
enum ConnectionType {
noConnection = 0,
gloveToHand = 1,
actionToHand = 2,
calibrate = 3
};
class Translator : public QObject
{
Q_OBJECT
public:
Translator();
~Translator();
/// Try to connect hardware glove. Returns true, if the glove is successfully connected.
bool connectGlove();
/// Try to connect hardware hand. Returns true, if the glove is successfully connected.
bool connectHand();
/// Esteblishes a connection of components, described in the current connection type.
void startConnection();
/// Stops all connections.
void stopConnection();
/// Returns an list of the last read data.
QList<int> *sensorData() { return &mSensorDatas; }
/// Returns an list of the last converted to hand data.
QList<int> *convertedData() { return &mConvertedDatas; }
/// Stops all connections, and set current connection type = type.
void setConnectionType(ConnectionType const& type);
/// Return current connection type.
ConnectionType connectionType() const { return mConnectionType; }
/**
* Starts loading action from the file.
* Sets current connection type = actionToHand.
* Start to send data to the hand.
*/
void startLoadAction(const QString &fileName);
/// Stops loading action and set current connection type = noConnection.
void stopLoadAction();
/// Starts saveing action to the file. Saves converted to hand data.
void startSaveAction(const QString &fileName, const int &freq);
/// Stops saveing action and set current connection type = noConnection.
void stopSaveAction();
/// Sets connection type = calibrate and start to calibrate glove.
void startCalibrate();
public slots:
void stopCalibrate();
protected slots:
void convertData();
void sendDataToCalibrator();
signals:
void loadingStoped();
protected:
void saveConvertedData(QList<int> const& data);
void saveSensorsData(QList<int> const& data);
int map(int const& value
, int const& firstMin, int const& firstMax
, int const& secondMin, int const& secondMax);
int map(int const& value
, int const& min, int const& max);
void sendDataToHand();
private:
ConnectionType mConnectionType;
QList<int> mConvertedDatas;
QList<int> mSensorDatas;
User *mUser;
FileActionPerformer *mFileActionPerformer;
GloveCalibrator *mGloveCalibrator;
GloveInterface *mGloveInterface;
HandInterface *mHandInterface;
};
#endif // TRANSLATOR_H