2025-05-21T16:36:47

This commit is contained in:
yuntang 2025-05-21 16:36:47 +08:00
parent 81d4b13cbd
commit 4f15bc595f
15 changed files with 213 additions and 47 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -9,7 +9,7 @@ QVector<Global::ExperimentData>PointCalculate:: _dataVtr;
QPointF PointCalculate::_peakPoint;
QPointF PointCalculate::_leftSelectedPoint,PointCalculate::_rightSelectedPoint;
void PointCalculate::setExperimentData(const QVector<Global::ExperimentData> &dataVtr)
void PointCalculate::setAnalysisData(const QVector<Global::ExperimentData> &dataVtr)
{
_dataVtr = dataVtr;
@ -263,6 +263,8 @@ float PointCalculate::calculateArea() {
float b = Global::_enthalpyCoefficientVtr.at(1);
float c = Global::_enthalpyCoefficientVtr.at(2);
logde<<"a,b,c:"<<a<<","<<b<<","<<c;
coefficient = a * startTemp * startTemp +
b * startTemp +
c;
@ -273,6 +275,8 @@ float PointCalculate::calculateArea() {
float area = integral * coefficient * Global::DefaultParamter;
logde<<"area:"<<area;
return area;
}
@ -641,7 +645,7 @@ QString PointCalculate::textFormatPeakPointWithTime(const float enthalpyValue, c
"起始点:%3min \n"
"终止点:%4min"
)
.arg(QString::number(enthalpyValue, 'f', 3))
.arg(QString::number(enthalpyValue, 'f', 4))
.arg(QString::number(peakValue, 'f', 3))
.arg(QString::number(startPoint, 'f', 3))
.arg(QString::number(endPoint, 'f', 3));

View File

@ -7,7 +7,7 @@
#include "global.h"
namespace PointCalculate{
void setExperimentData(const QVector<Global::ExperimentData>&);
void setAnalysisData(const QVector<Global::ExperimentData>&);
QPair<QPointF,QPointF> getStartAndEndPoint();
QVector<Global::ExperimentData> getDataInXRange(const float, const float);

View File

@ -213,6 +213,7 @@ void XlsxHandler::writeFile(const QString filePath)
xlsx.write(row , 1, ConPhaseIndex);
xlsx.write(row , 2, i + 1);
row++;
// phase info
xlsx.write(row , 1, ConPhaseCutoffTemp);
xlsx.write(row , 2, phase.cutoff_temp);

View File

@ -32,18 +32,6 @@ const QString RateStr("rate");
const double DefaultParamter = 8.177;
//
#if 0
enum AnalysisMode{
Null,
NumericalLabel,
StartPoint,
StopPoint,
PeakSynthesisAnalysis,
GlassTransition,
OnsetTemperaturePoint,
EndsetTemperaturePoint
};
#endif
enum Mode{
Analysis,
ConnectedToDev,
@ -126,10 +114,6 @@ extern bool _displayTimeValue;
QString converDoubleToStr(const double);
void quadraticLeastSquaresFit(double x[], double y[], int n, double coeff[]);
double findNegativeStartPoint(double m, double b, double start, double end);
};
#endif // GLOBAL_H

View File

@ -348,6 +348,7 @@ void MainWindow::slotSaveExperimentalDataMsgBox()
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
saveFile(Global::_experimentInfo.sampleName,Global::Mode::Experiment);
_leftWidget->reloadFileName();
} else {
on_actionClearAllData_triggered();
}

View File

@ -98,10 +98,6 @@ private:
void connections();
void setActionEnable(const bool);
void setSubWidgetAttribute(QWidget *);
#if 0
bool saveExperimentFile(const QString fileName);
bool saveAnalysisFile(const QString fileName);
#endif
bool saveFile(const QString fileName,const Global::Mode);
private:

View File

@ -110,6 +110,12 @@ void CentralWidget::switchAxisMode()
if(_axisMode == AxisMode::SingleY){
_axisMode = AxisMode::DoubleY;
_customPlot->yAxis2->setVisible(true);
_customPlot->yAxis2->setLabel(XlsxHandler::ConPhaseHeaderTemp);
_customPlot->yAxis->setLabel(XlsxHandler::ConPhaseHeaderTime);
#if 0
_customPlot->yAxis2->setVisible(true);
_customPlot->yAxis2->setLabel("Time/min");
@ -142,6 +148,7 @@ void CentralWidget::switchAxisMode()
// logde<<"plottableCount count:"<<_customPlot->plottableCount();
}
}
#endif
}else{
_axisMode = AxisMode::SingleY;
@ -272,7 +279,7 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
for(int i = 0;i < cfd.phaseTotalVtr.size();i++){
Global::PhaseTotalInfo& pti = cfd.phaseTotalVtr[i];
PointCalculate::setExperimentData(pti.dataVtr);
PointCalculate::setAnalysisData(pti.dataVtr);
QPair<QPointF,QPointF>startEndPointPair = PointCalculate::getStartAndEndPoint();
@ -306,6 +313,9 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
pti.curve = _currentCurve;
}
// Add data to global parameter.
Global::_curveFileDataVtr.push_back(cfd);
// Add analysis operation data.
if(cfd.analysisOperationVtr.size() > 0){
for(AnaOpRecorder::AnalysisOperation& ao
@ -316,13 +326,26 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
// Refresh ui.
_customPlot->rescaleAxes();
_customPlot->replot();
// Add data to global parameter.
Global::_curveFileDataVtr.push_back(cfd);
}
void CentralWidget::slotAnalysisSettingApply()
{
//Set the analysis data corresponding current curve.
if(!_currentCurve){
logde<<"failed. current curve is nullptr.";
return;
}
QVector<Global::ExperimentData> dataVtr;
for(Global::CurveFileData& cfd:Global::_curveFileDataVtr){
for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){
if(pti.curve == _currentCurve){
PointCalculate::setAnalysisData(pti.dataVtr);
break;
}
}
}
//
double x1 = _line1->point1->coords().x();
double x2 = _line2->point1->coords().x();
@ -1097,16 +1120,33 @@ void CentralWidget::loadAnalysisData(
//enthalpy
double sampleWeight = 0.0f;
for(Global::CurveFileData& cfd:Global::_curveFileDataVtr){
for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){
#if 0
if(_currentCurve && _currentCurve == pti.curve){
sampleWeight = cfd.ei.sampleWeight.toDouble();
}
#endif
if(_currentCurve){
if(_currentCurve == pti.curve){
sampleWeight = cfd.ei.sampleWeight.toDouble();
}else{
}
}else{
// logde<<"current curve nullptr.";
}
}
}
// logde<<"sample weight:"<<sampleWeight;
if(sampleWeight <= 0){
logde<<"sample weight set value 1,"<<sampleWeight;
sampleWeight = 1;
}
double enthalpyValue = PointCalculate::calculateArea() / sampleWeight;
// logde<<"enthalpyValue:"<<enthalpyValue;
// peak
QPointF peakPoint = PointCalculate::getPeakPoint();

View File

@ -1,4 +1,5 @@
#include <QtDebug>
#include <QDateTime>
#include "experimentsettingform.h"
#include "ui_experimentsettingform.h"
@ -22,6 +23,13 @@ ExperimentSettingForm::ExperimentSettingForm(QWidget *parent) : QWidget(parent),
ui->setupUi(this);
uiReset();
ui->checkBox_phase_1->setTristate(false);
ui->checkBox_phase_2->setTristate(false);
ui->checkBox_phase_3->setTristate(false);
ui->checkBox_phase_4->setTristate(false);
ui->checkBox_phase_5->setTristate(false);
ui->checkBox_phase_6->setTristate(false);
connect(ui->checkBox_phase_2, &QCheckBox::clicked,
this, &ExperimentSettingForm::slotPhase2StateChanged);
connect(ui->checkBox_phase_3, &QCheckBox::clicked,
@ -217,9 +225,10 @@ void ExperimentSettingForm::slotPhase2StateChanged(int state)
}
else
{
// unchecked
if (ui->checkBox_phase_3->isChecked())
{
ui->checkBox_phase_2->setCheckState(Qt::Checked);
ui->checkBox_phase_2->setChecked(true);
}
else
{
@ -281,10 +290,17 @@ void ExperimentSettingForm::slotPhase4StateChanged(int state)
}
else
{
ui->phase_4_cutoff_temp->setEnabled(false);
ui->phase_4_scan_rate->setEnabled(false);
ui->phase_4_constant_temp->setEnabled(false);
ui->comboBox_phase_4_atmosphere->setEnabled(false);
if (ui->checkBox_phase_5->isChecked())
{
ui->checkBox_phase_4->setChecked(true);
}
else
{
ui->phase_4_cutoff_temp->setEnabled(false);
ui->phase_4_scan_rate->setEnabled(false);
ui->phase_4_constant_temp->setEnabled(false);
ui->comboBox_phase_4_atmosphere->setEnabled(false);
}
}
}
@ -306,15 +322,24 @@ void ExperimentSettingForm::slotPhase5StateChanged(int state)
}
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);
if (ui->checkBox_phase_6->isChecked())
{
ui->checkBox_phase_5->setChecked(true);
}
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)
{
qDebug() << "slotPhase2StateChanged:" << state;
if (state == Qt::PartiallyChecked)
{
if (ui->checkBox_phase_5->isChecked())
@ -340,6 +365,13 @@ void ExperimentSettingForm::slotPhase6StateChanged(int state)
void ExperimentSettingForm::on_pushButton_deliverData_clicked()
{
float phase1CutoffTemp = 0.0;
float phase2CutoffTemp = 0.0;
float phase3CutoffTemp = 0.0;
float phase4CutoffTemp = 0.0;
float phase5CutoffTemp = 0.0;
float phase6CutoffTemp = 0.0;
QVector<Phase> phaseVtr;
{
Phase phase;
@ -351,6 +383,13 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
phase.gas = GasType::N2;
phaseVtr.push_back(phase);
//
phase1CutoffTemp = phase.cutoff_temp;
//
if(phase.temp_flow <= 0){
phaseScanRateErrorMesgBox(1);
return;
}
}
{
Phase phase;
@ -362,6 +401,17 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
phase.gas = GasType::N2;
phaseVtr.push_back(phase);
//
phase2CutoffTemp = phase.cutoff_temp;
if(phase2CutoffTemp < phase1CutoffTemp){
phaseCufoffTempErrorMesgBox(2);
return;
}
if(phase.temp_flow <= 0){
phaseScanRateErrorMesgBox(2);
return;
}
}
{
@ -373,6 +423,17 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
phase.gas = GasType::N2;
phaseVtr.push_back(phase);
//
phase3CutoffTemp = phase.cutoff_temp;
if(phase3CutoffTemp < phase2CutoffTemp){
phaseCufoffTempErrorMesgBox(3);
return;
}
if(phase.temp_flow <= 0){
phaseScanRateErrorMesgBox(3);
return;
}
}
{
@ -384,6 +445,17 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
// phase.gas = ui->comboBox_phase_1_atmosphere->currentIndex();
phase.gas = GasType::N2;
phaseVtr.push_back(phase);
//
phase4CutoffTemp = phase.cutoff_temp;
if(phase4CutoffTemp < phase3CutoffTemp){
phaseCufoffTempErrorMesgBox(4);
return;
}
if(phase.temp_flow <= 0){
phaseScanRateErrorMesgBox(4);
return;
}
}
{
@ -396,6 +468,17 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
phase.gas = GasType::N2;
phaseVtr.push_back(phase);
//
phase5CutoffTemp = phase.cutoff_temp;
if(phase5CutoffTemp < phase4CutoffTemp){
phaseCufoffTempErrorMesgBox(5);
return;
}
if(phase.temp_flow <= 0){
phaseScanRateErrorMesgBox(5);
return;
}
}
{
@ -408,6 +491,17 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
phase.gas = GasType::N2;
phaseVtr.push_back(phase);
//
phase6CutoffTemp = phase.cutoff_temp;
if(phase6CutoffTemp < phase5CutoffTemp){
phaseCufoffTempErrorMesgBox(6);
return;
}
if(phase.temp_flow <= 0){
phaseScanRateErrorMesgBox(6);
return;
}
}
//
Global::ExperimentInfo& ei = Global::_experimentInfo;
@ -451,6 +545,22 @@ void ExperimentSettingForm::slotCancel()
{
hide();
}
void ExperimentSettingForm::phaseCufoffTempErrorMesgBox(const int phaseNum)
{
QString title = QString("阶段%1截止温度错误").arg(QString::number(phaseNum));
QString text = QString("阶段%1截止温度不能小于上一阶段截止温度! ").arg(QString::number(phaseNum));
QMessageBox::question(this, title, text,
QMessageBox::Yes);
}
void ExperimentSettingForm::phaseScanRateErrorMesgBox(const int phaseNum)
{
QString title = QString("阶段%1扫描速率错误").arg(QString::number(phaseNum));
QString text = QString("阶段%1扫描速率必须大于0! ").arg(QString::number(phaseNum));
QMessageBox::question(this, title, text,
QMessageBox::Yes);
}
void ExperimentSettingForm::slotPhaseCheck()
{
if (sender() == ui->checkBox_phase_2)
@ -605,7 +715,7 @@ void ExperimentSettingForm::slotRecvPhaseInfo(const QByteArray &ba)
Global::_experimentInfo.phaseVtr = phaseVtr;
//ui update
// logde<<"phaseVtr size:"<<phaseVtr.size();
// logde<<"phaseVtr size:"<<phaseVtr.size();
uiReset();
@ -616,15 +726,15 @@ void ExperimentSettingForm::slotRecvPhaseInfo(const QByteArray &ba)
}
i++;
// qDebug()<<"index :"<<i;
// qDebug()<<"index :"<<i;
QString checkBoxName = QString("checkBox_phase_%1").arg(i);
QCheckBox *checkBox_phase = qobject_cast<QCheckBox*>(this->findChild<QObject*>(checkBoxName));
if (checkBox_phase) {
checkBox_phase->setChecked(true);
// qDebug()<<"found...";
// qDebug()<<"found...";
}else{
// qDebug()<<"not found...";
// qDebug()<<"not found...";
}
QString cutOffTempLineEditName = QString("phase_%1_cutoff_temp").arg(i);
@ -703,3 +813,11 @@ void ExperimentSettingForm::slotRecvPhaseInfo(const QByteArray &ba)
}
void ExperimentSettingForm::showEvent(QShowEvent *event)
{
QDateTime currentDateTime = QDateTime::currentDateTime();
QString internationalFormat = currentDateTime.toString("yyyy/MM/dd hh:mm:ss");
ui->dateTimeLineEdit->setText(internationalFormat);
}

View File

@ -23,6 +23,8 @@ signals:
void sigDeliverData(const QByteArray &);
public slots:
void slotRecvPhaseInfo(const QByteArray &);
protected:
void showEvent(QShowEvent *event) override;
private slots:
void on_pushButton_deliverData_clicked();
private:
@ -38,6 +40,9 @@ private:
void slotPhase6StateChanged(int state);
void slotCancel();
void phaseCufoffTempErrorMesgBox(const int);
void phaseScanRateErrorMesgBox(const int);
private:
Ui::ExperimentSettingForm *ui;
};

View File

@ -10,13 +10,15 @@ PrintPreviewForm::PrintPreviewForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::PrintPreviewForm)
,_printer(new QPrinter(QPrinter::HighResolution))
,_customPrintPreviewDialog(new QPrintPreviewDialog(_printer,this))
// ,_customPrintPreviewDialog(new QPrintPreviewDialog(_printer,this))
{
ui->setupUi(this);
_printer->setPageSize(QPageSize(QPageSize::A4));
_printer->setOrientation(QPrinter::Landscape);
_customPrintPreviewDialog = new QPrintPreviewDialog(_printer,this);
QObject::connect(_customPrintPreviewDialog, &QPrintPreviewDialog::paintRequested,
this,&PrintPreviewForm::slotPaintRequested);

View File

@ -3,7 +3,7 @@
#include "ui_realtimedataform.h"
RealTimeDataForm::RealTimeDataForm(QWidget *parent) : QWidget(parent),
ui(new Ui::RealTimeDataForm)
ui(new Ui::RealTimeDataForm)
{
ui->setupUi(this);
}
@ -100,5 +100,20 @@ void RealTimeDataForm::slotRevCommonData(const CommonData &data)
// 扫描速率
ui->scanRateLineEdit->setText("--");
// 当前气氛
ui->currentAtmosphereLineEdit->setText(QString::number(data.current_gas));
QString gasName;
switch(data.current_gas){
case GasType::NC:
gasName = "NC";
break;
case GasType::N2:
gasName = "N2";
break;
case GasType::O2:
gasName = "O2";
break;
default:
gasName = "NC";
break;
}
ui->currentAtmosphereLineEdit->setText(gasName);
}

View File

@ -144,13 +144,13 @@ void SpecificHeatComparisonMethodForm::on_pushButtonCalculate_clicked()
//
float targetTemperature = ui->LineEditTemperature->text().toFloat();
PointCalculate::setExperimentData(*_baseLineDataVtr);
PointCalculate::setAnalysisData(*_baseLineDataVtr);
QPointF baseLinePoint = PointCalculate::getClosestPointByX(targetTemperature);
PointCalculate::setExperimentData(*_standardSampleDataVtr);
PointCalculate::setAnalysisData(*_standardSampleDataVtr);
QPointF standardSamplePoint = PointCalculate::getClosestPointByX(targetTemperature);
PointCalculate::setExperimentData(*_sampleDataVtr);
PointCalculate::setAnalysisData(*_sampleDataVtr);
QPointF samplePoint = PointCalculate::getClosestPointByX(targetTemperature);
logde<<"baseLinePoint:"<<baseLinePoint.x()<<","<<baseLinePoint.y();