2025-04-22T16:59:26
This commit is contained in:
parent
58ccb873f1
commit
ed67bf9287
Binary file not shown.
BIN
experiment_data/sample_data/1111new.xlsx
Normal file
BIN
experiment_data/sample_data/1111new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/sample_data/22new.xlsx
Normal file
BIN
experiment_data/sample_data/22new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/sample_data/333new.xlsx
Normal file
BIN
experiment_data/sample_data/333new.xlsx
Normal file
Binary file not shown.
BIN
experiment_data/sample_data/new.xlsx
Normal file
BIN
experiment_data/sample_data/new.xlsx
Normal file
Binary file not shown.
@ -4,6 +4,9 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
CONFIG+=precompile_header
|
||||
PRECOMPILED_HEADER=stable.h
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
|
@ -476,7 +476,6 @@ QString PointCalculate::textFormatEndPoint(const QPointF point)
|
||||
).arg(QString::number(point.x(), 'f', 3));
|
||||
}
|
||||
|
||||
|
||||
QPointF PointCalculate::getClosestPointByY(const double left,const double right,const double valueY)
|
||||
{
|
||||
double minValue = std::numeric_limits<double>::infinity(); // 初始化为正无穷
|
||||
@ -484,7 +483,7 @@ QPointF PointCalculate::getClosestPointByY(const double left,const double right,
|
||||
|
||||
for (const Global::ExperimentData& ed : _dataVtr) {
|
||||
if (left < ed.sampleTemp && ed.sampleTemp < right) {
|
||||
float diff = std::abs(ed.dsc - valueY);
|
||||
double diff = std::abs(ed.dsc - valueY);
|
||||
if (diff < minValue) {
|
||||
minValue = diff;
|
||||
closestPoint = QPointF(ed.sampleTemp, ed.dsc);
|
||||
|
@ -19,7 +19,7 @@ enum Mode{
|
||||
Analysis,
|
||||
ConnectedToDev,
|
||||
DeliveredData,
|
||||
ExperimentStart
|
||||
Experiment
|
||||
};
|
||||
|
||||
enum DeviceConnectionStatus{
|
||||
@ -79,9 +79,9 @@ extern QVector<CurveFileData> _curveFileDataVtr;
|
||||
extern ExperimentInfo _experimentInfo;
|
||||
extern QVector<CurveExperimentData> _curveExperimentDataVtr;
|
||||
|
||||
//
|
||||
// Instrument coefficient.
|
||||
extern bool _enthalpyCoefficientEnableFlag;
|
||||
//abc
|
||||
///abc
|
||||
extern QVector<double> _enthalpyCoefficientVtr;
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "serialport.h"
|
||||
#include "dataparser.h"
|
||||
#include "filemanager.h"
|
||||
#include "logger.h"
|
||||
#include "xlsxhandler.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent),
|
||||
@ -82,6 +84,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
_eventHandler = _centralWidget->getEvnetHandler();
|
||||
//
|
||||
connections();
|
||||
//
|
||||
// ui->actionStop->setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
@ -90,7 +94,6 @@ MainWindow::~MainWindow()
|
||||
// 删除非QObject派生类的对象
|
||||
// 假设 Ui::MainWindow 不是 QObject 派生类
|
||||
delete ui;
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::slotContextMenuShow(const QPoint point)
|
||||
@ -156,6 +159,7 @@ void MainWindow::connections()
|
||||
connect(_eventHandler,&EventHandler::sigSetCurve,
|
||||
_specificHeatComparisonMethodForm,
|
||||
&SpecificHeatComparisonMethodForm::slotSetCurve);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::setActionEnable(const bool flag)
|
||||
@ -184,16 +188,44 @@ void MainWindow::setSubWidgetAttribute(QWidget *widget)
|
||||
widget->setFixedSize(widget->geometry().width(),widget->geometry().height());
|
||||
}
|
||||
|
||||
bool MainWindow::saveExperimentFile(const QString fileName)
|
||||
{
|
||||
QString localFileName = fileName;
|
||||
if(fileName.isEmpty()){
|
||||
localFileName = "new";
|
||||
}
|
||||
QString xlsxfilePath = Global::SampleDataFloder + "/" + localFileName + ".xlsx";
|
||||
QString filePath = QFileDialog::getSaveFileName(nullptr, "Save experiment file",
|
||||
xlsxfilePath, "Excel Files (*.xlsx)");
|
||||
logde<<"filePath:"<<filePath.toStdString();
|
||||
|
||||
if (filePath.isEmpty()) {
|
||||
qDebug() << "User cancel the operation.";
|
||||
return false;
|
||||
}
|
||||
|
||||
XlsxHandler::writeFile(filePath);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionStop_triggered()
|
||||
{
|
||||
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Stop);
|
||||
SerialPort::instance()->slotSendData(ba);
|
||||
if(Global::_mode == Global::Mode::Experiment)
|
||||
{
|
||||
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Stop);
|
||||
SerialPort::instance()->slotSendData(ba);
|
||||
|
||||
// Save data.
|
||||
#if 0
|
||||
// Save data.
|
||||
if(saveExperimentFile(Global::_experimentInfo.sampleName)){
|
||||
_leftWidget->reloadFileName();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||
Global::_mode = Global::Mode::Analysis;
|
||||
// Set software mode to analysis.
|
||||
Global::_mode = Global::Mode::Analysis;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionNew_triggered()
|
||||
@ -210,14 +242,14 @@ void MainWindow::on_actionStart_triggered()
|
||||
|
||||
SerialPort::instance()->slotSendData(ba);
|
||||
|
||||
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
||||
Global::_mode = Global::Mode::ExperimentStart;
|
||||
Global::_mode = Global::Mode::Experiment;
|
||||
|
||||
logde<<"start experiment,set soft into experiment mode.";
|
||||
}
|
||||
|
||||
void MainWindow::on_actionReadOnly_triggered()
|
||||
{
|
||||
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
||||
Global::_mode = Global::Mode::ExperimentStart;
|
||||
Global::_mode = Global::Mode::Experiment;
|
||||
SerialPort::instance()->openSp();
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ private slots:
|
||||
void on_actionStop_triggered();
|
||||
void on_actionReadOnly_triggered();
|
||||
void on_actionRealTimeWidget_triggered();
|
||||
|
||||
//analysis
|
||||
void on_actionNumericalLabel_triggered();
|
||||
void on_actionStartPoint_triggered();
|
||||
@ -84,6 +85,7 @@ private:
|
||||
void connections();
|
||||
void setActionEnable(const bool);
|
||||
void setSubWidgetAttribute(QWidget *);
|
||||
bool saveExperimentFile(const QString fileName);
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
CentralWidget *_centralWidget;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "dataparser.h"
|
||||
#include "defines.h"
|
||||
#include "global.h"
|
||||
#include "logger.h"
|
||||
|
||||
namespace DataParser
|
||||
{
|
||||
@ -183,7 +184,8 @@ namespace DataParser
|
||||
case DeviceRunStatus::Idle:
|
||||
case DeviceRunStatus::Cooling:
|
||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||
Global::_mode = Global::Mode::Analysis;
|
||||
// Global::_mode = Global::Mode::Analysis;
|
||||
// logde<<"Device into cooling status,then set the software into annlysis mode.";
|
||||
return true;
|
||||
break;
|
||||
default:break;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "defines.h"
|
||||
#include "dataparser.h"
|
||||
#include "global.h"
|
||||
#include "logger.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -132,11 +133,11 @@ void SerialPort::slotReadData()
|
||||
// read data
|
||||
if (spp->addr == 0)
|
||||
{
|
||||
if (Global::Mode::ExperimentStart == Global::_mode)
|
||||
if (Global::Mode::Experiment == Global::_mode)
|
||||
{
|
||||
emit sigSendCommonData(cd);
|
||||
}
|
||||
// emit sigSendCommonDataToRealDataForm(cd);
|
||||
emit sigSendCommonDataToRealDataForm(cd);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -174,6 +175,7 @@ void SerialPort::commonDataParser(const int dataLength, const u16 addr,
|
||||
case DeviceRunStatus::Cooling:
|
||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||
Global::_mode = Global::Mode::Analysis;
|
||||
logde<<"set global mode analysis.common data parser.";
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
@ -201,10 +203,11 @@ void SerialPort::commonDataParser(const int dataLength, const u16 addr,
|
||||
case DeviceStartMode::Stop:
|
||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||
Global::_mode = Global::Mode::Analysis;
|
||||
logde<<"set global mode analysis.";
|
||||
break;
|
||||
case DeviceStartMode::Start:
|
||||
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
||||
Global::_mode = Global::Mode::ExperimentStart;
|
||||
Global::_mode = Global::Mode::Experiment;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
46
src/stable.h
Normal file
46
src/stable.h
Normal file
@ -0,0 +1,46 @@
|
||||
// #ifndef STABLE_H //Qt官方例子没有定义这个条件编译
|
||||
// #define STABLE_H
|
||||
|
||||
// Add C includes here
|
||||
#include <iostream>
|
||||
|
||||
#if defined __cplusplus
|
||||
// Add C++ includes here
|
||||
#include <vector>
|
||||
|
||||
// Qt includes
|
||||
#include <QApplication>
|
||||
// #include <QtCore> //请谨慎包含
|
||||
// #include <QtGui> //请谨慎包含
|
||||
#include <QObject>
|
||||
#include <qglobal.h>
|
||||
#include <QDir>
|
||||
#include <QIntValidator>
|
||||
#include <QToolTip>
|
||||
#include <QDebug>
|
||||
#include <QMainWindow>
|
||||
#include <QDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QTimer>
|
||||
//#include <QtNetwork>
|
||||
#include <QTextCodec>
|
||||
#include <QThread>
|
||||
//#include <QtSql>
|
||||
#if (QT_VERSION > QT_VERSION_CHECK(5,0,0))
|
||||
#include <QtWidgets>
|
||||
#endif
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsItem>
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QGraphicsSceneWheelEvent>
|
||||
|
||||
// Other
|
||||
//#include "thirdparty/include/libmain.h"
|
||||
//#include "my_stable_class.h"
|
||||
|
||||
#endif //__cplusplus
|
||||
// #endif // STABLE_H
|
@ -74,6 +74,14 @@ CentralWidget::CentralWidget(QWidget *parent)
|
||||
_customPlot->replot();
|
||||
#endif
|
||||
// startTimer(1000);
|
||||
|
||||
|
||||
// 设置坐标轴标签
|
||||
_customPlot->xAxis->setLabel("Temp/℃");
|
||||
_customPlot->yAxis->setLabel("DSC/mW");
|
||||
// 设置坐标轴范围,以便我们可以看到全部数据
|
||||
_customPlot->xAxis->setRange(0, 400);
|
||||
_customPlot->yAxis->setRange(-50, 50);
|
||||
}
|
||||
|
||||
CentralWidget::~CentralWidget()
|
||||
@ -100,7 +108,7 @@ void CentralWidget::setAnalysisMode(const CentralWidget::AnalysisMode mode)
|
||||
|
||||
void CentralWidget::slotModeModify(const Global::Mode mode)
|
||||
{
|
||||
if (Global::Mode::ExperimentStart == mode)
|
||||
if (Global::Mode::Experiment == mode)
|
||||
{
|
||||
#if 0
|
||||
if (_customPlot->graphCount() > 0 && _currentGraph)
|
||||
@ -130,11 +138,20 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
||||
{
|
||||
qDebug() << "slotRevCommonData";
|
||||
|
||||
static double index = 0.0;
|
||||
|
||||
if(!_currentCurve){
|
||||
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
|
||||
}
|
||||
// Update curve.
|
||||
_currentCurve->addData(cd.sample_temp, cd.dsc);
|
||||
// _currentCurve->addData(cd.sample_temp, cd.dsc);
|
||||
_currentCurve->addData(index++,cd.sample_temp, cd.dsc);
|
||||
// _currentCurve->data()->add(QCPCurveData(index++, cd.sample_temp, cd.dsc));
|
||||
|
||||
|
||||
// 设置曲线数据
|
||||
// _currentCurve->setData(data);
|
||||
|
||||
|
||||
_customPlot->rescaleAxes();
|
||||
_customPlot->replot();
|
||||
|
@ -13,18 +13,18 @@ LeftWidget::LeftWidget(QWidget *parent ): QDockWidget(parent)
|
||||
_treeWidget = new QTreeWidget();
|
||||
_treeWidget->setHeaderHidden(true);
|
||||
|
||||
_analysisStateItem = new QTreeWidgetItem(_treeWidget);
|
||||
_analysisStateItem->setText(0,"分析状态");
|
||||
_baseLineItem = new QTreeWidgetItem(_treeWidget);
|
||||
_baseLineItem->setText(0,"基线");
|
||||
_sampleDataItem = new QTreeWidgetItem(_treeWidget);
|
||||
_sampleDataItem->setText(0,"样品数据");
|
||||
_baseLineItem = new QTreeWidgetItem(_treeWidget);
|
||||
_baseLineItem->setText(0,"基线");
|
||||
_analysisStateItem = new QTreeWidgetItem(_treeWidget);
|
||||
_analysisStateItem->setText(0,"分析状态");
|
||||
|
||||
_treeWidget->setSortingEnabled(false);
|
||||
|
||||
_treeWidget->addTopLevelItem(_sampleDataItem);
|
||||
_treeWidget->addTopLevelItem(_baseLineItem);
|
||||
_treeWidget->addTopLevelItem(_analysisStateItem);
|
||||
_treeWidget->insertTopLevelItem(0, _sampleDataItem);
|
||||
_treeWidget->insertTopLevelItem(1, _baseLineItem);
|
||||
_treeWidget->insertTopLevelItem(2, _analysisStateItem);
|
||||
|
||||
setWidget(_treeWidget);
|
||||
|
||||
@ -42,9 +42,21 @@ LeftWidget::LeftWidget(QWidget *parent ): QDockWidget(parent)
|
||||
this,&LeftWidget::slotTreeWidgetItemClicked);
|
||||
}
|
||||
|
||||
void LeftWidget::reloadFileName()
|
||||
{
|
||||
clearAllChildItems(_sampleDataItem);
|
||||
clearAllChildItems(_baseLineItem);
|
||||
clearAllChildItems(_analysisStateItem);
|
||||
|
||||
initFileName(_sampleDataItem,Global::SampleDataFloder);
|
||||
initFileName(_baseLineItem,Global::BaseLineFolder);
|
||||
initFileName(_analysisStateItem,Global::AnalysisStateFolder);
|
||||
}
|
||||
|
||||
void LeftWidget::initData()
|
||||
{
|
||||
const QString folderPath = QDir::currentPath()+"/../experiment_data";
|
||||
// const QString folderPath = QDir::currentPath()+"/../experiment_data";
|
||||
const QString folderPath = Global::SampleDataFloder;
|
||||
#if 1
|
||||
QDir dir(folderPath);
|
||||
if (!dir.exists()) {
|
||||
@ -111,16 +123,6 @@ void LeftWidget::initFileName(QTreeWidgetItem* parentItem,const QString &folderP
|
||||
// _sampleDataItem->addChild(new QTreeWidgetItem(0,fileName));
|
||||
parentItem->addChild(subItem);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// 获取文件夹中的所有文件名
|
||||
QStringList files = dir.entryList(QDir::Files); // 只列出文件
|
||||
qDebug() << "Files in the current directory:";
|
||||
foreach (const QString &fileName, files)
|
||||
{
|
||||
qDebug() << fileName;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void LeftWidget::expandAll(QTreeWidgetItem* item) {
|
||||
@ -130,6 +132,15 @@ void LeftWidget::expandAll(QTreeWidgetItem* item) {
|
||||
}
|
||||
}
|
||||
|
||||
void LeftWidget::clearAllChildItems(QTreeWidgetItem *parentItem)
|
||||
{
|
||||
int childCount = parentItem->childCount();
|
||||
for (int i = 0; i < childCount; ++i) {
|
||||
QTreeWidgetItem* childItem = parentItem->takeChild(0);
|
||||
delete childItem;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void LeftWidget::recursiveFolderOperation(const QString& folderPath) {
|
||||
QDir dir(folderPath);
|
||||
|
@ -11,12 +11,15 @@ class LeftWidget:public QDockWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
LeftWidget(QWidget *parent = nullptr);
|
||||
|
||||
void reloadFileName();
|
||||
signals:
|
||||
void sigSendAnalysisFileName(const QString&);
|
||||
private:
|
||||
void initData();
|
||||
void initFileName(QTreeWidgetItem*,const QString &folderPath);
|
||||
void expandAll(QTreeWidgetItem* item);
|
||||
signals:
|
||||
void sigSendAnalysisFileName(const QString&);
|
||||
void clearAllChildItems(QTreeWidgetItem* parentItem);
|
||||
protected:
|
||||
private slots:
|
||||
void slotTreeWidgetItemClicked(QTreeWidgetItem *item, int column);
|
||||
|
Loading…
Reference in New Issue
Block a user