|
@@ -103,7 +103,7 @@ static int save_to_csv(char *path, status_data_t *data, int flag)
|
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
if(i==0) fprintf(fp, "total voltage value,");
|
|
if(i==0) fprintf(fp, "total voltage value,");
|
|
|
fprintf(fp, "%.8f,", info->_total_voltage.ydata[i]);
|
|
fprintf(fp, "%.8f,", info->_total_voltage.ydata[i]);
|
|
|
- } fprintf(fp, "\n");
|
|
|
|
|
|
|
+ } fprintf(fp, "\n\n");
|
|
|
|
|
|
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
if(i==0) fprintf(fp, "total current time,");
|
|
if(i==0) fprintf(fp, "total current time,");
|
|
@@ -112,16 +112,16 @@ static int save_to_csv(char *path, status_data_t *data, int flag)
|
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
if(i==0) fprintf(fp, "total current value,");
|
|
if(i==0) fprintf(fp, "total current value,");
|
|
|
fprintf(fp, "%.8f,", info->_total_current.ydata[i]);
|
|
fprintf(fp, "%.8f,", info->_total_current.ydata[i]);
|
|
|
- } fprintf(fp, "\n");
|
|
|
|
|
|
|
+ } fprintf(fp, "\n\n");
|
|
|
|
|
|
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
- if(i==0) fprintf(fp, "total power, time");
|
|
|
|
|
|
|
+ if(i==0) fprintf(fp, "total power time,");
|
|
|
fprintf(fp, "%s,", info->_total_power.xAxis[i]);
|
|
fprintf(fp, "%s,", info->_total_power.xAxis[i]);
|
|
|
} fprintf(fp, "\n");
|
|
} fprintf(fp, "\n");
|
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
if(i==0) fprintf(fp, "total power value,");
|
|
if(i==0) fprintf(fp, "total power value,");
|
|
|
fprintf(fp, "%.8f,", info->_total_power.ydata[i]);
|
|
fprintf(fp, "%.8f,", info->_total_power.ydata[i]);
|
|
|
- } fprintf(fp, "\n");
|
|
|
|
|
|
|
+ } fprintf(fp, "\n\n");
|
|
|
|
|
|
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
if(i==0) fprintf(fp, "total consum time,");
|
|
if(i==0) fprintf(fp, "total consum time,");
|
|
@@ -130,7 +130,7 @@ static int save_to_csv(char *path, status_data_t *data, int flag)
|
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
if(i==0) fprintf(fp, "total consum value,");
|
|
if(i==0) fprintf(fp, "total consum value,");
|
|
|
fprintf(fp, "%.8f,", info->_total_consumption.ydata[i]);
|
|
fprintf(fp, "%.8f,", info->_total_consumption.ydata[i]);
|
|
|
- } fprintf(fp, "\n");
|
|
|
|
|
|
|
+ } fprintf(fp, "\n\n");
|
|
|
|
|
|
|
|
fclose(fp);
|
|
fclose(fp);
|
|
|
return 0;
|
|
return 0;
|
|
@@ -143,7 +143,7 @@ static int export_handle(void *conn, int flag)
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *hm = (struct mg_http_message *)s->ev_data;
|
|
struct mg_http_message *hm = (struct mg_http_message *)s->ev_data;
|
|
|
|
|
|
|
|
- sprintf(path, "%s_history.csv", (flag==0)?"overall":"channel");
|
|
|
|
|
|
|
+ sprintf(path, "%s.csv", (flag==0)?"overall":"channel");
|
|
|
r = save_to_csv(path, &wh->stt, flag);
|
|
r = save_to_csv(path, &wh->stt, flag);
|
|
|
if(r==0) {
|
|
if(r==0) {
|
|
|
struct mg_http_serve_opts opts = {.root_dir = NULL};
|
|
struct mg_http_serve_opts opts = {.root_dir = NULL};
|
|
@@ -163,7 +163,6 @@ static int upload_handle(void *conn, char *path)
|
|
|
size_t pos = 0, total_bytes = 0;
|
|
size_t pos = 0, total_bytes = 0;
|
|
|
struct mg_http_message *hm = (struct mg_http_message *)s->ev_data;
|
|
struct mg_http_message *hm = (struct mg_http_message *)s->ev_data;
|
|
|
|
|
|
|
|
- printf("___ upload file to %s 000\n", path);
|
|
|
|
|
memset(name, 0, sizeof(name));
|
|
memset(name, 0, sizeof(name));
|
|
|
while ((pos = mg_http_next_multipart(hm->body, pos, &part)) > 0) {
|
|
while ((pos = mg_http_next_multipart(hm->body, pos, &part)) > 0) {
|
|
|
memcpy(name, part.filename.buf, part.filename.len);
|
|
memcpy(name, part.filename.buf, part.filename.len);
|
|
@@ -174,7 +173,7 @@ static int upload_handle(void *conn, char *path)
|
|
|
total_bytes += part.body.len;
|
|
total_bytes += part.body.len;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- printf("___ upload file to %s %d\n", path, total_bytes);
|
|
|
|
|
|
|
+ //printf("___ upload file to %s %d\n", path, total_bytes);
|
|
|
|
|
|
|
|
return r;
|
|
return r;
|
|
|
}
|
|
}
|
|
@@ -207,7 +206,7 @@ static void *web_thread(void *arg)
|
|
|
thread_handle_t *h=(thread_handle_t*)arg;
|
|
thread_handle_t *h=(thread_handle_t*)arg;
|
|
|
const char *listen_addr="http://0.0.0.0:80";
|
|
const char *listen_addr="http://0.0.0.0:80";
|
|
|
|
|
|
|
|
- mg_log_set(MG_LL_DEBUG);
|
|
|
|
|
|
|
+ //mg_log_set(MG_LL_DEBUG);
|
|
|
mg_mgr_init(&mgr);
|
|
mg_mgr_init(&mgr);
|
|
|
|
|
|
|
|
//sys_get_path(h->rootDir, WEB_ROOT);
|
|
//sys_get_path(h->rootDir, WEB_ROOT);
|
|
@@ -430,14 +429,6 @@ static void getUserRouters(void* conn)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-static void log_message(const char *filename, const char *message) {
|
|
|
|
|
- FILE *fp = fopen(filename, "a");
|
|
|
|
|
- if (fp != NULL) {
|
|
|
|
|
- fprintf(fp, "%s", message);
|
|
|
|
|
- fclose(fp);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
/// @brief 设备总体信息
|
|
/// @brief 设备总体信息
|
|
|
/// @param stream
|
|
/// @param stream
|
|
|
static void overallStatusMonitoring(void* conn)
|
|
static void overallStatusMonitoring(void* conn)
|
|
@@ -461,7 +452,6 @@ static void overallStatusMonitoring(void* conn)
|
|
|
if (strstr(hm->uri.buf,"type=export")) {
|
|
if (strstr(hm->uri.buf,"type=export")) {
|
|
|
export_handle(conn, 0);
|
|
export_handle(conn, 0);
|
|
|
|
|
|
|
|
- http_reply(conn, 200, ack_str);
|
|
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
http_reply(conn, 400, NULL);
|
|
http_reply(conn, 400, NULL);
|
|
@@ -899,11 +889,6 @@ static void channelStatusMonitoring(void* conn)
|
|
|
{
|
|
{
|
|
|
if (strstr(hm->uri.buf,"type=export")) {
|
|
if (strstr(hm->uri.buf,"type=export")) {
|
|
|
export_handle(conn, 1);
|
|
export_handle(conn, 1);
|
|
|
-
|
|
|
|
|
- http_reply(conn, 200, ack_str);
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- http_reply(conn, 400, NULL);
|
|
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -3532,7 +3517,7 @@ static void equipmentMintenanceExport(void *conn)
|
|
|
//export_handle(conn, 0);
|
|
//export_handle(conn, 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- http_reply(conn, 200, "操作成功");
|
|
|
|
|
|
|
+ //http_reply(conn, 200, "操作成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static int webSetCallback(void)
|
|
static int webSetCallback(void)
|