删除统计波形数据到日志
This commit is contained in:
parent
1e0ad9e807
commit
092236cfd0
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
/Debug/
|
/Debug/
|
||||||
.settings/*
|
.settings/*
|
||||||
.cproject
|
.cproject
|
||||||
|
.vscode/
|
||||||
|
|||||||
84
.vscode/settings.json
vendored
84
.vscode/settings.json
vendored
@ -1,84 +0,0 @@
|
|||||||
{
|
|
||||||
"search.exclude": {
|
|
||||||
"**/Debug": true,
|
|
||||||
"**/Release": true
|
|
||||||
},
|
|
||||||
"files.exclude": {
|
|
||||||
"**/Debug": true,
|
|
||||||
"**/Release": true
|
|
||||||
},
|
|
||||||
"files.associations": {
|
|
||||||
"*.tcc": "cpp",
|
|
||||||
"array": "cpp",
|
|
||||||
"atomic": "cpp",
|
|
||||||
"bit": "cpp",
|
|
||||||
"cctype": "cpp",
|
|
||||||
"chrono": "cpp",
|
|
||||||
"clocale": "cpp",
|
|
||||||
"cmath": "cpp",
|
|
||||||
"compare": "cpp",
|
|
||||||
"concepts": "cpp",
|
|
||||||
"condition_variable": "cpp",
|
|
||||||
"cstdarg": "cpp",
|
|
||||||
"cstddef": "cpp",
|
|
||||||
"cstdint": "cpp",
|
|
||||||
"cstdio": "cpp",
|
|
||||||
"cstdlib": "cpp",
|
|
||||||
"cstring": "cpp",
|
|
||||||
"ctime": "cpp",
|
|
||||||
"cwchar": "cpp",
|
|
||||||
"cwctype": "cpp",
|
|
||||||
"deque": "cpp",
|
|
||||||
"list": "cpp",
|
|
||||||
"map": "cpp",
|
|
||||||
"set": "cpp",
|
|
||||||
"string": "cpp",
|
|
||||||
"unordered_map": "cpp",
|
|
||||||
"unordered_set": "cpp",
|
|
||||||
"vector": "cpp",
|
|
||||||
"exception": "cpp",
|
|
||||||
"algorithm": "cpp",
|
|
||||||
"functional": "cpp",
|
|
||||||
"iterator": "cpp",
|
|
||||||
"memory": "cpp",
|
|
||||||
"memory_resource": "cpp",
|
|
||||||
"numeric": "cpp",
|
|
||||||
"optional": "cpp",
|
|
||||||
"random": "cpp",
|
|
||||||
"ratio": "cpp",
|
|
||||||
"string_view": "cpp",
|
|
||||||
"system_error": "cpp",
|
|
||||||
"tuple": "cpp",
|
|
||||||
"type_traits": "cpp",
|
|
||||||
"utility": "cpp",
|
|
||||||
"fstream": "cpp",
|
|
||||||
"initializer_list": "cpp",
|
|
||||||
"iomanip": "cpp",
|
|
||||||
"iosfwd": "cpp",
|
|
||||||
"iostream": "cpp",
|
|
||||||
"istream": "cpp",
|
|
||||||
"limits": "cpp",
|
|
||||||
"mutex": "cpp",
|
|
||||||
"new": "cpp",
|
|
||||||
"numbers": "cpp",
|
|
||||||
"ostream": "cpp",
|
|
||||||
"semaphore": "cpp",
|
|
||||||
"sstream": "cpp",
|
|
||||||
"stdexcept": "cpp",
|
|
||||||
"stop_token": "cpp",
|
|
||||||
"streambuf": "cpp",
|
|
||||||
"thread": "cpp",
|
|
||||||
"cinttypes": "cpp",
|
|
||||||
"typeinfo": "cpp",
|
|
||||||
"csignal": "cpp",
|
|
||||||
"strstream": "cpp",
|
|
||||||
"bitset": "cpp",
|
|
||||||
"cfenv": "cpp",
|
|
||||||
"codecvt": "cpp",
|
|
||||||
"complex": "cpp",
|
|
||||||
"any": "cpp",
|
|
||||||
"future": "cpp",
|
|
||||||
"typeindex": "cpp"
|
|
||||||
},
|
|
||||||
"C_Cpp.errorSquiggles": "disabled"
|
|
||||||
}
|
|
||||||
@ -1343,145 +1343,6 @@ int SqliteDB::QueryofflineData() {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SqliteDB::CalculateData() {
|
|
||||||
int res = 0;
|
|
||||||
array_t vecRet = GetDataMultiLine(T_SENSOR_INFO(TNAME), " dataNodeNo,MeasurementID,NodeWaveSend,featureInterVal,waveInterVal,ZigbeePower ", NULL);
|
|
||||||
if (vecRet.size() > 0) {
|
|
||||||
int planCount = 0, planCountStatistic = 0, StatisticCountTotal = 0, SixCountTotal = 0, TimingCountTotal = 0, CountWaveXTotal = 0, waveInterVal = 0, featureInterVal = 0;
|
|
||||||
int CountWaveYTotal = 0, CountWaveZTotal = 0;
|
|
||||||
for (size_t i = 0; i < vecRet.size(); i++) {
|
|
||||||
planCount = 1440 / atoi(vecRet[i][4].c_str());
|
|
||||||
planCountStatistic = 1440 / atoi(vecRet[i][3].c_str());
|
|
||||||
int rate = readIntValue("config", "waveRate", (char *)GlobalConfig::Config_G.c_str());
|
|
||||||
char tableName[50] = {0x00};
|
|
||||||
char whereCon[128] = {0x00};
|
|
||||||
sprintf(tableName, "t_dataStatic_%s", vecRet[i][0].c_str());
|
|
||||||
const char *sql = " timestamp >= strftime('%s', 'now', '-1 day', 'start of day','utc') "
|
|
||||||
"AND timestamp < strftime('%s', 'now', '-1 day','start of day','utc','+24 hours') ";
|
|
||||||
int StatisticCount = GetTableRows(tableName, sql);
|
|
||||||
|
|
||||||
sql = "timeStamp >= strftime('%s', 'now', '-1 day', 'start of day','utc') AND timeStamp < strftime('%s', 'now', '-1 day','start of day','utc','+24 hours') and statisticType = '1' ";
|
|
||||||
int SixCount = GetTableRows(tableName, sql);
|
|
||||||
|
|
||||||
sql = "timeStamp >= strftime('%s', 'now', '-1 day', 'start of day','utc') AND timeStamp < strftime('%s', 'now', '-1 day','start of day','utc','+24 hours') and statisticType = '1' and timing = '0'";
|
|
||||||
int TimingCount = GetTableRows(tableName, sql);
|
|
||||||
zlog_info(zct, "nodeWaveSend = %s,waveInterVal = %s", vecRet[i][2].c_str(), vecRet[i][4].c_str());
|
|
||||||
if (vecRet[i][2] == "") continue;
|
|
||||||
std::vector<std::string> nodeWaveSend;
|
|
||||||
boost::split(nodeWaveSend, vecRet[i][2], boost::is_any_of(","), boost::token_compress_on);
|
|
||||||
int CountWaveX = 0, CountWaveY = 0, CountWaveZ = 0;
|
|
||||||
int CountWaveX2 = 0, CountWaveY2 = 0, CountWaveZ2 = 0;
|
|
||||||
int CountWaveX3 = 0, CountWaveY3 = 0, CountWaveZ3 = 0;
|
|
||||||
int rateX = 0, rateY = 0, rateZ = 0;
|
|
||||||
if (nodeWaveSend.size() < 3) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
sprintf(tableName, "t_data_waveSend");
|
|
||||||
const char *sql1 = "timeStamp >= strftime('%s', 'now', '-1 day', 'start of day','utc')"
|
|
||||||
" AND timeStamp < strftime('%s', 'now','-1 day', 'start of day','utc','+24 hours')";
|
|
||||||
|
|
||||||
const char *sql2 = "timeStamp >= strftime('%s', 'now', '-2 day', 'start of day','utc')"
|
|
||||||
" AND timeStamp < strftime('%s', 'now','-2 day', 'start of day','utc','+24 hours')";
|
|
||||||
|
|
||||||
const char *sql3 = "timeStamp >= strftime('%s', 'now', '-3 day', 'start of day','utc')"
|
|
||||||
" AND timeStamp < strftime('%s', 'now','-3 day', 'start of day','utc','+24 hours')";
|
|
||||||
if (nodeWaveSend[0] == "0") {
|
|
||||||
sprintf(whereCon, " and channelID = '%s-X'", vecRet[i][1].c_str());
|
|
||||||
std::string strsql = std::string(sql1) + std::string(whereCon);
|
|
||||||
zlog_info(zct, "sql = %s", strsql.c_str());
|
|
||||||
CountWaveX = GetTableRows(tableName, strsql.c_str());
|
|
||||||
sprintf(whereCon, " and channelID = '%s-X'", vecRet[i][1].c_str());
|
|
||||||
strsql = std::string(sql2) + std::string(whereCon);
|
|
||||||
CountWaveX2 = GetTableRows(tableName, strsql.c_str());
|
|
||||||
sprintf(whereCon, " and channelID = '%s-X'", vecRet[i][1].c_str());
|
|
||||||
strsql = std::string(sql3) + std::string(whereCon);
|
|
||||||
CountWaveX3 = GetTableRows(tableName, strsql.c_str());
|
|
||||||
if ((CountWaveX > 0 && (CountWaveX / planCount > (rate / 100))) && (CountWaveX2 > 0 && (CountWaveX2 / planCount > (rate / 100))) && (CountWaveX3 > 0 && (CountWaveX3 / planCount > (rate / 100)))) {
|
|
||||||
rateX = 1;
|
|
||||||
} else {
|
|
||||||
rateX = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nodeWaveSend[1] == "0") {
|
|
||||||
sprintf(whereCon, " and channelID = '%s-Y'", vecRet[i][1].c_str());
|
|
||||||
std::string strsql = std::string(sql1) + std::string(whereCon);
|
|
||||||
CountWaveY = GetTableRows(tableName, strsql.c_str());
|
|
||||||
sprintf(whereCon, " and channelID = '%s-Y'", vecRet[i][1].c_str());
|
|
||||||
strsql = std::string(sql2) + std::string(whereCon);
|
|
||||||
CountWaveY2 = GetTableRows(tableName, strsql.c_str());
|
|
||||||
sprintf(whereCon, " and channelID = '%s-Y'", vecRet[i][1].c_str());
|
|
||||||
strsql = std::string(sql3) + std::string(whereCon);
|
|
||||||
CountWaveY3 = GetTableRows(tableName, strsql.c_str());
|
|
||||||
|
|
||||||
if ((CountWaveY > 0 && (CountWaveY / planCount > (rate / 100))) && (CountWaveY2 > 0 && (CountWaveY2 / planCount > (rate / 100))) && (CountWaveY3 > 0 && (CountWaveY3 / planCount > (rate / 100)))) {
|
|
||||||
rateY = 1;
|
|
||||||
} else {
|
|
||||||
rateY = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nodeWaveSend[2] == "0") {
|
|
||||||
sprintf(whereCon, " and channelID = '%s-Z'", vecRet[i][1].c_str());
|
|
||||||
std::string strsql = std::string(sql1) + std::string(whereCon);
|
|
||||||
CountWaveZ = GetTableRows(tableName, strsql.c_str());
|
|
||||||
sprintf(whereCon, " and channelID = '%s-Z'", vecRet[i][1].c_str());
|
|
||||||
strsql = std::string(sql2) + std::string(whereCon);
|
|
||||||
CountWaveZ2 = GetTableRows(tableName, strsql.c_str());
|
|
||||||
sprintf(whereCon, " and channelID = '%s-Z'", vecRet[i][1].c_str());
|
|
||||||
strsql = std::string(sql3) + std::string(whereCon);
|
|
||||||
CountWaveZ3 = GetTableRows(tableName, strsql.c_str());
|
|
||||||
|
|
||||||
if ((CountWaveZ > 0 && (CountWaveZ / planCount > (rate / 100))) && (CountWaveZ2 > 0 && (CountWaveZ2 / planCount > (rate / 100))) && (CountWaveZ3 > 0 && (CountWaveZ3 / planCount > (rate / 100)))) {
|
|
||||||
rateZ = 1;
|
|
||||||
} else {
|
|
||||||
rateZ = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
StatisticCountTotal += StatisticCount;
|
|
||||||
SixCountTotal += SixCount;
|
|
||||||
TimingCountTotal += TimingCount;
|
|
||||||
CountWaveXTotal += CountWaveX;
|
|
||||||
CountWaveYTotal += CountWaveY;
|
|
||||||
CountWaveZTotal += CountWaveZ;
|
|
||||||
zlog_info(zct, "dataNodeNo = %s , Statistic Count = %d , 06 Count = %d , Timing Count = %d , CountWaveX = %d , CountWaveY = %d , CountWaveZ = %d , featureInterVal = %s , waveInterVal = %s , NodeWaveSend = %s", vecRet[i][0].c_str(), StatisticCount, SixCount,
|
|
||||||
TimingCount, CountWaveX, CountWaveY, CountWaveZ, vecRet[i][3].c_str(), vecRet[i][4].c_str(), vecRet[i][2].c_str());
|
|
||||||
|
|
||||||
int zigbeepowerEnable = readIntValue("config", "zigbeepowerEnable", (char *)GlobalConfig::Config_G.c_str());
|
|
||||||
if (zigbeepowerEnable) {
|
|
||||||
zlog_info(zct, "rateX = %d,rateY = %d,rateZ = %d,zigbeepower = %s", rateX, rateY, rateZ, vecRet[i][5].c_str());
|
|
||||||
if (rateX != -1 && rateY != -1 && rateZ != -1 && vecRet[i][5] == "3") {
|
|
||||||
char updateSql[50] = {0x00};
|
|
||||||
sprintf(updateSql, "ZigbeePower = '2',UpdateFlag = 0 ");
|
|
||||||
memset(whereCon, 0x00, sizeof(whereCon));
|
|
||||||
sprintf(whereCon, " dataNodeNo = '%s'", vecRet[i][0].c_str());
|
|
||||||
res = UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
|
||||||
if(res !=0 ){
|
|
||||||
zlog_error(zct, "res = %d", res);
|
|
||||||
}
|
|
||||||
zlog_info(zct, "2 update ZigbeePower ");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((rateX == -1 || rateY == -1 || rateZ == -1) && vecRet[i][5] == "2") {
|
|
||||||
char updateSql[50] = {0x00};
|
|
||||||
sprintf(updateSql, "ZigbeePower = '3',UpdateFlag = 0 ");
|
|
||||||
memset(whereCon, 0x00, sizeof(whereCon));
|
|
||||||
sprintf(whereCon, " dataNodeNo = '%s'", vecRet[i][0].c_str());
|
|
||||||
res = UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
|
|
||||||
if(res !=0 ){
|
|
||||||
zlog_error(zct, "res = %d", res);
|
|
||||||
}
|
|
||||||
zlog_info(zct, "3 update ZigbeePower ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
featureInterVal = atoi(vecRet[i][3].c_str());
|
|
||||||
waveInterVal = atoi(vecRet[i][4].c_str());
|
|
||||||
}
|
|
||||||
zlog_info(zct, "Node Count = %d , featureInterVal = %d , waveInterVal = %d", vecRet.size(), featureInterVal, waveInterVal);
|
|
||||||
zlog_info(zct, "plan Statistic Count = %d , 06 Count = %d , Timing Count = %d , CountWaveX = %d ", planCountStatistic * vecRet.size(), planCount * vecRet.size(), planCount * vecRet.size(), planCount * vecRet.size());
|
|
||||||
zlog_info(zct, "reality Statistic Count = %d , 06 Count = %d , Timing Count = %d , CountWaveX = %d ,CountWaveY = %d ,CountWaveZ = %d ", StatisticCountTotal, SixCountTotal, TimingCountTotal, CountWaveXTotal, CountWaveYTotal, CountWaveZTotal);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SqliteDB::TransBegin() { return sqlite3_exec(mDBAcess, "begin;", 0, 0, 0); }
|
int SqliteDB::TransBegin() { return sqlite3_exec(mDBAcess, "begin;", 0, 0, 0); }
|
||||||
|
|
||||||
int SqliteDB::TransRollback() { return sqlite3_exec(mDBAcess, "rollback;", 0, 0, 0); }
|
int SqliteDB::TransRollback() { return sqlite3_exec(mDBAcess, "rollback;", 0, 0, 0); }
|
||||||
|
|||||||
@ -67,8 +67,6 @@ public:
|
|||||||
int CalculateDip();
|
int CalculateDip();
|
||||||
int InintGateway();
|
int InintGateway();
|
||||||
int QueryofflineData();
|
int QueryofflineData();
|
||||||
int CalculateData();
|
|
||||||
int CalculateWaveRate();
|
|
||||||
std::string GetNodeConfigureInfor(const char *whereCon);
|
std::string GetNodeConfigureInfor(const char *whereCon);
|
||||||
int CloseDB();
|
int CloseDB();
|
||||||
|
|
||||||
|
|||||||
@ -103,16 +103,6 @@ void CheckThread() {
|
|||||||
std::string data = jd.JsonCmd_07();
|
std::string data = jd.JsonCmd_07();
|
||||||
data_publish(data.c_str(), GlobalConfig::Topic_G.mPubStatus.c_str());
|
data_publish(data.c_str(), GlobalConfig::Topic_G.mPubStatus.c_str());
|
||||||
HardStatus = 0;
|
HardStatus = 0;
|
||||||
int hour = 0;
|
|
||||||
struct tm *tm_info = get_current_date();
|
|
||||||
hour = tm_info->tm_hour;
|
|
||||||
int statistics = readIntValue("config", "statistics", (char *)GlobalConfig::Config_G.c_str());
|
|
||||||
if (statistics == 0 && hour > 13) {
|
|
||||||
writeIntValue("config", "statistics", 1, (char *)GlobalConfig::Config_G.c_str());
|
|
||||||
sqlite_db_ctrl::instance().CalculateData();
|
|
||||||
} else if (statistics == 1 && hour < 13) {
|
|
||||||
writeIntValue("config", "statistics", 0, (char *)GlobalConfig::Config_G.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (mqttresend == 7200) {
|
if (mqttresend == 7200) {
|
||||||
mqttresend = 0;
|
mqttresend = 0;
|
||||||
|
|||||||
@ -620,6 +620,7 @@ int Uart::CheckZigbeeACK() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mssleep(10000);
|
mssleep(10000);
|
||||||
|
time += 1;
|
||||||
} while (time < 150);
|
} while (time < 150);
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user