2025-03-10T17:35:07

This commit is contained in:
yuntang 2025-03-10 17:35:07 +08:00
parent c445ee422a
commit b6c5cc3d33
43 changed files with 6192 additions and 142 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5,10 +5,14 @@ debug/mainwindow.o
debug/dataparser.o debug/dataparser.o
debug/serialport.o debug/serialport.o
debug/qcustomplot.o debug/qcustomplot.o
debug/experimentsettingform.o
debug/leftwidget.o
debug/realtimedataform.o debug/realtimedataform.o
debug/moc_centralwidget.o debug/moc_centralwidget.o
debug/moc_mainwidget.o debug/moc_mainwidget.o
debug/moc_mainwindow.o debug/moc_mainwindow.o
debug/moc_serialport.o debug/moc_serialport.o
debug/moc_qcustomplot.o debug/moc_qcustomplot.o
debug/moc_experimentsettingform.o
debug/moc_leftwidget.o
debug/moc_realtimedataform.o debug/moc_realtimedataform.o

View File

@ -5,10 +5,14 @@ release/mainwindow.o
release/dataparser.o release/dataparser.o
release/serialport.o release/serialport.o
release/qcustomplot.o release/qcustomplot.o
release/experimentsettingform.o
release/leftwidget.o
release/realtimedataform.o release/realtimedataform.o
release/moc_centralwidget.o release/moc_centralwidget.o
release/moc_mainwidget.o release/moc_mainwidget.o
release/moc_mainwindow.o release/moc_mainwindow.o
release/moc_serialport.o release/moc_serialport.o
release/moc_qcustomplot.o release/moc_qcustomplot.o
release/moc_experimentsettingform.o
release/moc_leftwidget.o
release/moc_realtimedataform.o release/moc_realtimedataform.o

View File

View File

@ -23,6 +23,8 @@ SOURCES += \
serialport/dataparser.cpp \ serialport/dataparser.cpp \
serialport/serialport.cpp \ serialport/serialport.cpp \
thirdparty/qcustomplot/qcustomplot.cpp \ thirdparty/qcustomplot/qcustomplot.cpp \
ui/experimentsettingform.cpp \
ui/leftwidget.cpp \
ui/realtimedataform.cpp ui/realtimedataform.cpp
HEADERS += \ HEADERS += \
@ -33,10 +35,13 @@ HEADERS += \
serialport/protocol.h \ serialport/protocol.h \
serialport/serialport.h \ serialport/serialport.h \
thirdparty/qcustomplot/qcustomplot.h \ thirdparty/qcustomplot/qcustomplot.h \
ui/experimentsettingform.h \
ui/leftwidget.h \
ui/realtimedataform.h ui/realtimedataform.h
FORMS += \ FORMS += \
mainwindow.ui \ mainwindow.ui \
ui/experimentsettingform.ui \
ui/realtimedataform.ui ui/realtimedataform.ui
INCLUDEPATH += serialport \ INCLUDEPATH += serialport \

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2025-03-06T16:19:26. --> <!-- Written by QtCreator 4.11.1, 2025-03-10T17:17:05. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

25
src/AnalysTool.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35825.156 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AnalysTool", "AnalysTool.vcxproj", "{F30D2791-A8A0-38F9-928F-89C2B41456F0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F30D2791-A8A0-38F9-928F-89C2B41456F0}.Debug|x64.ActiveCfg = Debug|x64
{F30D2791-A8A0-38F9-928F-89C2B41456F0}.Debug|x64.Build.0 = Debug|x64
{F30D2791-A8A0-38F9-928F-89C2B41456F0}.Release|x64.ActiveCfg = Release|x64
{F30D2791-A8A0-38F9-928F-89C2B41456F0}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {084FD268-695B-4117-A631-0128BC510B8E}
EndGlobalSection
EndGlobal

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,29 +1,35 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication> #include <QApplication>
#include "centralwidget.h" #include "centralwidget.h"
#include "serialport/serialport.h" #include "serialport/serialport.h"
#include "ui/realtimedataform.h" #include "ui/realtimedataform.h"
#include "experimentsettingform.h"
int main(int argc, char *argv[]) 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();
CentralWidget central; ExperimentSettingForm es;
central.show(); es.show();
// CentralWidget central;
// central.show();
// SerialPort::parserTest(); // SerialPort::parserTest();
SerialPort sp; // SerialPort sp;
RealTimeDataForm r; // RealTimeDataForm r;
// r.show(); // r.show();
QObject::connect(&sp,&SerialPort::sigSendSerialPortData, // QObject::connect(&sp,&SerialPort::sigSendSerialPortData,
&r,&RealTimeDataForm::slotRevSerialPortData); // &r,&RealTimeDataForm::slotRevSerialPortData);
return a.exec(); return a.exec();
} }

View File

@ -5,11 +5,14 @@ MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
, ui(new Ui::MainWindow) , ui(new Ui::MainWindow)
, _centralWidget(new CentralWidget) , _centralWidget(new CentralWidget)
,_leftWidget(new LeftWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setToolTip("....."); this->setToolTip(".....");
setCentralWidget(_centralWidget); setCentralWidget(_centralWidget);
addDockWidget(Qt::LeftDockWidgetArea, _leftWidget);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()

View File

@ -2,7 +2,9 @@
#define MAINWINDOW_H #define MAINWINDOW_H
#include <QMainWindow> #include <QMainWindow>
#include "centralwidget.h" #include "centralwidget.h"
#include "leftwidget.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; } namespace Ui { class MainWindow; }
@ -19,5 +21,6 @@ public:
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
CentralWidget *_centralWidget; CentralWidget *_centralWidget;
LeftWidget*_leftWidget;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -4,3 +4,10 @@ DataParser::DataParser()
{ {
} }
void DataParser::connectToDevice(const QVector<Phase> &vtr)
{
for(const Phase& phase:vtr){
}
}

View File

@ -1,10 +1,15 @@
#ifndef DATAPARSER_H #ifndef DATAPARSER_H
#define DATAPARSER_H #define DATAPARSER_H
#include <QVector>
#include "protocol.h"
class DataParser class DataParser
{ {
public: public:
DataParser(); DataParser();
static void connectToDevice(const QVector<Phase>&);
}; };
#endif // DATAPARSER_H #endif // DATAPARSER_H

View File

@ -19,20 +19,20 @@ struct com_protocol
uint8_t data_buf[256]; uint8_t data_buf[256];
}; };
enum gas_type{ typedef enum gas_type {
NC, NC,
N2, N2,
O2 O2
}; }GasType;
struct control_data typedef struct control_data
{ {
uint8_t onoff; uint8_t onoff;
float cutoff_temp; float cutoff_temp;
float temp_flow; float temp_flow;
uint16_t constant_temp_time_min; uint16_t constant_temp_time_min;
enum gas_type gas; enum gas_type gas;
}; }Phase;
struct pid_data struct pid_data
{ {

Binary file not shown.

View File

@ -0,0 +1,212 @@
#include <QtDebug>
#include "experimentsettingform.h"
#include "ui_experimentsettingform.h"
#include "protocol.h"
ExperimentSettingForm::ExperimentSettingForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::ExperimentSettingForm)
{
ui->setupUi(this);
uiReset();
connect(ui->checkBox_phase_2,&QCheckBox::clicked,
this,&ExperimentSettingForm::slotPhase2StateChanged);
connect(ui->checkBox_phase_3,&QCheckBox::clicked,
this,&ExperimentSettingForm::slotPhase3StateChanged);
connect(ui->checkBox_phase_4,&QCheckBox::clicked,
this,&ExperimentSettingForm::slotPhase4StateChanged);
connect(ui->pushButton_connect_to_device,&QPushButton::click,
this,&ExperimentSettingForm::slotConnectToDevice);
connect(ui->pushButton_cancel,&QPushButton::click,
this,&ExperimentSettingForm::slotCancel);
}
ExperimentSettingForm::~ExperimentSettingForm()
{
delete ui;
}
void ExperimentSettingForm::uiReset()
{
//init data and status.
ui->checkBox_phase_1->setChecked(true);
ui->checkBox_phase_1->setEnabled(false);
ui->phase_1_cutoff_temp->setText("0");
ui->phase_2_cutoff_temp->setText("0");
ui->phase_3_cutoff_temp->setText("0");
ui->phase_4_cutoff_temp->setText("0");
ui->phase_1_scan_rate->setText("0");
ui->phase_2_scan_rate->setText("0");
ui->phase_3_scan_rate->setText("0");
ui->phase_4_scan_rate->setText("0");
ui->phase_1_constant_temp->setText("0");
ui->phase_2_constant_temp->setText("0");
ui->phase_3_constant_temp->setText("0");
ui->phase_4_constant_temp->setText("0");
ui->phase_2_cutoff_temp->setEnabled(false);
ui->phase_3_cutoff_temp->setEnabled(false);
ui->phase_4_cutoff_temp->setEnabled(false);
ui->phase_2_scan_rate->setEnabled(false);
ui->phase_3_scan_rate->setEnabled(false);
ui->phase_4_scan_rate->setEnabled(false);
ui->phase_2_constant_temp->setEnabled(false);
ui->phase_3_constant_temp->setEnabled(false);
ui->phase_4_constant_temp->setEnabled(false);
ui->comboBox_phase_2_atmosphere->setEnabled(false);
ui->comboBox_phase_3_atmosphere->setEnabled(false);
ui->comboBox_phase_4_atmosphere->setEnabled(false);
ui->radioButton_OIT_not->setChecked(true);
ui->checkBox_phase_2->setTristate(false);
ui->checkBox_phase_3->setTristate(false);
ui->checkBox_phase_4->setTristate(false);
}
void ExperimentSettingForm::slotPhase2StateChanged(int state)
{
qDebug()<<"slotPhase2StateChanged:"<<state;
if(state == Qt::PartiallyChecked){
ui->phase_2_cutoff_temp->setEnabled(true);
ui->phase_2_scan_rate->setEnabled(true);
ui->phase_2_constant_temp->setEnabled(true);
ui->comboBox_phase_2_atmosphere->setEnabled(true);
}else{
if(ui->checkBox_phase_3->isChecked()){
ui->checkBox_phase_2->setCheckState(Qt::Checked);
}else {
ui->phase_2_cutoff_temp->setEnabled(false);
ui->phase_2_scan_rate->setEnabled(false);
ui->phase_2_constant_temp->setEnabled(false);
ui->comboBox_phase_2_atmosphere->setEnabled(false);
}
}
}
void ExperimentSettingForm::slotPhase3StateChanged(int state)
{
if(state == Qt::PartiallyChecked){
if(ui->checkBox_phase_2->isChecked()){
ui->phase_3_cutoff_temp->setEnabled(true);
ui->phase_3_scan_rate->setEnabled(true);
ui->phase_3_constant_temp->setEnabled(true);
ui->comboBox_phase_3_atmosphere->setEnabled(true);
}else{
ui->checkBox_phase_3->setChecked(false);
}
}else{
if(ui->checkBox_phase_4->isChecked()){
ui->checkBox_phase_3->setChecked(true);
}else{
ui->phase_3_cutoff_temp->setEnabled(false);
ui->phase_3_scan_rate->setEnabled(false);
ui->phase_3_constant_temp->setEnabled(false);
ui->comboBox_phase_3_atmosphere->setEnabled(false);
}
}
}
void ExperimentSettingForm::slotPhase4StateChanged(int state)
{
if(state == Qt::PartiallyChecked){
if(ui->checkBox_phase_3->isChecked()){
ui->phase_4_cutoff_temp->setEnabled(true);
ui->phase_4_scan_rate->setEnabled(true);
ui->phase_4_constant_temp->setEnabled(true);
ui->comboBox_phase_4_atmosphere->setEnabled(true);
}else{
ui->checkBox_phase_4->setChecked(false);
}
}else{
ui->phase_4_cutoff_temp->setEnabled(false);
ui->phase_4_scan_rate->setEnabled(false);
ui->phase_4_constant_temp->setEnabled(false);
ui->comboBox_phase_4_atmosphere->setEnabled(false);
}
}
void ExperimentSettingForm::slotConnectToDevice()
{
QVector<Phase> phaseVtr;
if(ui->checkBox_phase_1->checkState()){
Phase phase;
phase.onoff = 1;
phase.cutoff_temp = ui->phase_1_cutoff_temp->text().toFloat();
phase.temp_flow = ui->phase_1_scan_rate->text().toFloat();
phase.constant_temp_time_min = (uint16_t)ui->phase_1_constant_temp->text().toInt();
// phase.gas = ui->comboBox_phase_1_atmosphere->currentIndex();
phase.gas = GasType::N2;
phaseVtr.push_back(phase);
}
if(ui->checkBox_phase_2->checkState()){
Phase phase;
phase.onoff = 1;
phase.cutoff_temp = ui->phase_2_cutoff_temp->text().toFloat();
phase.temp_flow = ui->phase_2_scan_rate->text().toFloat();
phase.constant_temp_time_min = (uint16_t)ui->phase_2_constant_temp->text().toInt();
// phase.gas = ui->comboBox_phase_1_atmosphere->currentIndex();
phase.gas = GasType::N2;
phaseVtr.push_back(phase);
}
}
void ExperimentSettingForm::slotCancel()
{
}
void ExperimentSettingForm::slotPhaseCheck()
{
if(sender() == ui->checkBox_phase_2){
if(ui->checkBox_phase_2->isChecked()){
ui->phase_2_cutoff_temp->setEnabled(true);
ui->phase_2_scan_rate->setEnabled(true);
ui->phase_2_constant_temp->setEnabled(true);
ui->comboBox_phase_2_atmosphere->setEnabled(true);
}else{
ui->phase_2_cutoff_temp->setEnabled(false);
ui->phase_2_scan_rate->setEnabled(false);
ui->phase_2_constant_temp->setEnabled(false);
ui->comboBox_phase_2_atmosphere->setEnabled(false);
}
}else if(sender() == ui->checkBox_phase_3){
if(ui->checkBox_phase_3->isChecked()){
ui->phase_3_cutoff_temp->setEnabled(true);
ui->phase_3_scan_rate->setEnabled(true);
ui->phase_3_constant_temp->setEnabled(true);
ui->comboBox_phase_3_atmosphere->setEnabled(true);
}else{
ui->phase_3_cutoff_temp->setEnabled(false);
ui->phase_3_scan_rate->setEnabled(false);
ui->phase_3_constant_temp->setEnabled(false);
ui->comboBox_phase_3_atmosphere->setEnabled(false);
}
}else if(sender() == ui->checkBox_phase_4){
if(ui->checkBox_phase_4->isChecked()){
ui->phase_4_cutoff_temp->setEnabled(true);
ui->phase_4_scan_rate->setEnabled(true);
ui->phase_4_constant_temp->setEnabled(true);
ui->comboBox_phase_4_atmosphere->setEnabled(true);
}else{
ui->phase_4_cutoff_temp->setEnabled(false);
ui->phase_4_scan_rate->setEnabled(false);
ui->phase_4_constant_temp->setEnabled(false);
ui->comboBox_phase_4_atmosphere->setEnabled(false);
}
}
}

View File

@ -0,0 +1,31 @@
#ifndef EXPERIMENTSETTINGFORM_H
#define EXPERIMENTSETTINGFORM_H
#include <QWidget>
namespace Ui {
class ExperimentSettingForm;
}
class ExperimentSettingForm : public QWidget
{
Q_OBJECT
public:
explicit ExperimentSettingForm(QWidget *parent = nullptr);
~ExperimentSettingForm();
private:
void uiReset();
//slot
void slotPhaseCheck();
void slotPhase2StateChanged(int state);
void slotPhase3StateChanged(int state);
void slotPhase4StateChanged(int state);
void slotConnectToDevice();
void slotCancel();
private:
Ui::ExperimentSettingForm *ui;
};
#endif // EXPERIMENTSETTINGFORM_H

View File

@ -0,0 +1,492 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExperimentSettingForm</class>
<widget class="QWidget" name="ExperimentSettingForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>851</width>
<height>338</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>821</width>
<height>271</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,2">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>样品参数</string>
</property>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>241</width>
<height>181</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="Label">
<property name="text">
<string>样品名称:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="sampleNameLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="Label_2">
<property name="text">
<string>样品质量:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="sampleWeightLineEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="Label_3">
<property name="text">
<string>实验日期:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="dateTimeLineEdit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="Label_4">
<property name="text">
<string>操作员:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="userLineEdit"/>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>实验参数</string>
</property>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>491</width>
<height>211</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="1,1,1,1,1,1">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>阶段</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="phase_1_cutoff_temp">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>截止温度</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="phase_1_scan_rate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="phase_1_constant_temp">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_4">
<property name="text">
<string>气氛</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_5">
<property name="text">
<string>恒温时间</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label">
<property name="text">
<string>扫描速率</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>测试类型:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="phase_2_cutoff_temp">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="phase_2_scan_rate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="phase_2_constant_temp">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="phase_3_cutoff_temp">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="phase_4_cutoff_temp">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="phase_3_scan_rate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="phase_4_scan_rate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLineEdit" name="phase_3_constant_temp">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLineEdit" name="phase_4_constant_temp">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QRadioButton" name="radioButton_OIT">
<property name="text">
<string>OIT</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QRadioButton" name="radioButton_OIT_not">
<property name="text">
<string>非OIT</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_phase_1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox_phase_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>2</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_phase_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>3</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBox_phase_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>4</string>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QComboBox" name="comboBox_initial_atmosphere">
<item>
<property name="text">
<string>NC</string>
</property>
</item>
<item>
<property name="text">
<string>N2</string>
</property>
</item>
<item>
<property name="text">
<string>O2</string>
</property>
</item>
</widget>
</item>
<item row="4" column="4">
<widget class="QComboBox" name="comboBox_phase_4_atmosphere">
<item>
<property name="text">
<string>NC</string>
</property>
</item>
<item>
<property name="text">
<string>N2</string>
</property>
</item>
<item>
<property name="text">
<string>O2</string>
</property>
</item>
</widget>
</item>
<item row="3" column="4">
<widget class="QComboBox" name="comboBox_phase_3_atmosphere">
<item>
<property name="text">
<string>NC</string>
</property>
</item>
<item>
<property name="text">
<string>N2</string>
</property>
</item>
<item>
<property name="text">
<string>O2</string>
</property>
</item>
</widget>
</item>
<item row="2" column="4">
<widget class="QComboBox" name="comboBox_phase_2_atmosphere">
<item>
<property name="text">
<string>NC</string>
</property>
</item>
<item>
<property name="text">
<string>N2</string>
</property>
</item>
<item>
<property name="text">
<string>O2</string>
</property>
</item>
</widget>
</item>
<item row="1" column="4">
<widget class="QComboBox" name="comboBox_phase_1_atmosphere">
<item>
<property name="text">
<string>NC</string>
</property>
</item>
<item>
<property name="text">
<string>N2</string>
</property>
</item>
<item>
<property name="text">
<string>O2</string>
</property>
</item>
</widget>
</item>
<item row="5" column="3">
<widget class="QLabel" name="label_7">
<property name="text">
<string>初始气氛:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="pushButton_connect_to_device">
<property name="geometry">
<rect>
<x>471</x>
<y>300</y>
<width>80</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>连接仪器</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_cancel">
<property name="geometry">
<rect>
<x>580</x>
<y>300</y>
<width>81</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

158
src/ui/leftwidget.cpp Normal file
View File

@ -0,0 +1,158 @@
#include <qdir.h>
#include <qdebug.h>
#include <QHBoxLayout>
#include "leftwidget.h"
const QString sampleDataFloder = QDir::currentPath()+"/../experiment_data/sample_data";
const QString baseLineFolder = QDir::currentPath()+"/../experiment_data/base_line";
const QString analysisStateFolder = QDir::currentPath()+"/../experiment_data/analysis_state";
LeftWidget::LeftWidget()
{
// setStyleSheet("background-color: yellow;");
_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,"样品数据");
_treeWidget->setSortingEnabled(false);
// _treeWidget->insertTopLevelItem(0,_sampleDataItem);
// _treeWidget->insertTopLevelItem(1,_baseLineItem);
// _treeWidget->insertTopLevelItem(2,_analysisStateItem);
_treeWidget->addTopLevelItem(_sampleDataItem);
_treeWidget->addTopLevelItem(_baseLineItem);
_treeWidget->addTopLevelItem(_analysisStateItem);
#if 0
qDebug()<<"current path:"<<QDir::currentPath();
QString folderPath = QDir::currentPath()+"/../experiment_data";
qDebug()<<"experit dir:"<<folderPath;
QDir dir(folderPath);
qDebug()<<"folderPath exist:"<< dir.exists();
#endif
//init file name.
initFileName(_sampleDataItem,sampleDataFloder);
initFileName(_baseLineItem,baseLineFolder);
initFileName(_analysisStateItem,analysisStateFolder);
expandAll(_sampleDataItem);
expandAll(_baseLineItem);
expandAll(_analysisStateItem);
setWidget(_treeWidget);
}
void LeftWidget::initData()
{
const QString folderPath = QDir::currentPath()+"/../experiment_data";
#if 1
QDir dir(folderPath);
if (!dir.exists()) {
qWarning() << "文件夹不存在: " << folderPath;
return;
}
// 遍历文件
QFileInfoList fileList = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
for (const QFileInfo& fileInfo : fileList) {
QFile file(fileInfo.absoluteFilePath());
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QString content = file.readAll();
qDebug() << "读取文件 " << fileInfo.absoluteFilePath() << " 内容: " << content;
file.close();
// 写入文件操作示例:这里简单在文件末尾追加一行内容
if (file.open(QIODevice::Append | QIODevice::Text)) {
file.write("\n这是通过递归写入添加的内容");
qDebug() << "已向文件 " << fileInfo.absoluteFilePath() << " 写入内容";
file.close();
} else {
qWarning() << "无法打开文件进行写入: " << fileInfo.absoluteFilePath();
}
} else {
qWarning() << "无法打开文件进行读取: " << fileInfo.absoluteFilePath();
}
}
#endif
}
void LeftWidget::initFileName(QTreeWidgetItem* parentItem,const QString &folderPath)
{
QDir dir(folderPath);
QStringList files = dir.entryList(QDir::Files);
for(const QString &fileName:files){
QTreeWidgetItem *subItem = new QTreeWidgetItem();
subItem->setText(0,fileName);
// _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) {
item->setExpanded(true);
for (int i = 0; i < item->childCount(); ++i) {
expandAll(item->child(i));
}
}
#if 0
void LeftWidget::recursiveFolderOperation(const QString& folderPath) {
QDir dir(folderPath);
if (!dir.exists()) {
qWarning() << "文件夹不存在: " << folderPath;
return;
}
// 遍历文件
QFileInfoList fileList = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
for (const QFileInfo& fileInfo : fileList) {
QFile file(fileInfo.absoluteFilePath());
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QString content = file.readAll();
qDebug() << "读取文件 " << fileInfo.absoluteFilePath() << " 内容: " << content;
file.close();
// 写入文件操作示例:这里简单在文件末尾追加一行内容
if (file.open(QIODevice::Append | QIODevice::Text)) {
file.write("\n这是通过递归写入添加的内容");
qDebug() << "已向文件 " << fileInfo.absoluteFilePath() << " 写入内容";
file.close();
} else {
qWarning() << "无法打开文件进行写入: " << fileInfo.absoluteFilePath();
}
} else {
qWarning() << "无法打开文件进行读取: " << fileInfo.absoluteFilePath();
}
}
// 递归遍历子文件夹
QFileInfoList subDirList = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
for (const QFileInfo& subDirInfo : subDirList) {
recursiveFolderOperation(subDirInfo.absoluteFilePath());
}
}
#endif

25
src/ui/leftwidget.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef LEFTWIDGET_H
#define LEFTWIDGET_H
#include <QWidget>
#include <QDockWidget>
#include <qtreewidget.h>
#include <QTreeWidgetItem>
class LeftWidget:public QDockWidget
{
Q_OBJECT
public:
LeftWidget();
private:
void initData();
void initFileName(QTreeWidgetItem*,const QString &folderPath);
void expandAll(QTreeWidgetItem* item);
private:
QTreeWidget *_treeWidget;
QTreeWidgetItem *_analysisStateItem,
*_baseLineItem,
*_sampleDataItem;
};
#endif // LEFTWIDGET_H

Binary file not shown.