v1.1.0
This commit is contained in:
82
threadchart.cpp
Normal file
82
threadchart.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
#include "threadchart.h"
|
||||
#include <QDebug>
|
||||
|
||||
ThreadChart::ThreadChart(QObject *parent)
|
||||
: QThread{parent} {
|
||||
}
|
||||
|
||||
void ThreadChart::setValue(QVector<int> jd, QString dataName, QDateTime beginTime, QDateTime endTime) {
|
||||
this->jd = jd;
|
||||
this->dataName = dataName;
|
||||
this->beginTime = beginTime;
|
||||
this->endTime = endTime;
|
||||
}
|
||||
|
||||
|
||||
void ThreadChart::run() {
|
||||
Gloab::m_chartViews.clear();
|
||||
Gloab::rule.clear();
|
||||
Gloab::rule.append("状态");
|
||||
//判断右侧数据是否为数字型
|
||||
bool isEnum = Gloab::namelist[dataName];
|
||||
for (int i = 0; i < jd.size(); ++i) {
|
||||
emit newCandS();
|
||||
qreal y = 114.514;
|
||||
QString tem1 = "无数据";
|
||||
// 为每个图表添加数据
|
||||
if (isEnum) {
|
||||
for (int j = 0; j < Gloab::g_param[jd[i]].size(); j++) {
|
||||
//更新进度条
|
||||
Gloab::bytesRead++;
|
||||
int percent = Gloab::bytesRead * 100 / Gloab::fileSize;
|
||||
emit setProgressBar(percent);
|
||||
|
||||
QDateTime temTime = QDateTime::fromString(Gloab::g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz");
|
||||
if (temTime >= beginTime && temTime < endTime) {
|
||||
if (!Gloab::g_param[jd[i]][j].contains(dataName)) {
|
||||
if (y != 114.514) {
|
||||
emit appSeries(temTime.toMSecsSinceEpoch(), y);
|
||||
}
|
||||
} else {
|
||||
if (Gloab::g_param[jd[i]][j][dataName].contains(".")) {
|
||||
y = Gloab::g_param[jd[i]][j][dataName].toDouble();
|
||||
emit appSeries(temTime.toMSecsSinceEpoch(), y);
|
||||
} else {
|
||||
y = Gloab::g_param[jd[i]][j][dataName].toLongLong();
|
||||
emit appSeries(temTime.toMSecsSinceEpoch(), y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < Gloab::g_param[jd[i]].size(); j++) {
|
||||
//更新进度条
|
||||
Gloab::bytesRead++;
|
||||
int percent = Gloab::bytesRead * 100 / Gloab::fileSize;
|
||||
emit setProgressBar(percent);
|
||||
|
||||
QDateTime temTime = QDateTime::fromString(Gloab::g_param[jd[i]][j]["时间"], "yyyy-MM-dd hh:mm:ss:zzz");
|
||||
if (temTime >= beginTime && temTime < endTime) {
|
||||
if (!Gloab::g_param[jd[i]][j].contains(dataName)) {
|
||||
if (tem1 != "无数据") {
|
||||
if (!Gloab::rule.contains(tem1)) {
|
||||
Gloab::rule.append(tem1);
|
||||
}
|
||||
emit appSeries(temTime.toMSecsSinceEpoch(), Gloab::rule.indexOf(tem1));
|
||||
}
|
||||
} else {
|
||||
tem1 = Gloab::g_param[jd[i]][j][dataName];
|
||||
if (!Gloab::rule.contains(tem1)) {
|
||||
Gloab::rule.append(tem1);
|
||||
}
|
||||
emit appSeries(temTime.toMSecsSinceEpoch(), Gloab::rule.indexOf(tem1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
emit setChartView(jd[i], isEnum);
|
||||
}
|
||||
|
||||
emit setWidget();
|
||||
quit();
|
||||
}
|
Reference in New Issue
Block a user