2025-03-18T11:43:14

This commit is contained in:
yuntang 2025-03-18 11:43:14 +08:00
parent 8020ae9dd9
commit 3a229c17c7
15 changed files with 949 additions and 653 deletions

View File

@ -1,3 +1,8 @@
{
"qtConfigure.qtKitDir": "D:/qt/Qt5.14.2/5.14.2/mingw73_64"
"qtConfigure.qtKitDir": "D:/qt/Qt5.14.2/5.14.2/mingw73_64",
"files.associations": {
"array": "cpp",
"string": "cpp",
"string_view": "cpp"
}
}

View File

@ -1,21 +1,74 @@
cmake_minimum_required(VERSION 3.5) # CMake install : https://cmake.org/download/
project(qt_new_proj LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_PREFIX_PATH "D:/qt/Qt5.14.2/5.14.2/mingw73_64") # Qt Kit Dir
cmake_minimum_required(VERSION 3.5)
project(AnalysisTool VERSION 1.0.0 LANGUAGES CXX)
# Set C++11 as the minimum standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Find Qt libraries
find_package(Qt5 REQUIRED COMPONENTS Core Gui SerialPort PrintSupport Widgets)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt5 COMPONENTS Widgets REQUIRED) # Qt COMPONENTS
aux_source_directory(./src srcs)
# Specify MSVC UTF-8 encoding
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
add_executable(${PROJECT_NAME}
WIN32 # If you need a terminal for debug, please comment this statement
${srcs}
#
set(SEARCH_FOLDERS
${CMAKE_SOURCE_DIR}
serialport
ui
thirdparty/qcustomplot
data
)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Widgets) # Qt5 Shared Library
#
set(SOURCES "")
set(HEADERS "")
# .cpp .h
foreach(FOLDER ${SEARCH_FOLDERS})
file(GLOB_RECURSE TEMP_CPP ${FOLDER}/*.cpp)
file(GLOB_RECURSE TEMP_H ${FOLDER}/*.h)
list(APPEND SOURCES ${TEMP_CPP})
list(APPEND HEADERS ${TEMP_H})
endforeach()
set(FORMS
mainwindow.ui
ui/experimentsettingform.ui
ui/realtimedataform.ui
)
# Resources
set(RESOURCES
images.qrc
)
# Add UI files to the project and automatically run uic
qt5_wrap_ui(UI_HEADERS ${FORMS})
# Add resources to the project and automatically run rcc
qt5_add_resources(RESOURCES_RCC ${RESOURCES})
# Create the executable
add_executable(${PROJECT_NAME}
${SOURCES}
${HEADERS}
${UI_HEADERS}
${RESOURCES_RCC}
)
target_include_directories(${PROJECT_NAME} PRIVATE
${SEARCH_FOLDERS}
${CMAKE_CURRENT_BINARY_DIR})
# Link against Qt5 libraries
target_link_libraries(${PROJECT_NAME}
Qt5::Core
Qt5::Gui
Qt5::SerialPort
Qt5::PrintSupport
Qt5::Widgets
)

View File

@ -8,12 +8,7 @@
#include "filemanager.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, _centralWidget(new CentralWidget)
,_leftWidget(new LeftWidget)
,_expertmentSettingForm(new ExperimentSettingForm)
,_realTimeDataForm(new RealTimeDataForm)
: QMainWindow(parent), ui(new Ui::MainWindow), _centralWidget(new CentralWidget), _leftWidget(new LeftWidget), _expertmentSettingForm(new ExperimentSettingForm), _realTimeDataForm(new RealTimeDataForm)
{
ui->setupUi(this);
@ -54,6 +49,10 @@ void MainWindow::connections()
connect(SerialPort::instance(), &SerialPort::sigSendCommonDataToRealDataForm,
_realTimeDataForm, &RealTimeDataForm::slotRevCommonData);
connect(SerialPort::instance(), &SerialPort::sigSendPhaseInfo,
_expertmentSettingForm, &ExperimentSettingForm::slotRecvPhaseInfo);
#endif
// mode
@ -63,12 +62,15 @@ void MainWindow::connections()
void MainWindow::setActionEnable(const bool flag)
{
if(flag){
if (flag)
{
ui->actionNew->setEnabled(true);
ui->actionStart->setEnabled(true);
ui->actionStop->setEnabled(true);
ui->actionRealTimeWidget->setEnabled(true);
}else{
}
else
{
ui->actionNew->setEnabled(false);
ui->actionStart->setEnabled(false);
ui->actionStop->setEnabled(false);
@ -113,10 +115,15 @@ void MainWindow::on_actionRealTimeWidget_triggered()
void MainWindow::on_actionConnectToDev_triggered()
{
if(SerialPort::instance()->openSp()){
if (SerialPort::instance()->openSp())
{
ui->actionNew->setEnabled(true);
Global::instance()->setMode(Global::Mode::ConnectedToDev);
}else{
QThread::msleep(300);
SerialPort::instance()->senddata(DataParser::inquirePhaseInfo());
}
else
{
QMessageBox::warning(this, "warnning", "Serial Port open failed.");
}
}

View File

@ -6,8 +6,9 @@
#include "defines.h"
#include "global.h"
bool DataParser::commonDataParser(const QByteArray &ba, CommonData &cd)
namespace DataParser
{
bool commonDataParser(const QByteArray &ba, CommonData &cd)
{
const char *charArray = ba.data();
@ -35,7 +36,6 @@ bool DataParser::commonDataParser(const QByteArray &ba, CommonData &cd)
return true;
}
#if 0
bool DataParser::slotDataParser(const QByteArray &ba)
{
@ -64,13 +64,11 @@ bool DataParser::slotDataParser(const QByteArray &ba)
}
#endif
void DataParser::writeData(const QByteArray &)
void writeData(const QByteArray &)
{
}
QByteArray DataParser::connectToDevice(const QVector<Phase> &vtr)
QByteArray connectToDevice(const QVector<Phase> &vtr)
{
const int phaseLength = sizeof(Phase);
const int phaseArrayLength = vtr.size() * phaseLength;
@ -121,7 +119,7 @@ QByteArray DataParser::connectToDevice(const QVector<Phase> &vtr)
return QByteArray(totalData, 6 + phaseArrayLength + 2);
}
QByteArray DataParser::setDeviceStartStop(const DeviceStartMode mode)
QByteArray setDeviceStartStop(const DeviceStartMode mode)
{
#if 1
SerialPortProtocol spp;
@ -168,7 +166,7 @@ QByteArray DataParser::setDeviceStartStop(const DeviceStartMode mode)
#endif
}
unsigned short DataParser::modbusCRC16(unsigned char *data, unsigned short length)
unsigned short modbusCRC16(unsigned char *data, unsigned short length)
{
unsigned short crc = 0xFFFF;
unsigned char i;
@ -191,3 +189,25 @@ unsigned short DataParser::modbusCRC16(unsigned char *data, unsigned short lengt
return crc;
}
QByteArray inquirePhaseInfo()
{
SerialPortProtocol spp;
spp.head = FRANE_HEAD;
spp.cmd = READ_CMD;
spp.addr = 0x0050;
//
int inquireDataLength = (u8)sizeof(Phase) * 6;
spp.data_buf[0] = inquireDataLength;
spp.len = 5 + inquireDataLength;
//
int crcDataLength = 3 + inquireDataLength;
u8 *dataPtr = (u8 *)&spp;
u16 crc = modbusCRC16((u8 *)(dataPtr + 3), crcDataLength);
//
int sppValidLength = 6 + inquireDataLength;
return QByteArray((char *)&spp, sppValidLength) +
QByteArray((char *)&crc, 2);
}
};

View File

@ -10,6 +10,7 @@
namespace DataParser {
QByteArray connectToDevice(const QVector<Phase>&);
QByteArray inquirePhaseInfo();
QByteArray setDeviceStartStop(const DeviceStartMode);
bool commonDataParser(const QByteArray&ba,CommonData &cd);
@ -18,30 +19,4 @@ void writeData(const QByteArray&);
unsigned short modbusCRC16(unsigned char *data,unsigned short length);
}
#if 0
class DataParser
{
public:
void dataParser(const QByteArray& ba);
static unsigned short modbusCRC16(unsigned char *data,unsigned short length);
static QByteArray connectToDevice(const QVector<Phase>&);
static QByteArray setDeviceStartStop(const DeviceStartMode);
static bool commonDataParser(const QByteArray&ba,CommonData &cd);
bool revDataParser(const QByteArray&ba);
#if 0
public slots:
void slotDataParser(const QByteArray& ba);
signals:
void sigSendCommonData(const CommonData&);
void sigSendCommonDataToRealDataForm(const CommonData&);
#endif
private:
void writeData(const QByteArray&);
void readData(const QByteArray&);
};
#endif
#endif // DATAPARSER_H

View File

@ -6,6 +6,7 @@
#define FRANE_HEAD 0x5AA5 //枕头
#define WRITE_CMD 0x82 //写指令
#define READ_CMD 0x83 //读指令
#define PHASE_START_ADDR 0X0050
#pragma pack(push)
#pragma pack(1)

View File

@ -121,12 +121,21 @@ void SerialPort::slotReadData()
}
else
{
// read data
if (spp->addr == 0)
{
if (Global::Mode::ExperimentStart == Global::instance()->getMode())
{
emit sigSendCommonData(cd);
}
emit sigSendCommonDataToRealDataForm(cd);
}
else if(spp->addr == PHASE_START_ADDR)
{
emit sigSendPhaseInfo(ba);
}
}
#endif
}
@ -137,7 +146,8 @@ void SerialPort::writeCmdHandle(const int dataLength, const u16 addr,
int localAddr = addr;
int phaseByteSize = sizeof(Phase);
auto phaseParserFunc = [&](const int index){
auto phaseParserFunc = [&](const int index)
{
Phase phase;
phase.onoff = 1;
phase.gas = cd.phase_data[index].gas;
@ -185,18 +195,25 @@ void SerialPort::writeCmdHandle(const int dataLength, const u16 addr,
break;
}
case offsetof(CommonData, phase_data[0].onoff):
phaseParserFunc(0); break;
phaseParserFunc(0);
break;
case offsetof(CommonData, phase_data[1].onoff):
phaseParserFunc(1); break;
phaseParserFunc(1);
break;
case offsetof(CommonData, phase_data[2].onoff):
phaseParserFunc(2); break;
phaseParserFunc(2);
break;
case offsetof(CommonData, phase_data[3].onoff):
phaseParserFunc(3); break;
phaseParserFunc(3);
break;
case offsetof(CommonData, phase_data[4].onoff):
phaseParserFunc(4); break;
phaseParserFunc(4);
break;
case offsetof(CommonData, phase_data[5].onoff):
phaseParserFunc(5); break;
default:break;
phaseParserFunc(5);
break;
default:
break;
};
}
}
@ -407,7 +424,8 @@ void SerialPort::slotSendData(const QByteArray &ba)
*
* 1
*/
if(WRITE_CMD == ba.at(3)){
if (WRITE_CMD == ba.at(3))
{
_lastWriteBa = ba;
}
qDebug() << "slotSendData:" << ba.size();
@ -419,7 +437,6 @@ void SerialPort::slotSendData(const QByteArray &ba)
else
{
qDebug() << "sp not open.";
// qErrnoWarning("sp not open.");
return;
}
}

View File

@ -12,7 +12,8 @@ class SerialPort:public QObject
{
Q_OBJECT
public:
enum E_CMD_TYPE{
enum E_CMD_TYPE
{
e_zero,
e_forward,
e_back
@ -21,25 +22,33 @@ public:
static SerialPort *instance();
~SerialPort();
void sendData(const QByteArray &data)
{
slotSendData(data);
}
void sendCmd(const E_CMD_TYPE e);
static void parserTest();
bool openSp();
protected:
void timerEvent(QTimerEvent *event);
signals:
void sigSendCommonData(const CommonData &);
void sigSendCommonDataToRealDataForm(const CommonData &);
void sigSendPhaseInfo(const QByteArray &);
public slots:
void slotDeliverData(const QByteArray &);
// void slotConnectToDevice(const QByteArray&);
void slotSendData(const QByteArray &);
void slotCloseSp();
signals:
void sigSendCommonData(const CommonData&);
void sigSendCommonDataToRealDataForm(const CommonData&);
protected:
void timerEvent(QTimerEvent *event);
private slots:
void slotReadData();
private:
void writeCmdHandle(const int dataLength, const u16 addr, const CommonData &cd);
void to_hex(char *in_char, int char_length, char *out_char);
void displayPortInfo();
private:
SerialPort(QObject *parent = nullptr);
QSerialPort *_sp;

View File

@ -1,12 +0,0 @@
#include "qt_new_proj.h"
#include <QApplication>
#pragma comment(lib, "user32.lib")
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
qt_new_proj w;
w.show();
return a.exec();
}

View File

@ -1,13 +0,0 @@
#include "qt_new_proj.h"
qt_new_proj::qt_new_proj(QWidget* parent)
: QMainWindow(parent)
, ui(new Ui_qt_new_proj)
{
ui->setupUi(this);
}
qt_new_proj::~qt_new_proj()
{
delete ui;
}

View File

@ -1,14 +0,0 @@
#pragma once
#include "ui_qt_new_proj.h"
#include <QMainWindow>
class qt_new_proj : public QMainWindow {
Q_OBJECT
public:
qt_new_proj(QWidget* parent = nullptr);
~qt_new_proj();
private:
Ui_qt_new_proj* ui;
};

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>qt_new_proj</class>
<widget class="QMainWindow" name="qt_new_proj">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>qt_new_proj</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar"/>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -8,8 +8,7 @@
#include "global.h"
#include "filemanager.h"
ExperimentSettingForm::ExperimentSettingForm(QWidget *parent) :
QWidget(parent),
ExperimentSettingForm::ExperimentSettingForm(QWidget *parent) : QWidget(parent),
ui(new Ui::ExperimentSettingForm)
{
ui->setupUi(this);
@ -21,6 +20,10 @@ ExperimentSettingForm::ExperimentSettingForm(QWidget *parent) :
this, &ExperimentSettingForm::slotPhase3StateChanged);
connect(ui->checkBox_phase_4, &QCheckBox::clicked,
this, &ExperimentSettingForm::slotPhase4StateChanged);
connect(ui->checkBox_phase_5, &QCheckBox::clicked,
this, &ExperimentSettingForm::slotPhase5StateChanged);
connect(ui->checkBox_phase_6, &QCheckBox::clicked,
this, &ExperimentSettingForm::slotPhase6StateChanged);
// connect(ui->pushButton_connect_to_device,&QPushButton::clicked,
// this,&ExperimentSettingForm::slotConnectToDevice);
@ -43,52 +46,89 @@ void ExperimentSettingForm::uiReset()
ui->phase_2_cutoff_temp->setText("0");
ui->phase_3_cutoff_temp->setText("0");
ui->phase_4_cutoff_temp->setText("0");
ui->phase_5_cutoff_temp->setText("0");
ui->phase_6_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_5_scan_rate->setText("0");
ui->phase_6_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_5_constant_temp->setText("0");
ui->phase_6_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_5_cutoff_temp->setEnabled(false);
ui->phase_6_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_5_scan_rate->setEnabled(false);
ui->phase_6_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->phase_5_constant_temp->setEnabled(false);
ui->phase_6_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->comboBox_phase_5_atmosphere->setEnabled(false);
ui->comboBox_phase_6_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);
ui->checkBox_phase_5->setTristate(false);
ui->checkBox_phase_6->setTristate(false);
}
void ExperimentSettingForm::uiUpdatePhase(QVector<Phase> &vtr)
{
for(int i = 0; i< vtr.size(); i++){
const Phase &phase = vtr[i];
if(phase.onoff == 0){
return;
}
QString checkBoxName = QString("checkBox_phase_%1").arg(i);
QCheckBox *checkBox = ui->findChild<QCheckBox*>(checkBoxName);
if (checkBox) {
checkBox->setTristate(false);
}
}
}
void ExperimentSettingForm::slotPhase2StateChanged(int state)
{
qDebug() << "slotPhase2StateChanged:" << state;
if(state == Qt::PartiallyChecked){
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()){
}
else
{
if (ui->checkBox_phase_3->isChecked())
{
ui->checkBox_phase_2->setCheckState(Qt::Checked);
}else {
}
else
{
ui->phase_2_cutoff_temp->setEnabled(false);
ui->phase_2_scan_rate->setEnabled(false);
ui->phase_2_constant_temp->setEnabled(false);
@ -99,19 +139,28 @@ void ExperimentSettingForm::slotPhase2StateChanged(int state)
void ExperimentSettingForm::slotPhase3StateChanged(int state)
{
if(state == Qt::PartiallyChecked){
if(ui->checkBox_phase_2->isChecked()){
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{
}
else
{
ui->checkBox_phase_3->setChecked(false);
}
}else{
if(ui->checkBox_phase_4->isChecked()){
}
else
{
if (ui->checkBox_phase_4->isChecked())
{
ui->checkBox_phase_3->setChecked(true);
}else{
}
else
{
ui->phase_3_cutoff_temp->setEnabled(false);
ui->phase_3_scan_rate->setEnabled(false);
ui->phase_3_constant_temp->setEnabled(false);
@ -122,16 +171,22 @@ void ExperimentSettingForm::slotPhase3StateChanged(int state)
void ExperimentSettingForm::slotPhase4StateChanged(int state)
{
if(state == Qt::PartiallyChecked){
if(ui->checkBox_phase_3->isChecked()){
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{
}
else
{
ui->checkBox_phase_4->setChecked(false);
}
}else{
}
else
{
ui->phase_4_cutoff_temp->setEnabled(false);
ui->phase_4_scan_rate->setEnabled(false);
ui->phase_4_constant_temp->setEnabled(false);
@ -139,10 +194,61 @@ void ExperimentSettingForm::slotPhase4StateChanged(int state)
}
}
void ExperimentSettingForm::slotPhase5StateChanged(int state)
{
if (state == Qt::PartiallyChecked)
{
if (ui->checkBox_phase_4->isChecked())
{
ui->phase_5_cutoff_temp->setEnabled(true);
ui->phase_5_scan_rate->setEnabled(true);
ui->phase_5_constant_temp->setEnabled(true);
ui->comboBox_phase_5_atmosphere->setEnabled(true);
}
else
{
ui->checkBox_phase_5->setChecked(false);
}
}
else
{
ui->phase_5_cutoff_temp->setEnabled(false);
ui->phase_5_scan_rate->setEnabled(false);
ui->phase_5_constant_temp->setEnabled(false);
ui->comboBox_phase_5_atmosphere->setEnabled(false);
}
}
void ExperimentSettingForm::slotPhase6StateChanged(int state)
{
if (state == Qt::PartiallyChecked)
{
if (ui->checkBox_phase_5->isChecked())
{
ui->phase_6_cutoff_temp->setEnabled(true);
ui->phase_6_scan_rate->setEnabled(true);
ui->phase_6_constant_temp->setEnabled(true);
ui->comboBox_phase_6_atmosphere->setEnabled(true);
}
else
{
ui->checkBox_phase_6->setChecked(false);
}
}
else
{
ui->phase_6_cutoff_temp->setEnabled(false);
ui->phase_6_scan_rate->setEnabled(false);
ui->phase_6_constant_temp->setEnabled(false);
ui->comboBox_phase_6_atmosphere->setEnabled(false);
}
}
void ExperimentSettingForm::slotConnectToDevice()
{
QVector<Phase> phaseVtr;
if(ui->checkBox_phase_1->checkState()){
if (ui->checkBox_phase_1->checkState())
{
Phase phase;
phase.onoff = 1;
phase.cutoff_temp = ui->phase_1_cutoff_temp->text().toFloat();
@ -153,7 +259,8 @@ void ExperimentSettingForm::slotConnectToDevice()
phaseVtr.push_back(phase);
}
if(ui->checkBox_phase_2->checkState()){
if (ui->checkBox_phase_2->checkState())
{
Phase phase;
phase.onoff = 1;
phase.cutoff_temp = ui->phase_2_cutoff_temp->text().toFloat();
@ -185,37 +292,51 @@ void ExperimentSettingForm::slotCancel()
}
void ExperimentSettingForm::slotPhaseCheck()
{
if(sender() == ui->checkBox_phase_2){
if(ui->checkBox_phase_2->isChecked()){
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{
}
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()){
}
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{
}
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()){
}
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{
}
else
{
ui->phase_4_cutoff_temp->setEnabled(false);
ui->phase_4_scan_rate->setEnabled(false);
ui->phase_4_constant_temp->setEnabled(false);
@ -233,3 +354,18 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
FileManager::_expeInfo.date = ui->dateTimeLineEdit->text();
FileManager::_expeInfo.userName = ui->userLineEdit->text();
}
void ExperimentSettingForm::slotRecvPhaseInfo(const QByteArray &ba)
{
QByteArray localba = ba;
SerialPortProtocol *spp = localba.data();
u8 *data = spp->data_buf;
vector<Phase> phaseVtr;
for (int i = 0; i < 6; i++)
{
Phase *phase = (Phase *)(data + i * sizeof(Phase));
phaseVtr.push_back(*phase);
}
}

View File

@ -2,8 +2,12 @@
#define EXPERIMENTSETTINGFORM_H
#include <QWidget>
#include <qvector.h>
namespace Ui {
#include "protocol.h"
namespace Ui
{
class ExperimentSettingForm;
}
@ -15,22 +19,28 @@ public:
explicit ExperimentSettingForm(QWidget *parent = nullptr);
~ExperimentSettingForm();
signals:
void sigDeliverData(const QByteArray &);
public slots:
void slotRecvPhaseInfo(const QByteArray &);
private slots:
void on_pushButton_deliverData_clicked();
private:
//ui
void uiReset();
void uiUpdatePhase(QVector<Phase> &);
// slot
void slotPhaseCheck();
void slotPhase2StateChanged(int state);
void slotPhase3StateChanged(int state);
void slotPhase4StateChanged(int state);
void slotPhase5StateChanged(int state);
void slotPhase6StateChanged(int state);
void slotConnectToDevice();
void slotCancel();
private:
Ui::ExperimentSettingForm *ui;
};

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>851</width>
<height>338</height>
<height>356</height>
</rect>
</property>
<property name="windowTitle">
@ -19,7 +19,7 @@
<x>10</x>
<y>10</y>
<width>821</width>
<height>271</height>
<height>291</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,2">
@ -93,263 +93,14 @@
<x>10</x>
<y>40</y>
<width>491</width>
<height>211</height>
<height>238</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="1,1,1,1,1,1">
<layout class="QGridLayout" name="gridLayout" rowstretch="1,0,0,0,0,0,0,0">
<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">
<item row="7" column="4">
<widget class="QComboBox" name="comboBox_initial_atmosphere">
<item>
<property name="text">
@ -368,42 +119,37 @@
</item>
</widget>
</item>
<item row="4" column="4">
<widget class="QComboBox" name="comboBox_phase_4_atmosphere">
<item>
<property name="text">
<string>NC</string>
<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>
</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>
<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>
</item>
<item>
<property name="text">
<string>N2</string>
<string>2</string>
</property>
</widget>
</item>
<item>
<property name="text">
<string>O2</string>
<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>
</item>
</widget>
</item>
<item row="2" column="4">
@ -425,6 +171,82 @@
</item>
</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="7" 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>
<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="5" column="1">
<widget class="QLineEdit" name="phase_5_cutoff_temp">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>100</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="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="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="4">
<widget class="QComboBox" name="comboBox_phase_1_atmosphere">
<item>
@ -444,13 +266,315 @@
</item>
</widget>
</item>
<item row="5" column="3">
<widget class="QLabel" name="label_7">
<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>
<string>阶段</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignCenter</set>
</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="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="6" column="4">
<widget class="QComboBox" name="comboBox_phase_6_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="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="7" column="2">
<widget class="QRadioButton" name="radioButton_OIT_not">
<property name="text">
<string>非OIT</string>
</property>
</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="5" column="0">
<widget class="QCheckBox" name="checkBox_phase_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>5</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QRadioButton" name="radioButton_OIT">
<property name="text">
<string>OIT</string>
</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="7" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>测试类型:</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLineEdit" name="phase_6_scan_rate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</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="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="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="5" column="2">
<widget class="QLineEdit" name="phase_5_scan_rate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>100</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="5" column="3">
<widget class="QLineEdit" name="phase_5_constant_temp">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>100</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="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="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="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="6" column="0">
<widget class="QCheckBox" name="checkBox_phase_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>6</string>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QLineEdit" name="phase_6_constant_temp">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</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="4">
<widget class="QComboBox" name="comboBox_phase_5_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="6" column="1">
<widget class="QLineEdit" name="phase_6_cutoff_temp">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
@ -463,8 +587,8 @@
<widget class="QPushButton" name="pushButton_deliverData">
<property name="geometry">
<rect>
<x>471</x>
<y>300</y>
<x>470</x>
<y>320</y>
<width>80</width>
<height>20</height>
</rect>
@ -476,8 +600,8 @@
<widget class="QPushButton" name="pushButton_cancel">
<property name="geometry">
<rect>
<x>580</x>
<y>300</y>
<x>579</x>
<y>320</y>
<width>81</width>
<height>20</height>
</rect>