2025-04-23T15:33:38
This commit is contained in:
parent
658c68b3ce
commit
12d4c03b3d
BIN
experiment_data/sample_data/23-1new.xlsx
Normal file
BIN
experiment_data/sample_data/23-1new.xlsx
Normal file
Binary file not shown.
Binary file not shown.
@ -195,7 +195,10 @@ void XlsxHandler::writeFile(const QString filePath)
|
||||
xlsx.write(row , 2, edVtr.size());
|
||||
row++;
|
||||
|
||||
logde<<"edVtr size:"<<edVtr.size();
|
||||
|
||||
for(int index = 0;index < edVtr.size();index++){
|
||||
logde<<"index :"<<index;
|
||||
const Global::ExperimentData & ed = edVtr.at(index);
|
||||
|
||||
xlsx.write(row , 1, index);
|
||||
|
@ -5,8 +5,10 @@ Mode _mode;
|
||||
|
||||
QVector<CurveFileData> _curveFileDataVtr;
|
||||
|
||||
int _currentPhase = 0;
|
||||
ExperimentInfo _experimentInfo;
|
||||
QVector<CurveExperimentData> _curveExperimentDataVtr;
|
||||
CurveExperimentData* _currentCurveExperimentDataPtr = nullptr;
|
||||
|
||||
bool _enthalpyCoefficientEnableFlag = false;
|
||||
QVector<double> _enthalpyCoefficientVtr;
|
||||
|
@ -76,8 +76,10 @@ extern Mode _mode;
|
||||
// Xlsx file data.
|
||||
extern QVector<CurveFileData> _curveFileDataVtr;
|
||||
// Experiment setting data.
|
||||
extern int _currentPhase;
|
||||
extern ExperimentInfo _experimentInfo;
|
||||
extern QVector<CurveExperimentData> _curveExperimentDataVtr;
|
||||
extern CurveExperimentData* _currentCurveExperimentDataPtr;
|
||||
|
||||
// Instrument coefficient.
|
||||
extern bool _enthalpyCoefficientEnableFlag;
|
||||
|
@ -62,8 +62,8 @@ int main(int argc, char *argv[])
|
||||
// ExperimentSettingForm es;
|
||||
// es.show();
|
||||
|
||||
// CentralWidget central;
|
||||
// central.show();
|
||||
// CentralWidget central;
|
||||
// central.show();
|
||||
|
||||
// SerialPort::parserTest();
|
||||
|
||||
|
@ -132,11 +132,14 @@ void MainWindow::connections()
|
||||
connect(SerialPort::instance(), &SerialPort::sigSendPhaseInfo,
|
||||
_expertmentSettingForm, &ExperimentSettingForm::slotRecvPhaseInfo);
|
||||
|
||||
connect(SerialPort::instance(), &SerialPort::sigAxisModify,
|
||||
_centralWidget, &CentralWidget::slotAxisModify);
|
||||
#endif
|
||||
|
||||
// mode
|
||||
// connect(Global::instance(), &Global::sigModeModify,
|
||||
// _centralWidget, &CentralWidget::slotModeModify);
|
||||
|
||||
//analysis
|
||||
connect(_leftWidget,&LeftWidget::sigSendAnalysisFileName,
|
||||
_centralWidget,&CentralWidget::slotRecvAnalysisFileName);
|
||||
@ -216,7 +219,7 @@ void MainWindow::on_actionStop_triggered()
|
||||
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Stop);
|
||||
SerialPort::instance()->slotSendData(ba);
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
// Save data.
|
||||
if(saveExperimentFile(Global::_experimentInfo.sampleName)){
|
||||
_leftWidget->reloadFileName();
|
||||
@ -376,3 +379,10 @@ void MainWindow::on_actionEnthalpyCorrectionSelection_triggered()
|
||||
{
|
||||
_coefficientSelectionForm->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSaveExperimentData_triggered()
|
||||
{
|
||||
if(saveExperimentFile(Global::_experimentInfo.sampleName)){
|
||||
_leftWidget->reloadFileName();
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,8 @@ private slots:
|
||||
|
||||
void on_actionEnthalpyCorrectionSelection_triggered();
|
||||
|
||||
void on_actionSaveExperimentData_triggered();
|
||||
|
||||
private:
|
||||
void connections();
|
||||
void setActionEnable(const bool);
|
||||
|
@ -28,6 +28,7 @@
|
||||
<string>文件</string>
|
||||
</property>
|
||||
<addaction name="actionNew"/>
|
||||
<addaction name="actionSaveExperimentData"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_2">
|
||||
<property name="title">
|
||||
@ -265,6 +266,14 @@
|
||||
<string>热焓校正系数选择</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSaveExperimentData">
|
||||
<property name="text">
|
||||
<string>保存实验数据</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>保存实验数据</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
|
@ -9,104 +9,104 @@
|
||||
|
||||
namespace DataParser
|
||||
{
|
||||
bool 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 (小端格式)
|
||||
if (static_cast<unsigned char>(charArray[0]) == 0xA5 &&
|
||||
// 判断前两个字节是否为 0xA5 和 0x5A (小端格式)
|
||||
if (static_cast<unsigned char>(charArray[0]) == 0xA5 &&
|
||||
static_cast<unsigned char>(charArray[1]) == 0x5A)
|
||||
{
|
||||
// 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;
|
||||
{
|
||||
// std::cout << "前两个字节是 0x5AA5 (小端)" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// std::cout << "前两个字节不是 0x5AA5 (小端)" << std::endl;
|
||||
qDebug() << "header failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QByteArray connectToDevice(const QVector<Phase> &vtr)
|
||||
if (static_cast<unsigned char>(charArray[3]) != 0x83)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// int totalDataLength = 0;
|
||||
char totalData[300] = {};
|
||||
|
||||
u16 header = 0x5aa5;
|
||||
memcpy(totalData, (char *)&header, sizeof(u16));
|
||||
// totalDataLength +=2;
|
||||
|
||||
totalData[2] = 1 + 2 + phaseArrayLength + 2;
|
||||
// totalDataLength++;
|
||||
|
||||
totalData[3] = 0x82;
|
||||
// totalDataLength++;
|
||||
|
||||
u16 address = 0x0050;
|
||||
memcpy(totalData + 4, (char *)&address, sizeof(u16));
|
||||
|
||||
memcpy(totalData + 6, phaseArray, phaseArrayLength);
|
||||
|
||||
//
|
||||
char data[300] = {};
|
||||
|
||||
data[0] = 0x82;
|
||||
|
||||
// u16 address = 0x0050;
|
||||
memcpy(data + 1, (char *)&address, sizeof(u16));
|
||||
|
||||
memcpy(data + 3, phaseArray, phaseArrayLength);
|
||||
|
||||
u16 crc = modbusCRC16((u8 *)data, 3 + phaseArrayLength);
|
||||
//
|
||||
memcpy(totalData + 6 + phaseArrayLength, (char *)&crc, sizeof(u16));
|
||||
|
||||
//
|
||||
|
||||
return QByteArray(totalData, 6 + phaseArrayLength + 2);
|
||||
qDebug() << "mark failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray setDeviceStartStop(const DeviceStartMode mode)
|
||||
memcpy(&cd, charArray + 6, sizeof(CommonData));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QByteArray 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;
|
||||
}
|
||||
|
||||
//
|
||||
// int totalDataLength = 0;
|
||||
char totalData[300] = {};
|
||||
|
||||
u16 header = 0x5aa5;
|
||||
memcpy(totalData, (char *)&header, sizeof(u16));
|
||||
// totalDataLength +=2;
|
||||
|
||||
totalData[2] = 1 + 2 + phaseArrayLength + 2;
|
||||
// totalDataLength++;
|
||||
|
||||
totalData[3] = 0x82;
|
||||
// totalDataLength++;
|
||||
|
||||
u16 address = 0x0050;
|
||||
memcpy(totalData + 4, (char *)&address, sizeof(u16));
|
||||
|
||||
memcpy(totalData + 6, phaseArray, phaseArrayLength);
|
||||
|
||||
//
|
||||
char data[300] = {};
|
||||
|
||||
data[0] = 0x82;
|
||||
|
||||
// u16 address = 0x0050;
|
||||
memcpy(data + 1, (char *)&address, sizeof(u16));
|
||||
|
||||
memcpy(data + 3, phaseArray, phaseArrayLength);
|
||||
|
||||
u16 crc = modbusCRC16((u8 *)data, 3 + phaseArrayLength);
|
||||
//
|
||||
memcpy(totalData + 6 + phaseArrayLength, (char *)&crc, sizeof(u16));
|
||||
|
||||
//
|
||||
|
||||
return QByteArray(totalData, 6 + phaseArrayLength + 2);
|
||||
}
|
||||
|
||||
QByteArray 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;
|
||||
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;
|
||||
int sppValidLength = 6 + 1;
|
||||
|
||||
u8 *dataPtr = (u8 *)&spp;
|
||||
u16 crc = modbusCRC16((u8 *)(dataPtr + 3), 4);
|
||||
u8 *dataPtr = (u8 *)&spp;
|
||||
u16 crc = modbusCRC16((u8 *)(dataPtr + 3), 4);
|
||||
|
||||
return QByteArray((char *)&spp, sppValidLength) +
|
||||
QByteArray((char *)&crc, 2);
|
||||
return QByteArray((char *)&spp, sppValidLength) +
|
||||
QByteArray((char *)&crc, 2);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
@ -135,62 +135,118 @@ namespace DataParser
|
||||
|
||||
return QByteArray(data,length);
|
||||
#endif
|
||||
}
|
||||
|
||||
void experimentalStateSwitching(const CommonData &cd)
|
||||
{
|
||||
switch(cd.run_type){
|
||||
case DeviceRunStatus::Heat:
|
||||
case DeviceRunStatus::ConstantTemp:
|
||||
Global::_mode = Global::Mode::Experiment;
|
||||
break;
|
||||
case DeviceRunStatus::Idle:
|
||||
case DeviceRunStatus::Cooling:
|
||||
Global::_mode = Global::Mode::Analysis;
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
|
||||
unsigned short modbusCRC16(unsigned char *data, unsigned short length)
|
||||
if(Global::_currentPhase != (int)cd.current_phase){
|
||||
Global::_currentPhase = (int)cd.current_phase;
|
||||
|
||||
// Global::CurveExperimentData ced{nullptr,"",QVector<Global::ExperimentData>()};
|
||||
Global::CurveExperimentData ced;
|
||||
|
||||
Global::_curveExperimentDataVtr.push_back(ced);
|
||||
Global::_currentCurveExperimentDataPtr = &Global::_curveExperimentDataVtr.last();
|
||||
|
||||
Global::_currentCurveExperimentDataPtr->fileName = Global::_experimentInfo.sampleName;
|
||||
}
|
||||
|
||||
logde<<"phase:"<<(int)cd.current_phase;
|
||||
logde<<"run type:"<<(int)cd.run_type;
|
||||
logde<<"software mode:"<<Global::_mode;
|
||||
}
|
||||
|
||||
unsigned short modbusCRC16(unsigned char *data, unsigned short length)
|
||||
{
|
||||
unsigned short crc = 0xFFFF;
|
||||
unsigned char i;
|
||||
for (unsigned short j = 0; j < length; j++)
|
||||
{
|
||||
unsigned short crc = 0xFFFF;
|
||||
unsigned char i;
|
||||
for (unsigned short j = 0; j < length; j++)
|
||||
crc ^= (unsigned short)data[j];
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
crc ^= (unsigned short)data[j];
|
||||
for (i = 0; i < 8; i++)
|
||||
if (crc & 0x0001)
|
||||
{
|
||||
if (crc & 0x0001)
|
||||
{
|
||||
crc = (crc >> 1) ^ 0xA001;
|
||||
}
|
||||
else
|
||||
{
|
||||
crc = crc >> 1;
|
||||
}
|
||||
crc = (crc >> 1) ^ 0xA001;
|
||||
}
|
||||
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;
|
||||
spp.len = 6;
|
||||
//
|
||||
spp.data_buf[0] = PHASE_BYTE_SIZE * 6 + 2;
|
||||
//
|
||||
u8 *dataPtr = (u8 *)&spp;
|
||||
u16 crc = modbusCRC16((u8 *)(dataPtr + 3), 4);
|
||||
//
|
||||
int sppValidLength = 6 + 1;
|
||||
return QByteArray((char *)&spp, sppValidLength) +
|
||||
QByteArray((char *)&crc, 2);
|
||||
}
|
||||
|
||||
bool isDevExperimentEnded(const CommonData &cd)
|
||||
{
|
||||
switch(cd.run_type){
|
||||
case DeviceRunStatus::Heat:
|
||||
case DeviceRunStatus::ConstantTemp:
|
||||
Global::_mode = Global::Mode::Experiment;
|
||||
break;
|
||||
case DeviceRunStatus::Idle:
|
||||
logde<<"idle...";
|
||||
case DeviceRunStatus::Cooling:
|
||||
Global::_mode = Global::Mode::Analysis;
|
||||
logde<<"cooling...";
|
||||
// return true;
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
|
||||
QByteArray inquirePhaseInfo()
|
||||
{
|
||||
SerialPortProtocol spp;
|
||||
spp.head = FRANE_HEAD;
|
||||
spp.cmd = READ_CMD;
|
||||
spp.addr = 0x0050;
|
||||
spp.len = 6;
|
||||
//
|
||||
spp.data_buf[0] = PHASE_BYTE_SIZE * 6 + 2;
|
||||
//
|
||||
u8 *dataPtr = (u8 *)&spp;
|
||||
u16 crc = modbusCRC16((u8 *)(dataPtr + 3), 4);
|
||||
//
|
||||
int sppValidLength = 6 + 1;
|
||||
return QByteArray((char *)&spp, sppValidLength) +
|
||||
QByteArray((char *)&crc, 2);
|
||||
}
|
||||
#if 0
|
||||
logde<<"phase:"<<(int)cd.current_phase;
|
||||
logde<<"run type:"<<(int)cd.run_type;
|
||||
|
||||
bool isDevExperimentEnded(const CommonData &cd)
|
||||
{
|
||||
switch(cd.run_type){
|
||||
case DeviceRunStatus::Idle:
|
||||
case DeviceRunStatus::Cooling:
|
||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||
// Global::_mode = Global::Mode::Analysis;
|
||||
// logde<<"Device into cooling status,then set the software into annlysis mode.";
|
||||
return true;
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
return false;
|
||||
switch(cd.run_type){
|
||||
case DeviceRunStatus::Idle:
|
||||
logde<<"idle...";
|
||||
// break;
|
||||
case DeviceRunStatus::Cooling:
|
||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||
// Global::_mode = Global::Mode::Analysis;
|
||||
// logde<<"Device into cooling status,then set the software into annlysis mode.";
|
||||
logde<<"cooling...";
|
||||
// return true;
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
@ -13,6 +13,7 @@ QByteArray connectToDevice(const QVector<Phase>&);
|
||||
QByteArray inquirePhaseInfo();
|
||||
QByteArray setDeviceStartStop(const DeviceStartMode);
|
||||
|
||||
void experimentalStateSwitching(const CommonData&cd);
|
||||
bool isDevExperimentEnded(const CommonData&cd);
|
||||
bool commonDataParser(const QByteArray&ba,CommonData &cd);
|
||||
|
||||
|
@ -94,12 +94,11 @@ void SerialPort::timerEvent(QTimerEvent *event)
|
||||
|
||||
void SerialPort::slotReadData()
|
||||
{
|
||||
#if 1
|
||||
QByteArray ba = _sp->readAll();
|
||||
if(ba.size() == 0){
|
||||
return;
|
||||
}
|
||||
#if 1
|
||||
#if 0
|
||||
QString hexData = ba.toHex(' '); // ' ' 作为分隔符,可选参数
|
||||
qDebug() << "receive info (hex):" << hexData;
|
||||
#endif
|
||||
@ -128,19 +127,18 @@ void SerialPort::slotReadData()
|
||||
}
|
||||
else if (READ_CMD == spp->cmd)
|
||||
{
|
||||
// judge the device status.
|
||||
DataParser::isDevExperimentEnded(cd);
|
||||
// read data
|
||||
DataParser::experimentalStateSwitching(cd);
|
||||
setAxis();
|
||||
|
||||
if (spp->addr == 0)
|
||||
{
|
||||
if (Global::Mode::Experiment == Global::_mode)
|
||||
{
|
||||
emit sigSendCommonData(cd);
|
||||
}
|
||||
emit sigSendCommonDataToRealDataForm(cd);
|
||||
// emit sigSendCommonDataToRealDataForm(cd);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SerialPort::commonDataParser(const int dataLength, const u16 addr,
|
||||
@ -173,7 +171,7 @@ void SerialPort::commonDataParser(const int dataLength, const u16 addr,
|
||||
{
|
||||
switch(cd.run_type){
|
||||
case DeviceRunStatus::Cooling:
|
||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||
Global::_mode = Global::Mode::Analysis;
|
||||
logde<<"set global mode analysis.common data parser.";
|
||||
break;
|
||||
@ -201,12 +199,12 @@ void SerialPort::commonDataParser(const int dataLength, const u16 addr,
|
||||
switch (mode)
|
||||
{
|
||||
case DeviceStartMode::Stop:
|
||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||
Global::_mode = Global::Mode::Analysis;
|
||||
logde<<"set global mode analysis.";
|
||||
break;
|
||||
case DeviceStartMode::Start:
|
||||
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
||||
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
||||
Global::_mode = Global::Mode::Experiment;
|
||||
break;
|
||||
default:
|
||||
@ -394,6 +392,26 @@ void SerialPort::displayPortInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SerialPort::setAxis()
|
||||
{
|
||||
static Global::Mode previousMode = Global::Analysis; // 记录上一次的模式
|
||||
|
||||
if (previousMode == Global::Analysis &&
|
||||
Global::_mode == Global::Experiment) {
|
||||
// std::cout << "Mode has changed from Analysis to Experiment!" << std::endl;
|
||||
Global::ExperimentInfo & eti = Global::_experimentInfo;
|
||||
if(eti.phaseVtr.size() > 0){
|
||||
logde<<"serialport set axis.";
|
||||
float temp = eti.phaseVtr.at(0).cutoff_temp;
|
||||
emit sigAxisModify(temp);
|
||||
}
|
||||
}
|
||||
|
||||
if(previousMode != Global::_mode){
|
||||
previousMode = Global::_mode;
|
||||
}
|
||||
}
|
||||
void SerialPort::parserTest()
|
||||
{
|
||||
const uchar data[] = {0xa5, 0x5a, 0x2d, 0x83,
|
||||
|
@ -34,6 +34,7 @@ signals:
|
||||
void sigSendCommonData(const CommonData &);
|
||||
void sigSendCommonDataToRealDataForm(const CommonData &);
|
||||
void sigSendPhaseInfo(const QByteArray &);
|
||||
void sigAxisModify(const float temp);
|
||||
public slots:
|
||||
void slotDeliverData(const QByteArray &);
|
||||
// void slotConnectToDevice(const QByteArray&);
|
||||
@ -46,7 +47,7 @@ private:
|
||||
void commonDataParser(const int dataLength, const u16 addr, const CommonData &cd);
|
||||
void to_hex(char *in_char, int char_length, char *out_char);
|
||||
void displayPortInfo();
|
||||
|
||||
void setAxis();
|
||||
private:
|
||||
SerialPort(QObject *parent = nullptr);
|
||||
QSerialPort *_sp;
|
||||
|
@ -9,8 +9,6 @@ AboutForm::AboutForm(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// setFixedSize(geometry().width(),geometry().height());
|
||||
|
||||
setWindowTitle("About");
|
||||
|
||||
QPixmap pixmap(":/images/logo.png"); // 假设图片在资源文件中
|
||||
@ -22,19 +20,16 @@ AboutForm::AboutForm(QWidget *parent) :
|
||||
ui->labelTitle->setText(QString("<p style=\"font-size: 18px;\">关于差示扫描量热仪数据分析软件</p>"));
|
||||
|
||||
|
||||
//#define COMPILE_TIME QString("编译时间:%1 %2").arg(__DATE__).arg(__TIME__)
|
||||
|
||||
QString ConCompleTime = QString("编译时间:%1 %2").arg(__DATE__).arg(__TIME__);
|
||||
|
||||
QString aboutText = QString(
|
||||
"<p>软件版本:%1</p>"
|
||||
"<p>%2</p>"
|
||||
"<p>版权所有 © 2025 山东云唐智能科技有限公司 保留所有权</p>"
|
||||
"<br>"
|
||||
"<p style=\"font-size: 10px;\">本软件基于 Qt 框架开发,Qt 遵循 "
|
||||
"<a href='https://www.gnu.org/licenses/lgpl-3.0.html'>LGPL 协议</a>。</p>"
|
||||
"<p style=\"font-size: 10px;\">Qt 官网:<a href='https://www.qt.io'>www.qt.io</a></p>")
|
||||
.arg(Global::ConSoftVersion).arg(ConCompleTime);
|
||||
.arg(Global::ConSoftVersion);
|
||||
|
||||
ui->labelContent->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
||||
ui->labelContent->setTextFormat(Qt::RichText);
|
||||
|
@ -74,15 +74,15 @@ CentralWidget::CentralWidget(QWidget *parent)
|
||||
_customPlot->yAxis->setRange(0, 100);
|
||||
_customPlot->replot();
|
||||
#endif
|
||||
// startTimer(1000);
|
||||
|
||||
|
||||
// 设置坐标轴标签
|
||||
_customPlot->xAxis->setLabel("Temp/℃");
|
||||
_customPlot->yAxis->setLabel("DSC/mW");
|
||||
// 设置坐标轴范围,以便我们可以看到全部数据
|
||||
_customPlot->xAxis->setRange(0, 400);
|
||||
_customPlot->yAxis->setRange(-100,200);
|
||||
_customPlot->xAxis->setRange(0,100);
|
||||
_customPlot->yAxis->setRange(0,20);
|
||||
|
||||
// startTimer(300);
|
||||
}
|
||||
|
||||
CentralWidget::~CentralWidget()
|
||||
@ -137,30 +137,47 @@ void CentralWidget::slotModeModify(const Global::Mode mode)
|
||||
|
||||
void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
||||
{
|
||||
qDebug() << "slotRevCommonData";
|
||||
// logde<<"slotRecvCommonData...";
|
||||
|
||||
static double index = 0.0;
|
||||
|
||||
if(!_currentCurve){
|
||||
logde<<"_currentCurve is nullptr";
|
||||
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
|
||||
}
|
||||
|
||||
logde<<"temp:"<<cd.sample_temp<<",dsc:"<<cd.dsc;
|
||||
|
||||
// Update curve.
|
||||
// _currentCurve->addData(cd.sample_temp, cd.dsc);
|
||||
// _currentCurve->data()->add(QCPCurveData(index++, cd.sample_temp, cd.dsc));
|
||||
_currentCurve->addData(index++,cd.sample_temp, cd.dsc);
|
||||
|
||||
// _currentCurve->addData(index++,cd.sample_temp, cd.dsc);
|
||||
// _customPlot->rescaleAxes();
|
||||
_customPlot->replot();
|
||||
|
||||
// 设置曲线数据
|
||||
// _currentCurve->setData(data);
|
||||
|
||||
|
||||
// _customPlot->rescaleAxes();
|
||||
// _customPlot->replot();
|
||||
// return;
|
||||
|
||||
// Record data.
|
||||
logde<<"record data...";
|
||||
|
||||
if(!Global::_currentCurveExperimentDataPtr){
|
||||
logde<<"_currentCurveExperimentDataPtr is nullptr.";
|
||||
exit(0);
|
||||
}else{
|
||||
logde<<"add ed...";
|
||||
|
||||
Global::ExperimentData ed;
|
||||
ed.dsc = cd .dsc;
|
||||
ed.sampleTemp = cd.sample_temp;
|
||||
ed.runTime = cd.add_run_time;
|
||||
ed.constantTempTime = cd.add_constan_temp_time;
|
||||
|
||||
Global::_currentCurveExperimentDataPtr->dataVtr.push_back(ed);
|
||||
logde<<"111";
|
||||
Global::_currentCurveExperimentDataPtr->curve = _currentCurve;
|
||||
logde<<"222";
|
||||
}
|
||||
|
||||
#if 0
|
||||
logde<<"record data...";
|
||||
QVector<Global::ExperimentData>* pEdVtr = nullptr; // 声明指针变量
|
||||
for(auto item:Global::_curveExperimentDataVtr){
|
||||
if(item.curve == _currentCurve){
|
||||
@ -180,12 +197,15 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
||||
ed.constantTempTime = cd.add_constan_temp_time;
|
||||
|
||||
pEdVtr->push_back(ed);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
|
||||
{
|
||||
qDebug() << "slotRecvAnalysisFileName" << filePath;
|
||||
|
||||
_customPlot->setInteractions(QCP::iSelectPlottables);
|
||||
|
||||
// todo.禁止重复文件添加。
|
||||
Global::CurveFileData cfd;
|
||||
if(XlsxHandler::readFile(filePath,cfd) != 0){
|
||||
@ -417,6 +437,9 @@ void CentralWidget::slotAnalysisSettingLineXPoint(const int index, const double)
|
||||
|
||||
void CentralWidget::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
_customPlot->replot();
|
||||
|
||||
#if 0
|
||||
// key的单位是秒
|
||||
double key = QDateTime::currentDateTime().toMSecsSinceEpoch() / 1000.0;
|
||||
// 添加数据
|
||||
@ -439,6 +462,7 @@ void CentralWidget::timerEvent(QTimerEvent *event)
|
||||
_customPlot->yAxis->setRange(0, 20); // 设定x轴的范围
|
||||
_customPlot->xAxis->setRange(key + 0.25, 80, Qt::AlignRight); // 设定x轴的范围
|
||||
_customPlot->replot();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CentralWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
@ -901,6 +925,7 @@ void CentralWidget::clearData(const CentralWidget::ClearDataMode mode)
|
||||
QCPGraph *graph = _customPlot->graph(i);
|
||||
_customPlot->removeGraph(graph);
|
||||
}
|
||||
_currentCurve = nullptr;
|
||||
#endif
|
||||
|
||||
// Delete items.
|
||||
@ -922,3 +947,13 @@ void CentralWidget::clearAllData()
|
||||
{
|
||||
clearData(ClearDataMode::All);
|
||||
}
|
||||
|
||||
void CentralWidget::slotAxisModify(const float temp)
|
||||
{
|
||||
_customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
|
||||
|
||||
float value = temp + 20;
|
||||
|
||||
_customPlot->xAxis->setRange(10,value);
|
||||
_customPlot->yAxis->setRange(-5,5);
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ signals:
|
||||
void sigSendLineXCoord(const int,const double);
|
||||
void sigRightDockWidgetHide();
|
||||
public slots:
|
||||
// experiment
|
||||
void slotAxisModify(const float temp);
|
||||
void slotModeModify(const Global::Mode);
|
||||
void slotRecvCommonData(const CommonData&);
|
||||
void slotRecvAnalysisFileName(const QString&);
|
||||
|
@ -404,12 +404,12 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
|
||||
}
|
||||
//
|
||||
Global::ExperimentInfo& ei = Global::_experimentInfo;
|
||||
ei.phaseVtr = phaseVtr;
|
||||
ei.sampleName = ui->sampleNameLineEdit->text();
|
||||
ei.sampleWeight = ui->sampleWeightLineEdit->text();
|
||||
ei.date = ui->dateTimeLineEdit->text();
|
||||
ei.experimentor = ui->userLineEdit->text();
|
||||
|
||||
#if 0
|
||||
ei.phaseVtr = phaseVtr;
|
||||
if(ui->radioButton_OIT->isChecked()){
|
||||
ei.testType = Global::TestType::OIT;
|
||||
} else if(ui->radioButton_OIT_not->isChecked()){
|
||||
@ -417,7 +417,7 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
|
||||
}
|
||||
|
||||
ei.initialAtmosPhere = (GasType)(ui->comboBox_phase_1_atmosphere->currentIndex());
|
||||
|
||||
#endif
|
||||
//
|
||||
QByteArray ba = DataParser::connectToDevice(phaseVtr);
|
||||
qDebug() << "ba size:" << ba.size();
|
||||
@ -497,6 +497,7 @@ void ExperimentSettingForm::slotRecvPhaseInfo(const QByteArray &ba)
|
||||
Phase *phase = (Phase *)(data + i * PHASE_BYTE_SIZE);
|
||||
phaseVtr.push_back(*phase);
|
||||
}
|
||||
Global::_experimentInfo.phaseVtr = phaseVtr;
|
||||
|
||||
//ui update
|
||||
for(int i = 0; i< phaseVtr.size();){
|
||||
|
Loading…
Reference in New Issue
Block a user