2025-03-14T16:58:07
This commit is contained in:
parent
d1c95336e1
commit
859dde6b50
@ -23,8 +23,16 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
setCentralWidget(_centralWidget);
|
setCentralWidget(_centralWidget);
|
||||||
addDockWidget(Qt::LeftDockWidgetArea, _leftWidget);
|
addDockWidget(Qt::LeftDockWidgetArea, _leftWidget);
|
||||||
|
//
|
||||||
|
ui->statusbar->showMessage("showMessage show temp message!");
|
||||||
|
// permenent show
|
||||||
|
QLabel *permenentLabel = new QLabel(this);
|
||||||
|
permenentLabel->setText("Permanent show!");
|
||||||
|
ui->statusbar->addPermanentWidget(permenentLabel);
|
||||||
|
//
|
||||||
connections();
|
connections();
|
||||||
|
//
|
||||||
|
_realTimeDataForm->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -38,8 +46,15 @@ void MainWindow::connections()
|
|||||||
connect(_expertmentSettingForm,&ExperimentSettingForm::sigConnectToDevice,
|
connect(_expertmentSettingForm,&ExperimentSettingForm::sigConnectToDevice,
|
||||||
SerialPort::instance(),&SerialPort::slotConnectToDevice);
|
SerialPort::instance(),&SerialPort::slotConnectToDevice);
|
||||||
//dynamic data
|
//dynamic data
|
||||||
|
#if 1
|
||||||
connect(SerialPort::instance(),&SerialPort::sigSendCommonData,
|
connect(SerialPort::instance(),&SerialPort::sigSendCommonData,
|
||||||
_centralWidget,&CentralWidget::slotRevCommonData);
|
_centralWidget,&CentralWidget::slotRevCommonData);
|
||||||
|
connect(SerialPort::instance(),&SerialPort::sigSendCommonData,
|
||||||
|
_realTimeDataForm,&RealTimeDataForm::slotRevCommonData);
|
||||||
|
connect(SerialPort::instance(),&SerialPort::sigSendCommonDataToRealDataForm,
|
||||||
|
_realTimeDataForm,&RealTimeDataForm::slotRevCommonData);
|
||||||
|
#endif
|
||||||
|
|
||||||
//mode
|
//mode
|
||||||
connect(Global::instance(),&Global::sigModeModify,
|
connect(Global::instance(),&Global::sigModeModify,
|
||||||
_centralWidget,&CentralWidget::slotModeModify);
|
_centralWidget,&CentralWidget::slotModeModify);
|
||||||
@ -64,7 +79,7 @@ void MainWindow::on_actionStop_triggered()
|
|||||||
{
|
{
|
||||||
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Stop);
|
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Stop);
|
||||||
SerialPort::instance()->slotSendData(ba);
|
SerialPort::instance()->slotSendData(ba);
|
||||||
SerialPort::instance()->slotCloseSp();
|
// SerialPort::instance()->slotCloseSp();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionNew_triggered()
|
void MainWindow::on_actionNew_triggered()
|
||||||
@ -75,6 +90,10 @@ void MainWindow::on_actionNew_triggered()
|
|||||||
void MainWindow::on_actionStart_triggered()
|
void MainWindow::on_actionStart_triggered()
|
||||||
{
|
{
|
||||||
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Start);
|
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Start);
|
||||||
|
|
||||||
|
QString hexData = ba.toHex(' '); // ' ' 作为分隔符,可选参数
|
||||||
|
qDebug() << "on_actionStart_triggered info (hex):" << hexData;
|
||||||
|
|
||||||
SerialPort::instance()->slotSendData(ba);
|
SerialPort::instance()->slotSendData(ba);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,11 +2,13 @@
|
|||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QStatusBar>
|
||||||
|
|
||||||
#include "centralwidget.h"
|
#include "centralwidget.h"
|
||||||
#include "leftwidget.h"
|
#include "leftwidget.h"
|
||||||
#include "experimentsettingform.h"
|
#include "experimentsettingform.h"
|
||||||
#include "realtimedataform.h"
|
#include "realtimedataform.h"
|
||||||
|
#include "dataparser.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
@ -35,5 +37,6 @@ private:
|
|||||||
LeftWidget*_leftWidget;
|
LeftWidget*_leftWidget;
|
||||||
ExperimentSettingForm *_expertmentSettingForm;
|
ExperimentSettingForm *_expertmentSettingForm;
|
||||||
RealTimeDataForm* _realTimeDataForm;
|
RealTimeDataForm* _realTimeDataForm;
|
||||||
|
QStatusBar *_statusBar;
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "dataparser.h"
|
#include "dataparser.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
DataParser::DataParser()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DataParser::commonDataParser(const QByteArray &ba, CommonData &cd)
|
bool DataParser::commonDataParser(const QByteArray &ba, CommonData &cd)
|
||||||
{
|
{
|
||||||
@ -17,7 +16,6 @@ bool DataParser::commonDataParser(const QByteArray &ba, CommonData &cd)
|
|||||||
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
|
else
|
||||||
{
|
{
|
||||||
@ -37,6 +35,41 @@ bool DataParser::commonDataParser(const QByteArray &ba, CommonData &cd)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
bool DataParser::slotDataParser(const QByteArray &ba)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
SerialPortProtocol spp;
|
||||||
|
memcpy(&spp,ba.data(),ba.size());
|
||||||
|
#endif
|
||||||
|
SerialPortProtocol *spp = (SerialPortProtocol *)ba.data();
|
||||||
|
int length = spp->len - 5;
|
||||||
|
|
||||||
|
CommonData cd;
|
||||||
|
u8* cdPtr = (u8*)&cd;
|
||||||
|
|
||||||
|
memcpy(cdPtr + spp->addr,spp->data_buf,length);
|
||||||
|
|
||||||
|
qDebug()<<"revDataParser run_type:"<<cd.run_mode;
|
||||||
|
|
||||||
|
while(length){
|
||||||
|
switch(spp->addr){
|
||||||
|
case offsetof(CommonData,run_mode):
|
||||||
|
Global::Mode mode = (Global::Mode)cd.run_mode;
|
||||||
|
length--;
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void DataParser::writeData(const QByteArray &)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QByteArray DataParser::connectToDevice(const QVector<Phase> &vtr)
|
QByteArray DataParser::connectToDevice(const QVector<Phase> &vtr)
|
||||||
{
|
{
|
||||||
const int phaseLength = sizeof(Phase);
|
const int phaseLength = sizeof(Phase);
|
||||||
@ -90,6 +123,24 @@ QByteArray DataParser::connectToDevice(const QVector<Phase> &vtr)
|
|||||||
|
|
||||||
QByteArray DataParser::setDeviceStartStop(const DeviceStartMode mode)
|
QByteArray DataParser::setDeviceStartStop(const DeviceStartMode mode)
|
||||||
{
|
{
|
||||||
|
#if 1
|
||||||
|
SerialPortProtocol spp;
|
||||||
|
spp.head = FRANE_HEAD;
|
||||||
|
spp.len = 1 + 2 + 1 + 2;
|
||||||
|
spp.cmd = WRITE_CMD;
|
||||||
|
spp.addr = 0x002c;
|
||||||
|
spp.data_buf[0] = mode;
|
||||||
|
|
||||||
|
int sppValidLength = 6 + 1;
|
||||||
|
|
||||||
|
u8 *dataPtr = (u8*)&spp;
|
||||||
|
u16 crc = modbusCRC16((u8*)(dataPtr + 3),4);
|
||||||
|
|
||||||
|
return QByteArray((char*)&spp,sppValidLength) +
|
||||||
|
QByteArray((char*)&crc,2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
char data[300] = {};
|
char data[300] = {};
|
||||||
// header
|
// header
|
||||||
u16 header = 0x5aa5;
|
u16 header = 0x5aa5;
|
||||||
@ -114,6 +165,7 @@ QByteArray DataParser::setDeviceStartStop(const DeviceStartMode mode)
|
|||||||
int length = 9;
|
int length = 9;
|
||||||
|
|
||||||
return QByteArray(data,length);
|
return QByteArray(data,length);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short DataParser::modbusCRC16(unsigned char *data, unsigned short length)
|
unsigned short DataParser::modbusCRC16(unsigned char *data, unsigned short length)
|
||||||
|
|||||||
@ -3,20 +3,45 @@
|
|||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <qbytearray.h>
|
#include <qbytearray.h>
|
||||||
|
#include <qobject.h>
|
||||||
|
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
|
namespace DataParser {
|
||||||
|
QByteArray connectToDevice(const QVector<Phase>&);
|
||||||
|
QByteArray setDeviceStartStop(const DeviceStartMode);
|
||||||
|
|
||||||
|
bool commonDataParser(const QByteArray&ba,CommonData &cd);
|
||||||
|
void writeData(const QByteArray&);
|
||||||
|
|
||||||
|
unsigned short modbusCRC16(unsigned char *data,unsigned short length);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
class DataParser
|
class DataParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DataParser();
|
void dataParser(const QByteArray& ba);
|
||||||
|
|
||||||
static unsigned short modbusCRC16(unsigned char *data,unsigned short length);
|
static unsigned short modbusCRC16(unsigned char *data,unsigned short length);
|
||||||
static QByteArray connectToDevice(const QVector<Phase>&);
|
static QByteArray connectToDevice(const QVector<Phase>&);
|
||||||
static QByteArray setDeviceStartStop(const DeviceStartMode);
|
static QByteArray setDeviceStartStop(const DeviceStartMode);
|
||||||
|
|
||||||
static bool commonDataParser(const QByteArray&ba,CommonData &cd);
|
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
|
||||||
|
|||||||
@ -17,14 +17,14 @@ enum DeviceStartMode{
|
|||||||
StopAutoTune // 停止升温速率自整定
|
StopAutoTune // 停止升温速率自整定
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
typedef enum gas_type {
|
typedef enum gas_type {
|
||||||
NC,
|
NC,
|
||||||
|
|||||||
@ -93,53 +93,67 @@ void SerialPort::timerEvent(QTimerEvent *event)
|
|||||||
|
|
||||||
void SerialPort::slotReadData()
|
void SerialPort::slotReadData()
|
||||||
{
|
{
|
||||||
|
#if 1
|
||||||
QByteArray ba = _sp->readAll();
|
QByteArray ba = _sp->readAll();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// 将 QByteArray 转换为十六进制字符串
|
|
||||||
QString hexData = ba.toHex(' '); // ' ' 作为分隔符,可选参数
|
QString hexData = ba.toHex(' '); // ' ' 作为分隔符,可选参数
|
||||||
qDebug() << "receive info (hex):" << hexData;
|
qDebug() << "receive info (hex):" << hexData;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CommonData cd;
|
SerialPortProtocol *spp = (SerialPortProtocol*)ba.data();
|
||||||
if (!DataParser::commonDataParser(ba, cd))
|
qDebug()<<"header:"<<QString::number(spp->head,16).toUpper();
|
||||||
{
|
if(FRANE_HEAD != spp->head){
|
||||||
qDebug() << "CommonData parse failed.";
|
qDebug()<<"Data header error.";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化输出 float 类型,保留两位小数
|
int length = spp->len - 5;
|
||||||
QString formattedRunTime = QString::number(cd.add_run_time, 'f', 2);
|
|
||||||
qDebug() << "run time:" << formattedRunTime;
|
|
||||||
|
|
||||||
qDebug()<<"phase:"<<QString::number(cd.current_phase);
|
CommonData cd;
|
||||||
qDebug()<<"dsc:"<<QString::number(cd.dsc,'f',3);
|
u8* cdPtr = (u8*)&cd;
|
||||||
|
memcpy(cdPtr + spp->addr,spp->data_buf,length);
|
||||||
// 格式化输出 double 类型,保留三位小数
|
|
||||||
QString formattedSampleTemp = QString::number(cd.sample_temp, 'f', 3);
|
|
||||||
qDebug() << "sample temp:" << formattedSampleTemp;
|
|
||||||
|
|
||||||
QString formattedColdTemp = QString::number(cd.cold_temp, 'f', 3);
|
|
||||||
qDebug() << "cold temp:" << formattedColdTemp;
|
|
||||||
|
|
||||||
|
if(WRITE_CMD == spp->cmd){
|
||||||
|
writeCmdHandle(spp->len,spp->addr,cd);
|
||||||
|
}else{
|
||||||
if(Global::Mode::ExperimentStart == Global::instance()->getMode()){
|
if(Global::Mode::ExperimentStart == Global::instance()->getMode()){
|
||||||
emit sigSendCommonData(cd);
|
emit sigSendCommonData(cd);
|
||||||
}
|
}
|
||||||
|
emit sigSendCommonDataToRealDataForm(cd);
|
||||||
#if 0
|
}
|
||||||
CommonData *serialPortData =
|
|
||||||
reinterpret_cast<CommonData*>(const_cast<char*>(&data.data()[6]));
|
|
||||||
|
|
||||||
// 格式化输出 double 类型,保留三位小数
|
|
||||||
QString formattedSampleTemp = QString::number(serialPortData->sample_temp, 'f', 3);
|
|
||||||
qDebug() << "sample temp:" << formattedSampleTemp;
|
|
||||||
|
|
||||||
QString formattedColdTemp = QString::number(serialPortData->cold_temp, 'f', 3);
|
|
||||||
qDebug() << "cold temp:" << formattedColdTemp;
|
|
||||||
|
|
||||||
emit sigSendSerialPortData(*serialPortData);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SerialPort::writeCmdHandle(const int dataLength,const u16 addr,const CommonData&cd)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
SerialPortProtocol spp;
|
||||||
|
memcpy(&spp,ba.data(),ba.size());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// SerialPortProtocol *spp = (SerialPortProtocol *)ba.data();
|
||||||
|
// int length = spp->len - 5;
|
||||||
|
|
||||||
|
// CommonData cd;
|
||||||
|
// u8* cdPtr = (u8*)&cd;
|
||||||
|
|
||||||
|
// memcpy(cdPtr + spp->addr,spp->data_buf,length);
|
||||||
|
|
||||||
|
qDebug()<<"revDataParser run_type:"<<cd.run_mode;
|
||||||
|
|
||||||
|
int length = dataLength;
|
||||||
|
|
||||||
|
while(dataLength){
|
||||||
|
switch(addr){
|
||||||
|
case offsetof(CommonData,run_mode):
|
||||||
|
// Global::Mode mode = (Global::Mode)cd.run_mode;
|
||||||
|
length--;
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool SerialPort::openSp()
|
bool SerialPort::openSp()
|
||||||
{
|
{
|
||||||
if(_sp != nullptr && _sp->isOpen()){
|
if(_sp != nullptr && _sp->isOpen()){
|
||||||
@ -351,29 +365,6 @@ void SerialPort::slotSendData(const QByteArray &ba)
|
|||||||
// qErrnoWarning("sp not open.");
|
// qErrnoWarning("sp not open.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
// 将 QByteArray 转换为十六进制字符串
|
|
||||||
QString hexData = ba.toHex(' '); // ' ' 作为分隔符,可选参数
|
|
||||||
qDebug() << "send info (hex):" << hexData;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CommonData cd;
|
|
||||||
if (!DataParser::commonDataParser(ba, cd))
|
|
||||||
{
|
|
||||||
qDebug() << "CommonData parse failed.";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 格式化输出 float 类型,保留两位小数
|
|
||||||
QString formattedRunTime = QString::number(cd.add_run_time, 'f', 2);
|
|
||||||
qDebug() << "run time:" << formattedRunTime;
|
|
||||||
|
|
||||||
// 格式化输出 double 类型,保留三位小数
|
|
||||||
QString formattedSampleTemp = QString::number(cd.sample_temp, 'f', 3);
|
|
||||||
qDebug() << "sample temp:" << formattedSampleTemp;
|
|
||||||
|
|
||||||
QString formattedColdTemp = QString::number(cd.cold_temp, 'f', 3);
|
|
||||||
qDebug() << "cold temp:" << formattedColdTemp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerialPort::slotCloseSp()
|
void SerialPort::slotCloseSp()
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include <QSerialPort>
|
#include <QSerialPort>
|
||||||
#include <QSerialPortInfo>
|
#include <QSerialPortInfo>
|
||||||
|
|
||||||
|
#include "defines.h"
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
|
||||||
class SerialPort:public QObject
|
class SerialPort:public QObject
|
||||||
@ -28,13 +29,14 @@ public slots:
|
|||||||
void slotSendData(const QByteArray&);
|
void slotSendData(const QByteArray&);
|
||||||
void slotCloseSp();
|
void slotCloseSp();
|
||||||
signals:
|
signals:
|
||||||
// void sigSendSerialPortData(const CommonData&);
|
|
||||||
void sigSendCommonData(const CommonData&);
|
void sigSendCommonData(const CommonData&);
|
||||||
|
void sigSendCommonDataToRealDataForm(const CommonData&);
|
||||||
protected:
|
protected:
|
||||||
void timerEvent(QTimerEvent *event);
|
void timerEvent(QTimerEvent *event);
|
||||||
private slots:
|
private slots:
|
||||||
void slotReadData();
|
void slotReadData();
|
||||||
private:
|
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 to_hex(char* in_char, int char_length, char* out_char);
|
||||||
void displayPortInfo();
|
void displayPortInfo();
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -2,12 +2,10 @@
|
|||||||
#include "realtimedataform.h"
|
#include "realtimedataform.h"
|
||||||
#include "ui_realtimedataform.h"
|
#include "ui_realtimedataform.h"
|
||||||
|
|
||||||
RealTimeDataForm::RealTimeDataForm(QWidget *parent) :
|
RealTimeDataForm::RealTimeDataForm(QWidget *parent) : QWidget(parent),
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::RealTimeDataForm)
|
ui(new Ui::RealTimeDataForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RealTimeDataForm::~RealTimeDataForm()
|
RealTimeDataForm::~RealTimeDataForm()
|
||||||
@ -15,7 +13,7 @@ RealTimeDataForm::~RealTimeDataForm()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RealTimeDataForm::slotRevSerialPortData(const CommonData & data)
|
void RealTimeDataForm::slotRevCommonData(const CommonData &data)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
qDebug()<<"rev-------------------------";
|
qDebug()<<"rev-------------------------";
|
||||||
@ -26,7 +24,7 @@ void RealTimeDataForm::slotRevSerialPortData(const CommonData & data)
|
|||||||
QString formattedColdTemp = QString::number(data.cold_temp, 'f', 3);
|
QString formattedColdTemp = QString::number(data.cold_temp, 'f', 3);
|
||||||
qDebug() << "cold temp:" << formattedColdTemp;
|
qDebug() << "cold temp:" << formattedColdTemp;
|
||||||
#endif
|
#endif
|
||||||
//异常信息
|
// 异常信息
|
||||||
/**
|
/**
|
||||||
* @brief abnormalStr
|
* @brief abnormalStr
|
||||||
* 0:空闲状态
|
* 0:空闲状态
|
||||||
@ -36,39 +34,71 @@ void RealTimeDataForm::slotRevSerialPortData(const CommonData & data)
|
|||||||
4:升温速率自整定
|
4:升温速率自整定
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QString abnormalStr = "空闲状态";
|
QString abnormalStr = "正常";
|
||||||
|
|
||||||
switch (data.hardware_err) {
|
switch (data.hardware_err)
|
||||||
case 0:abnormalStr = "空闲状态";
|
{
|
||||||
|
case 0:
|
||||||
|
abnormalStr = "正常";
|
||||||
break;
|
break;
|
||||||
case 1:abnormalStr = "加热运行";
|
case 1:
|
||||||
|
abnormalStr = "冷端温度错误";
|
||||||
break;
|
break;
|
||||||
case 2:abnormalStr = "恒温运行";
|
case 2:
|
||||||
|
abnormalStr = "采集板卡错误";
|
||||||
break;
|
break;
|
||||||
case 3:abnormalStr = "冷却中";
|
case 3:
|
||||||
|
abnormalStr = "样品温度错误";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
abnormalStr = "DSC错误";
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
abnormalStr = "加热模块错误";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
case 4:abnormalStr = "升温速率自整定";break;
|
|
||||||
default:break;
|
|
||||||
}
|
}
|
||||||
ui->abnormalLineEdit->setText(abnormalStr);
|
ui->abnormalLineEdit->setText(abnormalStr);
|
||||||
//运行状态
|
// 运行状态
|
||||||
ui->runStatusLineEdit->setText(QString::number(data.run_type));
|
QString runTypeStr = "空闲状态";
|
||||||
//当前阶段
|
switch (data.run_type)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
runTypeStr = "空闲状态";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
runTypeStr = "加热运行";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
runTypeStr = "恒温运行";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
runTypeStr = "冷却中";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
runTypeStr = "升温速率自整定";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ui->runStatusLineEdit->setText(runTypeStr);
|
||||||
|
// 当前阶段
|
||||||
ui->currentStageLineEdit->setText(QString::number(data.current_phase));
|
ui->currentStageLineEdit->setText(QString::number(data.current_phase));
|
||||||
//累计运行时间
|
// 累计运行时间
|
||||||
ui->addruntimeLineEdit->setText(QString::number(data.add_run_time, 'f', 3));
|
ui->addruntimeLineEdit->setText(QString::number(data.add_run_time, 'f', 3));
|
||||||
//恒温时间
|
// 恒温时间
|
||||||
ui->constantTempTimeLineEdit->setText(QString::number(data.add_constan_temp_time, 'f', 3));
|
ui->constantTempTimeLineEdit->setText(QString::number(data.add_constan_temp_time, 'f', 3));
|
||||||
//温度
|
// 温度
|
||||||
ui->tempLineEdit->setText(QString::number(data.sample_temp, 'f', 3));
|
ui->tempLineEdit->setText(QString::number(data.sample_temp, 'f', 3));
|
||||||
//DSC
|
// DSC
|
||||||
ui->dSCMwLineEdit->setText(QString::number(data.dsc, 'f', 3));
|
ui->dSCMwLineEdit->setText(QString::number(data.dsc, 'f', 3));
|
||||||
//样品质量
|
// 样品质量
|
||||||
ui->weightLineEdit->setText("--");
|
ui->weightLineEdit->setText("--");
|
||||||
//通氧时间
|
// 通氧时间
|
||||||
ui->oxyTimeLineEdit->setText("--");
|
ui->oxyTimeLineEdit->setText("--");
|
||||||
//扫描速率
|
// 扫描速率
|
||||||
ui->scanRateLineEdit->setText("--");
|
ui->scanRateLineEdit->setText("--");
|
||||||
//当前气氛
|
// 当前气氛
|
||||||
ui->currentAtmosphereLineEdit->setText(QString::number(data.current_gas));
|
ui->currentAtmosphereLineEdit->setText(QString::number(data.current_gas));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public:
|
|||||||
explicit RealTimeDataForm(QWidget *parent = nullptr);
|
explicit RealTimeDataForm(QWidget *parent = nullptr);
|
||||||
~RealTimeDataForm();
|
~RealTimeDataForm();
|
||||||
public:
|
public:
|
||||||
void slotRevSerialPortData(const CommonData&);
|
void slotRevCommonData(const CommonData&);
|
||||||
private:
|
private:
|
||||||
Ui::RealTimeDataForm *ui;
|
Ui::RealTimeDataForm *ui;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user