84 lines
3.2 KiB
C++
84 lines
3.2 KiB
C++
#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_QCView.clear();
|
|
Gloab::rule.clear();
|
|
Gloab::rule.append("状态");
|
|
//判断右侧数据是否为数字型
|
|
bool isEnum = Gloab::namelist[dataName];
|
|
for (int i = 0; i < jd.size(); ++i) {
|
|
// emit newCandS();
|
|
Gloab::xData.clear();
|
|
Gloab::yData.clear();
|
|
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) {
|
|
Gloab::xData.append(temTime.toMSecsSinceEpoch()/1000.0);
|
|
Gloab::yData.append(y);
|
|
}
|
|
} else {
|
|
y = Gloab::g_param[jd[i]][j][dataName].toDouble();
|
|
Gloab::xData.append(temTime.toMSecsSinceEpoch()/1000.0);
|
|
Gloab::yData.append(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);
|
|
}
|
|
Gloab::xData.append(temTime.toMSecsSinceEpoch()/1000.0);
|
|
Gloab::yData.append(Gloab::rule.indexOf(tem1));
|
|
}
|
|
} else {
|
|
tem1 = Gloab::g_param[jd[i]][j][dataName];
|
|
if (!Gloab::rule.contains(tem1)) {
|
|
Gloab::rule.append(tem1);
|
|
}
|
|
Gloab::xData.append(temTime.toMSecsSinceEpoch()/1000.0);
|
|
Gloab::yData.append(Gloab::rule.indexOf(tem1));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
emit setChartView(jd[i], isEnum);
|
|
}
|
|
|
|
emit setWidget();
|
|
quit();
|
|
}
|