2025-06-19T16:27:16

This commit is contained in:
yuntang 2025-06-19 16:27:17 +08:00
parent 29866f73c6
commit ede02dfbfa
14 changed files with 271 additions and 68 deletions

View File

@ -0,0 +1,47 @@
[2025-06-19 11:29:31,232] main...
[2025-06-19 11:29:31,232] config file existed.
[2025-06-19 11:29:31,245] version:1.0.4.0
[2025-06-19 11:29:31,253] setEventHandlerEnable...0
[2025-06-19 11:30:36,317] main...
[2025-06-19 11:30:36,319] config file existed.
[2025-06-19 11:30:36,329] version:1.0.4.0
[2025-06-19 11:30:36,337] setEventHandlerEnable...0
[2025-06-19 11:30:39,937] xlsx sample weight:26.89
[2025-06-19 11:30:39,937] startLineIndex:11
[2025-06-19 11:30:39,937] data size:839
[2025-06-19 11:30:39,939] startLineIndex:857
[2025-06-19 11:30:39,939] data size:1157
[2025-06-19 11:30:39,939] Cell does not exist.
[2025-06-19 11:30:41,742] xlsx sample weight:7
[2025-06-19 11:30:41,743] Cell does not exist.
[2025-06-19 11:30:43,161] xlsx sample weight:1
[2025-06-19 11:30:43,161] startLineIndex:11
[2025-06-19 11:30:43,161] data size:298
[2025-06-19 11:30:43,161] Cell does not exist.
[2025-06-19 11:31:50,869] main...
[2025-06-19 11:31:50,869] config file existed.
[2025-06-19 11:31:50,878] version:1.0.4.0
[2025-06-19 11:31:50,888] setEventHandlerEnable...0
[2025-06-19 11:31:53,589] xlsx sample weight:1
[2025-06-19 11:31:53,589] startLineIndex:11
[2025-06-19 11:31:53,589] data size:298
[2025-06-19 11:31:53,589] Cell does not exist.
[2025-06-19 11:31:55,248] clearExperimentData...
[2025-06-19 11:31:56,695] xlsx sample weight:26.89
[2025-06-19 11:31:56,695] startLineIndex:11
[2025-06-19 11:31:56,695] data size:830
[2025-06-19 11:31:56,697] startLineIndex:848
[2025-06-19 11:31:56,697] data size:6631
[2025-06-19 11:31:56,701] ana op size:1
[2025-06-19 11:31:56,701] cfd fileName:new.xlsx
[2025-06-19 11:31:56,701] ao mode:OIT
[2025-06-19 11:31:56,701] x1:33.1687,x2:91.1893
[2025-06-19 11:32:16,013] clearExperimentData...
[2025-06-19 11:32:18,019] xlsx sample weight:7
[2025-06-19 11:32:18,019] Cell does not exist.
[2025-06-19 11:32:19,224] xlsx sample weight:26.89
[2025-06-19 11:32:19,224] startLineIndex:11
[2025-06-19 11:32:19,224] data size:839
[2025-06-19 11:32:19,224] startLineIndex:857
[2025-06-19 11:32:19,224] data size:1157
[2025-06-19 11:32:19,224] Cell does not exist.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -283,8 +283,10 @@ float PointCalculate::calculateArea() {
QPair<QPointF, QPointF> PointCalculate::calculateStartAndEndPoint()
{
QPair<QPointF,QPointF> leftMaxDiffPointPair = PointCalculate::calculateMaxDiffPointLeft();
QPair<QPointF,QPointF> rightMaxDiffPointPair = PointCalculate::calculateMaxDiffPointRight();
QPair<QPointF,QPointF> leftMaxDiffPointPair =
PointCalculate::calculateMaxDiffPointLeft();
QPair<QPointF,QPointF> rightMaxDiffPointPair =
PointCalculate::calculateMaxDiffPointRight();
#if 0
logde<<"b1:"<<leftMaxDiffPointPair.first.x()<<","<<leftMaxDiffPointPair.first.y();
@ -293,6 +295,7 @@ QPair<QPointF, QPointF> PointCalculate::calculateStartAndEndPoint()
logde<<"b3:"<<rightMaxDiffPointPair.first.x()<<","<<rightMaxDiffPointPair.first.y();
logde<<"b4:"<<rightMaxDiffPointPair.second.x()<<","<<rightMaxDiffPointPair.second.y();
#endif
QPointF startPoint = calculateIntersection(_leftSelectedPoint,_rightSelectedPoint,
leftMaxDiffPointPair.first,
leftMaxDiffPointPair.second);
@ -903,8 +906,10 @@ Global::ExperimentData PointCalculate::findOnSetDataByTime(const double x1, cons
}
Global::ExperimentData resultEd;
if(edVtr.empty()){
if(!edVtr.empty()){
resultEd = edVtr.last();
}else{
logde<<"edVtr empty...";
return resultEd;
}
@ -928,18 +933,170 @@ Global::ExperimentData PointCalculate::findOnSetDataByTime(const double x1, cons
Global::ExperimentData PointCalculate::getOITStartData(const double x1,const double x2)
{
Global::ExperimentData startEd;
Global::ExperimentData startEd = _dataVtr.first();
logde<<"startEd phase index:"<<startEd.phaseIndex;
Global::ExperimentData edSelectTimeX2 = getClosestDataByTime(x2);
logde<<"edSelectTimeX2 phase index:"<<edSelectTimeX2.phaseIndex;
for(const Global::ExperimentData &ed : _dataVtr) {
if(ed.runTime < x2){
if(ed.phaseIndex != Global::PhaseIndexDefault){
logde<<"find not equal phase default."<<ed.phaseIndex;
startEd = ed;
}
}else if (ed.runTime > x2){
if(ed.phaseIndex == edSelectTimeX2.phaseIndex){
startEd = ed;
break;
}
}
return startEd;
}
Global::ExperimentData PointCalculate::getClosestDataByTime(const float time)
{
ExperimentData resultData;
float minDiff = std::numeric_limits<float>::max();
for(Global::ExperimentData &ed:_dataVtr){
float diff = std::abs(ed.runTime - time);
if (diff < minDiff) {
minDiff = diff;
resultData = ed;
}
}
return resultData;
}
Global::ExperimentData PointCalculate::findEndSetDataByTime(const double x1, const double x2)
{
Global::ExperimentData resultEd;
// QVector<Global::ExperimentData> edVtr = getDataInXRange(x1,x2);
// if(edVtr.empty()){
// return resultEd;
// }
QVector<Global::ExperimentData> edVtr;
for(const Global::ExperimentData &ed : _dataVtr) {
if(x1 < ed.runTime && ed.runTime < x2){
edVtr.push_back(ed);
}else if (ed.runTime > x2){
break;
}
}
double maxDsc = std::numeric_limits<float>::min();
for(Global::ExperimentData& ed:edVtr){
if(ed.dsc > maxDsc){
maxDsc = ed.dsc;
}
}
// 从后往前遍历,找到第一个 dsc 与 standardDsc 相等的 ExperimentData
for (auto it = edVtr.begin(); it != edVtr.end(); ++it) {
if(std::abs(it->dsc - maxDsc) < Global::OnsetAndEndSetRate * maxDsc){
resultEd = *it; // 找到匹配项,返回该值
break;
}
}
return resultEd;
}
QPair<QPointF,QPointF>
PointCalculate::calculateOITStartAndEndDataByTime(const double x1, const double x2)
{
// 获取起点数据。
Global::ExperimentData startData = getOITStartData(x1,x2);
// 计算OIT结束数据需根据实际逻辑实现
Global::ExperimentData endData;
QPair<Global::ExperimentData,Global::ExperimentData> maxDiffDataPair =
calculateMaxDiffDataByTime(x1,x2);
ExperimentData selectedData = getClosestDataByTime(x1);
// calculate intersection point.
QPointF selectedPoint1(selectedData.runTime,selectedData.dsc);
QPointF selectedPoint2(selectedData.runTime + 10,selectedData.dsc);
QPointF maxDiffPoint1(maxDiffDataPair.first.runTime,maxDiffDataPair.first.dsc);
QPointF maxDiffPoint2(maxDiffDataPair.second.runTime,maxDiffDataPair.second.dsc);
QPointF intersectionPoint = calculateIntersection(selectedPoint1,selectedPoint2,
maxDiffPoint1,maxDiffPoint2);
return qMakePair(QPointF(startData.runTime,startData.dsc),
intersectionPoint);
}
QPair<Global::ExperimentData, Global::ExperimentData>
PointCalculate::calculateMaxDiffDataByTime(
const double x1,const double x2)
{
QVector<Global::ExperimentData> rangeEdVtr;
for(const Global::ExperimentData &ed : _dataVtr) {
if(x1 < ed.runTime && ed.runTime < x2){
rangeEdVtr.push_back(ed);
}else if (ed.runTime > x2){
break;
}
}
//
float maxDiff = std::numeric_limits<float>::min();
Global::ExperimentData targetCurrentData,targetLastPointData;
for(int i = 0; i < rangeEdVtr.size() - 1;i++){
Global::ExperimentData currentData = rangeEdVtr.at(i);
Global::ExperimentData lastPointData = rangeEdVtr.at(i+1);
double diff = std::abs(lastPointData.dsc - currentData.dsc);
if(diff > maxDiff){
maxDiff = diff;
targetCurrentData = currentData;
targetLastPointData = lastPointData;
}
}
return qMakePair(targetCurrentData,targetLastPointData);
#if 0
float maxDiff = std::numeric_limits<float>::min();
QPointF currentPoint,lastPoint;
for (int i = 0; i < _dataVtr.size() - 1; ++i) {
const float currentTime = _dataVtr.at(i).sampleTemp;
const float currentY = _dataVtr.at(i).dsc;
// if(type == MaxDiffPointDetailType::Left){
// if(currentX <= _leftSelectedPoint.x()){
// continue;
// }
// if(currentX >= _peakPoint.x()){
// break;
// }
// }else{
if(currentTime <= _peakPoint.x()){
continue;
}
if(currentTime >= _rightSelectedPoint.x()){
break;
}
// }
//
const float lastX = _dataVtr.at(i + 1).sampleTemp;
const float lastY = _dataVtr.at(i + 1).dsc;
float diff = std::abs(currentY - lastY);
if(diff > maxDiff){
maxDiff = diff;
currentPoint.setX(currentTime);
currentPoint.setY(currentY);
lastPoint.setX(lastX);
lastPoint.setY(lastY);
}
}
return qMakePair(currentPoint,lastPoint);
#endif
}

View File

@ -24,6 +24,8 @@ QVector<QPointF> getPointVtrInXRange(const float, const float);
void setRegionPointX(const float,const float);
ExperimentData getClosestDataByTemperature(const float);
ExperimentData getClosestDataByTime(const float);
QPointF getClosestPointByX(const float);
QVector<QPointF> getNearbyPointGroupByX(const float);
@ -38,6 +40,8 @@ QPair<float, float> getTheMaximumAndMinimumValuesOfTime(
QPair<QPointF,QPointF> calculateStartAndEndPoint();
QPair<ExperimentData,ExperimentData> calculateStartAndEndData();
QPair<QPointF,QPointF> calculateOITStartAndEndDataByTime(const double x1,const double x2);
float calculateArea();
double obtainTimeValueBasedOnTemperatureValue(const double sampleTemp);
@ -45,6 +49,7 @@ ExperimentData findOnSetDataByTemperature(const double x1,const double x2);
ExperimentData findEndSetDataByTemperature(const double x1,const double x2);
ExperimentData findOnSetDataByTime(const double x1,const double x2);
ExperimentData findEndSetDataByTime(const double x1,const double x2);
ExperimentData getOITStartData(const double x1,const double x2);
@ -90,6 +95,8 @@ enum MaxDiffPointDetailType{
Right
};
QPair<QPointF,QPointF> calculateMaxDiffPointDetail(const MaxDiffPointDetailType type);
QPair<Global::ExperimentData,Global::ExperimentData> calculateMaxDiffDataByTime(
const double x1,const double x2);
QPointF calculateIntersection(const QPointF p1,const QPointF p2,
const QPointF p3, const QPointF p4);

View File

@ -108,10 +108,13 @@ void XlsxHandler::readPhaseData(QXlsx::Worksheet *workSheet, int &startLineIndex
for(int i = 0; i < dataSize; i++)
{
Global::ExperimentData data;
data.phaseIndex = phaseTotal.phaseIndex;
#if 0
if(i == 0){
data.phaseIndex = phaseTotal.phaseIndex;
logde<<"read file,set phaseIndex:"<<data.phaseIndex;
}
#endif
data.runTime = workSheet->cellAt(startLineIndex, 2)->value().toDouble();
data.sampleTemp = workSheet->cellAt(startLineIndex, 3)->value().toDouble();
data.dsc = workSheet->cellAt(startLineIndex, 4)->value().toDouble();

View File

@ -208,9 +208,11 @@ void CentralWidget::startExperiment()
if(_yAxis2Curve != nullptr){
_yAxis2Curve = nullptr;
}
_customPlot->yAxis2->setRange(0, 400);
_customPlot->xAxis->setRange(-5, 400);
_customPlot->xAxis->setRange(-5, 60);
_customPlot->yAxis->setRange(-20, 20);
_customPlot->yAxis2->setRange(0, 400);
_customPlot->replot();
}
void CentralWidget::setAnalysisMode(const AnalysisMode mode)
@ -276,8 +278,6 @@ void CentralWidget::slotModeModify(const Global::Mode mode)
void CentralWidget::slotRecvCommonData(const CommonData &cd)
{
logde<<"slotRecvCommonData run time:"<<cd.add_run_time;
// Record data.
if(!Global::_currentCurveExperimentDataPtr){
loger<<"_currentCurveExperimentDataPtr is nullptr.";
@ -291,7 +291,7 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
if(Global::_currentCurveExperimentDataPtr->dataVtr.empty()){
ed.phaseIndex = Global::_currentCurveExperimentDataPtr->phaseIndex;
logde<<"current phase index:"<<Global::_currentCurveExperimentDataPtr->phaseIndex;
logde<<"change phase, index:"<<Global::_currentCurveExperimentDataPtr->phaseIndex;
_currentCurve = nullptr;
}
@ -304,7 +304,9 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
if(!_currentCurve){
logde<<"_currentCurve is nullptr";
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
_currentCurve->setObjectName(Global::ObjectNameExperiemnt);
_currentCurve->setObjectName(Global::ObjectNameExperiemnt
+ Global::Separator
+ QString::number(Global::_currentCurveExperimentDataPtr->phaseIndex));
Global::_currentCurveExperimentDataPtr->curve = _currentCurve;
}
@ -320,39 +322,17 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
_yAxis2Curve->setObjectName(Global::ObjectNameExperiemnt);
// 设置曲线颜色
QPen pen(Qt::red); // 创建一个红色的画笔
pen.setWidth(1); // 设置画笔宽度
QPen pen(Qt::red); // 创建一个红色的画笔
pen.setWidth(1); // 设置画笔宽度
_yAxis2Curve->setPen(pen); // 将画笔应用到曲线
}
_yAxis2Curve->addData(index++,cd.add_run_time, cd.sample_temp);
_currentCurve->addData(index++,cd.add_run_time, cd.dsc);
// _customPlot->yAxis2->setRange(0, 400);
}
// Set asis xy range.
// axis dsc -20 20
// time 0 100
// temp 0 400
// _customPlot->xAxis->setRange(0, 400);
// _customPlot->yAxis->setRange(-20, 20);
// _customPlot->rescaleAxes();
_customPlot->replot();
#if 0
logde<<"_curveExperimentDataVtr size:"
<<Global::_curveExperimentDataVtr.size();
logde<<"_currentCurveExperimentDataPtr dataVtr size:"
<<Global::_currentCurveExperimentDataPtr->dataVtr.size();
#endif
}
void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
@ -385,6 +365,7 @@ void CentralWidget::slotAnalysisSettingApply()
}
QString selectedCurveObjectName = _currentCurve->objectName();
logde<<"slotAnalysisSettingApply objectName:"<<selectedCurveObjectName.toStdString();
// Set curve data to PointCalculate.
QVector<ExperimentData> totalDataVtr;
@ -398,6 +379,7 @@ void CentralWidget::slotAnalysisSettingApply()
if(ced.smoothDataVtr.empty()){
// PointCalculate::setAnalysisData(ced.dataVtr);
totalDataVtr.append(ced.dataVtr);
}else{
// PointCalculate::setAnalysisData(ced.smoothDataVtr);
totalDataVtr.append(ced.smoothDataVtr);
@ -429,6 +411,8 @@ void CentralWidget::slotAnalysisSettingApply()
for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){
if(pti.smoothDataVtr.empty()){
totalDataVtr.append(pti.dataVtr);
logde <<" data phase index:"<<pti.dataVtr.first().phaseIndex;
}else{
totalDataVtr.append(pti.smoothDataVtr);
}
@ -442,15 +426,6 @@ void CentralWidget::slotAnalysisSettingApply()
PointCalculate::setAnalysisData(totalDataVtr);
// display data
for(Global::ExperimentData ed:totalDataVtr){
if(ed.phaseIndex != Global::PhaseIndexDefault){
logde<<"find not equal phase index:"
<<ed.phaseIndex;
}
}
//
double x1 = _line1->point1->coords().x();
double x2 = _line2->point1->coords().x();
@ -463,7 +438,7 @@ void CentralWidget::slotAnalysisSettingApply()
}
//
loadAnalysisData(_analysisMode,x1,x2,_currentCurve->objectName());
calculateAnalysisResult(_analysisMode,x1,x2,_currentCurve->objectName());
if(Global::_mode == Global::Mode::Analysis){
AnalysisOperation ao;
@ -619,18 +594,10 @@ void CentralWidget::slotSelectionChangedByUser()
for (QCPAbstractPlottable* plottable : selectedPlottables) {
// 检查是否是 QCPCurve
if (QCPCurve* curve = dynamic_cast<QCPCurve*>(plottable)) {
logde << "Selected Curve:" << curve->objectName().toStdString();
logde << "selected Curve:" << curve->objectName().toStdString();
_currentCurve = curve; // 更新当前选中的曲线
}
}
#if 0
// 如果没有选中的曲线
if (selectedPlottables.isEmpty()) {
logde<< "No curve selected";
_currentCurve = nullptr; // 清空当前选中的曲线
}
#endif
}
void CentralWidget::uiLoadXlsxFileData()
@ -766,7 +733,7 @@ void CentralWidget::uiLoadXlsxFileData()
if(!cfd.analysisOperationVtr.empty()){
for(AnaOpRecorder::AnalysisOperation& ao
:cfd.analysisOperationVtr){
loadAnalysisData(ao.mode,ao.x1,ao.x2,cfd.filePath);
calculateAnalysisResult(ao.mode,ao.x1,ao.x2,cfd.filePath);
}
}
}
@ -1356,9 +1323,11 @@ void CentralWidget::deleteCurveByObjectName(const QString objectName)
_customPlot->replot();
}
void CentralWidget::loadAnalysisData(
void CentralWidget::calculateAnalysisResult(
const AnalysisMode mode,const double x1,const double x2,const QString objectName)
{
logde<<"calculateAnalysisResult...";
switch (mode) {
case AnalysisMode::NumericalLabel:
{
@ -1536,25 +1505,45 @@ void CentralWidget::loadAnalysisData(
case AnalysisMode::OIT:{
logde<<"oit x1,x2:"<<x1<<","<<x2;
#if 0
//
QVector<double> tickPositions = _customPlot->yAxis->tickVector();
double step = tickPositions.at(1) - tickPositions.at(0);
//
Global::ExperimentData ed = PointCalculate::findOnSetDataByTime(x1,x2);
Global::ExperimentData startData = PointCalculate::getOITStartData(x1,x2);
// Global::ExperimentData endData = PointCalculate::findOnSetDataByTime(x1,x2);
PointCalculate::setRegionPointX(x1,x2);
QPair<Global::ExperimentData,Global::ExperimentData>
startEndDataPair = PointCalculate::calculateStartAndEndData();
// Global::ExperimentData ed = PointCalculate::findOnSetDataByTemperature(x1,x2);
// PointCalculate::setRegionPointX(x1,x2);
Global::ExperimentData startData = PointCalculate::getOITStartData(x1,x2);
// QPair<Global::ExperimentData,Global::ExperimentData>
// startEndDataPair = PointCalculate::calculateStartAndEndData();
logde<<"start data time:"<<startData.runTime;
logde<<"end data time:"<<ed.runTime;
logde<<"end data time:"<<startEndDataPair.second.runTime;
#endif
QVector<double> tickPositions = _customPlot->yAxis->tickVector();
double step = tickPositions.at(1) - tickPositions.at(0);
drawOITLine(startData,ed,step,objectName);
QPair<QPointF,QPointF>startEndPointPair =
PointCalculate::calculateOITStartAndEndDataByTime(x1,x2);
Global::ExperimentData startData;
startData.runTime = startEndPointPair.first.x();
startData.dsc = startEndPointPair.first.y();
Global::ExperimentData endData;
endData.runTime = startEndPointPair.second.x();
endData.dsc = startEndPointPair.second.y();
drawOITLine(startData,endData,step,objectName);
break;
}
@ -1675,7 +1664,7 @@ void CentralWidget::slotAxisModify(const float temp)
float value = temp + 20;
_customPlot->xAxis->setRange(10,value);
_customPlot->xAxis->setRange(0,value);
_customPlot->yAxis->setRange(-5,5);
}

View File

@ -114,7 +114,7 @@ private:
void clearData(const ClearDataMode);
void clearAllUiData();
void loadAnalysisData(const AnalysisMode mode,const double x1,const double x2,const QString objectName);
void calculateAnalysisResult(const AnalysisMode mode,const double x1,const double x2,const QString objectName);
void drawOITLine(const Global::ExperimentData startData,
const Global::ExperimentData endData,