-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmotorworker.h
More file actions
50 lines (43 loc) · 1016 Bytes
/
Copy pathmotorworker.h
File metadata and controls
50 lines (43 loc) · 1016 Bytes
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
#ifndef MOTORWORKER_H
#define MOTORWORKER_H
#include <QThread>
#include <QtCore>
#include "steppermotor.h"
class MotorWorker : public QObject
{
Q_OBJECT
StepperMotor *_Motor;
public:
bool StopThread;
bool IsBusy;
int StepDelay;
MotorWorker(StepperMotor *Motor, int MS_Delay = 10)
{
this->_Motor = Motor;
this->StopThread = false;
this->StepDelay = MS_Delay;
}
public slots:
void DoWork()
{
qDebug()<< "Firing Thread!";
while (!this->StopThread)
{
_Motor->Rotate(_Motor->Direction, 1, 10);
qDebug()<< "Stepping";
emit ProgressChanged(QString::number(_Motor->Position));
}
this->StopThread = false;
emit WorkComplete("Done");
}
void Stop()
{
qDebug()<< "Setting Stop Flag!";
this->StopThread = true;
}
signals:
void ProgressChanged(QString info);
void WorkComplete(QString result);
void Error(QString err);
};
#endif // MOTORWORKER_H