add codes

This commit is contained in:
zhangsheng 2025-05-20 17:47:29 +08:00
parent e08f3c1e7b
commit f7e27c5638
7 changed files with 61 additions and 39 deletions

View File

@ -57,7 +57,7 @@ public :
}; };
#define SAVE_COUNT 6048 #define SAVE_COUNT 6148
#define OneWeek 86400 * 7 #define OneWeek 86400 * 7

View File

@ -107,6 +107,10 @@ void SqliteDB::SqliteInit(const char *pDbName) {
if(iRet == 0){ if(iRet == 0){
CreateTable("ALTER TABLE t_sensor_info ADD COLUMN 'upgradeStatus'"); CreateTable("ALTER TABLE t_sensor_info ADD COLUMN 'upgradeStatus'");
} }
iRet = GetTableRows(" sqlite_master "," name = 'receive_wave_status' and sql LIKE '%resend%' ");
if(iRet == 0){
CreateTable("ALTER TABLE receive_wave_status ADD COLUMN 'resend'");
}
memset(sql_exec, 0, 2048); memset(sql_exec, 0, 2048);
sprintf(sql_exec,"update t_sensor_info set MeasurementID = dataNodeNo where MeasurementID IS NULL ;"); sprintf(sql_exec,"update t_sensor_info set MeasurementID = dataNodeNo where MeasurementID IS NULL ;");

View File

@ -299,7 +299,7 @@ std::string JsonData::JsonCmd_Cgi_10(Param_10 &param) {
sprintf(whereCon, "channelID like '%%%s%%' and %s <> ''", param.MeasurementID.c_str(), param.strStatic.c_str()); sprintf(whereCon, "channelID like '%%%s%%' and %s <> ''", param.MeasurementID.c_str(), param.strStatic.c_str());
} else { } else {
sprintf(whereCon, " channelID like '%%%s%%' and %s <> '' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(), param.strStatic.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); sprintf(whereCon, " channelID like '%%%s%%' and %s <> '' and timeStamp < '%s' and timeStamp > '%s' and nodeResend = 0 ", param.MeasurementID.c_str(), param.strStatic.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
} }
int rows = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon); int rows = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon);
@ -333,7 +333,7 @@ std::string JsonData::JsonCmd_Cgi_10(Param_10 &param) {
if (param.timeEnd == "") { if (param.timeEnd == "") {
sprintf(whereCon, "channelID like '%%%s%%' and %s <> '' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.strStatic.c_str(), 550, packgeNum); sprintf(whereCon, "channelID like '%%%s%%' and %s <> '' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.strStatic.c_str(), 550, packgeNum);
} else { } else {
sprintf(whereCon, "channelID like '%%%s%%' and %s <> '' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.strStatic.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum); sprintf(whereCon, "channelID like '%%%s%%' and %s <> '' and timeStamp < '%s' and timeStamp > '%s' and nodeResend = 0 order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.strStatic.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
} }
array_t vecRes; array_t vecRes;

View File

@ -908,16 +908,16 @@ std::string JsonData::JsonCmd_Cgi_62(Param_62 &param){
if(param.straxis == ""){ if(param.straxis == ""){
if (param.mMode == 1){ if (param.mMode == 1){
sprintf(whereCon, " channelID like '%s-X' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); sprintf(whereCon, " channelID like '%s-X' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null)", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
}else{ }else{
sprintf(whereCon, " data_nodeno like '%%%s%%' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); sprintf(whereCon, " data_nodeno like '%%%s%%' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null)", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
} }
} }
else{ else{
if (param.mMode == 1){ if (param.mMode == 1){
sprintf(whereCon, " channelID = '%s-X' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); sprintf(whereCon, " channelID = '%s-X' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null)", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
}else{ }else{
sprintf(whereCon, " data_nodeno = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str()); sprintf(whereCon, " data_nodeno = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null)", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
} }
} }
@ -951,15 +951,15 @@ std::string JsonData::JsonCmd_Cgi_62(Param_62 &param){
if(param.straxis == "") if(param.straxis == "")
{ {
if (param.mMode == 1){ if (param.mMode == 1){
sprintf(whereCon, " channelID like '%s-X' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum); sprintf(whereCon, " channelID like '%s-X' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null) order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
}else{ }else{
sprintf(whereCon, " data_nodeno like '%%%s%%' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum); sprintf(whereCon, " data_nodeno like '%%%s%%' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null) order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
} }
}else{ }else{
if (param.mMode == 1){ if (param.mMode == 1){
sprintf(whereCon, " channelID = '%s-X' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum); sprintf(whereCon, " channelID = '%s-X' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null) order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
}else{ }else{
sprintf(whereCon, "data_nodeno = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum); sprintf(whereCon, "data_nodeno = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null) order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
} }
} }
array_t vecRes; array_t vecRes;
@ -1104,8 +1104,8 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 &param){
scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,featureInterTime,waveInterTime,maxSensorNum); scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,featureInterTime,waveInterTime,maxSensorNum);
Json::Value jsBody; Json::Value jsBody;
char count_sql[1024] = {0}; char count_sql[1024] = {0};
int recive_feature = 0, send_feature = 0; int recive_feature = 0, send_feature = 0,resend_feature = 0;
int recive_x = 0, recive_y = 0, recive_z = 0; int recive_x = 0, recive_y = 0, recive_z = 0,resend_z = 0;
//int send_x = 0, send_y = 0, send_z = 0; //int send_x = 0, send_y = 0, send_z = 0;
for (size_t i = 0; i < nSize; i++) for (size_t i = 0; i < nSize; i++)
{ {
@ -1121,16 +1121,18 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 &param){
memset(count_sql,0,sizeof(count_sql)); memset(count_sql,0,sizeof(count_sql));
snprintf(count_sql,sizeof(count_sql), snprintf(count_sql,sizeof(count_sql),
"SELECT " "SELECT "
"COUNT(*) FILTER (WHERE channelID = '%s-X') AS recive_feature," "COUNT(*) FILTER (WHERE channelID = '%s-X' and nodeResend = 0 AS recive_feature,"
"COUNT(*) FILTER (WHERE channelID = '%s-X' and sendMsg = 1) AS send_feature " "COUNT(*) FILTER (WHERE channelID = '%s-X' and sendMsg = 1 and nodeResend = 0 ) AS send_feature "
"COUNT(*) FILTER (WHERE channelID = '%s-X' and nodeResend <> 0) AS send_feature "
"FROM ( " "FROM ( "
"SELECT * FROM %s " "SELECT * FROM %s "
"WHERE timeStamp BETWEEN '%s' AND '%s');",MeasurementID.c_str(),MeasurementID.c_str(),szTableName,param.timeStart.c_str(),param.timeEnd.c_str()); "WHERE timeStamp BETWEEN '%s' AND '%s');",MeasurementID.c_str(),MeasurementID.c_str(),MeasurementID.c_str(),szTableName,param.timeStart.c_str(),param.timeEnd.c_str());
vec_t vecResult1 = sqlite_db_ctrl::instance().GetDataSingleLine(count_sql); vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine(count_sql);
if (vecResult1.size() > 0) if (vecResult.size() > 0)
{ {
recive_feature = atoi(vecResult1[0].c_str()); recive_feature = atoi(vecResult[0].c_str());
send_feature = atoi(vecResult1[1].c_str()); send_feature = atoi(vecResult[1].c_str());
resend_feature = atoi(vecResult[2].c_str());
} }
iTem.append(MeasurementID); iTem.append(MeasurementID);
@ -1140,15 +1142,17 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 &param){
"COUNT(*) FILTER (WHERE data_nodeno = '%s-X') AS recive_x," "COUNT(*) FILTER (WHERE data_nodeno = '%s-X') AS recive_x,"
"COUNT(*) FILTER (WHERE data_nodeno = '%s-Y') AS recive_y," "COUNT(*) FILTER (WHERE data_nodeno = '%s-Y') AS recive_y,"
"COUNT(*) FILTER (WHERE data_nodeno = '%s-Z') AS recive_z " "COUNT(*) FILTER (WHERE data_nodeno = '%s-Z') AS recive_z "
"COUNT(*) FILTER (WHERE data_nodeno = '%s-Z' and resend is not null) AS resend_z "
"FROM ( " "FROM ( "
"SELECT * FROM receive_wave_status " "SELECT * FROM receive_wave_status "
"WHERE error_code = 1 and timeStamp BETWEEN '%s' AND '%s');",MeasurementID.c_str(),MeasurementID.c_str(),MeasurementID.c_str(),param.timeStart.c_str(),param.timeEnd.c_str()); "WHERE error_code = 1 and timeStamp BETWEEN '%s' AND '%s');",MeasurementID.c_str(),MeasurementID.c_str(),MeasurementID.c_str(),MeasurementID.c_str(),param.timeStart.c_str(),param.timeEnd.c_str());
vec_t vecResult2 = sqlite_db_ctrl::instance().GetDataSingleLine(count_sql); vec_t vecResult2 = sqlite_db_ctrl::instance().GetDataSingleLine(count_sql);
if (vecResult2.size() > 0) if (vecResult2.size() > 0)
{ {
recive_x = atoi(vecResult2[0].c_str()); recive_x = atoi(vecResult2[0].c_str());
recive_y = atoi(vecResult2[1].c_str()); recive_y = atoi(vecResult2[1].c_str());
recive_z = atoi(vecResult2[2].c_str()); recive_z = atoi(vecResult2[2].c_str());
resend_z = atoi(vecResult2[3].c_str());
iTem.append((float(recive_feature)/(interval/featureInterVal))); iTem.append((float(recive_feature)/(interval/featureInterVal)));
iTem.append(recive_feature); iTem.append(recive_feature);
iTem.append((float( recive_x)/(interval/waveInterVal))); iTem.append((float( recive_x)/(interval/waveInterVal)));
@ -1157,8 +1161,8 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 &param){
iTem.append(recive_y); iTem.append(recive_y);
iTem.append((float(recive_z)/(interval/waveInterVal))); iTem.append((float(recive_z)/(interval/waveInterVal)));
iTem.append(recive_z); iTem.append(recive_z);
}
}
// memset(count_sql,0,sizeof(count_sql)); // memset(count_sql,0,sizeof(count_sql));
// snprintf(count_sql,sizeof(count_sql), // snprintf(count_sql,sizeof(count_sql),
// "SELECT " // "SELECT "
@ -1191,6 +1195,8 @@ std::string JsonData::JsonCmd_Cgi_65(Param_65 &param){
iTem.append(0); iTem.append(0);
iTem.append(0); iTem.append(0);
iTem.append(0); iTem.append(0);
iTem.append(resend_feature);
iTem.append(resend_z);
std::vector<std::string> vRssi; std::vector<std::string> vRssi;
boost::split(vRssi, vetRes[i][2], boost::is_any_of(","), boost::token_compress_on); boost::split(vRssi, vetRes[i][2], boost::is_any_of(","), boost::token_compress_on);
if (vRssi.size() > 0 ){ if (vRssi.size() > 0 ){

View File

@ -449,7 +449,7 @@ bool SensorScheduler::MissedWave(uint16_t short_addr) {
return false; return false;
} }
void SensorScheduler::WaveSuccess(uint16_t short_addr) { int SensorScheduler::WaveSuccess(uint16_t short_addr) {
zlog_warn(zct, "[WaveSuccess][%x]", short_addr); zlog_warn(zct, "[WaveSuccess][%x]", short_addr);
success_set_.insert(short_addr); success_set_.insert(short_addr);
patch_set_.erase(short_addr); patch_set_.erase(short_addr);
@ -457,12 +457,13 @@ void SensorScheduler::WaveSuccess(uint16_t short_addr) {
if (iter != failure_map_.end()) { if (iter != failure_map_.end()) {
zlog_warn(zct, "[WaveSuccess][%x] try %d times success", short_addr, 4 - iter->second); zlog_warn(zct, "[WaveSuccess][%x] try %d times success", short_addr, 4 - iter->second);
failure_map_.erase(short_addr); failure_map_.erase(short_addr);
return; return 4 - iter->second;
} }
return; return 0;
} }
void SensorScheduler::ClearFailureSuccessMap() { void SensorScheduler::ClearFailureSuccessMap() {
zlog_warn(zct, "[ClearFailureSuccessMap]");
failure_map_.clear(); failure_map_.clear();
success_set_.clear(); success_set_.clear();
patch_set_.clear(); patch_set_.clear();

View File

@ -43,7 +43,7 @@ public:
// int GetNextDuration(int short_addr); // int GetNextDuration(int short_addr);
int WaveError(uint16_t short_addr); int WaveError(uint16_t short_addr);
void WaveSuccess(uint16_t short_addr); int WaveSuccess(uint16_t short_addr);
long GetBaseTimestamp(int id); long GetBaseTimestamp(int id);
long CalcNextTimestamp(int id, uint16_t short_addr, int& next_task_id); long CalcNextTimestamp(int id, uint16_t short_addr, int& next_task_id);

View File

@ -47,8 +47,10 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
char whereCon[1024] = {0}; char whereCon[1024] = {0};
char updateSql[1024] = {0}; char updateSql[1024] = {0};
char buf[20] = {0x00}; char buf[20] = {0x00};
int nodeResend = 0, timing = 0; int timing = 0;
long staticIndex = 0; long staticIndex = 0;
uint8_t nodeResend = pData[6] & 0xFF;
zlog_info(zct, "nodeResend = %d", nodeResend);
sprintf(buf, "%02x%02x", pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]); sprintf(buf, "%02x%02x", pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]);
if (flag == 1) { if (flag == 1) {
zlog_info(zct, "DealDataNodeFeature %02x%02x, %d", pRecvData->ShortAddr[0], pRecvData->ShortAddr[1], flag); zlog_info(zct, "DealDataNodeFeature %02x%02x, %d", pRecvData->ShortAddr[0], pRecvData->ShortAddr[1], flag);
@ -92,7 +94,6 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
strTimetamp = nowTimetamp; strTimetamp = nowTimetamp;
int iTemp = 0; int iTemp = 0;
// unsigned char highbit = 0;
unsigned int lowbit = 0; unsigned int lowbit = 0;
float n = 0; float n = 0;
@ -160,7 +161,6 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
WriteToUart((const char*)send_data, 100); WriteToUart((const char*)send_data, 100);
mssleep(50000); mssleep(50000);
WriteToUart((const char*)send_data, 100); WriteToUart((const char*)send_data, 100);
return -3;
} }
memset(whereCon, 0x00, sizeof(whereCon)); memset(whereCon, 0x00, sizeof(whereCon));
sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str()); sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
@ -311,7 +311,7 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %ld,nodeResend = %d ", Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %ld,nodeResend = %d ",
dataDymX.DiagnosisPk, dataDymX.IntegratPk, dataDymX.IntegratRMS, dataDymX.RmsValues, dataDymX.EnvelopEnergy, dataDymX.Amp1, dataDymX.Amp2, dataDymX.Amp3, dataDymX.Amp4, dataDymX.Amp5, dataDymX.Phase1, dataDymX.Phase2, dataDymX.Phase3, dataDymX.Phase4, dataDymX.DiagnosisPk, dataDymX.IntegratPk, dataDymX.IntegratRMS, dataDymX.RmsValues, dataDymX.EnvelopEnergy, dataDymX.Amp1, dataDymX.Amp2, dataDymX.Amp3, dataDymX.Amp4, dataDymX.Amp5, dataDymX.Phase1, dataDymX.Phase2, dataDymX.Phase3, dataDymX.Phase4,
nowTimetamp.c_str(), staticIndex, nodeResend); nowTimetamp.c_str(), staticIndex, nodeResend);
if ((Count * 3 < SAVE_COUNT && lTime < OneWeek) || strTime.size() == 0) { // 1 week if ((Count * 3 < SAVE_COUNT && lTime < OneWeek) || strTime.size() == 0 || nodeResend != 0) { // 1 week
char insertSql[1024] = {0}; char insertSql[1024] = {0};
memset(insertSql, 0x00, sizeof(insertSql)); memset(insertSql, 0x00, sizeof(insertSql));
sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%ld,'%s','1',%d", strMeasurementID.c_str(), (strMeasurementID + "-X").c_str(), dataDymX.DiagnosisPk, dataDymX.IntegratPk, dataDymX.IntegratRMS, dataDymX.RmsValues, sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%ld,'%s','1',%d", strMeasurementID.c_str(), (strMeasurementID + "-X").c_str(), dataDymX.DiagnosisPk, dataDymX.IntegratPk, dataDymX.IntegratRMS, dataDymX.RmsValues,
@ -324,7 +324,7 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
sqlite_db_ctrl::instance().UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon); sqlite_db_ctrl::instance().UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon);
} else { } else {
memset(whereCon, 0x00, sizeof(whereCon)); memset(whereCon, 0x00, sizeof(whereCon));
sprintf(whereCon, "channelID='%s' and timeStamp = '%s'", (strMeasurementID + "-X").c_str(), strTime.c_str()); sprintf(whereCon, "channelID='%s' and timeStamp = '%s' and nodeResend = 0", (strMeasurementID + "-X").c_str(), strTime.c_str());
sqlite_db_ctrl::instance().UpdateTableData(szTableName, updateSql, whereCon); sqlite_db_ctrl::instance().UpdateTableData(szTableName, updateSql, whereCon);
memset(whereCon, 0x00, sizeof(whereCon)); memset(whereCon, 0x00, sizeof(whereCon));
@ -417,7 +417,7 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
sqlite_db_ctrl::instance().UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon); sqlite_db_ctrl::instance().UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon);
} else { } else {
memset(whereCon, 0x00, sizeof(whereCon)); memset(whereCon, 0x00, sizeof(whereCon));
sprintf(whereCon, "channelID='%s' and timeStamp = '%s'", (strMeasurementID + "-Y").c_str(), strTime.c_str()); sprintf(whereCon, "channelID='%s' and timeStamp = '%s' and nodeResend = 0", (strMeasurementID + "-Y").c_str(), strTime.c_str());
sqlite_db_ctrl::instance().UpdateTableData(szTableName, updateSql, whereCon); sqlite_db_ctrl::instance().UpdateTableData(szTableName, updateSql, whereCon);
memset(whereCon, 0x00, sizeof(whereCon)); memset(whereCon, 0x00, sizeof(whereCon));
sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-Y").c_str()); sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-Y").c_str());
@ -499,7 +499,7 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %ld,nodeResend = %d ", Amp1='%f',Amp2='%f',Amp3='%f',Amp4='%f',Amp5='%f',Phase1='%f',Phase2='%f',Phase3='%f',Phase4='%f',timeStamp='%s',StaticIndex = %ld,nodeResend = %d ",
dataDymZ.DiagnosisPk, dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues, dataDymZ.EnvelopEnergy, dataDymZ.Amp1, dataDymZ.Amp2, dataDymZ.Amp3, dataDymZ.Amp4, dataDymZ.Amp5, dataDymZ.Phase1, dataDymZ.Phase2, dataDymZ.Phase3, dataDymZ.Phase4, dataDymZ.DiagnosisPk, dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues, dataDymZ.EnvelopEnergy, dataDymZ.Amp1, dataDymZ.Amp2, dataDymZ.Amp3, dataDymZ.Amp4, dataDymZ.Amp5, dataDymZ.Phase1, dataDymZ.Phase2, dataDymZ.Phase3, dataDymZ.Phase4,
nowTimetamp.c_str(), staticIndex, nodeResend); nowTimetamp.c_str(), staticIndex, nodeResend);
if (/*0 == sqlite_db_ctrl::instance().GetTableRows(T_DATA_INFO(TNAME), whereCon)*/ Count * 3 < SAVE_COUNT && (lTime < OneWeek || strTime.size() == 0)) { if (/*0 == sqlite_db_ctrl::instance().GetTableRows(T_DATA_INFO(TNAME), whereCon)*/ (Count * 3 < SAVE_COUNT && lTime < OneWeek) || strTime.size() == 0 ) {
char insertSql[1024] = {0}; char insertSql[1024] = {0};
memset(insertSql, 0x00, sizeof(insertSql)); memset(insertSql, 0x00, sizeof(insertSql));
sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%ld,'%s','1',%d", strMeasurementID.c_str(), (strMeasurementID + "-Z").c_str(), dataDymZ.DiagnosisPk, dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues, sprintf(insertSql, "'%s','%s','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f','%f',%ld,'%s','1',%d", strMeasurementID.c_str(), (strMeasurementID + "-Z").c_str(), dataDymZ.DiagnosisPk, dataDymZ.IntegratPk, dataDymZ.IntegratRMS, dataDymZ.RmsValues,
@ -512,7 +512,7 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
sqlite_db_ctrl::instance().UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon); sqlite_db_ctrl::instance().UpdateTableData(T_DATA_INFO(TNAME), updateSql, whereCon);
} else { } else {
memset(whereCon, 0x00, sizeof(whereCon)); memset(whereCon, 0x00, sizeof(whereCon));
sprintf(whereCon, "channelID='%s' and timeStamp = '%s'", (strMeasurementID + "-Z").c_str(), strTime.c_str()); sprintf(whereCon, "channelID='%s' and timeStamp = '%s' and nodeResend = 0", (strMeasurementID + "-Z").c_str(), strTime.c_str());
sqlite_db_ctrl::instance().UpdateTableData(szTableName, updateSql, whereCon); sqlite_db_ctrl::instance().UpdateTableData(szTableName, updateSql, whereCon);
memset(whereCon, 0x00, sizeof(whereCon)); memset(whereCon, 0x00, sizeof(whereCon));
sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-Z").c_str()); sprintf(whereCon, "channelID='%s' ", (strMeasurementID + "-Z").c_str());
@ -605,6 +605,10 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
if (flag == 1) { if (flag == 1) {
zlog_info(zct, "DealDataNodeFeature end %02x%02x", pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]); zlog_info(zct, "DealDataNodeFeature end %02x%02x", pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]);
} }
memset(whereCon, 0x00, sizeof(whereCon));
sprintf(whereCon, " timestamp < '%ld' ", atol(localtimestamp) - 2592000); //删除1个月前的数据
sqlite_db_ctrl::instance().DeleteTableData(szTableNameStatic, whereCon);
sqlite_db_ctrl::instance().DeleteTableData(szTableNameData, whereCon);
return 0; return 0;
} }
@ -843,17 +847,17 @@ void Uart::DealWave() {
memset(whereCon, 0x00, sizeof(whereCon)); memset(whereCon, 0x00, sizeof(whereCon));
if (vecDataX.size() > 0) if (vecDataX.size() > 0)
{ {
sprintf(insertSql, "'%s-X','%02x%02x','%s',0,'1','%s' ", strMeasurementID.c_str(),(wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp,""); sprintf(insertSql, "'%s-X','%02x%02x','%s',0,'1','%s','' ", strMeasurementID.c_str(),(wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp,"");
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql); sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
} }
if (vecDataY.size() > 0) if (vecDataY.size() > 0)
{ {
sprintf(insertSql, "'%s-Y','%02x%02x','%s',0,'1','%s' ", strMeasurementID.c_str(),(wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp,""); sprintf(insertSql, "'%s-Y','%02x%02x','%s',0,'1','%s','' ", strMeasurementID.c_str(),(wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp,"");
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql); sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
} }
if (vecDataZ.size() > 0) if (vecDataZ.size() > 0)
{ {
sprintf(insertSql, "'%s-Z','%02x%02x','%s',0,'1','%s' ", strMeasurementID.c_str(),(wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp,""); sprintf(insertSql, "'%s-Z','%02x%02x','%s',0,'1','%s','' ", strMeasurementID.c_str(),(wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp,"");
sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql); sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql);
} }
zlog_warn(zct,"waveCountX = %d, waveCountY = %d, waveCountZ = %d", vecDataX.size() , vecDataY.size(), vecDataZ.size()); zlog_warn(zct,"waveCountX = %d, waveCountY = %d, waveCountZ = %d", vecDataX.size() , vecDataY.size(), vecDataZ.size());
@ -867,7 +871,14 @@ void Uart::DealWave() {
(vecDataY.size() > 0 && g_mapCompress[strShortAddr].CountY > 0) || (vecDataY.size() > 0 && g_mapCompress[strShortAddr].CountY > 0) ||
(vecDataZ.size() > 0 && g_mapCompress[strShortAddr].CountZ > 0)) (vecDataZ.size() > 0 && g_mapCompress[strShortAddr].CountZ > 0))
{ {
scheduler::instance().WaveSuccess(wave_shortAddr); int iRet = scheduler::instance().WaveSuccess(wave_shortAddr);
if (iRet != 0) {
memset(whereCon, 0x00, sizeof(whereCon));
char updateSql[1024] = { 0 };
sprintf(updateSql, "resend = '%d'", iRet);
sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp);
sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon);
}
} }
if (g_mapCompress[strShortAddr].CountX <= 0 && g_mapCompress[strShortAddr].CountY <= 0 && g_mapCompress[strShortAddr].CountZ <= 0) if (g_mapCompress[strShortAddr].CountX <= 0 && g_mapCompress[strShortAddr].CountY <= 0 && g_mapCompress[strShortAddr].CountZ <= 0)