-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbthread.h
195 lines (165 loc) · 4.25 KB
/
dbthread.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
#ifndef DBTHREAD_H
#define DBTHREAD_H
#include <QThread>
#include <QtSql>
#include <QtSql/QSql>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlDriver>
extern QString clientAddress;
extern QString dbName;
extern QString dbUser;
extern QString dbPass;
extern const int zoneNumber;
extern int statTotalActiveZones[];
extern int statTotalActiveZonesDurations[];
extern int totalTime;
extern float statTotalActiveZonesPercent[];
extern QString tableNames[];
extern QString tableSummary;
extern QString tableNgValue;
extern QString tblSummaryFiels[];
class dbThread: public QThread{
Q_OBJECT
public:
dbThread();
~dbThread();
void stop();
void connectToDB();
void analyzeAllZones();
void analyzeZone();
void summaryReport();
void insertToSummaryTable();
void analyzeZonesForGraph();
void getGraphData();
void getTemperature();
void getAvgTemperature();
void analyzeZones();
void ngConsumption();
void updateMeterValue();
void appendMeterUpdateList(int index, float value);
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
QSqlQuery qry;
//QList<int> totalActiveZoneList;
QList<int> timeDiffList;
QList<int> timeDiffListOn;
QList<int> timeDiffListOff;
QList<int> stateList;
QList<int> thresholdIndexList;
QString beginDate;
QString endDate;
QString beginTime;
QString endTime;
QString beginTimeDelimiter;
QString endTimeDelimiter;
QString queryBeginTime;
bool delimiterEncountered;
int currentZone = 0;
int ONtime;
int OFFtime;
int ONcount;
int OFFcount;
int zeroStateLowThreshold = 0;
int zeroStateLowTime = 0;
int zeroStateLowCount = 0;
int zeroStateHighTime = 0;
int zeroStateHighCount = 0;
bool verbose = false;
bool cmdConnect = false;
bool cmdAnalyzeAllZones = false;
bool cmdAnalyzeZone = false;
bool cmdSummaryReport = false;
bool cmdInsertToSummaryTable = false;
bool cmdGraphData = false;
bool cmdTempData = false;
bool cmdAvgTempData = false;
bool cmdAnalyzeZones = false;
bool cmdSingleZone = false;
bool cmdNgConsumption = false;
bool cmdUpdateMeterValue = false;
struct summaryTable {
QString date;
float zone0_rate;
float zone1_rate;
float zone2_rate;
float zone3_rate;
float zone4_rate;
float zone5_rate;
float zone6_rate;
float zone7_rate;
int zone0_thr_count;
QString zone0_thr_time;
float on_rate_oto;
float on_rate_sln;
float on_rate_blk;
float on_rate_mut;
float on_rate_eyo;
float on_rate_cyo;
float on_rate_yod;
int on_count_oto;
int on_count_sln;
int on_count_blk;
int on_count_mut;
int on_count_eyo;
int on_count_cyo;
int on_count_yod;
int on_time_oto;
int on_time_sln;
int on_time_blk;
int on_time_mut;
int on_time_eyo;
int on_time_cyo;
int on_time_yod;
float tempAvg;
float tempMin;
float tempMax;
float ngMeter;
} summaryData;
struct graphData {
int timeDiff;
int state;
};
struct tempData {
int timeDiff;
float value;
};
QList<graphData> graphList[7];
float tempOut = -99;
float tempAvg = -99;
float tempMin = -99;
float tempMax = 99;
QString tempDate="", tempTime="";
QList<tempData> tempList;
QList<tempData> ngMeterList;
int meterDataSize = 6;
struct meterData {
int index;
QString date;
QString time;
float value;
QString note;
float ocr;
};
QList<meterData> ngMeterTableList;
QList<meterData> ngMeterUpdateList;
bool ngMeterTableListAllDay;
public slots:
protected:
void run();
private:
volatile bool stopped;
signals:
void connected();
void unconnected();
void allZonesProcessed();
void zoneProcessed();
void summaryReportProcess();
void summaryReportDone();
void graphDataDone();
void tempOutDone();
void tempOutAvgDone();
void analyzeZonesDone();
void singleZoneDone();
void ngConsumptionDone(float);
void ngConsumptionGraph();
};
#endif // DBTHREAD_H