|
@@ -4675,13 +4675,14 @@ static int sql_requery(sqlite3 *db, int tab_id, time_t from, time_t to, void *da
|
|
|
char *p,temp[1024];
|
|
char *p,temp[1024];
|
|
|
char time_s[64],time_e[64];
|
|
char time_s[64],time_e[64];
|
|
|
sqlite3_stmt *stmt=NULL;
|
|
sqlite3_stmt *stmt=NULL;
|
|
|
- GlobalPowerInfo *pwrInfo;
|
|
|
|
|
|
|
+ GlobalPowerInfo *pwr=NULL;
|
|
|
|
|
+ GlobalTreeACManager *pwr3=NULL;
|
|
|
|
|
|
|
|
get_time_str(time_s, sizeof(time_s), from);
|
|
get_time_str(time_s, sizeof(time_s), from);
|
|
|
get_time_str(time_e, sizeof(time_e), to);
|
|
get_time_str(time_e, sizeof(time_e), to);
|
|
|
|
|
|
|
|
if(tab_id==TAB_ID_POWER_INFO) {
|
|
if(tab_id==TAB_ID_POWER_INFO) {
|
|
|
- snprintf(temp, sizeof(temp), "SELECT * FROM %s WHERE (product_samp_time BETWEEN '%s' AND '%s';", tabNamePool[tab_id], time_s, time_e);
|
|
|
|
|
|
|
+ snprintf(temp, sizeof(temp), "SELECT * FROM %s WHERE product_samp_time BETWEEN '%s' AND '%s';", tabNamePool[tab_id], time_s, time_e);
|
|
|
|
|
|
|
|
r = sqlite3_prepare_v2(db, temp, -1, &stmt, 0);
|
|
r = sqlite3_prepare_v2(db, temp, -1, &stmt, 0);
|
|
|
if (r != SQLITE_OK) {
|
|
if (r != SQLITE_OK) {
|
|
@@ -4690,31 +4691,15 @@ static int sql_requery(sqlite3 *db, int tab_id, time_t from, time_t to, void *da
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
|
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
|
|
- //ser[idx].id = sqlite3_column_int(stmt, 0);
|
|
|
|
|
- //ser[idx].mode = sqlite3_column_int(stmt, 1);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 2);
|
|
|
|
|
- //if(p) strcpy(ser[idx].name, p);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 3);
|
|
|
|
|
- //if(p) strcpy(ser[idx].server, p);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 4);
|
|
|
|
|
- // if(p) strcpy(ser[idx].port, p);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 5);
|
|
|
|
|
- //if(p) strcpy(ser[idx].cid, p);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 6);
|
|
|
|
|
- //if(p) strcpy(ser[idx].user, p);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 7);
|
|
|
|
|
- //if(p) strcpy(ser[idx].password, p);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 8);
|
|
|
|
|
- //if(p) strcpy(ser[idx].cert, p);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ pwr->product_id = sqlite3_column_int(stmt, 1);
|
|
|
|
|
+ pwr->product_ch_id = sqlite3_column_int(stmt, 2);
|
|
|
|
|
+ pwr->product_status = sqlite3_column_int(stmt, 3);
|
|
|
|
|
+ pwr->_power_info.voltage = sqlite3_column_double(stmt, 4);
|
|
|
|
|
+ pwr->_power_info.current = sqlite3_column_double(stmt, 5);
|
|
|
|
|
+ pwr->_power_info.power = sqlite3_column_double(stmt, 6);
|
|
|
|
|
+ pwr->_power_info.freq = sqlite3_column_double(stmt, 7);
|
|
|
|
|
+ pwr->_power_info.consumption = sqlite3_column_double(stmt, 8);
|
|
|
|
|
+ pwr->_power_info.factor = sqlite3_column_double(stmt, 9);
|
|
|
}
|
|
}
|
|
|
sqlite3_finalize(stmt);
|
|
sqlite3_finalize(stmt);
|
|
|
|
|
|
|
@@ -4727,45 +4712,19 @@ static int sql_requery(sqlite3 *db, int tab_id, time_t from, time_t to, void *da
|
|
|
log_e("___mqtt_load, sqlite3_prepare_v2 failed\n");
|
|
log_e("___mqtt_load, sqlite3_prepare_v2 failed\n");
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-#if 0
|
|
|
|
|
- strcpy(_globalPowerInfoTemp->samp_time,pResult[i*ncolumn+0]);//i=0 10
|
|
|
|
|
- _globalPowerInfoTemp->product_id = atoi(pResult[i*ncolumn+1]);
|
|
|
|
|
- _globalPowerInfoTemp->product_ch_id = atoi(pResult[i*ncolumn+2]);
|
|
|
|
|
- _globalPowerInfoTemp->product_status = atoi(pResult[i*ncolumn+3]);
|
|
|
|
|
- _globalPowerInfoTemp->_power_info.voltage = atof(pResult[i*ncolumn+4]);
|
|
|
|
|
- _globalPowerInfoTemp->_power_info.current = atof(pResult[i*ncolumn+5]);
|
|
|
|
|
- _globalPowerInfoTemp->_power_info.power = atof(pResult[i*ncolumn+6]);
|
|
|
|
|
- _globalPowerInfoTemp->_power_info.freq = atof(pResult[i*ncolumn+7]);
|
|
|
|
|
- _globalPowerInfoTemp->_power_info.consumption = atof(pResult[i*ncolumn+8]);
|
|
|
|
|
- _globalPowerInfoTemp->_power_info.factor = atof(pResult[i*ncolumn+9]);
|
|
|
|
|
-#endif
|
|
|
|
|
- while (sqlite3_step(stmt) == SQLITE_ROW) {
|
|
|
|
|
- //ser[idx].id = sqlite3_column_int(stmt, 0);
|
|
|
|
|
- //ser[idx].mode = sqlite3_column_int(stmt, 1);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 2);
|
|
|
|
|
- //if(p) strcpy(ser[idx].name, p);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 3);
|
|
|
|
|
- //if(p) strcpy(ser[idx].server, p);
|
|
|
|
|
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 4);
|
|
|
|
|
- // if(p) strcpy(ser[idx].port, p);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 5);
|
|
|
|
|
- //if(p) strcpy(ser[idx].cid, p);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 6);
|
|
|
|
|
- //if(p) strcpy(ser[idx].user, p);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 7);
|
|
|
|
|
- //if(p) strcpy(ser[idx].password, p);
|
|
|
|
|
-
|
|
|
|
|
- p = (char*)sqlite3_column_text(stmt, 8);
|
|
|
|
|
- //if(p) strcpy(ser[idx].cert, p);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
|
|
|
|
|
+ /*
|
|
|
|
|
+ pwr3->product_id = sqlite3_column_int(stmt, 1);
|
|
|
|
|
+ pwr3->product_ph_type = sqlite3_column_int(stmt, 2);
|
|
|
|
|
+ pwr3->product_ch_id = sqlite3_column_int(stmt, 3);
|
|
|
|
|
+ pwr3->_PowerInfo.voltage = sqlite3_column_double(stmt, 4);
|
|
|
|
|
+ pwr3->_PowerInfo.current = sqlite3_column_double(stmt, 5);
|
|
|
|
|
+ pwr3->_PowerInfo.power = sqlite3_column_double(stmt, 6);
|
|
|
|
|
+ pwr3->_PowerInfo.freq = sqlite3_column_double(stmt, 7);
|
|
|
|
|
+ pwr3->_PowerInfo.consumption = sqlite3_column_double(stmt, 8);
|
|
|
|
|
+ pwr3->_PowerInfo.factor = sqlite3_column_double(stmt, 9);
|
|
|
|
|
+ */
|
|
|
}
|
|
}
|
|
|
sqlite3_finalize(stmt);
|
|
sqlite3_finalize(stmt);
|
|
|
}
|
|
}
|