mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-20 11:59:42 +08:00
添加了温度测试
This commit is contained in:
117
othersoft/TemperatureControler/src/json/logout.cpp
Normal file
117
othersoft/TemperatureControler/src/json/logout.cpp
Normal file
@ -0,0 +1,117 @@
|
||||
#include "logout.h"
|
||||
#include "iostream"
|
||||
extern FILE *file=NULL;
|
||||
#define _DEBUG
|
||||
void (*pFunction)(QString message)= nullptr;
|
||||
QString colorcode = "\033[";
|
||||
QString lastdatestr="";
|
||||
int outputlevel = 2;
|
||||
//
|
||||
//void logout(QString str)
|
||||
//{
|
||||
//#ifdef _DEBUG
|
||||
// qDebug()<<str;
|
||||
//#endif
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
void Log(QString str, int level)
|
||||
{
|
||||
|
||||
|
||||
if(outputlevel>5)
|
||||
{
|
||||
if (pFunction!= nullptr)
|
||||
{
|
||||
pFunction(str);
|
||||
}
|
||||
|
||||
}
|
||||
//return;
|
||||
if (level > outputlevel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//QTextCodec *codec = QTextCodec::codecForName("GBK");//<2F><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int colorint;
|
||||
switch (level)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
|
||||
// return;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
|
||||
qDebug() << "\033[32m";//<2F><>ɫ
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
|
||||
qDebug() << "\033[35m";//<2F><>ɫ
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
|
||||
qDebug() << "\033[31m";//<2F><>ɫ
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
qDebug() << "\033[36m";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
//str=codec->toUnicode(str.toStdString().c_str());
|
||||
//qDebug() << str;
|
||||
//qDebug() << "\033[0m";
|
||||
//std::cout<<str.toStdString()<<"<br>";
|
||||
std::fflush(stdout);
|
||||
|
||||
}
|
||||
|
||||
void setoutlevel(int level /*= 4*/)
|
||||
{
|
||||
outputlevel = level;
|
||||
|
||||
}
|
||||
|
||||
void setfunc(void (*sendmassage1)(QString)) {
|
||||
pFunction=sendmassage1;
|
||||
}
|
||||
|
||||
void writelogtofile(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/log/"+currentTime.toString("yyyy_MM_dd")+".log";
|
||||
system("mkdir -p /home/iris/log");
|
||||
file=fopen(path.toStdString().c_str(),"a+");
|
||||
fprintf(file,"\n\n\n\nstart---------------------------------------------------------------------------------\n");
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
Reference in New Issue
Block a user