3.2.5 beta 6 日志文件存储到1M,优化数据统计模块
This commit is contained in:
parent
bfdb4cdbf7
commit
ad5bb32d1a
@ -81,7 +81,14 @@ void log_write(const char *level, const char* format, ...)
|
|||||||
|
|
||||||
char cmd[256] = { 0 };
|
char cmd[256] = { 0 };
|
||||||
sprintf(cmd, "cp %s %s_bak", gLogParam.m_log_full_name, gLogParam.m_log_full_name);
|
sprintf(cmd, "cp %s %s_bak", gLogParam.m_log_full_name, gLogParam.m_log_full_name);
|
||||||
system(cmd);
|
|
||||||
|
int iRet = system(cmd);
|
||||||
|
if (iRet == -1)
|
||||||
|
{
|
||||||
|
perror("system() error");
|
||||||
|
}
|
||||||
|
|
||||||
|
print_brown("iRet = %d,cmd = %s\n",iRet,cmd);
|
||||||
remove(gLogParam.m_log_full_name);
|
remove(gLogParam.m_log_full_name);
|
||||||
fp = fopen(gLogParam.m_log_full_name, "a");
|
fp = fopen(gLogParam.m_log_full_name, "a");
|
||||||
if(fp == NULL) {
|
if(fp == NULL) {
|
||||||
|
@ -1461,7 +1461,7 @@ int SqliteDB::CalculateData()
|
|||||||
sprintf(whereCon," and channelID = '%s-X'",vecRet[i][1].c_str());
|
sprintf(whereCon," and channelID = '%s-X'",vecRet[i][1].c_str());
|
||||||
strsql = string(sql3) + string(whereCon);
|
strsql = string(sql3) + string(whereCon);
|
||||||
CountWaveX3 = GetTableRows(tableName,strsql.c_str());
|
CountWaveX3 = GetTableRows(tableName,strsql.c_str());
|
||||||
if ((CountWaveX > 0 && (CountWaveX / planCount > rate)) && (CountWaveX2 > 0 && (CountWaveX2 / planCount > rate)) && (CountWaveX3 > 0 && (CountWaveX3 / planCount > rate)))
|
if ((CountWaveX > 0 && (CountWaveX / planCount > (rate/100))) && (CountWaveX2 > 0 && (CountWaveX2 / planCount > (rate/100))) && (CountWaveX3 > 0 && (CountWaveX3 / planCount > (rate/100))))
|
||||||
{
|
{
|
||||||
rateX = 1;
|
rateX = 1;
|
||||||
}else{
|
}else{
|
||||||
@ -1481,7 +1481,7 @@ int SqliteDB::CalculateData()
|
|||||||
strsql = string(sql3) + string(whereCon);
|
strsql = string(sql3) + string(whereCon);
|
||||||
CountWaveY3 = GetTableRows(tableName,strsql.c_str());
|
CountWaveY3 = GetTableRows(tableName,strsql.c_str());
|
||||||
|
|
||||||
if ((CountWaveY > 0 && (CountWaveY / planCount > rate)) && (CountWaveY2 > 0 && (CountWaveY2 / planCount > rate)) && (CountWaveY3 > 0 && (CountWaveY3 / planCount > rate)))
|
if ((CountWaveY > 0 && (CountWaveY / planCount > (rate/100))) && (CountWaveY2 > 0 && (CountWaveY2 / planCount > (rate/100))) && (CountWaveY3 > 0 && (CountWaveY3 / planCount > (rate/100))))
|
||||||
{
|
{
|
||||||
rateY = 1;
|
rateY = 1;
|
||||||
}else{
|
}else{
|
||||||
@ -1501,7 +1501,7 @@ int SqliteDB::CalculateData()
|
|||||||
strsql = string(sql3) + string(whereCon);
|
strsql = string(sql3) + string(whereCon);
|
||||||
CountWaveZ3 = GetTableRows(tableName,strsql.c_str());
|
CountWaveZ3 = GetTableRows(tableName,strsql.c_str());
|
||||||
|
|
||||||
if ((CountWaveZ > 0 && (CountWaveZ / planCount > rate)) && (CountWaveZ2 > 0 && (CountWaveZ2 / planCount > rate)) && (CountWaveZ3 > 0 && (CountWaveZ3 / planCount > rate)))
|
if ((CountWaveZ > 0 && (CountWaveZ / planCount > (rate/100))) && (CountWaveZ2 > 0 && (CountWaveZ2 / planCount > (rate/100))) && (CountWaveZ3 > 0 && (CountWaveZ3 / planCount > (rate/100))))
|
||||||
{
|
{
|
||||||
rateZ = 1;
|
rateZ = 1;
|
||||||
}else{
|
}else{
|
||||||
@ -1519,6 +1519,7 @@ int SqliteDB::CalculateData()
|
|||||||
|
|
||||||
int zigbeepowerEnable = readIntValue( "config", "zigbeepowerEnable",(char*)GlobalConfig::Config_G.c_str());
|
int zigbeepowerEnable = readIntValue( "config", "zigbeepowerEnable",(char*)GlobalConfig::Config_G.c_str());
|
||||||
if(zigbeepowerEnable){
|
if(zigbeepowerEnable){
|
||||||
|
LOG_INFO("rateX = %d,rateY = %d,rateZ = %d,zigbeepower = %s \n",rateX,rateY,rateZ,vecRet[i][5].c_str());
|
||||||
if (rateX != -1 && rateY != -1 && rateZ != -1 && vecRet[i][5] == "3")
|
if (rateX != -1 && rateY != -1 && rateZ != -1 && vecRet[i][5] == "3")
|
||||||
{
|
{
|
||||||
char updateSql[50] = {0x00};
|
char updateSql[50] = {0x00};
|
||||||
@ -1526,7 +1527,7 @@ int SqliteDB::CalculateData()
|
|||||||
memset(whereCon,0x00,sizeof(whereCon));
|
memset(whereCon,0x00,sizeof(whereCon));
|
||||||
sprintf(whereCon," dataNodeNo = '%s'",vecRet[i][0].c_str());
|
sprintf(whereCon," dataNodeNo = '%s'",vecRet[i][0].c_str());
|
||||||
UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
||||||
LOG_INFO("update ZigbeePower 2");
|
LOG_INFO("2 update ZigbeePower ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rateX == -1 || rateY == -1 || rateZ == -1 ) && vecRet[i][5] == "2")
|
if ((rateX == -1 || rateY == -1 || rateZ == -1 ) && vecRet[i][5] == "2")
|
||||||
@ -1536,7 +1537,7 @@ int SqliteDB::CalculateData()
|
|||||||
memset(whereCon,0x00,sizeof(whereCon));
|
memset(whereCon,0x00,sizeof(whereCon));
|
||||||
sprintf(whereCon," dataNodeNo = '%s'",vecRet[i][0].c_str());
|
sprintf(whereCon," dataNodeNo = '%s'",vecRet[i][0].c_str());
|
||||||
UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
||||||
LOG_INFO("update ZigbeePower 3");
|
LOG_INFO("3 update ZigbeePower ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
featureInterVal = atoi(vecRet[i][3].c_str());
|
featureInterVal = atoi(vecRet[i][3].c_str());
|
||||||
|
2
main.cpp
2
main.cpp
@ -29,7 +29,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
printf(" Firmware compile time:%s %s,version %s\n", __DATE__, __TIME__,GlobalConfig::Version.c_str());
|
printf(" Firmware compile time:%s %s,version %s\n", __DATE__, __TIME__,GlobalConfig::Version.c_str());
|
||||||
// 初始化日志记录,日志缓存区,记录数,未使用,后期,命令启动
|
// 初始化日志记录,日志缓存区,记录数,未使用,后期,命令启动
|
||||||
log_init(SOFTWARE_RUN_LOG, 1380, 160 * 1024 * 2);
|
log_init(SOFTWARE_RUN_LOG, 1380, 1000 * 1024);
|
||||||
LOG_INFO("####CIDNSOFT start####\n");
|
LOG_INFO("####CIDNSOFT start####\n");
|
||||||
|
|
||||||
// 查看版本信息
|
// 查看版本信息
|
||||||
|
@ -2026,6 +2026,7 @@ void Uart::DealDataNodeInfo(const char *pData)
|
|||||||
g_mapCompress.insert(std::make_pair(dataNodeInfo.ZigbeeShortAddr,tempchannel));
|
g_mapCompress.insert(std::make_pair(dataNodeInfo.ZigbeeShortAddr,tempchannel));
|
||||||
print_info("new Node,size = %d\n",g_mapCompress.size());
|
print_info("new Node,size = %d\n",g_mapCompress.size());
|
||||||
}
|
}
|
||||||
|
LOG_INFO("DealDataNodeInfo %s \n",dataNodeInfo.ZigbeeShortAddr.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uart::RecordBattery(string & strLongAddr,DataRecvStatic& dataStatic,string& nowTimetamp)
|
void Uart::RecordBattery(string & strLongAddr,DataRecvStatic& dataStatic,string& nowTimetamp)
|
||||||
@ -2336,8 +2337,8 @@ void Uart::DealDataNodeFeature(const char *pData, int flag)
|
|||||||
print_info("dataStatic.TemTop : %f dataStatic.TemBot : %f dataStatic.Dip :%d dataStatic.Voltage : %d\n", dataStatic.TemTop\
|
print_info("dataStatic.TemTop : %f dataStatic.TemBot : %f dataStatic.Dip :%d dataStatic.Voltage : %d\n", dataStatic.TemTop\
|
||||||
, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage);
|
, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage);
|
||||||
|
|
||||||
sprintf(updateSql, "temTop='%f',temBot='%f',dip='%d',voltage='%d',timeStamp='%s',StaticIndex = %d, nodeResend = %d,zigbeeSignal = '',zigbeeSignalNode = '',statisticType = '',timing = '' ",\
|
sprintf(updateSql, "temTop='%f',temBot='%f',dip='%d',voltage='%d',timeStamp='%s',StaticIndex = %d, nodeResend = %d,zigbeeSignal = '',zigbeeSignalNode = '',statisticType = '%d',timing = '%d' ",\
|
||||||
dataStatic.TemTop, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage, nowTimetamp.c_str(),staticIndex,nodeResend);
|
dataStatic.TemTop, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage, nowTimetamp.c_str(),staticIndex,nodeResend,flag,timing);
|
||||||
sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-S").c_str());
|
sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-S").c_str());
|
||||||
if ( /*0 == sql_ctl->GetTableRows(T_DATASTATIC_INFO(TNAME), whereCon)*/ (Count * 3 < SAVE_COUNT && lTime < OneWeek ) || strTime.size() == 0 ) {
|
if ( /*0 == sql_ctl->GetTableRows(T_DATASTATIC_INFO(TNAME), whereCon)*/ (Count * 3 < SAVE_COUNT && lTime < OneWeek ) || strTime.size() == 0 ) {
|
||||||
print_info("insert static data to sql\n");
|
print_info("insert static data to sql\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user