|
|
@@ -4703,7 +4703,7 @@ static int db_exec(sqlite3 *db, int tab_id, int io_type, time_t from, time_t to,
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- while (sqlite3_step(stmt) == SQLITE_ROW) {
|
|
|
+ while (sqlite3_step(stmt) == SQLITE_ROW) { //column start from 0
|
|
|
tmp.product_id = sqlite3_column_int(stmt, 1);
|
|
|
tmp.product_ch_id = sqlite3_column_int(stmt, 2);
|
|
|
tmp.product_status = sqlite3_column_int(stmt, 3);
|
|
|
@@ -4713,6 +4713,7 @@ static int db_exec(sqlite3 *db, int tab_id, int io_type, time_t from, time_t to,
|
|
|
tmp._power_info.freq = sqlite3_column_double(stmt, 7);
|
|
|
tmp._power_info.consumption = sqlite3_column_double(stmt, 8);
|
|
|
tmp._power_info.factor = sqlite3_column_double(stmt, 9);
|
|
|
+ strcpy(tmp.samp_time, (char*)sqlite3_column_text(stmt, 0));
|
|
|
|
|
|
xlist_append(l, tab_id, &tmp, sizeof(tmp));
|
|
|
}
|
|
|
@@ -4724,14 +4725,14 @@ static int db_exec(sqlite3 *db, int tab_id, int io_type, time_t from, time_t to,
|
|
|
{
|
|
|
GlobalTreeACManager tmp;
|
|
|
|
|
|
- snprintf(temp, sizeof(temp), "SELECT * FROM %s WHERE (product_ph_samp_time BETWEEN '%s' AND '%s') ORDER BY product_index DESC;", tabNamePool[tab_id], time_s, time_e);
|
|
|
+ snprintf(temp, sizeof(temp), "SELECT * FROM %s WHERE (product_ph_samp_time BETWEEN '%s' AND '%s') ORDER BY product_index ASC;", tabNamePool[tab_id], time_s, time_e);
|
|
|
r = sqlite3_prepare_v2(db, temp, -1, &stmt, 0);
|
|
|
if (r != SQLITE_OK) {
|
|
|
log_e("___db_requery TAB_ID_POWER3_INFO, sqlite3_prepare_v2 failed\n");
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- while (sqlite3_step(stmt) == SQLITE_ROW) {
|
|
|
+ while (sqlite3_step(stmt)==SQLITE_ROW) {
|
|
|
tmp.product_id = sqlite3_column_int(stmt, 1);
|
|
|
tmp.product_ph_type = sqlite3_column_int(stmt, 2);
|
|
|
tmp.product_ch_id = sqlite3_column_int(stmt, 3);
|
|
|
@@ -4741,6 +4742,7 @@ static int db_exec(sqlite3 *db, int tab_id, int io_type, time_t from, time_t to,
|
|
|
tmp._PowerInfo.freq = sqlite3_column_double(stmt, 7);
|
|
|
tmp._PowerInfo.consumption = sqlite3_column_double(stmt, 8);
|
|
|
tmp._PowerInfo.factor = sqlite3_column_double(stmt, 9);
|
|
|
+ strcpy(tmp.samp_time, (char*)sqlite3_column_text(stmt, 10));
|
|
|
|
|
|
xlist_append(l, tab_id, &tmp, sizeof(tmp));
|
|
|
}
|
|
|
@@ -5122,8 +5124,6 @@ int dev_serv_xport(int io_type, char *path)
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
sprintf(path, "/tmp/serv.ini");
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -5158,6 +5158,15 @@ typedef struct {
|
|
|
FILE *fp;
|
|
|
int id;
|
|
|
}pwr_arg_t;
|
|
|
+static void replace_chr(char *buf, char a, char b)
|
|
|
+{
|
|
|
+ while(*buf) {
|
|
|
+ if((*buf)==a) {
|
|
|
+ *buf = b;
|
|
|
+ }
|
|
|
+ buf++;
|
|
|
+ }
|
|
|
+}
|
|
|
static int pwr_iterator_fn(handle_t l, node_t *node, node_t *xd, void *arg, int *act)
|
|
|
{
|
|
|
pwr_arg_t *parg=(pwr_arg_t*)arg;
|
|
|
@@ -5173,6 +5182,8 @@ static int pwr_iterator_fn(handle_t l, node_t *node, node_t *xd, void *arg, int
|
|
|
fprintf(parg->fp, "%0.2f,", tmp->_power_info.freq);
|
|
|
fprintf(parg->fp, "%0.2f,", tmp->_power_info.consumption);
|
|
|
fprintf(parg->fp, "%0.2f,", tmp->_power_info.factor);
|
|
|
+
|
|
|
+ replace_chr(tmp->samp_time, '-', '.');
|
|
|
fprintf(parg->fp, "%s,", tmp->samp_time);
|
|
|
fprintf(parg->fp, "\n");
|
|
|
parg->id++;
|
|
|
@@ -5189,6 +5200,8 @@ static int pwr_iterator_fn(handle_t l, node_t *node, node_t *xd, void *arg, int
|
|
|
fprintf(parg->fp, "%0.2f,", tmp->_PowerInfo.freq);
|
|
|
fprintf(parg->fp, "%0.2f,", tmp->_PowerInfo.consumption);
|
|
|
fprintf(parg->fp, "%0.2f,", tmp->_PowerInfo.factor);
|
|
|
+
|
|
|
+ replace_chr(tmp->samp_time, '-', '.');
|
|
|
fprintf(parg->fp, "%s,", tmp->samp_time);
|
|
|
fprintf(parg->fp, "\n");
|
|
|
parg->id++;
|
|
|
@@ -5222,8 +5235,7 @@ int dev_power_xport(int type, time_t from, time_t to, char *path)
|
|
|
fprintf(fp, "id,product_id,product_ph_type,product_ch_id,voltage,current,power,freq,consumption,factor,samp_time\n");
|
|
|
}
|
|
|
|
|
|
- arg.fp = fp;
|
|
|
- arg.id = 1;
|
|
|
+ arg.fp = fp; arg.id = 1;
|
|
|
xlist_iterator(l, NULL, pwr_iterator_fn, &arg);
|
|
|
fclose(fp);
|
|
|
r = 0;
|