任立新 修改该温控系统的逻辑

This commit is contained in:
xin
2025-05-08 13:25:48 +08:00
parent dcba7db121
commit 3275a1abd6
9 changed files with 478 additions and 32 deletions

View File

@ -114,4 +114,30 @@ void writelogtofile(QString sender,QString qstr)
fprintf(file,"%s %s: %s\n",currentTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString().c_str(),sender.toStdString().c_str(),qstr.toStdString().c_str());
fflush(file);
}
void saveData(QString sender,QString qstr)
{
QDateTime currentTime = QDateTime::currentDateTime();
QString datestr=currentTime.toString("yyyy_MM_dd");
if (lastdatestr!=datestr)
{
if (file!=NULL)
{
fclose(file);
file=NULL;
}
lastdatestr=datestr;
}
if (file==NULL)
{
QString path="/home/iris/TempData/"+currentTime.toString("yyyy_MM_dd")+".csv";
system("mkdir -p /home/iris/TempData");
file=fopen(path.toStdString().c_str(),"a+");
fprintf(file,QString::fromLocal8Bit("日期, 数据类型, 日期~n").toStdString().c_str());
}
fprintf(file,"%s,%s,%s\n",currentTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString().c_str(),sender.toStdString().c_str(),qstr.toStdString().c_str());
fflush(file);
}