-
Notifications
You must be signed in to change notification settings - Fork 16
/
minerprocess.h
174 lines (121 loc) · 3.16 KB
/
minerprocess.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
#ifndef MINERPROCESS_H
#define MINERPROCESS_H
#include <QObject>
#include <QProcess>
#include <QTextEdit>
#include <QThread>
#include <QSettings>
class MinerProcess;
class donateThrd;
// waitter before to monitor for O.OOMH/s
class zeroMHsWaitter : public QThread
{
Q_OBJECT
public:
zeroMHsWaitter(unsigned int delay, QObject* pParent = Q_NULLPTR);
void run();
private:
unsigned int _delay;
MinerProcess* _pParent;
};
class restarter : public QThread
{
Q_OBJECT
public:
restarter(unsigned int delay);
void run();
private:
unsigned int _delay;
signals:
void restartsignal();
};
// Timer for any MH/s
// If no hasrate reported after a given delay
// this worker will signal for issue
class anyMHsWaitter : public QThread
{
Q_OBJECT
public:
anyMHsWaitter(unsigned int delay, QObject* pParent = Q_NULLPTR);
void run();
private:
unsigned int _delay;
MinerProcess* _pParent;
unsigned int _hashrateCount;
signals:
void notHashing();
};
class MinerProcess : public QObject
{
Q_OBJECT
public:
MinerProcess(QSettings* settings);
~MinerProcess();
void start(const QString& path, const QString& args);
void stop();
void setLogControl(QTextEdit* log){_log = log;}
void setRestartDelay(unsigned int delay){ _restartDelay = delay;}
void setRestartOption(bool restart){_autoRestart = restart;}
void setMax0MHs(unsigned int max0mhs){_max0mhs = max0mhs;}
void setShareOnly(bool shareOnly){_shareOnly = shareOnly;}
void setDelayBefore0MHs(unsigned int delay){_delayBefore0MHs = delay;}
void setDelayBeforeNoHash(unsigned int delay){_delayBeforeNoHash = delay;}
unsigned int getCurrentHRCount(){return _hashrateCount;}
void setLEDOptions(unsigned short hash, unsigned short share, bool activated);
void restart();
bool isRunning(){return _isRunning;}
private:
QProcess _miner;
zeroMHsWaitter* _waitter;
anyMHsWaitter* _anyHR;
donateThrd* _donate;
QTextEdit* _log;
QString _minerPath;
QString _minerArgs;
QSettings* _settings;
QString _outHelper = QString();
bool _isRunning;
bool _autoRestart;
bool _shareOnly;
bool _readyToMonitor;
unsigned int _max0mhs;
unsigned int _0mhs;
unsigned int _restartDelay;
unsigned int _delayBefore0MHs;
unsigned int _delayBeforeNoHash;
unsigned int _hashrateCount;
unsigned int _acceptedShare;
unsigned int _staleShare;
QString _shareNumber;
unsigned short _ledHash;
unsigned short _ledShare;
bool _ledActivated;
void onReadyToReadStdout();
void onReadyToReadStderr();
void onExit();
void onStarted();
public slots:
void onReadyToMonitor();
void onNoHashing();
void onDonate();
void onBackToNormal();
void onReadyToRestart();
signals:
void emitStarted();
void emitStoped();
void emitHashRate(QString& hashrate);
void emitError();
};
class donateThrd : public QThread
{
Q_OBJECT
public:
donateThrd(QObject* pParent = Q_NULLPTR);
void run();
signals:
void donate();
void backToNormal();
private:
MinerProcess* _parent;
};
#endif // MINERPROCESS_H