-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.h
216 lines (153 loc) · 5.06 KB
/
controller.h
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <QObject>
#include <QMutex>
#include <QThread>
#include <QStringList>
#include "joystick.h"
#include "mainthread.h"
class Controller : public QObject
{
Q_OBJECT
Q_PROPERTY(bool Running READ Running WRITE SetRunning NOTIFY RunningChanged)
Q_PROPERTY(bool Communication READ Communication WRITE SetCommunication NOTIFY CommunicationChanged)
Q_PROPERTY(QStringList JoystickDevices READ JoystickDevices NOTIFY JoystickDevicesChanged)
Q_PROPERTY(int JoystickCount READ JoystickCount NOTIFY JoystickCountChanged)
Q_PROPERTY(QString JoystickName READ JoystickName NOTIFY JoystickNameChanged)
Q_PROPERTY(QStringList ThrusterValues READ ThrusterValues NOTIFY ThrusterValuesChanged)
Q_PROPERTY(QString ConnectionIP READ ConnectionIP WRITE setConnectionIP NOTIFY ConnectionIPChanged)
Q_PROPERTY(int ConnectionPort READ ConnectionPort WRITE setConnectionPort NOTIFY ConnectionPortChanged)
Q_PROPERTY(QList<int> TempData READ TempData NOTIFY TempDataChanged)
Q_PROPERTY(int Rotation READ Rotation WRITE setRotation NOTIFY RotationChanged)
Q_PROPERTY(int Pitch READ Pitch WRITE setPitch NOTIFY PitchChanged)
/////////////////////////////////////////
// Class & (de)Contsructor Definitions //
/////////////////////////////////////////
public:
static Controller* getInstance();
private:
Controller() {};
Controller(Controller const&);
void operator=(Controller const&);
~Controller();
void updateTempData();
static Controller* instance;
static QMutex mutex;
void init();
/////////////////////////////////////////
// Thread Control Properties & Fns //
/////////////////////////////////////////
//Running Property
public:
bool Running() const; //Read property
void SetRunning(bool running); //Write Property
private: //Dependencies
bool running;
signals: //Signal to emit on change
void RunningChanged();
//Thread Control Functions
private:
void startThread();
void stopThread();
private: //Dependecies
QThread* qThread;
Mainthread* mainthread;
/////////////////////////////////////////
// Communication Properties //
/////////////////////////////////////////
//Running Property
public:
bool Communication() const; //Read property
void SetCommunication(bool communication); //Write Property
private: //Dependencies
bool communication;
signals: //Signal to emit on change
void CommunicationChanged();
/////////////////////////////////////////
// Joystick Control Properties //
/////////////////////////////////////////
//QML Property Definitions
public:
QStringList JoystickDevices() const; //Read property
int JoystickCount() const;
QString JoystickName() const;
//Write Property
private: //Dependencies
QStringList joystickDevices;
signals: //Signal to emit on change
void JoystickDevicesChanged();
void JoystickCountChanged();
void JoystickNameChanged();
//Additional Control Methods
public slots:
//Select a device based combo index
void JoystickSelect(int index);
private: //dependencies
int joystickIndex;
Joystick* joystick;
/////////////////////////////////////////
// Thruster Control Properties //
/////////////////////////////////////////
//QML Property Definitions
public:
//Read property
QStringList ThrusterValues() const;
//Write Property
void SetThrusterValues(int values[]);
private: //Dependencies
QStringList thrusterValues;
signals: //Signal to emit on change
void ThrusterValuesChanged();
/////////////////////////////////////////
// TempData Properties //
/////////////////////////////////////////
//QML Property Definitions
public:
//Read property
QList<int> TempData() const;
void addTempData(int data);
private: //Dependencies
QList<int> tempData;
signals: //Signal to emit on change
void TempDataChanged();
/////////////////////////////////////////
// Connection Properties //
/////////////////////////////////////////
//QML Property Definitions
public:
//Read property
QString ConnectionIP() const;
int ConnectionPort() const;
//Write Property
void setConnectionIP(QString ip);
void setConnectionPort(int port);
private: //Dependencies
QString connectionIP;
int connectionPort;
signals: //Signal to emit on change
void ConnectionIPChanged();
void ConnectionPortChanged();
/////////////////////////////////////////
// Rotation Properties //
/////////////////////////////////////////
//QML Property Definitions
public:
//Read property
int Rotation() const;
int Pitch() const;
//Write Property
void setRotation(int rotation);
void setPitch(int pitch);
private: //Dependencies
int rotation;
int pitch;
signals: //Signal to emit on change
void RotationChanged();
void PitchChanged();
/////////////////////////////////////////
// Misc Public Slots //
/////////////////////////////////////////
public slots:
void RefreshLists();
};
#endif // CONTROLLER_H