2025-04-15T16:02:59
This commit is contained in:
parent
3a6c5fb642
commit
4b8027eb49
@ -20,6 +20,7 @@ include(thirdparty\QtXlsxWriter-0.3.0\src\xlsx\qtxlsx.pri)
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
data/filemanager.cpp \
|
data/filemanager.cpp \
|
||||||
data/pointcalculate.cpp \
|
data/pointcalculate.cpp \
|
||||||
|
data/txthandler.cpp \
|
||||||
global.cpp \
|
global.cpp \
|
||||||
logger/logger.cpp \
|
logger/logger.cpp \
|
||||||
ui/aboutform.cpp \
|
ui/aboutform.cpp \
|
||||||
@ -44,6 +45,7 @@ SOURCES += \
|
|||||||
data/xlsxhandler.cpp
|
data/xlsxhandler.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
data/txthandler.h \
|
||||||
global.h \
|
global.h \
|
||||||
data/filemanager.h \
|
data/filemanager.h \
|
||||||
data/pointcalculate.h \
|
data/pointcalculate.h \
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "filemanager.h"
|
#include "filemanager.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
namespace FileManager {
|
namespace FileManager {
|
||||||
|
|
||||||
Global::ExperimentInfo _expeInfo;
|
Global::ExperimentInfo _expeInfo;
|
||||||
@ -17,6 +17,7 @@ void writeExperimentFile(const CommonData &cd)
|
|||||||
|
|
||||||
createExperimentFile();
|
createExperimentFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream out(&_expeFile);
|
QTextStream out(&_expeFile);
|
||||||
out.setRealNumberPrecision(3); // 设置精度为三位小数
|
out.setRealNumberPrecision(3); // 设置精度为三位小数
|
||||||
out.setRealNumberNotation(QTextStream::FixedNotation);
|
out.setRealNumberNotation(QTextStream::FixedNotation);
|
||||||
@ -67,7 +68,6 @@ void close()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void readExperimentFile(const QString fileName, QVector<Global::ExperimentData> &dataVtr)
|
void readExperimentFile(const QString fileName, QVector<Global::ExperimentData> &dataVtr)
|
||||||
{
|
{
|
||||||
if(fileName.isEmpty()){
|
if(fileName.isEmpty()){
|
||||||
@ -101,5 +101,11 @@ void readExperimentFile(const QString fileName, QVector<Global::ExperimentData>
|
|||||||
_expeFile.close();
|
_expeFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void writeFile()
|
||||||
|
{
|
||||||
|
createExperimentFile();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -9,15 +9,13 @@
|
|||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
namespace FileManager{
|
namespace FileManager{
|
||||||
const QString ExperimentDirPath = QDir::currentPath()+"/../experiment_data";
|
|
||||||
const QString SampleDataFloder = ExperimentDirPath + "/sample_data";
|
|
||||||
const QString BaseLineFolder = ExperimentDirPath + "/base_line";
|
|
||||||
const QString AnalysisStateFolder = ExperimentDirPath + "/analysis_state";
|
|
||||||
|
|
||||||
extern Global::ExperimentInfo _expeInfo;
|
extern Global::ExperimentInfo _expeInfo;
|
||||||
extern QFile _expeFile;
|
extern QFile _expeFile;
|
||||||
|
|
||||||
|
void writeFile();
|
||||||
|
|
||||||
void createExperimentFile();
|
void createExperimentFile();
|
||||||
void writeExperimentFile(const CommonData&);
|
void writeExperimentFile(const CommonData&);
|
||||||
void close();
|
void close();
|
||||||
@ -26,5 +24,6 @@ void readExperimentFile(const QString fileName,QVector<Global::ExperimentData>&)
|
|||||||
|
|
||||||
void test();
|
void test();
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
2
src/data/txthandler.cpp
Normal file
2
src/data/txthandler.cpp
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#include "txthandler.h"
|
||||||
|
|
||||||
8
src/data/txthandler.h
Normal file
8
src/data/txthandler.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef TXTHANDLER_H
|
||||||
|
#define TXTHANDLER_H
|
||||||
|
|
||||||
|
namespace TxtHandler {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TXTHANDLER_H
|
||||||
@ -3,33 +3,39 @@
|
|||||||
|
|
||||||
void XlsxHandler::test()
|
void XlsxHandler::test()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
QString sourceFilePath = QDir::currentPath() + "/sample.xlsx";
|
QString sourceFilePath = QDir::currentPath() + "/sample.xlsx";
|
||||||
qDebug() << "fileName:" << sourceFilePath;
|
qDebug() << "fileName:" << sourceFilePath;
|
||||||
readFile(sourceFilePath);
|
readFile(sourceFilePath);
|
||||||
|
#endif
|
||||||
|
QString sourceFilePath = QDir::currentPath() + "/sample-save.xlsx";
|
||||||
|
writeFile(sourceFilePath);
|
||||||
}
|
}
|
||||||
void XlsxHandler::readFile(const QString sourceFilePath)
|
int XlsxHandler::readFile(const QString sourceFilePath, Global::CurveFileData &cfd)
|
||||||
{
|
{
|
||||||
// 检查文件是否存在
|
|
||||||
if(!QFile::exists(sourceFilePath))
|
if(!QFile::exists(sourceFilePath))
|
||||||
{
|
{
|
||||||
qDebug() << "xlsx file not existed:" << sourceFilePath;
|
qDebug() << "xlsx file not existed:" << sourceFilePath;
|
||||||
return;
|
return 1;
|
||||||
|
}
|
||||||
|
QFileInfo fileInfo(sourceFilePath);
|
||||||
|
|
||||||
|
// 获取文件的后缀名并转换为小写,方便比较
|
||||||
|
QString fileSuffix = fileInfo.suffix().toLower();
|
||||||
|
|
||||||
|
// 判断后缀名是否为 "xlsx"
|
||||||
|
if (fileSuffix != "xlsx") {
|
||||||
|
std::cout << "该文件的后缀不是 xlsx" << std::endl;
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 尝试打开文件
|
|
||||||
QXlsx::Document xlsx(sourceFilePath);
|
QXlsx::Document xlsx(sourceFilePath);
|
||||||
|
|
||||||
#if 0
|
|
||||||
// 获取所有工作表名称
|
|
||||||
QStringList sheetNames = xlsx.sheetNames();
|
|
||||||
qDebug() << "工作表名称:" << sheetNames;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QXlsx::Worksheet *workSheet = xlsx.currentWorksheet();
|
QXlsx::Worksheet *workSheet = xlsx.currentWorksheet();
|
||||||
if(!workSheet)
|
if(!workSheet)
|
||||||
{
|
{
|
||||||
qDebug() << "current sheet is empty.";
|
logde << "current sheet is empty.";
|
||||||
return;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取工作表的行数和列数
|
// 获取工作表的行数和列数
|
||||||
@ -40,9 +46,9 @@ void XlsxHandler::readFile(const QString sourceFilePath)
|
|||||||
logde << "0:" << workSheet->cellAt(1, 1)->value().toString().toStdString();
|
logde << "0:" << workSheet->cellAt(1, 1)->value().toString().toStdString();
|
||||||
qDebug() << workSheet->cellAt(1, 1)->value().toString();
|
qDebug() << workSheet->cellAt(1, 1)->value().toString();
|
||||||
|
|
||||||
|
//
|
||||||
int index = 2;
|
int index = 2;
|
||||||
Global::ExperimentInfo ei;
|
Global::ExperimentInfo& ei = cfd.ei;
|
||||||
ei.sampleName = workSheet->cellAt(index++, 2)->value().toString();
|
ei.sampleName = workSheet->cellAt(index++, 2)->value().toString();
|
||||||
ei.sampleWeight = workSheet->cellAt(index++, 2)->value().toString();
|
ei.sampleWeight = workSheet->cellAt(index++, 2)->value().toString();
|
||||||
index++; // skip crucible weight.
|
index++; // skip crucible weight.
|
||||||
@ -51,7 +57,7 @@ void XlsxHandler::readFile(const QString sourceFilePath)
|
|||||||
index++; // skip measure type.
|
index++; // skip measure type.
|
||||||
ei.phaseSize = workSheet->cellAt(index++, 2)->value().toInt();
|
ei.phaseSize = workSheet->cellAt(index++, 2)->value().toInt();
|
||||||
|
|
||||||
QVector<Global::PhaseTotalInfo> phaseTotalVtr;
|
QVector<Global::PhaseTotalInfo>& phaseTotalVtr = cfd.phaseTotalVtr;
|
||||||
int startLineIndex = 9;
|
int startLineIndex = 9;
|
||||||
for(int i = 0; i < ei.phaseSize; i++)
|
for(int i = 0; i < ei.phaseSize; i++)
|
||||||
{
|
{
|
||||||
@ -61,6 +67,7 @@ void XlsxHandler::readFile(const QString sourceFilePath)
|
|||||||
readPhaseData(workSheet, startLineIndex, phaseTotal);
|
readPhaseData(workSheet, startLineIndex, phaseTotal);
|
||||||
phaseTotalVtr.push_back(phaseTotal);
|
phaseTotalVtr.push_back(phaseTotal);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XlsxHandler::readPhaseData(QXlsx::Worksheet *workSheet, int &startLineIndex,
|
void XlsxHandler::readPhaseData(QXlsx::Worksheet *workSheet, int &startLineIndex,
|
||||||
@ -90,14 +97,15 @@ void XlsxHandler::readPhaseData(QXlsx::Worksheet *workSheet, int &startLineIndex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void XlsxHandler::writeFile()
|
void XlsxHandler::writeFile(const QString filePath)
|
||||||
{
|
{
|
||||||
Global::ExperimentInfo& ei = Global::_experimentInfo;
|
Global::ExperimentInfo& ei = Global::_experimentInfo;
|
||||||
|
|
||||||
QXlsx::Document xlsx;
|
QXlsx::Document xlsx;
|
||||||
xlsx.addSheet("Sheet1"); // 添加一个新的工作表
|
xlsx.addSheet("Sheet1"); // 添加一个新的工作表
|
||||||
|
|
||||||
int row = 0;
|
// Write experiment info.
|
||||||
|
int row = 1;
|
||||||
xlsx.write(row++ , 1, ConFileDataInfo);
|
xlsx.write(row++ , 1, ConFileDataInfo);
|
||||||
|
|
||||||
xlsx.write(row , 1, ConSampleName);
|
xlsx.write(row , 1, ConSampleName);
|
||||||
@ -130,7 +138,7 @@ void XlsxHandler::writeFile()
|
|||||||
xlsx.write(row , 2, ei.phaseVtr.size());
|
xlsx.write(row , 2, ei.phaseVtr.size());
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
// write phase data
|
// Write phase data.
|
||||||
int dataSizeRow = 0;
|
int dataSizeRow = 0;
|
||||||
for(int i = 0; i < ei.phaseVtr.size();i++){
|
for(int i = 0; i < ei.phaseVtr.size();i++){
|
||||||
const Phase& phase = ei.phaseVtr.at(i);
|
const Phase& phase = ei.phaseVtr.at(i);
|
||||||
@ -176,13 +184,30 @@ void XlsxHandler::writeFile()
|
|||||||
row++;
|
row++;
|
||||||
|
|
||||||
// phase data.
|
// phase data.
|
||||||
|
|
||||||
|
const QVector<Global::ExperimentData>& edVtr =
|
||||||
|
Global::_curveExperimentDataVtr.at(i).dataVtr;
|
||||||
|
// phase data size.
|
||||||
dataSizeRow = row;
|
dataSizeRow = row;
|
||||||
xlsx.write(row , 1, ConPhaseDataSize);
|
xlsx.write(row , 1, ConPhaseDataSize);
|
||||||
xlsx.write(row , 2, 0);
|
xlsx.write(row , 2, edVtr.size());
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
|
for(int index = 0;index < edVtr.size();index++){
|
||||||
|
const Global::ExperimentData & ed = edVtr.at(index);
|
||||||
|
|
||||||
|
xlsx.write(row , 1, index);
|
||||||
|
xlsx.write(row , 2, ed.runTime);
|
||||||
|
xlsx.write(row , 3, ed.constantTempTime);
|
||||||
|
xlsx.write(row , 4, ed.sampleTemp);
|
||||||
|
xlsx.write(row , 5, ed.dsc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!xlsx.saveAs(filePath)) {
|
||||||
|
logde<<"Save xlsx failed.";
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// 创建一个新的 Excel 文档
|
// 创建一个新的 Excel 文档
|
||||||
@ -213,3 +238,4 @@ void XlsxHandler::writeFile()
|
|||||||
return ;
|
return ;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,10 +9,19 @@
|
|||||||
|
|
||||||
namespace XlsxHandler {
|
namespace XlsxHandler {
|
||||||
void test();
|
void test();
|
||||||
void readFile(const QString filePath);
|
/**
|
||||||
|
* @brief readFile
|
||||||
|
* @param filePath
|
||||||
|
* @return
|
||||||
|
* 0:Succ;
|
||||||
|
* 1:File not existed;
|
||||||
|
* 2:File not xlsx;
|
||||||
|
* 3:Sheet is empty.
|
||||||
|
*/
|
||||||
|
int readFile(const QString filePath,Global::CurveFileData&);
|
||||||
void readPhaseData(QXlsx::Worksheet*,int& startLineIndex,Global::PhaseTotalInfo&);
|
void readPhaseData(QXlsx::Worksheet*,int& startLineIndex,Global::PhaseTotalInfo&);
|
||||||
|
|
||||||
void writeFile();
|
void writeFile(const QString filePath);
|
||||||
|
|
||||||
const QString ConUnitMg = "mg";
|
const QString ConUnitMg = "mg";
|
||||||
const QString ConUnitDegreeCentigrade = "℃";
|
const QString ConUnitDegreeCentigrade = "℃";
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
namespace Global {
|
namespace Global {
|
||||||
ExperimentInfo _experimentInfo;
|
|
||||||
Mode _mode;
|
Mode _mode;
|
||||||
|
|
||||||
QVector<QPair<QCPCurve*,QVector<Global::ExperimentData>>> _curveDataVtr;
|
QVector<CurveFileData> _curveFileDataVtr;
|
||||||
|
|
||||||
|
ExperimentInfo _experimentInfo;
|
||||||
|
QVector<CurveExperimentData> _curveExperimentDataVtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|||||||
39
src/global.h
39
src/global.h
@ -8,6 +8,11 @@
|
|||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
|
||||||
namespace Global {
|
namespace Global {
|
||||||
|
const QString ExperimentDirPath = QDir::currentPath()+"/../experiment_data";
|
||||||
|
const QString SampleDataFloder = ExperimentDirPath + "/sample_data";
|
||||||
|
const QString BaseLineFolder = ExperimentDirPath + "/base_line";
|
||||||
|
const QString AnalysisStateFolder = ExperimentDirPath + "/analysis_state";
|
||||||
|
|
||||||
enum Mode{
|
enum Mode{
|
||||||
Analysis,
|
Analysis,
|
||||||
ConnectedToDev,
|
ConnectedToDev,
|
||||||
@ -50,12 +55,26 @@ struct PhaseTotalInfo{
|
|||||||
int phaseIndex; // from 1 to 6.
|
int phaseIndex; // from 1 to 6.
|
||||||
Phase phase;
|
Phase phase;
|
||||||
QVector<ExperimentData> dataVtr;
|
QVector<ExperimentData> dataVtr;
|
||||||
|
QCPCurve * curve;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
struct CurveFileData{
|
||||||
extern QVector<QPair<QCPCurve*,QVector<Global::ExperimentData>>> _curveDataVtr;
|
Global::ExperimentInfo ei;
|
||||||
extern ExperimentInfo _experimentInfo;
|
QVector<Global::PhaseTotalInfo> phaseTotalVtr;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CurveExperimentData{
|
||||||
|
QCPCurve * curve;
|
||||||
|
QVector<Global::ExperimentData> dataVtr;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Soft mode.
|
||||||
extern Mode _mode;
|
extern Mode _mode;
|
||||||
|
// Xlsx file data.
|
||||||
|
extern QVector<CurveFileData> _curveFileDataVtr;
|
||||||
|
// Experiment setting data.
|
||||||
|
extern ExperimentInfo _experimentInfo;
|
||||||
|
extern QVector<CurveExperimentData> _curveExperimentDataVtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -92,13 +111,13 @@ public:
|
|||||||
float dsc;
|
float dsc;
|
||||||
};
|
};
|
||||||
|
|
||||||
// struct ExpeInfo
|
// struct ExpeInfo
|
||||||
// {
|
// {
|
||||||
// QString sampleName;
|
// QString sampleName;
|
||||||
// float sampleWeight;
|
// float sampleWeight;
|
||||||
// QString date;
|
// QString date;
|
||||||
// QString userName;
|
// QString userName;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
enum TestType{
|
enum TestType{
|
||||||
OIT,
|
OIT,
|
||||||
|
|||||||
@ -22,10 +22,10 @@ int main(int argc, char *argv[])
|
|||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // 启用高DPI缩放
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // 启用高DPI缩放
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
// MainWindow w;
|
MainWindow w;
|
||||||
// w.show();
|
w.show();
|
||||||
|
|
||||||
XlsxHandler::test();
|
// XlsxHandler::test();
|
||||||
|
|
||||||
|
|
||||||
// FileManager::test();
|
// FileManager::test();
|
||||||
|
|||||||
@ -55,8 +55,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
Qt::Dialog);
|
Qt::Dialog);
|
||||||
_OITAutoAnalysisParamForm->setWindowFlags(_OITAutoAnalysisParamForm->windowFlags()|
|
_OITAutoAnalysisParamForm->setWindowFlags(_OITAutoAnalysisParamForm->windowFlags()|
|
||||||
Qt::Dialog);
|
Qt::Dialog);
|
||||||
// _degreeOfCrystallinityForm->setWindowFlags(_degreeOfCrystallinityForm->windowFlags()|
|
// _degreeOfCrystallinityForm->setWindowFlags(_degreeOfCrystallinityForm->windowFlags()|
|
||||||
// Qt::Dialog);
|
// Qt::Dialog);
|
||||||
|
|
||||||
// 设置子窗口为模态对话框
|
// 设置子窗口为模态对话框
|
||||||
_degreeOfCrystallinityForm->setWindowModality(Qt::ApplicationModal);
|
_degreeOfCrystallinityForm->setWindowModality(Qt::ApplicationModal);
|
||||||
@ -87,7 +87,6 @@ MainWindow::~MainWindow()
|
|||||||
// 假设 Ui::MainWindow 不是 QObject 派生类
|
// 假设 Ui::MainWindow 不是 QObject 派生类
|
||||||
delete ui;
|
delete ui;
|
||||||
|
|
||||||
FileManager::close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::slotContextMenuShow(const QPoint point)
|
void MainWindow::slotContextMenuShow(const QPoint point)
|
||||||
@ -116,8 +115,8 @@ void MainWindow::connections()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// mode
|
// mode
|
||||||
// connect(Global::instance(), &Global::sigModeModify,
|
// connect(Global::instance(), &Global::sigModeModify,
|
||||||
// _centralWidget, &CentralWidget::slotModeModify);
|
// _centralWidget, &CentralWidget::slotModeModify);
|
||||||
//analysis
|
//analysis
|
||||||
connect(_leftWidget,&LeftWidget::sigSendAnalysisFileName,
|
connect(_leftWidget,&LeftWidget::sigSendAnalysisFileName,
|
||||||
_centralWidget,&CentralWidget::slotRecvAnalysisFileName);
|
_centralWidget,&CentralWidget::slotRecvAnalysisFileName);
|
||||||
@ -171,9 +170,10 @@ void MainWindow::on_actionStop_triggered()
|
|||||||
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Stop);
|
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Stop);
|
||||||
SerialPort::instance()->slotSendData(ba);
|
SerialPort::instance()->slotSendData(ba);
|
||||||
|
|
||||||
FileManager::close();
|
// Save data.
|
||||||
|
|
||||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
|
||||||
|
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||||
Global::_mode = Global::Mode::Analysis;
|
Global::_mode = Global::Mode::Analysis;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,16 +190,14 @@ void MainWindow::on_actionStart_triggered()
|
|||||||
qDebug() << "on_actionStart_triggered info (hex):" << hexData;
|
qDebug() << "on_actionStart_triggered info (hex):" << hexData;
|
||||||
|
|
||||||
SerialPort::instance()->slotSendData(ba);
|
SerialPort::instance()->slotSendData(ba);
|
||||||
//
|
|
||||||
FileManager::createExperimentFile();
|
|
||||||
|
|
||||||
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
||||||
Global::_mode = Global::Mode::ExperimentStart;
|
Global::_mode = Global::Mode::ExperimentStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionReadOnly_triggered()
|
void MainWindow::on_actionReadOnly_triggered()
|
||||||
{
|
{
|
||||||
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
||||||
Global::_mode = Global::Mode::ExperimentStart;
|
Global::_mode = Global::Mode::ExperimentStart;
|
||||||
SerialPort::instance()->openSp();
|
SerialPort::instance()->openSp();
|
||||||
}
|
}
|
||||||
@ -214,7 +212,7 @@ void MainWindow::on_actionConnectToDev_triggered()
|
|||||||
if (SerialPort::instance()->openSp())
|
if (SerialPort::instance()->openSp())
|
||||||
{
|
{
|
||||||
setActionEnable(true);
|
setActionEnable(true);
|
||||||
// Global::instance()->setMode(Global::Mode::ConnectedToDev);
|
// Global::instance()->setMode(Global::Mode::ConnectedToDev);
|
||||||
Global::_mode = Global::Mode::ConnectedToDev;
|
Global::_mode = Global::Mode::ConnectedToDev;
|
||||||
|
|
||||||
QByteArray ba = DataParser::inquirePhaseInfo();
|
QByteArray ba = DataParser::inquirePhaseInfo();
|
||||||
@ -274,7 +272,7 @@ void MainWindow::on_actionSpecificHeatCompMethod_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionDegreeOfCrystallinity_triggered()
|
void MainWindow::on_actionDegreeOfCrystallinity_triggered()
|
||||||
{
|
{
|
||||||
// QMessageBox::warning(this, "warnning", "结晶度.");
|
// QMessageBox::warning(this, "warnning", "结晶度.");
|
||||||
_degreeOfCrystallinityForm->show();
|
_degreeOfCrystallinityForm->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ AnalysisSettingForm::AnalysisSettingForm(QWidget *parent) :
|
|||||||
|
|
||||||
QFormLayout *editLayout = new QFormLayout();
|
QFormLayout *editLayout = new QFormLayout();
|
||||||
editLayout->addRow("左边界:",_leftBorderSpinBox);
|
editLayout->addRow("左边界:",_leftBorderSpinBox);
|
||||||
editLayout->addRow("有边界:",_rightBorderSpinBox);
|
editLayout->addRow("右边界:",_rightBorderSpinBox);
|
||||||
editLayout->addRow("阈值:",_thresholdLineEdit);
|
editLayout->addRow("阈值:",_thresholdLineEdit);
|
||||||
|
|
||||||
QGridLayout *buttonLayout = new QGridLayout();
|
QGridLayout *buttonLayout = new QGridLayout();
|
||||||
@ -40,9 +40,9 @@ AnalysisSettingForm::AnalysisSettingForm(QWidget *parent) :
|
|||||||
layout->addLayout(editLayout);
|
layout->addLayout(editLayout);
|
||||||
layout->addSpacerItem(spacer);
|
layout->addSpacerItem(spacer);
|
||||||
layout->addLayout(buttonLayout);
|
layout->addLayout(buttonLayout);
|
||||||
layout->addLayout(editLayout);
|
// layout->addLayout(editLayout);
|
||||||
// layout->setSpacing(1);
|
// layout->setSpacing(1);
|
||||||
layout->addLayout(buttonLayout);
|
// layout->addLayout(buttonLayout);
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
//
|
//
|
||||||
#if 0
|
#if 0
|
||||||
|
|||||||
@ -8,10 +8,11 @@
|
|||||||
#include "filemanager.h"
|
#include "filemanager.h"
|
||||||
#include "pointcalculate.h"
|
#include "pointcalculate.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "xlsxhandler.h"
|
||||||
|
|
||||||
CentralWidget::CentralWidget(QWidget *parent)
|
CentralWidget::CentralWidget(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent)
|
||||||
_customPlot(new QCustomPlot(this))
|
,_customPlot(new QCustomPlot(this))
|
||||||
,_analysisMode(AnalysisMode::None)
|
,_analysisMode(AnalysisMode::None)
|
||||||
{
|
{
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
@ -46,7 +47,8 @@ CentralWidget::CentralWidget(QWidget *parent)
|
|||||||
|
|
||||||
_customPlot->installEventFilter(_eventHandler);
|
_customPlot->installEventFilter(_eventHandler);
|
||||||
// _customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
|
// _customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
|
||||||
_customPlot->setInteractions( QCP::iRangeZoom | QCP::iSelectPlottables);
|
// _customPlot->setInteractions( QCP::iRangeZoom | QCP::iSelectPlottables);
|
||||||
|
_customPlot->setInteractions(QCP::iSelectPlottables);
|
||||||
|
|
||||||
connect(_eventHandler,&EventHandler::sigSendLineXCoord,
|
connect(_eventHandler,&EventHandler::sigSendLineXCoord,
|
||||||
this,&CentralWidget::sigSendLineXCoord);
|
this,&CentralWidget::sigSendLineXCoord);
|
||||||
@ -75,7 +77,6 @@ CentralWidget::CentralWidget(QWidget *parent)
|
|||||||
|
|
||||||
CentralWidget::~CentralWidget()
|
CentralWidget::~CentralWidget()
|
||||||
{
|
{
|
||||||
FileManager::close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CentralWidget::setAnalysisMode(const CentralWidget::AnalysisMode mode)
|
void CentralWidget::setAnalysisMode(const CentralWidget::AnalysisMode mode)
|
||||||
@ -121,7 +122,6 @@ void CentralWidget::slotModeModify(const Global::Mode mode)
|
|||||||
else if (Global::Mode::Analysis == mode)
|
else if (Global::Mode::Analysis == mode)
|
||||||
{
|
{
|
||||||
qDebug() << "file close...";
|
qDebug() << "file close...";
|
||||||
FileManager::close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,15 +131,25 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
|||||||
|
|
||||||
if(!_currentCurve){
|
if(!_currentCurve){
|
||||||
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
|
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
|
||||||
|
|
||||||
Global::_curveDataVtr.clear();
|
|
||||||
|
|
||||||
Global::_curveDataVtr.push_back(qMakePair<QCPCurve*, QVector<Global::ExperimentData>>(
|
|
||||||
_currentCurve, QVector<Global::ExperimentData>()
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
// Update curve.
|
||||||
|
_currentCurve->addData(cd.sample_temp, cd.dsc);
|
||||||
|
|
||||||
QVector<Global::ExperimentData>& edVtr = Global::_curveDataVtr.first().second;
|
_customPlot->rescaleAxes();
|
||||||
|
_customPlot->replot();
|
||||||
|
|
||||||
|
// Record data.
|
||||||
|
QVector<Global::ExperimentData>* pEdVtr = nullptr; // 声明指针变量
|
||||||
|
for(auto item:Global::_curveExperimentDataVtr){
|
||||||
|
if(item.curve == _currentCurve){
|
||||||
|
pEdVtr = &item.dataVtr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!pEdVtr){
|
||||||
|
Global::_curveExperimentDataVtr.push_back({_currentCurve, {}});
|
||||||
|
pEdVtr = &Global::_curveExperimentDataVtr.back().dataVtr;
|
||||||
|
}
|
||||||
|
|
||||||
Global::ExperimentData ed;
|
Global::ExperimentData ed;
|
||||||
ed.dsc = cd .dsc;
|
ed.dsc = cd .dsc;
|
||||||
@ -147,19 +157,7 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
|||||||
ed.runTime = cd.add_run_time;
|
ed.runTime = cd.add_run_time;
|
||||||
ed.constantTempTime = cd.add_constan_temp_time;
|
ed.constantTempTime = cd.add_constan_temp_time;
|
||||||
|
|
||||||
edVtr.push_back(ed);
|
pEdVtr->push_back(ed);
|
||||||
|
|
||||||
_currentCurve->addData(cd.sample_temp, cd.dsc);
|
|
||||||
|
|
||||||
// customPlot->xAxis->rescale();
|
|
||||||
// customPlot->yAxis->rescale();
|
|
||||||
|
|
||||||
// _customPlot->graph(0)->addData(cd.sample_temp, cd.dsc); // 添加数据到曲线
|
|
||||||
|
|
||||||
_customPlot->rescaleAxes();
|
|
||||||
_customPlot->replot();
|
|
||||||
//
|
|
||||||
FileManager::writeExperimentFile(cd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
||||||
@ -167,18 +165,13 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
|||||||
qDebug() << "slotRecvAnalysisFileName" << fileName;
|
qDebug() << "slotRecvAnalysisFileName" << fileName;
|
||||||
|
|
||||||
// todo.禁止重复文件添加。
|
// todo.禁止重复文件添加。
|
||||||
|
Global::CurveFileData cfd;
|
||||||
|
XlsxHandler::readFile(fileName,cfd);
|
||||||
|
|
||||||
_dataVtr.clear();
|
for(int i = 0;i < cfd.phaseTotalVtr.size();i++){
|
||||||
FileManager::readExperimentFile(fileName, _dataVtr);
|
Global::PhaseTotalInfo& pti = cfd.phaseTotalVtr[i];
|
||||||
|
|
||||||
if (_dataVtr.size() < 0)
|
PointCalculate::setExperimentData(pti.dataVtr);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// _customPlot->xAxis->setRange(0, 500);
|
|
||||||
// _customPlot->yAxis->setRange(-20, 20);
|
|
||||||
PointCalculate::setExperimentData(_dataVtr);
|
|
||||||
QPair<QPointF,QPointF>startEndPointPair = PointCalculate::getStartAndEndPoint();
|
QPair<QPointF,QPointF>startEndPointPair = PointCalculate::getStartAndEndPoint();
|
||||||
|
|
||||||
QPointF endPoint = startEndPointPair.second;
|
QPointF endPoint = startEndPointPair.second;
|
||||||
@ -194,7 +187,7 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
|||||||
|
|
||||||
QVector<double> tVtr,xVtr, yVtr;
|
QVector<double> tVtr,xVtr, yVtr;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (Global::ExperimentData &ed : _dataVtr)
|
for (Global::ExperimentData &ed : pti.dataVtr)
|
||||||
{
|
{
|
||||||
tVtr.push_back(index++);
|
tVtr.push_back(index++);
|
||||||
xVtr.push_back(ed.sampleTemp);
|
xVtr.push_back(ed.sampleTemp);
|
||||||
@ -208,8 +201,7 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
|||||||
_currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选
|
_currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选
|
||||||
// _currentCurve->setSelectable(QCP::stPlottable); // 设置曲线可选
|
// _currentCurve->setSelectable(QCP::stPlottable); // 设置曲线可选
|
||||||
|
|
||||||
Global::_curveDataVtr.push_back(qMakePair<QCPCurve*,QVector<Global::ExperimentData>>(
|
}
|
||||||
_currentCurve,_dataVtr));
|
|
||||||
|
|
||||||
// 清除第一个图表上的数据
|
// 清除第一个图表上的数据
|
||||||
#if 0
|
#if 0
|
||||||
@ -629,7 +621,7 @@ void CentralWidget::clearData(const CentralWidget::ClearDataMode mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clear data.
|
// Clear data.
|
||||||
Global::_curveDataVtr.clear();
|
Global::_curveExperimentDataVtr.clear();
|
||||||
|
|
||||||
// Set lines visiable false.
|
// Set lines visiable false.
|
||||||
_line1->setVisible(false);
|
_line1->setVisible(false);
|
||||||
|
|||||||
@ -69,7 +69,7 @@ private:
|
|||||||
// QVector<QCPGraph*> _graphVtr;
|
// QVector<QCPGraph*> _graphVtr;
|
||||||
EventHandler* _eventHandler;
|
EventHandler* _eventHandler;
|
||||||
QCPItemStraightLine *_line1,*_line2;
|
QCPItemStraightLine *_line1,*_line2;
|
||||||
QVector<Global::ExperimentData> _dataVtr;
|
// QVector<Global::ExperimentData> _dataVtr;
|
||||||
QVector<QCPItemStraightLine*> _lineVtr;
|
QVector<QCPItemStraightLine*> _lineVtr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,7 @@ ExperimentSettingForm::ExperimentSettingForm(QWidget *parent) : QWidget(parent),
|
|||||||
|
|
||||||
// connect(ui->pushButton_connect_to_device,&QPushButton::clicked,
|
// connect(ui->pushButton_connect_to_device,&QPushButton::clicked,
|
||||||
// this,&ExperimentSettingForm::slotConnectToDevice);
|
// this,&ExperimentSettingForm::slotConnectToDevice);
|
||||||
|
|
||||||
connect(ui->pushButton_cancel, &QPushButton::clicked,
|
connect(ui->pushButton_cancel, &QPushButton::clicked,
|
||||||
this, &ExperimentSettingForm::slotCancel);
|
this, &ExperimentSettingForm::slotCancel);
|
||||||
}
|
}
|
||||||
@ -326,7 +327,7 @@ void ExperimentSettingForm::slotPhase6StateChanged(int state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExperimentSettingForm::slotConnectToDevice()
|
void ExperimentSettingForm::on_pushButton_deliverData_clicked()
|
||||||
{
|
{
|
||||||
QVector<Phase> phaseVtr;
|
QVector<Phase> phaseVtr;
|
||||||
if (ui->checkBox_phase_1->checkState())
|
if (ui->checkBox_phase_1->checkState())
|
||||||
@ -401,11 +402,6 @@ void ExperimentSettingForm::slotConnectToDevice()
|
|||||||
|
|
||||||
phaseVtr.push_back(phase);
|
phaseVtr.push_back(phase);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray ba = DataParser::connectToDevice(phaseVtr);
|
|
||||||
qDebug() << "ba size:" << ba.size();
|
|
||||||
emit sigDeliverData(ba);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
Global::ExperimentInfo& ei = Global::_experimentInfo;
|
Global::ExperimentInfo& ei = Global::_experimentInfo;
|
||||||
ei.phaseVtr = phaseVtr;
|
ei.phaseVtr = phaseVtr;
|
||||||
@ -422,6 +418,10 @@ void ExperimentSettingForm::slotConnectToDevice()
|
|||||||
|
|
||||||
ei.initialAtmosPhere = (GasType)(ui->comboBox_phase_1_atmosphere->currentIndex());
|
ei.initialAtmosPhere = (GasType)(ui->comboBox_phase_1_atmosphere->currentIndex());
|
||||||
|
|
||||||
|
//
|
||||||
|
QByteArray ba = DataParser::connectToDevice(phaseVtr);
|
||||||
|
qDebug() << "ba size:" << ba.size();
|
||||||
|
emit sigDeliverData(ba);
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,16 +484,6 @@ void ExperimentSettingForm::slotPhaseCheck()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExperimentSettingForm::on_pushButton_deliverData_clicked()
|
|
||||||
{
|
|
||||||
slotConnectToDevice();
|
|
||||||
|
|
||||||
FileManager::_expeInfo.sampleName = ui->sampleNameLineEdit->text();
|
|
||||||
FileManager::_expeInfo.sampleWeight = ui->sampleWeightLineEdit->text().toInt(nullptr, 16);
|
|
||||||
FileManager::_expeInfo.date = ui->dateTimeLineEdit->text();
|
|
||||||
FileManager::_expeInfo.experimentor = ui->userLineEdit->text();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExperimentSettingForm::slotRecvPhaseInfo(const QByteArray &ba)
|
void ExperimentSettingForm::slotRecvPhaseInfo(const QByteArray &ba)
|
||||||
{
|
{
|
||||||
QByteArray localba = ba;
|
QByteArray localba = ba;
|
||||||
|
|||||||
@ -37,9 +37,7 @@ private:
|
|||||||
void slotPhase5StateChanged(int state);
|
void slotPhase5StateChanged(int state);
|
||||||
void slotPhase6StateChanged(int state);
|
void slotPhase6StateChanged(int state);
|
||||||
|
|
||||||
void slotConnectToDevice();
|
|
||||||
void slotCancel();
|
void slotCancel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ExperimentSettingForm *ui;
|
Ui::ExperimentSettingForm *ui;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -18,11 +18,6 @@ void InstrumentCoefficientForm::on_pushButtonCalculate_clicked()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstrumentCoefficientForm::on_pushButtonExit_clicked()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void InstrumentCoefficientForm::on_pushButtonCancel_clicked()
|
void InstrumentCoefficientForm::on_pushButtonCancel_clicked()
|
||||||
{
|
{
|
||||||
hide();
|
hide();
|
||||||
|
|||||||
@ -18,8 +18,6 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void on_pushButtonCalculate_clicked();
|
void on_pushButtonCalculate_clicked();
|
||||||
|
|
||||||
void on_pushButtonExit_clicked();
|
|
||||||
|
|
||||||
void on_pushButtonCancel_clicked();
|
void on_pushButtonCancel_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -29,9 +29,9 @@ LeftWidget::LeftWidget(QWidget *parent ): QDockWidget(parent)
|
|||||||
setWidget(_treeWidget);
|
setWidget(_treeWidget);
|
||||||
|
|
||||||
//init file name.
|
//init file name.
|
||||||
initFileName(_sampleDataItem,FileManager::SampleDataFloder);
|
initFileName(_sampleDataItem,Global::SampleDataFloder);
|
||||||
initFileName(_baseLineItem,FileManager::BaseLineFolder);
|
initFileName(_baseLineItem,Global::BaseLineFolder);
|
||||||
initFileName(_analysisStateItem,FileManager::AnalysisStateFolder);
|
initFileName(_analysisStateItem,Global::AnalysisStateFolder);
|
||||||
|
|
||||||
expandAll(_sampleDataItem);
|
expandAll(_sampleDataItem);
|
||||||
expandAll(_baseLineItem);
|
expandAll(_baseLineItem);
|
||||||
@ -88,11 +88,11 @@ void LeftWidget::slotTreeWidgetItemClicked(QTreeWidgetItem *item, int column){
|
|||||||
if (parentItem) {
|
if (parentItem) {
|
||||||
qDebug() << "parent item text:" << parentItem->text(0);
|
qDebug() << "parent item text:" << parentItem->text(0);
|
||||||
if(parentItem == _sampleDataItem){
|
if(parentItem == _sampleDataItem){
|
||||||
fileName =FileManager::SampleDataFloder + "/" + item->text(0);
|
fileName =Global::SampleDataFloder + "/" + item->text(0);
|
||||||
}else if(parentItem == _baseLineItem){
|
}else if(parentItem == _baseLineItem){
|
||||||
fileName =FileManager::BaseLineFolder + "/" +item->text(0);
|
fileName =Global::BaseLineFolder + "/" +item->text(0);
|
||||||
}else if(parentItem == _analysisStateItem){
|
}else if(parentItem == _analysisStateItem){
|
||||||
fileName =FileManager::AnalysisStateFolder + "/" +item->text(0);
|
fileName =Global::AnalysisStateFolder + "/" +item->text(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "item has no parent (it is a top-level item)";
|
qDebug() << "item has no parent (it is a top-level item)";
|
||||||
|
|||||||
@ -82,18 +82,18 @@ void SpecificHeatComparisonMethodForm::slotSetCurve(const int type, QCPCurve *c
|
|||||||
|
|
||||||
void SpecificHeatComparisonMethodForm::on_pushButtonCalculate_clicked()
|
void SpecificHeatComparisonMethodForm::on_pushButtonCalculate_clicked()
|
||||||
{
|
{
|
||||||
auto& curveDataVtr = Global::_curveDataVtr;
|
auto& curveDataVtr = Global::_curveExperimentDataVtr;
|
||||||
QVector<Global::ExperimentData> *baseLineDataVtr = nullptr,
|
QVector<Global::ExperimentData> *baseLineDataVtr = nullptr,
|
||||||
*standardSampleDataVtr = nullptr,
|
*standardSampleDataVtr = nullptr,
|
||||||
*sampleDataVtr = nullptr;
|
*sampleDataVtr = nullptr;
|
||||||
|
|
||||||
for (auto& pair : curveDataVtr) {
|
for (auto& item : curveDataVtr) {
|
||||||
if(pair.first == _baseLineCurve){
|
if(item.curve == _baseLineCurve){
|
||||||
baseLineDataVtr = &(pair.second);
|
baseLineDataVtr = &(item.dataVtr);
|
||||||
}else if(pair.first == _standardSampleCurve){
|
}else if(item.curve == _standardSampleCurve){
|
||||||
standardSampleDataVtr = &(pair.second);
|
standardSampleDataVtr = &(item.dataVtr);
|
||||||
}else if(pair.first == _sampleCurve){
|
}else if(item.curve == _sampleCurve){
|
||||||
sampleDataVtr = &(pair.second);
|
sampleDataVtr = &(item.dataVtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user