将历史电池电量数据移动到历史表,传感器传递波形时不解析特征值
This commit is contained in:
parent
509e3dfaa4
commit
408d0c7c42
@ -187,7 +187,7 @@ void SqliteDB::SqliteInit(const char *pDbName, bool isDB2)
|
||||
}
|
||||
|
||||
memset(sql_exec, 0, 2048);
|
||||
sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s,%s);",
|
||||
sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s,%s);",
|
||||
T_BATTERY_INFO(TNAME),
|
||||
T_BATTERY_INFO(DATANODENO),
|
||||
T_BATTERY_INFO(DIP),
|
||||
@ -199,6 +199,20 @@ void SqliteDB::SqliteInit(const char *pDbName, bool isDB2)
|
||||
T_BATTERY_INFO(BATTERYREMAIN),
|
||||
T_BATTERY_INFO(TIMESTAMP));
|
||||
CreateTable(sql_exec, isDB2);
|
||||
|
||||
memset(sql_exec, 0, 2048);
|
||||
sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s,%s);",
|
||||
"t_battery_history",
|
||||
T_BATTERY_INFO(DATANODENO),
|
||||
T_BATTERY_INFO(DIP),
|
||||
T_BATTERY_INFO(TEMBOT),
|
||||
T_BATTERY_INFO(NODEWORKTIME),
|
||||
T_BATTERY_INFO(NODESENDTIME),
|
||||
T_BATTERY_INFO(BATTERYVOLTAGE),
|
||||
T_BATTERY_INFO(BATTERYUSAGE),
|
||||
T_BATTERY_INFO(BATTERYREMAIN),
|
||||
T_BATTERY_INFO(TIMESTAMP));
|
||||
CreateTable(sql_exec, isDB2);
|
||||
|
||||
/*memset(sql_exec, 0, 2048);
|
||||
sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s integer,%s integer ,%s integer ,%s integer,%s integer);",
|
||||
@ -363,7 +377,17 @@ int SqliteDB::CreateTable(const char *sql, bool isDB2)
|
||||
}
|
||||
return iRet;
|
||||
}
|
||||
|
||||
int SqliteDB::ExeSql(const char *sql, bool isDB2)
|
||||
{
|
||||
print_light_green("%s\n", sql);
|
||||
char *msg;
|
||||
int iRet = sqlite3_exec(GetDbHandle(isDB2), sql, 0, 0, &msg);
|
||||
if (iRet != SQLITE_OK) {
|
||||
print_error("sqlite3 error: code=%d msg=%s\n", iRet, msg);
|
||||
sqlite3_free(msg);
|
||||
}
|
||||
return iRet;
|
||||
}
|
||||
int SqliteDB::GetTableColumnCount(const char *tablename, bool isDB2)
|
||||
{
|
||||
std::string strSql = "select * from ";
|
||||
@ -931,6 +955,12 @@ int SqliteDB::CalculateBattery()
|
||||
memset(whereCon,0x00,sizeof(whereCon));
|
||||
memset(updateSql,0x00,sizeof(updateSql));
|
||||
|
||||
char insertSql[1024]={0x00},deleteSql[1024]={0x00};
|
||||
sprintf(insertSql,"insert into t_battery_history select * from t_battery_info where timeStamp < '%s' and dataNodeNo = '%s'",strtimeStamp.c_str(),vecRes[i][0].c_str());
|
||||
ExeSql(insertSql);
|
||||
|
||||
sprintf(deleteSql,"delete from t_battery_info where timeStamp < '%s' and dataNodeNo = '%s'",strtimeStamp.c_str(),vecRes[i][0].c_str());
|
||||
ExeSql(deleteSql);
|
||||
|
||||
sprintf(whereCon,"dataNodeNo = '%s' ",vecRes[i][0].c_str());
|
||||
if(startCapacity > 0){
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
int TransRollback();
|
||||
int TransCommit();
|
||||
int CreateTable(const char *sql, bool isDB2=false);
|
||||
int ExeSql(const char *sql, bool isDB2=false);
|
||||
int GetTableColumnCount(const char *tablename, bool isDB2 = false);
|
||||
int GetTableRows(const char *tablename, const char *whereCon);
|
||||
int AlterTable(const char *tablename, const char *column, bool isAdd = true, bool isDB2=false);
|
||||
|
@ -307,7 +307,7 @@ void CheckThread()
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
char whereCon[1024] = {0};
|
||||
sprintf(whereCon," timestamp < '%ld' ",atol(localtimestamp) - 15638400); //删除半年前的数据
|
||||
sql_ctl->DeleteTableData(T_BATTERY_INFO(TNAME),whereCon);
|
||||
sql_ctl->DeleteTableData(" t_battery_history ",whereCon);
|
||||
/*staticData = 0;
|
||||
Json::Value jsHeart;
|
||||
Json::FastWriter fw;
|
||||
|
@ -1964,8 +1964,9 @@ void Uart::DealDataNodeFeature(const char *pData, int flag)
|
||||
char buf[20] = {0x00};
|
||||
int nodeResend = 0;
|
||||
sprintf(buf, "%02x%02x", pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]);
|
||||
LOG_INFO("DealDataNodeFeature %02x%02x\n",pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]);
|
||||
|
||||
LOG_INFO("DealDataNodeFeature %02x%02x,isWave \n",pRecvData->ShortAddr[0], pRecvData->ShortAddr[1],flag);
|
||||
if (bSendTimeStamp)//波形处理中
|
||||
return;
|
||||
std::string strShortAddr = std::string(buf);
|
||||
print_info("zigbeeShortAddr='%s'\n", strShortAddr.c_str());
|
||||
char getLongAddr_sql[32] = { 0 };
|
||||
@ -3432,7 +3433,8 @@ void Uart::DealDataNodeFeature(const char *pData, int flag)
|
||||
}
|
||||
bZigbeeSinal = false;
|
||||
}
|
||||
LOG_INFO("DealDataNodeFeature end\n");
|
||||
|
||||
LOG_INFO("DealDataNodeFeature end %02x%02x,isWave \n",pRecvData->ShortAddr[0], pRecvData->ShortAddr[1],flag);
|
||||
}
|
||||
|
||||
void Uart::DealDataNodeWave(const char *pData)
|
||||
|
Loading…
x
Reference in New Issue
Block a user