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/ cmake_minimum_required(VERSION 3.5)
project(qt_new_proj LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON) project(AnalysisTool VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_PREFIX_PATH "D:/qt/Qt5.14.2/5.14.2/mingw73_64") # Qt Kit Dir
# 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_AUTOUIC ON)
set(CMAKE_AUTOMOC 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>") set(SEARCH_FOLDERS
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>") ${CMAKE_SOURCE_DIR}
serialport
add_executable(${PROJECT_NAME} ui
WIN32 # If you need a terminal for debug, please comment this statement thirdparty/qcustomplot
${srcs} 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" #include "filemanager.h"
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent), ui(new Ui::MainWindow), _centralWidget(new CentralWidget), _leftWidget(new LeftWidget), _expertmentSettingForm(new ExperimentSettingForm), _realTimeDataForm(new RealTimeDataForm)
, ui(new Ui::MainWindow)
, _centralWidget(new CentralWidget)
,_leftWidget(new LeftWidget)
,_expertmentSettingForm(new ExperimentSettingForm)
,_realTimeDataForm(new RealTimeDataForm)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -42,33 +37,40 @@ MainWindow::~MainWindow()
void MainWindow::connections() void MainWindow::connections()
{ {
//ui // ui
connect(_expertmentSettingForm,&ExperimentSettingForm::sigDeliverData, connect(_expertmentSettingForm, &ExperimentSettingForm::sigDeliverData,
SerialPort::instance(),&SerialPort::slotDeliverData); SerialPort::instance(), &SerialPort::slotDeliverData);
#if 1 #if 1
//dynamic data // dynamic data
connect(SerialPort::instance(),&SerialPort::sigSendCommonData, connect(SerialPort::instance(), &SerialPort::sigSendCommonData,
_centralWidget,&CentralWidget::slotRevCommonData); _centralWidget, &CentralWidget::slotRevCommonData);
connect(SerialPort::instance(),&SerialPort::sigSendCommonData, connect(SerialPort::instance(), &SerialPort::sigSendCommonData,
_realTimeDataForm,&RealTimeDataForm::slotRevCommonData); _realTimeDataForm, &RealTimeDataForm::slotRevCommonData);
connect(SerialPort::instance(), &SerialPort::sigSendCommonDataToRealDataForm,
_realTimeDataForm, &RealTimeDataForm::slotRevCommonData);
connect(SerialPort::instance(), &SerialPort::sigSendPhaseInfo,
_expertmentSettingForm, &ExperimentSettingForm::slotRecvPhaseInfo);
connect(SerialPort::instance(),&SerialPort::sigSendCommonDataToRealDataForm,
_realTimeDataForm,&RealTimeDataForm::slotRevCommonData);
#endif #endif
//mode // mode
connect(Global::instance(),&Global::sigModeModify, connect(Global::instance(), &Global::sigModeModify,
_centralWidget,&CentralWidget::slotModeModify); _centralWidget, &CentralWidget::slotModeModify);
} }
void MainWindow::setActionEnable(const bool flag) void MainWindow::setActionEnable(const bool flag)
{ {
if(flag){ if (flag)
{
ui->actionNew->setEnabled(true); ui->actionNew->setEnabled(true);
ui->actionStart->setEnabled(true); ui->actionStart->setEnabled(true);
ui->actionStop->setEnabled(true); ui->actionStop->setEnabled(true);
ui->actionRealTimeWidget->setEnabled(true); ui->actionRealTimeWidget->setEnabled(true);
}else{ }
else
{
ui->actionNew->setEnabled(false); ui->actionNew->setEnabled(false);
ui->actionStart->setEnabled(false); ui->actionStart->setEnabled(false);
ui->actionStop->setEnabled(false); ui->actionStop->setEnabled(false);
@ -113,10 +115,15 @@ void MainWindow::on_actionRealTimeWidget_triggered()
void MainWindow::on_actionConnectToDev_triggered() void MainWindow::on_actionConnectToDev_triggered()
{ {
if(SerialPort::instance()->openSp()){ if (SerialPort::instance()->openSp())
{
ui->actionNew->setEnabled(true); ui->actionNew->setEnabled(true);
Global::instance()->setMode(Global::Mode::ConnectedToDev); Global::instance()->setMode(Global::Mode::ConnectedToDev);
}else{ QThread::msleep(300);
SerialPort::instance()->senddata(DataParser::inquirePhaseInfo());
}
else
{
QMessageBox::warning(this, "warnning", "Serial Port open failed."); QMessageBox::warning(this, "warnning", "Serial Port open failed.");
} }
} }

View File

@ -6,35 +6,35 @@
#include "defines.h" #include "defines.h"
#include "global.h" #include "global.h"
namespace DataParser
bool DataParser::commonDataParser(const QByteArray &ba, CommonData &cd)
{ {
const char *charArray = ba.data(); bool commonDataParser(const QByteArray &ba, CommonData &cd)
{
const char *charArray = ba.data();
// 判断前两个字节是否为 0xA5 和 0x5A (小端格式) // 判断前两个字节是否为 0xA5 和 0x5A (小端格式)
if (static_cast<unsigned char>(charArray[0]) == 0xA5 && if (static_cast<unsigned char>(charArray[0]) == 0xA5 &&
static_cast<unsigned char>(charArray[1]) == 0x5A) static_cast<unsigned char>(charArray[1]) == 0x5A)
{ {
// std::cout << "前两个字节是 0x5AA5 (小端)" << std::endl; // std::cout << "前两个字节是 0x5AA5 (小端)" << std::endl;
}
else
{
// std::cout << "前两个字节不是 0x5AA5 (小端)" << std::endl;
qDebug() << "header failed.";
return false;
}
if (static_cast<unsigned char>(charArray[3]) != 0x83)
{
qDebug() << "mark failed.";
return false;
}
memcpy(&cd, charArray + 6, sizeof(CommonData));
return true;
} }
else
{
// std::cout << "前两个字节不是 0x5AA5 (小端)" << std::endl;
qDebug()<<"header failed.";
return false;
}
if (static_cast<unsigned char>(charArray[3]) != 0x83)
{
qDebug()<<"mark failed.";
return false;
}
memcpy(&cd, charArray + 6, sizeof(CommonData));
return true;
}
#if 0 #if 0
bool DataParser::slotDataParser(const QByteArray &ba) bool DataParser::slotDataParser(const QByteArray &ba)
@ -64,80 +64,78 @@ bool DataParser::slotDataParser(const QByteArray &ba)
} }
#endif #endif
void DataParser::writeData(const QByteArray &) void writeData(const QByteArray &)
{
}
QByteArray DataParser::connectToDevice(const QVector<Phase> &vtr)
{
const int phaseLength = sizeof(Phase);
const int phaseArrayLength = vtr.size() * phaseLength;
char phaseArray[300] = {};
int offset = 0;
for (const Phase &phase : vtr)
{ {
memcpy(phaseArray + offset, &phase, sizeof(Phase));
offset += phaseLength;
} }
// QByteArray connectToDevice(const QVector<Phase> &vtr)
// int totalDataLength = 0; {
char totalData[300] = {}; const int phaseLength = sizeof(Phase);
const int phaseArrayLength = vtr.size() * phaseLength;
char phaseArray[300] = {};
int offset = 0;
u16 header = 0x5aa5; for (const Phase &phase : vtr)
memcpy(totalData, (char *)&header, sizeof(u16)); {
// totalDataLength +=2; memcpy(phaseArray + offset, &phase, sizeof(Phase));
offset += phaseLength;
}
totalData[2] = 1 + 2 + phaseArrayLength + 2; //
// totalDataLength++; // int totalDataLength = 0;
char totalData[300] = {};
totalData[3] = 0x82; u16 header = 0x5aa5;
// totalDataLength++; memcpy(totalData, (char *)&header, sizeof(u16));
// totalDataLength +=2;
u16 address = 0x0050; totalData[2] = 1 + 2 + phaseArrayLength + 2;
memcpy(totalData + 4, (char *)&address, sizeof(u16)); // totalDataLength++;
memcpy(totalData + 6, phaseArray, phaseArrayLength); totalData[3] = 0x82;
// totalDataLength++;
// u16 address = 0x0050;
char data[300] = {}; memcpy(totalData + 4, (char *)&address, sizeof(u16));
data[0] = 0x82; memcpy(totalData + 6, phaseArray, phaseArrayLength);
// u16 address = 0x0050; //
memcpy(data + 1, (char *)&address, sizeof(u16)); char data[300] = {};
memcpy(data + 3, phaseArray, phaseArrayLength); data[0] = 0x82;
u16 crc = modbusCRC16((u8 *)data, 3 + phaseArrayLength); // u16 address = 0x0050;
// memcpy(data + 1, (char *)&address, sizeof(u16));
memcpy(totalData + 6 + phaseArrayLength, (char *)&crc, sizeof(u16));
// memcpy(data + 3, phaseArray, phaseArrayLength);
return QByteArray(totalData, 6 + phaseArrayLength + 2); u16 crc = modbusCRC16((u8 *)data, 3 + phaseArrayLength);
} //
memcpy(totalData + 6 + phaseArrayLength, (char *)&crc, sizeof(u16));
QByteArray DataParser::setDeviceStartStop(const DeviceStartMode mode) //
{
return QByteArray(totalData, 6 + phaseArrayLength + 2);
}
QByteArray setDeviceStartStop(const DeviceStartMode mode)
{
#if 1 #if 1
SerialPortProtocol spp; SerialPortProtocol spp;
spp.head = FRANE_HEAD; spp.head = FRANE_HEAD;
spp.len = 1 + 2 + 1 + 2; spp.len = 1 + 2 + 1 + 2;
spp.cmd = WRITE_CMD; spp.cmd = WRITE_CMD;
spp.addr = 0x002c; spp.addr = 0x002c;
spp.data_buf[0] = mode; spp.data_buf[0] = mode;
int sppValidLength = 6 + 1; int sppValidLength = 6 + 1;
u8 *dataPtr = (u8*)&spp; u8 *dataPtr = (u8 *)&spp;
u16 crc = modbusCRC16((u8*)(dataPtr + 3),4); u16 crc = modbusCRC16((u8 *)(dataPtr + 3), 4);
return QByteArray((char*)&spp,sppValidLength) + return QByteArray((char *)&spp, sppValidLength) +
QByteArray((char*)&crc,2); QByteArray((char *)&crc, 2);
#endif #endif
#if 0 #if 0
@ -166,28 +164,50 @@ QByteArray DataParser::setDeviceStartStop(const DeviceStartMode mode)
return QByteArray(data,length); return QByteArray(data,length);
#endif #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;
for (unsigned short j = 0; j < length; j++)
{ {
crc ^= (unsigned short)data[j]; unsigned short crc = 0xFFFF;
for (i = 0; i < 8; i++) unsigned char i;
for (unsigned short j = 0; j < length; j++)
{ {
if (crc & 0x0001) crc ^= (unsigned short)data[j];
for (i = 0; i < 8; i++)
{ {
crc = (crc >> 1) ^ 0xA001; if (crc & 0x0001)
} {
else crc = (crc >> 1) ^ 0xA001;
{ }
crc = crc >> 1; else
{
crc = crc >> 1;
}
} }
} }
// CRC结果低字节在前高字节在后
return crc;
} }
// CRC结果低字节在前高字节在后
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 { namespace DataParser {
QByteArray connectToDevice(const QVector<Phase>&); QByteArray connectToDevice(const QVector<Phase>&);
QByteArray inquirePhaseInfo();
QByteArray setDeviceStartStop(const DeviceStartMode); QByteArray setDeviceStartStop(const DeviceStartMode);
bool commonDataParser(const QByteArray&ba,CommonData &cd); bool commonDataParser(const QByteArray&ba,CommonData &cd);
@ -18,30 +19,4 @@ void writeData(const QByteArray&);
unsigned short modbusCRC16(unsigned char *data,unsigned short length); 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 #endif // DATAPARSER_H

View File

@ -6,87 +6,88 @@
#define FRANE_HEAD 0x5AA5 //枕头 #define FRANE_HEAD 0x5AA5 //枕头
#define WRITE_CMD 0x82 //写指令 #define WRITE_CMD 0x82 //写指令
#define READ_CMD 0x83 //读指令 #define READ_CMD 0x83 //读指令
#define PHASE_START_ADDR 0X0050
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
enum DeviceStartMode{ enum DeviceStartMode{
Stop, Stop,
Start, Start,
StartAutoTune, // 启动升温速率自整定 StartAutoTune, // 启动升温速率自整定
StopAutoTune // 停止升温速率自整定 StopAutoTune // 停止升温速率自整定
}; };
typedef struct com_protocol typedef struct com_protocol
{ {
uint16_t head; uint16_t head;
uint8_t len; uint8_t len;
uint8_t cmd; uint8_t cmd;
uint16_t addr; uint16_t addr;
uint8_t data_buf[256]; uint8_t data_buf[256];
}SerialPortProtocol; }SerialPortProtocol;
typedef enum gas_type { typedef enum gas_type {
NC, NC,
N2, N2,
O2 O2
}GasType; }GasType;
typedef 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; }Phase;
struct pid_data struct pid_data
{ {
float kp; float kp;
float ki; float ki;
float kd; float kd;
}; };
typedef struct com_data typedef struct com_data
{ {
uint8_t run_type; //0,运行状态 uint8_t run_type; //0,运行状态
uint8_t current_phase; //1,当前阶段 uint8_t current_phase; //1,当前阶段
float add_run_time; //2,累计运行时间 float add_run_time; //2,累计运行时间
float add_constan_temp_time; //6,当前阶段恒温时间 float add_constan_temp_time; //6,当前阶段恒温时间
double sample_temp; //A,样品温度 double sample_temp; //A,样品温度
double dsc; //12,热流 double dsc; //12,热流
double temp_flow; //1a,升温速率 double temp_flow; //1a,升温速率
float cold_temp; //22,冷端温度 float cold_temp; //22,冷端温度
uint8_t hardware_err; //26,硬件错误 uint8_t hardware_err; //26,硬件错误
uint8_t current_gas; //27,当前气氛 uint8_t current_gas; //27,当前气氛
float auto_pid_temp_flow; //28,自整定升温速率 float auto_pid_temp_flow; //28,自整定升温速率
uint8_t run_mode; //2c,启动模式 uint8_t run_mode; //2c,启动模式
uint8_t reserve_buf[35]; //2d-4f,保留 uint8_t reserve_buf[35]; //2d-4f,保留
struct control_data phase_data[6];//50-97,阶段控制数据 struct control_data phase_data[6];//50-97,阶段控制数据
uint8_t meas_type; //98测试类型 uint8_t meas_type; //98测试类型
uint8_t init_gas; //99, 初始气氛 uint8_t init_gas; //99, 初始气氛
struct pid_data temp_flow_pid_low;//9a-a5,升温速率 低pid struct pid_data temp_flow_pid_low;//9a-a5,升温速率 低pid
struct pid_data temp_flow_pid_high;//a6-B1,升温速率 高pid struct pid_data temp_flow_pid_high;//a6-B1,升温速率 高pid
float cold_temp_cali_standard; //B2,冷端标准温度 float cold_temp_cali_standard; //B2,冷端标准温度
float cold_temp_cali_meas; //B6,冷端测量温度 float cold_temp_cali_meas; //B6,冷端测量温度
uint8_t cold_cali_flag; //B7,冷端温度计算 uint8_t cold_cali_flag; //B7,冷端温度计算
float cold_temp_slope; //B8,冷端温度倍率 float cold_temp_slope; //B8,冷端温度倍率
float sample_temp_calilow_standard;//BC,样品标准温度低倍率 float sample_temp_calilow_standard;//BC,样品标准温度低倍率
float sample_temp_calilow_meas; //C0,样品测量温度低倍率 float sample_temp_calilow_meas; //C0,样品测量温度低倍率
uint8_t sample_temp_cali_low_flag;//C4,样品温度计算低倍率 uint8_t sample_temp_cali_low_flag;//C4,样品温度计算低倍率
float sample_temp_slope_low; //C5,样品温度低倍率低倍率 float sample_temp_slope_low; //C5,样品温度低倍率低倍率
float sample_temp_calimid_standard;//C9,样品标准温度中倍率 float sample_temp_calimid_standard;//C9,样品标准温度中倍率
float sample_temp_calimid_meas; //CD,样品测量温度中倍率 float sample_temp_calimid_meas; //CD,样品测量温度中倍率
uint8_t sample_temp_cali_mid_flag;//D1,样品温度计算中倍率 uint8_t sample_temp_cali_mid_flag;//D1,样品温度计算中倍率
float sample_temp_slope_middle; //D2,样品温度中倍率 float sample_temp_slope_middle; //D2,样品温度中倍率
float sample_temp_calihigh_standard;//D6,样品标准温度高倍率 float sample_temp_calihigh_standard;//D6,样品标准温度高倍率
float sample_temp_calihigh_meas; //样品测量温度高倍率 float sample_temp_calihigh_meas; //样品测量温度高倍率
uint8_t sample_temp_cali_high_flag; //样品温度计算高倍率 uint8_t sample_temp_cali_high_flag; //样品温度计算高倍率
float sample_temp_slope_high; //样品温度高倍率 float sample_temp_slope_high; //样品温度高倍率
float enthalpy_equation_a; //热焓方程式系数a float enthalpy_equation_a; //热焓方程式系数a
float enthalpy_equation_b; //热焓方程式系数b float enthalpy_equation_b; //热焓方程式系数b
float enthalpy_equation_c; //热焓方程式系数c float enthalpy_equation_c; //热焓方程式系数c
} CommonData; } CommonData;
#pragma pack(pop) #pragma pack(pop)
@ -94,7 +95,7 @@ typedef struct com_data
#if 0 #if 0
struct com_device struct com_device
{ {
struct temp_control* temp; struct temp_control* temp;
}; };
struct com_data* com_data_get(void); struct com_data* com_data_get(void);
void com_protocol_init(struct com_device* dev); void com_protocol_init(struct com_device* dev);

View File

@ -121,11 +121,20 @@ void SerialPort::slotReadData()
} }
else else
{ {
if (Global::Mode::ExperimentStart == Global::instance()->getMode()) // read data
if (spp->addr == 0)
{ {
emit sigSendCommonData(cd);
if (Global::Mode::ExperimentStart == Global::instance()->getMode())
{
emit sigSendCommonData(cd);
}
emit sigSendCommonDataToRealDataForm(cd);
}
else if(spp->addr == PHASE_START_ADDR)
{
emit sigSendPhaseInfo(ba);
} }
emit sigSendCommonDataToRealDataForm(cd);
} }
#endif #endif
} }
@ -137,14 +146,15 @@ void SerialPort::writeCmdHandle(const int dataLength, const u16 addr,
int localAddr = addr; int localAddr = addr;
int phaseByteSize = sizeof(Phase); int phaseByteSize = sizeof(Phase);
auto phaseParserFunc = [&](const int index){ auto phaseParserFunc = [&](const int index)
{
Phase phase; Phase phase;
phase.onoff = 1; phase.onoff = 1;
phase.gas = cd.phase_data[index].gas; phase.gas = cd.phase_data[index].gas;
phase.temp_flow = cd.phase_data[index].temp_flow; phase.temp_flow = cd.phase_data[index].temp_flow;
phase.cutoff_temp = cd.phase_data[index].cutoff_temp; phase.cutoff_temp = cd.phase_data[index].cutoff_temp;
phase.constant_temp_time_min = phase.constant_temp_time_min =
cd.phase_data[index].constant_temp_time_min; cd.phase_data[index].constant_temp_time_min;
localLength -= phaseByteSize; localLength -= phaseByteSize;
localAddr += phaseByteSize; localAddr += phaseByteSize;
@ -154,12 +164,12 @@ void SerialPort::writeCmdHandle(const int dataLength, const u16 addr,
{ {
switch (localAddr) switch (localAddr)
{ {
case offsetof(CommonData, current_gas): //当前气氛 case offsetof(CommonData, current_gas): // 当前气氛
// gas_type_set(dev->temp, msg_data.current_gas); // gas_type_set(dev->temp, msg_data.current_gas);
localAddr += 1; localAddr += 1;
localLength -= 1; localLength -= 1;
break; break;
case offsetof(CommonData, auto_pid_temp_flow): //自整定升温速率 case offsetof(CommonData, auto_pid_temp_flow): // 自整定升温速率
localAddr += 4; localAddr += 4;
localLength -= 4; localLength -= 4;
break; break;
@ -185,18 +195,25 @@ void SerialPort::writeCmdHandle(const int dataLength, const u16 addr,
break; break;
} }
case offsetof(CommonData, phase_data[0].onoff): case offsetof(CommonData, phase_data[0].onoff):
phaseParserFunc(0); break; phaseParserFunc(0);
break;
case offsetof(CommonData, phase_data[1].onoff): case offsetof(CommonData, phase_data[1].onoff):
phaseParserFunc(1); break; phaseParserFunc(1);
break;
case offsetof(CommonData, phase_data[2].onoff): case offsetof(CommonData, phase_data[2].onoff):
phaseParserFunc(2); break; phaseParserFunc(2);
break;
case offsetof(CommonData, phase_data[3].onoff): case offsetof(CommonData, phase_data[3].onoff):
phaseParserFunc(3); break; phaseParserFunc(3);
break;
case offsetof(CommonData, phase_data[4].onoff): case offsetof(CommonData, phase_data[4].onoff):
phaseParserFunc(4); break; phaseParserFunc(4);
break;
case offsetof(CommonData, phase_data[5].onoff): case offsetof(CommonData, phase_data[5].onoff):
phaseParserFunc(5); break; phaseParserFunc(5);
default:break; break;
default:
break;
}; };
} }
} }
@ -407,7 +424,8 @@ void SerialPort::slotSendData(const QByteArray &ba)
* *
* 1 * 1
*/ */
if(WRITE_CMD == ba.at(3)){ if (WRITE_CMD == ba.at(3))
{
_lastWriteBa = ba; _lastWriteBa = ba;
} }
qDebug() << "slotSendData:" << ba.size(); qDebug() << "slotSendData:" << ba.size();
@ -419,7 +437,6 @@ void SerialPort::slotSendData(const QByteArray &ba)
else else
{ {
qDebug() << "sp not open."; qDebug() << "sp not open.";
// qErrnoWarning("sp not open.");
return; return;
} }
} }

View File

@ -8,11 +8,12 @@
#include "defines.h" #include "defines.h"
#include "protocol.h" #include "protocol.h"
class SerialPort:public QObject class SerialPort : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
enum E_CMD_TYPE{ enum E_CMD_TYPE
{
e_zero, e_zero,
e_forward, e_forward,
e_back e_back
@ -21,27 +22,35 @@ public:
static SerialPort *instance(); static SerialPort *instance();
~SerialPort(); ~SerialPort();
void sendData(const QByteArray &data)
{
slotSendData(data);
}
void sendCmd(const E_CMD_TYPE e); void sendCmd(const E_CMD_TYPE e);
static void parserTest(); static void parserTest();
bool openSp(); bool openSp();
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: protected:
void timerEvent(QTimerEvent *event); 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();
private slots: private slots:
void slotReadData(); void slotReadData();
private: private:
void writeCmdHandle(const int dataLength,const u16 addr,const CommonData&cd); void writeCmdHandle(const int dataLength, const u16 addr, const CommonData &cd);
void to_hex(char* in_char, int char_length, char* out_char); void to_hex(char *in_char, int char_length, char *out_char);
void displayPortInfo(); void displayPortInfo();
private: private:
SerialPort(QObject* parent=nullptr); SerialPort(QObject *parent = nullptr);
QSerialPort *_sp; QSerialPort *_sp;
QByteArray _lastWriteBa; QByteArray _lastWriteBa;
}; };

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,24 +8,27 @@
#include "global.h" #include "global.h"
#include "filemanager.h" #include "filemanager.h"
ExperimentSettingForm::ExperimentSettingForm(QWidget *parent) : ExperimentSettingForm::ExperimentSettingForm(QWidget *parent) : QWidget(parent),
QWidget(parent), ui(new Ui::ExperimentSettingForm)
ui(new Ui::ExperimentSettingForm)
{ {
ui->setupUi(this); ui->setupUi(this);
uiReset(); uiReset();
connect(ui->checkBox_phase_2,&QCheckBox::clicked, connect(ui->checkBox_phase_2, &QCheckBox::clicked,
this,&ExperimentSettingForm::slotPhase2StateChanged); this, &ExperimentSettingForm::slotPhase2StateChanged);
connect(ui->checkBox_phase_3,&QCheckBox::clicked, connect(ui->checkBox_phase_3, &QCheckBox::clicked,
this,&ExperimentSettingForm::slotPhase3StateChanged); this, &ExperimentSettingForm::slotPhase3StateChanged);
connect(ui->checkBox_phase_4,&QCheckBox::clicked, connect(ui->checkBox_phase_4, &QCheckBox::clicked,
this,&ExperimentSettingForm::slotPhase4StateChanged); 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, // 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);
} }
ExperimentSettingForm::~ExperimentSettingForm() ExperimentSettingForm::~ExperimentSettingForm()
@ -35,7 +38,7 @@ ExperimentSettingForm::~ExperimentSettingForm()
void ExperimentSettingForm::uiReset() void ExperimentSettingForm::uiReset()
{ {
//init data and status. // init data and status.
ui->checkBox_phase_1->setChecked(true); ui->checkBox_phase_1->setChecked(true);
ui->checkBox_phase_1->setEnabled(false); ui->checkBox_phase_1->setEnabled(false);
@ -43,52 +46,89 @@ void ExperimentSettingForm::uiReset()
ui->phase_2_cutoff_temp->setText("0"); ui->phase_2_cutoff_temp->setText("0");
ui->phase_3_cutoff_temp->setText("0"); ui->phase_3_cutoff_temp->setText("0");
ui->phase_4_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_1_scan_rate->setText("0");
ui->phase_2_scan_rate->setText("0"); ui->phase_2_scan_rate->setText("0");
ui->phase_3_scan_rate->setText("0"); ui->phase_3_scan_rate->setText("0");
ui->phase_4_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_1_constant_temp->setText("0");
ui->phase_2_constant_temp->setText("0"); ui->phase_2_constant_temp->setText("0");
ui->phase_3_constant_temp->setText("0"); ui->phase_3_constant_temp->setText("0");
ui->phase_4_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_2_cutoff_temp->setEnabled(false);
ui->phase_3_cutoff_temp->setEnabled(false); ui->phase_3_cutoff_temp->setEnabled(false);
ui->phase_4_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_2_scan_rate->setEnabled(false);
ui->phase_3_scan_rate->setEnabled(false); ui->phase_3_scan_rate->setEnabled(false);
ui->phase_4_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_2_constant_temp->setEnabled(false);
ui->phase_3_constant_temp->setEnabled(false); ui->phase_3_constant_temp->setEnabled(false);
ui->phase_4_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_2_atmosphere->setEnabled(false);
ui->comboBox_phase_3_atmosphere->setEnabled(false); ui->comboBox_phase_3_atmosphere->setEnabled(false);
ui->comboBox_phase_4_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->radioButton_OIT_not->setChecked(true);
ui->checkBox_phase_2->setTristate(false); ui->checkBox_phase_2->setTristate(false);
ui->checkBox_phase_3->setTristate(false); ui->checkBox_phase_3->setTristate(false);
ui->checkBox_phase_4->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) void ExperimentSettingForm::slotPhase2StateChanged(int state)
{ {
qDebug()<<"slotPhase2StateChanged:"<<state; qDebug() << "slotPhase2StateChanged:" << state;
if(state == Qt::PartiallyChecked){ if (state == Qt::PartiallyChecked)
{
ui->phase_2_cutoff_temp->setEnabled(true); ui->phase_2_cutoff_temp->setEnabled(true);
ui->phase_2_scan_rate->setEnabled(true); ui->phase_2_scan_rate->setEnabled(true);
ui->phase_2_constant_temp->setEnabled(true); ui->phase_2_constant_temp->setEnabled(true);
ui->comboBox_phase_2_atmosphere->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); ui->checkBox_phase_2->setCheckState(Qt::Checked);
}else { }
else
{
ui->phase_2_cutoff_temp->setEnabled(false); ui->phase_2_cutoff_temp->setEnabled(false);
ui->phase_2_scan_rate->setEnabled(false); ui->phase_2_scan_rate->setEnabled(false);
ui->phase_2_constant_temp->setEnabled(false); ui->phase_2_constant_temp->setEnabled(false);
@ -99,19 +139,28 @@ void ExperimentSettingForm::slotPhase2StateChanged(int state)
void ExperimentSettingForm::slotPhase3StateChanged(int state) void ExperimentSettingForm::slotPhase3StateChanged(int state)
{ {
if(state == Qt::PartiallyChecked){ if (state == Qt::PartiallyChecked)
if(ui->checkBox_phase_2->isChecked()){ {
if (ui->checkBox_phase_2->isChecked())
{
ui->phase_3_cutoff_temp->setEnabled(true); ui->phase_3_cutoff_temp->setEnabled(true);
ui->phase_3_scan_rate->setEnabled(true); ui->phase_3_scan_rate->setEnabled(true);
ui->phase_3_constant_temp->setEnabled(true); ui->phase_3_constant_temp->setEnabled(true);
ui->comboBox_phase_3_atmosphere->setEnabled(true); ui->comboBox_phase_3_atmosphere->setEnabled(true);
}else{ }
else
{
ui->checkBox_phase_3->setChecked(false); 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); ui->checkBox_phase_3->setChecked(true);
}else{ }
else
{
ui->phase_3_cutoff_temp->setEnabled(false); ui->phase_3_cutoff_temp->setEnabled(false);
ui->phase_3_scan_rate->setEnabled(false); ui->phase_3_scan_rate->setEnabled(false);
ui->phase_3_constant_temp->setEnabled(false); ui->phase_3_constant_temp->setEnabled(false);
@ -122,16 +171,22 @@ void ExperimentSettingForm::slotPhase3StateChanged(int state)
void ExperimentSettingForm::slotPhase4StateChanged(int state) void ExperimentSettingForm::slotPhase4StateChanged(int state)
{ {
if(state == Qt::PartiallyChecked){ if (state == Qt::PartiallyChecked)
if(ui->checkBox_phase_3->isChecked()){ {
if (ui->checkBox_phase_3->isChecked())
{
ui->phase_4_cutoff_temp->setEnabled(true); ui->phase_4_cutoff_temp->setEnabled(true);
ui->phase_4_scan_rate->setEnabled(true); ui->phase_4_scan_rate->setEnabled(true);
ui->phase_4_constant_temp->setEnabled(true); ui->phase_4_constant_temp->setEnabled(true);
ui->comboBox_phase_4_atmosphere->setEnabled(true); ui->comboBox_phase_4_atmosphere->setEnabled(true);
}else{ }
else
{
ui->checkBox_phase_4->setChecked(false); ui->checkBox_phase_4->setChecked(false);
} }
}else{ }
else
{
ui->phase_4_cutoff_temp->setEnabled(false); ui->phase_4_cutoff_temp->setEnabled(false);
ui->phase_4_scan_rate->setEnabled(false); ui->phase_4_scan_rate->setEnabled(false);
ui->phase_4_constant_temp->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() void ExperimentSettingForm::slotConnectToDevice()
{ {
QVector<Phase> phaseVtr; QVector<Phase> phaseVtr;
if(ui->checkBox_phase_1->checkState()){ if (ui->checkBox_phase_1->checkState())
{
Phase phase; Phase phase;
phase.onoff = 1; phase.onoff = 1;
phase.cutoff_temp = ui->phase_1_cutoff_temp->text().toFloat(); phase.cutoff_temp = ui->phase_1_cutoff_temp->text().toFloat();
@ -153,7 +259,8 @@ void ExperimentSettingForm::slotConnectToDevice()
phaseVtr.push_back(phase); phaseVtr.push_back(phase);
} }
if(ui->checkBox_phase_2->checkState()){ if (ui->checkBox_phase_2->checkState())
{
Phase phase; Phase phase;
phase.onoff = 1; phase.onoff = 1;
phase.cutoff_temp = ui->phase_2_cutoff_temp->text().toFloat(); phase.cutoff_temp = ui->phase_2_cutoff_temp->text().toFloat();
@ -166,7 +273,7 @@ void ExperimentSettingForm::slotConnectToDevice()
} }
QByteArray ba = DataParser::connectToDevice(phaseVtr); QByteArray ba = DataParser::connectToDevice(phaseVtr);
qDebug()<<"ba size:"<<ba.size(); qDebug() << "ba size:" << ba.size();
emit sigDeliverData(ba); emit sigDeliverData(ba);
// Global::instance()->setMode(Global::Mode::ConnectedToDev); // Global::instance()->setMode(Global::Mode::ConnectedToDev);
@ -185,37 +292,51 @@ void ExperimentSettingForm::slotCancel()
} }
void ExperimentSettingForm::slotPhaseCheck() void ExperimentSettingForm::slotPhaseCheck()
{ {
if(sender() == ui->checkBox_phase_2){ if (sender() == ui->checkBox_phase_2)
if(ui->checkBox_phase_2->isChecked()){ {
if (ui->checkBox_phase_2->isChecked())
{
ui->phase_2_cutoff_temp->setEnabled(true); ui->phase_2_cutoff_temp->setEnabled(true);
ui->phase_2_scan_rate->setEnabled(true); ui->phase_2_scan_rate->setEnabled(true);
ui->phase_2_constant_temp->setEnabled(true); ui->phase_2_constant_temp->setEnabled(true);
ui->comboBox_phase_2_atmosphere->setEnabled(true); ui->comboBox_phase_2_atmosphere->setEnabled(true);
}else{ }
else
{
ui->phase_2_cutoff_temp->setEnabled(false); ui->phase_2_cutoff_temp->setEnabled(false);
ui->phase_2_scan_rate->setEnabled(false); ui->phase_2_scan_rate->setEnabled(false);
ui->phase_2_constant_temp->setEnabled(false); ui->phase_2_constant_temp->setEnabled(false);
ui->comboBox_phase_2_atmosphere->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_cutoff_temp->setEnabled(true);
ui->phase_3_scan_rate->setEnabled(true); ui->phase_3_scan_rate->setEnabled(true);
ui->phase_3_constant_temp->setEnabled(true); ui->phase_3_constant_temp->setEnabled(true);
ui->comboBox_phase_3_atmosphere->setEnabled(true); ui->comboBox_phase_3_atmosphere->setEnabled(true);
}else{ }
else
{
ui->phase_3_cutoff_temp->setEnabled(false); ui->phase_3_cutoff_temp->setEnabled(false);
ui->phase_3_scan_rate->setEnabled(false); ui->phase_3_scan_rate->setEnabled(false);
ui->phase_3_constant_temp->setEnabled(false); ui->phase_3_constant_temp->setEnabled(false);
ui->comboBox_phase_3_atmosphere->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_cutoff_temp->setEnabled(true);
ui->phase_4_scan_rate->setEnabled(true); ui->phase_4_scan_rate->setEnabled(true);
ui->phase_4_constant_temp->setEnabled(true); ui->phase_4_constant_temp->setEnabled(true);
ui->comboBox_phase_4_atmosphere->setEnabled(true); ui->comboBox_phase_4_atmosphere->setEnabled(true);
}else{ }
else
{
ui->phase_4_cutoff_temp->setEnabled(false); ui->phase_4_cutoff_temp->setEnabled(false);
ui->phase_4_scan_rate->setEnabled(false); ui->phase_4_scan_rate->setEnabled(false);
ui->phase_4_constant_temp->setEnabled(false); ui->phase_4_constant_temp->setEnabled(false);
@ -228,8 +349,23 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
{ {
slotConnectToDevice(); slotConnectToDevice();
FileManager::_expeInfo.sampleName= ui->sampleNameLineEdit->text(); FileManager::_expeInfo.sampleName = ui->sampleNameLineEdit->text();
FileManager::_expeInfo.sampleWeight = ui->sampleWeightLineEdit->text().toInt(nullptr,16); FileManager::_expeInfo.sampleWeight = ui->sampleWeightLineEdit->text().toInt(nullptr, 16);
FileManager::_expeInfo.date = ui->dateTimeLineEdit->text(); FileManager::_expeInfo.date = ui->dateTimeLineEdit->text();
FileManager::_expeInfo.userName = ui->userLineEdit->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 #define EXPERIMENTSETTINGFORM_H
#include <QWidget> #include <QWidget>
#include <qvector.h>
namespace Ui { #include "protocol.h"
namespace Ui
{
class ExperimentSettingForm; class ExperimentSettingForm;
} }
@ -15,22 +19,28 @@ public:
explicit ExperimentSettingForm(QWidget *parent = nullptr); explicit ExperimentSettingForm(QWidget *parent = nullptr);
~ExperimentSettingForm(); ~ExperimentSettingForm();
signals: signals:
void sigDeliverData(const QByteArray&); void sigDeliverData(const QByteArray &);
public slots:
void slotRecvPhaseInfo(const QByteArray &);
private slots: private slots:
void on_pushButton_deliverData_clicked(); void on_pushButton_deliverData_clicked();
private: private:
//ui
void uiReset(); void uiReset();
//slot void uiUpdatePhase(QVector<Phase> &);
// slot
void slotPhaseCheck(); void slotPhaseCheck();
void slotPhase2StateChanged(int state); void slotPhase2StateChanged(int state);
void slotPhase3StateChanged(int state); void slotPhase3StateChanged(int state);
void slotPhase4StateChanged(int state); void slotPhase4StateChanged(int state);
void slotPhase5StateChanged(int state);
void slotPhase6StateChanged(int state);
void slotConnectToDevice(); void slotConnectToDevice();
void slotCancel(); void slotCancel();
private: private:
Ui::ExperimentSettingForm *ui; Ui::ExperimentSettingForm *ui;
}; };

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>851</width> <width>851</width>
<height>338</height> <height>356</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -19,7 +19,7 @@
<x>10</x> <x>10</x>
<y>10</y> <y>10</y>
<width>821</width> <width>821</width>
<height>271</height> <height>291</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,2"> <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,2">
@ -93,263 +93,14 @@
<x>10</x> <x>10</x>
<y>40</y> <y>40</y>
<width>491</width> <width>491</width>
<height>211</height> <height>238</height>
</rect> </rect>
</property> </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"> <property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum> <enum>QLayout::SetDefaultConstraint</enum>
</property> </property>
<item row="0" column="0"> <item row="7" column="4">
<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"> <widget class="QComboBox" name="comboBox_initial_atmosphere">
<item> <item>
<property name="text"> <property name="text">
@ -368,42 +119,37 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="4" column="4"> <item row="2" column="2">
<widget class="QComboBox" name="comboBox_phase_4_atmosphere"> <widget class="QLineEdit" name="phase_2_scan_rate">
<item> <property name="sizePolicy">
<property name="text"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<string>NC</string> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
</item> </sizepolicy>
<item> </property>
<property name="text">
<string>N2</string>
</property>
</item>
<item>
<property name="text">
<string>O2</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="3" column="4"> <item row="2" column="0">
<widget class="QComboBox" name="comboBox_phase_3_atmosphere"> <widget class="QCheckBox" name="checkBox_phase_2">
<item> <property name="sizePolicy">
<property name="text"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<string>NC</string> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
</item> </sizepolicy>
<item> </property>
<property name="text"> <property name="text">
<string>N2</string> <string>2</string>
</property> </property>
</item> </widget>
<item> </item>
<property name="text"> <item row="4" column="3">
<string>O2</string> <widget class="QLineEdit" name="phase_4_constant_temp">
</property> <property name="sizePolicy">
</item> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget> </widget>
</item> </item>
<item row="2" column="4"> <item row="2" column="4">
@ -425,6 +171,82 @@
</item> </item>
</widget> </widget>
</item> </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"> <item row="1" column="4">
<widget class="QComboBox" name="comboBox_phase_1_atmosphere"> <widget class="QComboBox" name="comboBox_phase_1_atmosphere">
<item> <item>
@ -444,13 +266,315 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="5" column="3"> <item row="0" column="0">
<widget class="QLabel" name="label_7"> <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"> <property name="text">
<string>初始气氛:</string> <string>阶段</string>
</property> </property>
<property name="alignment"> <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> </property>
</widget> </widget>
</item> </item>
@ -463,8 +587,8 @@
<widget class="QPushButton" name="pushButton_deliverData"> <widget class="QPushButton" name="pushButton_deliverData">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>471</x> <x>470</x>
<y>300</y> <y>320</y>
<width>80</width> <width>80</width>
<height>20</height> <height>20</height>
</rect> </rect>
@ -476,8 +600,8 @@
<widget class="QPushButton" name="pushButton_cancel"> <widget class="QPushButton" name="pushButton_cancel">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>580</x> <x>579</x>
<y>300</y> <y>320</y>
<width>81</width> <width>81</width>
<height>20</height> <height>20</height>
</rect> </rect>