2025-05-29T17:19:11

This commit is contained in:
yuntang 2025-05-29 17:19:11 +08:00
parent cfcf8b0ecf
commit 2a23ee4c74
21 changed files with 114 additions and 70 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -9,9 +9,9 @@ CONFIG+=precompile_header
PRECOMPILED_HEADER=stable.h
#
VERSION = 1.0.0
VERSION = 1.0.1
# 设置目标文件名,包含版本号
TARGET = AnalysisTool_$${VERSION}
TARGET = DSCAnalysisTool_$${VERSION}
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings

File diff suppressed because one or more lines are too long

View File

@ -31,6 +31,9 @@ const QString RateStr("rate");
//
const double DefaultParamter = 8.177;
const double OnsetAndEndSetRate = 0.01;
//curve object name
const QString objectNameExperiemnt("experiment");
//
enum LanguageType{
Chinese,

View File

@ -10,5 +10,6 @@
<file>images/axis.png</file>
<file>images/clear_data.png</file>
<file>images/real_time.png</file>
<file>images/disconnect.png</file>
</qresource>
</RCC>

BIN
src/images/disconnect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -15,7 +15,6 @@
int main(int argc, char *argv[])
{
system("chcp 65001");
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForLocale(codec);
@ -41,6 +40,7 @@ int main(int argc, char *argv[])
logde<<"config,instrument coefficient:"
<<ConfigHandler::_configMap[ConInstrumentCoefficientStr].toFloat();
#endif
//
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // 启用高DPI缩放
QApplication a(argc, argv);
@ -58,7 +58,7 @@ int main(int argc, char *argv[])
#if 1
MainWindow w;
w.setWindowTitle("Analysis Tool");
w.setWindowTitle("DSC Analysis Tool");
// w.setWindowIcon(QIcon(":/images/logo.png"));
w.setWindowIcon(icon);
w.show();

View File

@ -354,16 +354,23 @@ void MainWindow::slotSaveExperimentalDataMsgBox()
} else {
on_actionClearAllData_triggered();
}
#if 0
// Clear data.
logde<<"save mesg box.clearExperimentData...";
Global::clearExperimentData();
#endif
}
void MainWindow::on_actionConnectToDev_triggered()
{
logde<<"Connect to device.";
if(SerialPort::instance()->isOpen()){
SerialPort::instance()->closeSp();
ui->actionConnectToDev->setIcon(QIcon(":/images/connect.png"));
ui->actionConnectToDev->setText("连接设备");
logde<<"close serial port.";
}else{
if (SerialPort::instance()->openSp())
{
setActionEnable(true);
@ -372,11 +379,17 @@ void MainWindow::on_actionConnectToDev_triggered()
QByteArray ba = DataParser::inquirePhaseInfo();
SerialPort::instance()->sendData(ba);
ui->actionConnectToDev->setIcon(QIcon(":/images/disconnect.png"));
ui->actionConnectToDev->setText("断开连接");
logde<<"open serial port.";
}
else
{
QMessageBox::warning(this, "warnning", "Serial Port open failed.");
}
}
}
void MainWindow::on_actionStartPoint_triggered()

View File

@ -126,4 +126,5 @@ private:
PrintPreviewForm *_printPreviewForm;
AxisSettingForm * _axisSettingForm;
};
#endif // MAINWINDOW_H

View File

@ -19,7 +19,8 @@ const u16 conVid = 1155; // 0x0483
const u16 conPid = 22336; // 0x5740
SerialPort::SerialPort(QObject *parent)
: QObject(parent), _sp(nullptr)
: QObject(parent)
,_sp(new QSerialPort(this))
{
// displayPortInfo();
@ -333,7 +334,7 @@ bool SerialPort::openSp()
if ((pid == conPid) && (vid == conVid))
{
_sp = new QSerialPort(info);
_sp->setPort(info);
break;
}
}
@ -371,6 +372,15 @@ bool SerialPort::openSp()
return true;
}
bool SerialPort::closeSp()
{
if (_sp && _sp->isOpen())
{
_sp->clear();
_sp->close();
}
}
void SerialPort::sendCmd(const SerialPort::E_CMD_TYPE e)
{
#if 1

View File

@ -27,7 +27,8 @@ public:
void sendCmd(const E_CMD_TYPE e);
static void parserTest();
bool openSp();
bool isOpen(){return _sp->isOpen();}
bool closeSp();
protected:
void timerEvent(QTimerEvent *event);
signals:

View File

@ -178,17 +178,15 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
if(!_currentCurve){
logde<<"_currentCurve is nullptr";
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
_currentCurve->setObjectName(Global::objectNameExperiemnt);
}
// logde<<"temp:"<<cd.sample_temp<<",dsc:"<<cd.dsc;
_currentCurve->addData(index++,cd.sample_temp, cd.dsc);
// _customPlot->rescaleAxes();
_customPlot->replot();
// return;
// Record data.
if(!Global::_currentCurveExperimentDataPtr){
loger<<"_currentCurveExperimentDataPtr is nullptr.";
@ -245,8 +243,10 @@ void CentralWidget::slotAnalysisSettingApply()
if(Global::_curveFileDataVtr.empty()){
// Load experiment data.
logde<<"experiment vtr size:"<<Global::_curveExperimentDataVtr.size();
for(Global::CurveExperimentData& ced:Global::_curveExperimentDataVtr){
if(ced.curve == _currentCurve){
logde<<"load experiment data.";
PointCalculate::setAnalysisData(ced.dataVtr);
}
}
@ -428,17 +428,18 @@ void CentralWidget::slotSelectionChangedByUser()
for (QCPAbstractPlottable* plottable : selectedPlottables) {
// 检查是否是 QCPCurve
if (QCPCurve* curve = dynamic_cast<QCPCurve*>(plottable)) {
qDebug() << "Selected Curve:" << curve->objectName();
logde<<curve->objectName().toStdString();
logde << "Selected Curve:" << curve->objectName().toStdString();
_currentCurve = curve; // 更新当前选中的曲线
}
}
#if 0
// 如果没有选中的曲线
if (selectedPlottables.isEmpty()) {
qDebug() << "No curve selected";
logde<< "No curve selected";
_currentCurve = nullptr; // 清空当前选中的曲线
}
#endif
}
void CentralWidget::uiLoadXlsxFileData()
@ -719,8 +720,6 @@ void CentralWidget::glassTransitionHandle(const double x1,const double x2,const
}
drawText(averagePoint,str);
}
// 使用最小二乘法计算线性回归
PointCalculate::Line CentralWidget::calculateLinearRegression(const QVector<double>& x, const QVector<double>& y) {
@ -1250,6 +1249,7 @@ void CentralWidget::loadAnalysisData(
peakPointTime,
startPointTime,
endPointTime);
drawText(peakPoint,str,objectName);
}else{

View File

@ -391,6 +391,7 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
return;
}
}
{
Phase phase;
phase.onoff = ui->checkBox_phase_2->checkState()?1:0;
@ -402,6 +403,8 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
phaseVtr.push_back(phase);
//
if(phase.onoff){
logde<<"phase 2 enable.";
phase2CutoffTemp = phase.cutoff_temp;
if(phase2CutoffTemp < phase1CutoffTemp){
phaseCufoffTempErrorMesgBox(2);
@ -413,6 +416,7 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
return;
}
}
}
{
Phase phase;
@ -424,6 +428,8 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
phaseVtr.push_back(phase);
//
if(phase.onoff){
logde<<"phase 3 enable.";
phase3CutoffTemp = phase.cutoff_temp;
if(phase3CutoffTemp < phase2CutoffTemp){
phaseCufoffTempErrorMesgBox(3);
@ -435,6 +441,7 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
return;
}
}
}
{
Phase phase;
@ -446,6 +453,8 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
phase.gas = GasType::N2;
phaseVtr.push_back(phase);
//
if(phase.onoff){
logde<<"phase 4 enable.";
phase4CutoffTemp = phase.cutoff_temp;
if(phase4CutoffTemp < phase3CutoffTemp){
phaseCufoffTempErrorMesgBox(4);
@ -457,6 +466,7 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
return;
}
}
}
{
Phase phase;
@ -469,6 +479,8 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
phaseVtr.push_back(phase);
//
if(phase.onoff){
logde<<"phase 5 enable.";
phase5CutoffTemp = phase.cutoff_temp;
if(phase5CutoffTemp < phase4CutoffTemp){
phaseCufoffTempErrorMesgBox(5);
@ -480,6 +492,7 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
return;
}
}
}
{
Phase phase;
@ -492,6 +505,8 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
phaseVtr.push_back(phase);
//
if(phase.onoff){
logde<<"phase 6 enable.";
phase6CutoffTemp = phase.cutoff_temp;
if(phase6CutoffTemp < phase5CutoffTemp){
phaseCufoffTempErrorMesgBox(6);
@ -503,6 +518,7 @@ void ExperimentSettingForm::on_pushButton_deliverData_clicked()
return;
}
}
}
//
Global::ExperimentInfo& ei = Global::_experimentInfo;
ei.sampleName = ui->sampleNameLineEdit->text();