2025-04-24T16:41:19

This commit is contained in:
yuntang 2025-04-24 16:41:20 +08:00
parent 834751d2a8
commit 71c308ac2d
76 changed files with 84817 additions and 263 deletions

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
{
"InstrumentCoefficient": 1
}

View File

@ -0,0 +1,11 @@
*GLOBAL:
ENABLED = true
TO_FILE = true
TO_STANDARD_OUTPUT = true
FORMAT = "[%datetime] %msg"
FILENAME = "log-sdk/%datetime{%Y%M%d}.log"
MILLISECONDS_WIDTH = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 104857600
LOG_FLUSH_THRESHOLD = 0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,37 +0,0 @@
2025-04-15 16:25:15,306 DEBUG [default] main...
2025-04-15 16:25:15,558 DEBUG [default] setEventHandlerEnable...0
2025-04-15 16:25:15,558 DEBUG [default] xMax:5
2025-04-15 16:25:19,903 DEBUG [default] peakPoint:186.879,2.2
2025-04-15 16:25:20,731 DEBUG [default] peakPoint:33.156,-2.366
2025-04-15 16:25:21,296 DEBUG [default] peakPoint:136.386,-3.03
2025-04-15 17:09:54,935 DEBUG [default] main...
2025-04-15 17:09:54,952 DEBUG [default] setEventHandlerEnable...0
2025-04-15 17:09:54,953 DEBUG [default] xMax:5
2025-04-15 17:10:04,848 DEBUG [default] peakPoint:186.879,2.2
2025-04-15 17:10:05,521 DEBUG [default] peakPoint:33.156,-2.366
2025-04-15 17:10:06,448 DEBUG [default] peakPoint:136.386,-3.03
2025-04-15 17:10:09,876 DEBUG [default] context menu...
2025-04-15 17:10:09,876 DEBUG [default] selected...
2025-04-15 17:10:11,336 DEBUG [default] slotBaseLine...
2025-04-15 17:10:11,342 DEBUG [default] index:0
2025-04-15 17:10:12,838 DEBUG [default] context menu...
2025-04-15 17:10:12,838 DEBUG [default] selected...
2025-04-15 17:10:14,440 DEBUG [default] index:1
2025-04-15 17:10:15,719 DEBUG [default] context menu...
2025-04-15 17:10:15,719 DEBUG [default] selected...
2025-04-15 17:10:17,216 DEBUG [default] index:2
2025-04-15 17:10:25,154 DEBUG [default] Base,standard,sample not selected.
2025-04-15 17:10:28,909 DEBUG [default] Base,standard,sample not selected.
2025-04-15 17:10:30,014 DEBUG [default] Base,standard,sample not selected.
2025-04-15 17:10:33,063 DEBUG [default] Base,standard,sample not selected.
2025-04-15 17:10:33,241 DEBUG [default] Base,standard,sample not selected.
2025-04-15 17:10:33,424 DEBUG [default] Base,standard,sample not selected.
2025-04-15 17:10:33,595 DEBUG [default] Base,standard,sample not selected.
2025-04-15 17:10:33,782 DEBUG [default] Base,standard,sample not selected.
2025-04-15 17:10:33,952 DEBUG [default] Base,standard,sample not selected.
2025-04-15 17:10:45,031 DEBUG [default] Base,standard,sample not selected.
2025-04-15 17:10:45,194 DEBUG [default] Base,standard,sample not selected.
2025-04-15 17:10:45,371 DEBUG [default] Base,standard,sample not selected.
2025-04-15 17:25:42,781 DEBUG [default] main...
2025-04-15 17:25:42,794 DEBUG [default] setEventHandlerEnable...0
2025-04-15 17:25:42,794 DEBUG [default] xMax:5

Binary file not shown.

View File

@ -14,7 +14,7 @@ void ConfigHandler::reader()
if (QFile::exists(ConConfigFilePath)) { if (QFile::exists(ConConfigFilePath)) {
logde << "config config file existed. "; logde << "config config file existed. ";
}else{ }else{
writer(true); writer(false);
} }
// 读取JSON文件 // 读取JSON文件
@ -37,7 +37,7 @@ void ConfigHandler::reader()
_configMap[ConInstrumentCoefficientStr] = QVariant(obj[ConInstrumentCoefficientStr].toDouble()); _configMap[ConInstrumentCoefficientStr] = QVariant(obj[ConInstrumentCoefficientStr].toDouble());
} }
#if 0
void ConfigHandler::createDefaultFile() void ConfigHandler::createDefaultFile()
{ {
logde<<"createDefaultFile"; logde<<"createDefaultFile";
@ -48,8 +48,12 @@ void ConfigHandler::createDefaultFile()
// obj["age"] = 30; // obj["age"] = 30;
// obj["city"] = "New York"; // obj["city"] = "New York";
obj[ConInstrumentCoefficientStr] = double coefficient =
ConDefaultMap[ConInstrumentCoefficientStr].toFloat(); ConfigHandler::ConDefaultMap.value(ConInstrumentCoefficientStr).toDouble();
logde<<"coefficient:"<<coefficient;
obj[ConInstrumentCoefficientStr] =coefficient;
// 将 QJsonObject 转换为 QJsonDocument // 将 QJsonObject 转换为 QJsonDocument
QJsonDocument doc(obj); QJsonDocument doc(obj);
@ -65,6 +69,7 @@ void ConfigHandler::createDefaultFile()
file.write(doc.toJson()); file.write(doc.toJson());
file.close(); // 确保文件关闭 file.close(); // 确保文件关闭
} }
#endif
void ConfigHandler::writer(const bool writeRealDataFlag) void ConfigHandler::writer(const bool writeRealDataFlag)
{ {
@ -76,7 +81,7 @@ void ConfigHandler::writer(const bool writeRealDataFlag)
} }
obj[ConInstrumentCoefficientStr] = obj[ConInstrumentCoefficientStr] =
(*mapPtr)[ConInstrumentCoefficientStr].toFloat(); (*mapPtr).value(ConInstrumentCoefficientStr).toFloat();
// 将 QJsonObject 转换为 QJsonDocument // 将 QJsonObject 转换为 QJsonDocument
QJsonDocument doc(obj); QJsonDocument doc(obj);

View File

@ -6,8 +6,17 @@
const QString ConInstrumentCoefficientStr = "InstrumentCoefficient"; const QString ConInstrumentCoefficientStr = "InstrumentCoefficient";
namespace ConfigHandler { namespace ConfigHandler {
const QString ConConfigFilePath = QDir::currentPath() + "/config.json";
const QMap<QString, QVariant> ConDefaultMap = {
{ConInstrumentCoefficientStr, QVariant(1.000f)},
};
extern QMap<QString, QVariant> _configMap;
//
void reader(); void reader();
void createDefaultFile(); //void createDefaultFile();
/** /**
* @brief writer * @brief writer
* @param writeRealDataFlag * @param writeRealDataFlag
@ -15,14 +24,6 @@ void createDefaultFile();
* false:Write ConDefaultMap content. * false:Write ConDefaultMap content.
*/ */
void writer(const bool writeRealDataFlag = true); void writer(const bool writeRealDataFlag = true);
const QString ConConfigFilePath = QDir::currentPath() + "/config.json";
const QMap<QString, QVariant> ConDefaultMap = {
{ConInstrumentCoefficientStr, 1.001f},
};
extern QMap<QString, QVariant> _configMap;
} }

View File

@ -251,7 +251,9 @@ float PointCalculate::calculateArea() {
/* /*
* H = K * S / w; * H = K * S / w;
*/ */
float coefficient = ConfigHandler::_configMap[ConInstrumentCoefficientStr].toFloat(); float coefficient = ConfigHandler::_configMap.value(ConInstrumentCoefficientStr).toFloat();
logde<<"coefficient:"<<coefficient;
if(Global::_enthalpyCoefficientEnableFlag){ if(Global::_enthalpyCoefficientEnableFlag){
logde<<"_enthalpyCoefficientEnableFlag..."; logde<<"_enthalpyCoefficientEnableFlag...";
@ -266,10 +268,8 @@ float PointCalculate::calculateArea() {
value3; value3;
} }
logde<<"coefficient:"<<coefficient;
float weight = 1.0f; float area = integral * coefficient ;
float area = integral * coefficient / weight;
return area; return area;
} }

View File

@ -38,21 +38,13 @@ int XlsxHandler::readFile(const QString sourceFilePath, Global::CurveFileData &c
return 3; return 3;
} }
#if 0
// 获取工作表的行数和列数
int rowCount = workSheet->dimension().rowCount();
int colCount = workSheet->dimension().columnCount();
qDebug() << "row:" << rowCount << "col:" << colCount;
logde << "0:" << workSheet->cellAt(1, 1)->value().toString().toStdString();
qDebug() << workSheet->cellAt(1, 1)->value().toString();
#endif
// //
int index = 2; int index = 2;
Global::ExperimentInfo& ei = cfd.ei; Global::ExperimentInfo& ei = cfd.ei;
ei.sampleName = workSheet->cellAt(index++, 2)->value().toString(); ei.sampleName = workSheet->cellAt(index++, 2)->value().toString();
ei.sampleWeight = workSheet->cellAt(index++, 2)->value().toString(); ei.sampleWeight = workSheet->cellAt(index++, 2)->value().toString();
logde<<"xlsx sample weight:"<<ei.sampleWeight.toStdString();
index++; // skip crucible weight. index++; // skip crucible weight.
ei.date = workSheet->cellAt(index++, 2)->value().toString(); ei.date = workSheet->cellAt(index++, 2)->value().toString();
ei.experimentor = workSheet->cellAt(index++, 2)->value().toString(); ei.experimentor = workSheet->cellAt(index++, 2)->value().toString();

View File

@ -8,9 +8,10 @@
#include "protocol.h" #include "protocol.h"
namespace Global { namespace Global {
const QString ConSoftVersion = "0.9.1"; const QString ConSoftVersion = "0.9.7";
const QString ExperimentDirPath = QDir::currentPath()+"/../experiment_data"; const QString ExperimentDirPath = QDir::currentPath()+"/../experiment_data";
const QString SampleDataFloder = ExperimentDirPath + "/sample_data"; const QString SampleDataFloder = ExperimentDirPath + "/sample_data";
const QString BaseLineFolder = ExperimentDirPath + "/base_line"; const QString BaseLineFolder = ExperimentDirPath + "/base_line";
const QString AnalysisStateFolder = ExperimentDirPath + "/analysis_state"; const QString AnalysisStateFolder = ExperimentDirPath + "/analysis_state";

View File

@ -22,8 +22,13 @@ int main(int argc, char *argv[])
logde<<"main..."; logde<<"main...";
// //
ConfigHandler::reader(); ConfigHandler::reader();
#if 0
logde<<"config,instrument coefficient:" logde<<"config,instrument coefficient:"
<<ConfigHandler::_configMap[ConInstrumentCoefficientStr].toFloat(); <<ConfigHandler::_configMap.value(ConInstrumentCoefficientStr).toFloat();
logde<<"config,default coefficient:"
<<ConfigHandler::ConDefaultMap.value(ConInstrumentCoefficientStr).toFloat();
#endif
#if 0 #if 0
ConfigHandler::_configMap[ConInstrumentCoefficientStr] = 2.001f; ConfigHandler::_configMap[ConInstrumentCoefficientStr] = 2.001f;

View File

@ -44,29 +44,6 @@ MainWindow::MainWindow(QWidget *parent)
permenentLabel->setText("Software Ver:" + Global::ConSoftVersion); permenentLabel->setText("Software Ver:" + Global::ConSoftVersion);
ui->statusbar->addPermanentWidget(permenentLabel); ui->statusbar->addPermanentWidget(permenentLabel);
// //
#if 0
_expertmentSettingForm->setWindowFlags(_expertmentSettingForm->windowFlags()|
Qt::Dialog);
_specificHeatComparisonMethodForm->setWindowFlags(
_specificHeatComparisonMethodForm->windowFlags()| Qt::Dialog);
_realTimeDataForm->setWindowFlags(_realTimeDataForm->windowFlags()|
Qt::Dialog);
_degreeOfCureForm->setWindowFlags(_degreeOfCureForm->windowFlags()|
Qt::Dialog);
_instrumentCoefficientForm->setWindowFlags(_instrumentCoefficientForm->windowFlags()|
Qt::Dialog);
_OITAutoAnalysisParamForm->setWindowFlags(_OITAutoAnalysisParamForm->windowFlags()|
Qt::Dialog);
// _degreeOfCrystallinityForm->setWindowFlags(_degreeOfCrystallinityForm->windowFlags()|
// Qt::Dialog);
// 设置子窗口为模态对话框
_degreeOfCrystallinityForm->setWindowModality(Qt::ApplicationModal);
_degreeOfCrystallinityForm->setWindowFlags(Qt::Dialog);
#endif
setSubWidgetAttribute(_expertmentSettingForm); setSubWidgetAttribute(_expertmentSettingForm);
setSubWidgetAttribute(_specificHeatComparisonMethodForm); setSubWidgetAttribute(_specificHeatComparisonMethodForm);
setSubWidgetAttribute(_realTimeDataForm); setSubWidgetAttribute(_realTimeDataForm);
@ -101,6 +78,11 @@ void MainWindow::slotContextMenuShow(const QPoint point)
_contextMenu->exec(point); _contextMenu->exec(point);
} }
void MainWindow::slotStatusbarMesg(const QString)
{
}
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
// 弹出确认对话框 // 弹出确认对话框

View File

@ -35,6 +35,7 @@ public:
public slots: public slots:
void slotContextMenuShow(const QPoint); void slotContextMenuShow(const QPoint);
void slotStatusbarMesg(const QString);
protected: protected:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
private slots: private slots:

View File

@ -140,6 +140,7 @@ QByteArray setDeviceStartStop(const DeviceStartMode mode)
void experimentalStateSwitching(const CommonData &cd) void experimentalStateSwitching(const CommonData &cd)
{ {
// Switch the software mode accord to the serial port data.
switch(cd.run_type){ switch(cd.run_type){
case DeviceRunStatus::Heat: case DeviceRunStatus::Heat:
case DeviceRunStatus::ConstantTemp: case DeviceRunStatus::ConstantTemp:
@ -152,10 +153,10 @@ void experimentalStateSwitching(const CommonData &cd)
default:break; default:break;
} }
// If phase update, add new phase data to the global param.
if(Global::_currentPhase != (int)cd.current_phase){ if(Global::_currentPhase != (int)cd.current_phase){
Global::_currentPhase = (int)cd.current_phase; Global::_currentPhase = (int)cd.current_phase;
// Global::CurveExperimentData ced{nullptr,"",QVector<Global::ExperimentData>()};
Global::CurveExperimentData ced; Global::CurveExperimentData ced;
Global::_curveExperimentDataVtr.push_back(ced); Global::_curveExperimentDataVtr.push_back(ced);
@ -210,43 +211,6 @@ QByteArray inquirePhaseInfo()
QByteArray((char *)&crc, 2); 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;
}
#if 0
logde<<"phase:"<<(int)cd.current_phase;
logde<<"run type:"<<(int)cd.run_type;
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
}

View File

@ -14,7 +14,6 @@ QByteArray inquirePhaseInfo();
QByteArray setDeviceStartStop(const DeviceStartMode); QByteArray setDeviceStartStop(const DeviceStartMode);
void experimentalStateSwitching(const CommonData&cd); void experimentalStateSwitching(const CommonData&cd);
bool isDevExperimentEnded(const CommonData&cd);
bool commonDataParser(const QByteArray&ba,CommonData &cd); bool commonDataParser(const QByteArray&ba,CommonData &cd);
unsigned short modbusCRC16(unsigned char *data,unsigned short length); unsigned short modbusCRC16(unsigned char *data,unsigned short length);

View File

@ -129,6 +129,7 @@ void SerialPort::slotReadData()
{ {
DataParser::experimentalStateSwitching(cd); DataParser::experimentalStateSwitching(cd);
setAxis(); setAxis();
updateStatusbarMsg();
if (spp->addr == 0) if (spp->addr == 0)
{ {
@ -141,6 +142,11 @@ void SerialPort::slotReadData()
} }
} }
void SerialPort::updateStatusbarMsg()
{
}
void SerialPort::commonDataParser(const int dataLength, const u16 addr, void SerialPort::commonDataParser(const int dataLength, const u16 addr,
const CommonData &cd) const CommonData &cd)
{ {

View File

@ -44,6 +44,7 @@ private slots:
void slotReadData(); void slotReadData();
private: private:
void updateStatusbarMsg();
void commonDataParser(const int dataLength, const u16 addr, const CommonData &cd); void commonDataParser(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();

View File

@ -207,6 +207,7 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
qDebug() << "slotRecvAnalysisFileName" << filePath; qDebug() << "slotRecvAnalysisFileName" << filePath;
// todo.禁止重复文件添加。 // todo.禁止重复文件添加。
Global::CurveFileData cfd; Global::CurveFileData cfd;
if(XlsxHandler::readFile(filePath,cfd) != 0){ if(XlsxHandler::readFile(filePath,cfd) != 0){
QMessageBox::warning((QWidget*)this->parent(), "warnning", "File parse error."); QMessageBox::warning((QWidget*)this->parent(), "warnning", "File parse error.");
@ -249,9 +250,12 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
// Add data to global parameter. // Add data to global parameter.
QFileInfo fileInfo(filePath); QFileInfo fileInfo(filePath);
Global::_curveExperimentDataVtr.push_back({_currentCurve,fileInfo.fileName(),pti.dataVtr});
pti.curve = _currentCurve;
} }
Global::_curveFileDataVtr.push_back(cfd);
_customPlot->rescaleAxes(); _customPlot->rescaleAxes();
_customPlot->replot(); _customPlot->replot();
} }
@ -380,7 +384,18 @@ void CentralWidget::slotAnalysisSettingApply()
PointCalculate::setRegionPointX(x1,x2); PointCalculate::setRegionPointX(x1,x2);
//enthalpy //enthalpy
double enthalpyValue = PointCalculate::calculateArea(); double sampleWeight = 0.0f;
for(Global::CurveFileData& cfd:Global::_curveFileDataVtr){
for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){
if(_currentCurve && _currentCurve == pti.curve){
sampleWeight = cfd.ei.sampleWeight.toDouble();
}
}
}
logde<<"sample weight:"<<sampleWeight;
double enthalpyValue = PointCalculate::calculateArea() / sampleWeight;
//peak //peak
QPointF peakPoint = PointCalculate::getPeakPoint(); QPointF peakPoint = PointCalculate::getPeakPoint();
@ -391,7 +406,8 @@ void CentralWidget::slotAnalysisSettingApply()
logde<<"start,end:"<<startEndPointPair.first.x()<<"," logde<<"start,end:"<<startEndPointPair.first.x()<<","
<<startEndPointPair.second.x(); <<startEndPointPair.second.x();
drawText(peakPoint,PointCalculate::textFormatPeakPoint(enthalpyValue, drawText(peakPoint,
PointCalculate::textFormatPeakPoint(enthalpyValue,
peakPoint.x(), peakPoint.x(),
startEndPointPair.first.x(), startEndPointPair.first.x(),
startEndPointPair.second.x())); startEndPointPair.second.x()));
@ -833,11 +849,11 @@ void CentralWidget::setEventHandlerEnable(const bool flag)
double xMax = _customPlot->xAxis->range().upper; double xMax = _customPlot->xAxis->range().upper;
double xMin = _customPlot->xAxis->range().lower; double xMin = _customPlot->xAxis->range().lower;
logde<<"xMax:"<<xMax; // logde<<"xMax:"<<xMax;
QVector<double> ticks = _customPlot->xAxis->tickVector(); // QVector<double> ticks = _customPlot->xAxis->tickVector();
int numTicks = ticks.size(); // int numTicks = ticks.size();
logde<<"ticks:"<<numTicks; // logde<<"ticks:"<<numTicks;
double range = xMax - xMin; double range = xMax - xMin;
double xLeft = xMin + range / 3; double xLeft = xMin + range / 3;

View File

@ -43,12 +43,12 @@ public slots:
void slotSelectionChanged(); void slotSelectionChanged();
//analysis setting //analysis setting
void slotAnalysisSettingLineXPoint(const int index,const double);
void slotAnalysisSettingApply(); void slotAnalysisSettingApply();
void slotAnalysisSettingConfirm(); void slotAnalysisSettingConfirm();
void slotAnalysisSettingUndo(); void slotAnalysisSettingUndo();
void slotAnalysisSettingCancel(); void slotAnalysisSettingCancel();
void slotAnalysisSettingLineXPoint(const int index,const double);
protected: protected:
void timerEvent(QTimerEvent* event); void timerEvent(QTimerEvent* event);
void contextMenuEvent(QContextMenuEvent *event); void contextMenuEvent(QContextMenuEvent *event);

View File

@ -15,7 +15,6 @@ RealTimeDataForm::~RealTimeDataForm()
void RealTimeDataForm::slotRevCommonData(const CommonData &data) void RealTimeDataForm::slotRevCommonData(const CommonData &data)
{ {
return;
#if 0 #if 0
qDebug()<<"rev-------------------------"; qDebug()<<"rev-------------------------";
// 格式化输出 double 类型,保留三位小数 // 格式化输出 double 类型,保留三位小数