|
|
@@ -14,7 +14,7 @@
|
|
|
#include "language_common.h"
|
|
|
#include "websocket_handle.h"
|
|
|
|
|
|
-
|
|
|
+#define TOTAL_COUNT 60
|
|
|
#define FN_MAX 30
|
|
|
typedef void (*http_fn_t)(void *arg);
|
|
|
|
|
|
@@ -36,7 +36,7 @@ typedef struct {
|
|
|
}mg_handle_t;
|
|
|
typedef struct {
|
|
|
_OverAllPwrAckInfo all;
|
|
|
- _OverChnPwrAckInfo chn;
|
|
|
+ _OverAllPwrAckInfo chn;
|
|
|
}status_data_t;
|
|
|
typedef struct {
|
|
|
mg_handle_t mg;
|
|
|
@@ -85,22 +85,57 @@ static void httpAddCallback(char *uri, http_fn_t f)
|
|
|
h->cnt++;
|
|
|
}
|
|
|
}
|
|
|
-static int save_to_csv(char *path, status_data_t *data)
|
|
|
+static int save_to_csv(char *path, status_data_t *data, int flag)
|
|
|
{
|
|
|
- int tlen=0;
|
|
|
+ int i=0;
|
|
|
FILE *fp=NULL;
|
|
|
+ _OverAllPwrAckInfo *info=(flag==0)?&data->all:&data->chn;
|
|
|
|
|
|
fp = fopen(path, "wt");
|
|
|
if(!fp) {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- fprintf(fp, "hello world");
|
|
|
+ for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
+ if(i==0) fprintf(fp, "total voltage time,");
|
|
|
+ fprintf(fp, "%s,", info->_total_voltage.xAxis[i]);
|
|
|
+ } fprintf(fp, "\n");
|
|
|
+ for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
+ if(i==0) fprintf(fp, "total voltage value,");
|
|
|
+ fprintf(fp, "%.8f,", info->_total_voltage.ydata[i]);
|
|
|
+ } fprintf(fp, "\n");
|
|
|
+
|
|
|
+ for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
+ if(i==0) fprintf(fp, "total current time,");
|
|
|
+ fprintf(fp, "%s,", info->_total_current.xAxis[i]);
|
|
|
+ } fprintf(fp, "\n");
|
|
|
+ for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
+ if(i==0) fprintf(fp, "total current value,");
|
|
|
+ fprintf(fp, "%.8f,", info->_total_current.ydata[i]);
|
|
|
+ } fprintf(fp, "\n");
|
|
|
+
|
|
|
+ for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
+ if(i==0) fprintf(fp, "total power, time");
|
|
|
+ fprintf(fp, "%s,", info->_total_power.xAxis[i]);
|
|
|
+ } fprintf(fp, "\n");
|
|
|
+ for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
+ if(i==0) fprintf(fp, "total power value,");
|
|
|
+ fprintf(fp, "%.8f,", info->_total_power.ydata[i]);
|
|
|
+ } fprintf(fp, "\n");
|
|
|
+
|
|
|
+ for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
+ if(i==0) fprintf(fp, "total consum time,");
|
|
|
+ fprintf(fp, "%s,", info->_total_consumption.xAxis[i]);
|
|
|
+ } fprintf(fp, "\n");
|
|
|
+ for(i=0; i<TOTAL_COUNT; i++) {
|
|
|
+ if(i==0) fprintf(fp, "total consum value,");
|
|
|
+ fprintf(fp, "%.8f,", info->_total_consumption.ydata[i]);
|
|
|
+ } fprintf(fp, "\n");
|
|
|
|
|
|
fclose(fp);
|
|
|
return 0;
|
|
|
}
|
|
|
-static int download_handle(void *conn, int flag)
|
|
|
+static int export_handle(void *conn, int flag)
|
|
|
{
|
|
|
int r;
|
|
|
char path[100];
|
|
|
@@ -108,8 +143,8 @@ static int download_handle(void *conn, int flag)
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
struct mg_http_message *hm = (struct mg_http_message *)s->ev_data;
|
|
|
|
|
|
- sprintf(path, "/tmp/%s_history.csv", (flag==0)?"overall":"channel");
|
|
|
- r = save_to_csv(path, &wh->stt);
|
|
|
+ sprintf(path, "%s_history.csv", (flag==0)?"overall":"channel");
|
|
|
+ r = save_to_csv(path, &wh->stt, flag);
|
|
|
if(r==0) {
|
|
|
struct mg_http_serve_opts opts = {.root_dir = NULL};
|
|
|
mg_http_serve_file(s->c, hm, path, &opts);
|
|
|
@@ -122,24 +157,30 @@ static int download_handle(void *conn, int flag)
|
|
|
static int upload_handle(void *conn, char *path)
|
|
|
{
|
|
|
int r=-1;
|
|
|
+ char name[200];
|
|
|
struct mg_http_part part;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
size_t pos = 0, total_bytes = 0;
|
|
|
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));
|
|
|
while ((pos = mg_http_next_multipart(hm->body, pos, &part)) > 0) {
|
|
|
- printf("filename: %s length: %lu bytes", part.filename.buf, (unsigned long) part.body.len);
|
|
|
+ memcpy(name, part.filename.buf, part.filename.len);
|
|
|
+ printf("filename: %s length: %lu bytes\n", name, (unsigned long) part.body.len);
|
|
|
|
|
|
if (mg_path_is_sane(mg_str(path))) {
|
|
|
mg_file_write(&mg_fs_posix, path, part.body.buf, part.body.len);
|
|
|
total_bytes += part.body.len;
|
|
|
}
|
|
|
}
|
|
|
+ printf("___ upload file to %s %d\n", path, total_bytes);
|
|
|
+
|
|
|
return r;
|
|
|
}
|
|
|
static void http_mg_cb(struct mg_connection *c, int ev, void *ev_data)
|
|
|
{
|
|
|
- int i,j;
|
|
|
+ int i,j,flag=0;
|
|
|
mg_handle_t *h=&webHandle.mg;
|
|
|
mg_stream_t s={c,ev,ev_data};
|
|
|
|
|
|
@@ -147,11 +188,12 @@ static void http_mg_cb(struct mg_connection *c, int ev, void *ev_data)
|
|
|
struct mg_http_message *hm = ev_data;
|
|
|
for(i=0; i<h->cnt; i++) {
|
|
|
if (h->fn[i].f && h->fn[i].uri && mg_match(hm->uri, mg_str(h->fn[i].uri), NULL)) {
|
|
|
- h->fn[i].f(&s); c->pfn = NULL;
|
|
|
+ h->fn[i].f(&s);
|
|
|
+ flag = 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (c->pfn != NULL) {
|
|
|
+ if (flag==0) {
|
|
|
struct mg_http_serve_opts opts = {.root_dir = h->rootDir};
|
|
|
mg_http_serve_dir(c, ev_data, &opts);
|
|
|
}
|
|
|
@@ -165,7 +207,7 @@ static void *web_thread(void *arg)
|
|
|
thread_handle_t *h=(thread_handle_t*)arg;
|
|
|
const char *listen_addr="http://0.0.0.0:80";
|
|
|
|
|
|
- //mg_log_set(MG_LL_ERROR);
|
|
|
+ mg_log_set(MG_LL_DEBUG);
|
|
|
mg_mgr_init(&mgr);
|
|
|
|
|
|
//sys_get_path(h->rootDir, WEB_ROOT);
|
|
|
@@ -194,9 +236,9 @@ static void systemConfiguration(void* conn)
|
|
|
{
|
|
|
char *ack_str = NULL;
|
|
|
char *g_token = NULL;
|
|
|
- mg_stream_t *s = (mg_stream_t *)conn;
|
|
|
- struct mg_http_message *msg = s->ev_data;
|
|
|
- char* rx_Head_buf = (char *)msg->head.buf;
|
|
|
+ mg_stream_t *s=(mg_stream_t *)conn;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char* rx_Head_buf=(char *)hm->head.buf;
|
|
|
|
|
|
g_token = json_to_Token_info(rx_Head_buf);
|
|
|
// 检查token是否有效
|
|
|
@@ -223,8 +265,8 @@ static void changeLanguages(void* conn)
|
|
|
{
|
|
|
char* ack_str = NULL;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char* rx_body_buf = (char*)msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char* rx_body_buf=(char*)hm->body.buf;
|
|
|
|
|
|
json_to_switch_language(rx_body_buf);
|
|
|
dev_update_device_genera_info(__globalDeviceManage.db,__globalDeviceManage._global_device_info);
|
|
|
@@ -240,8 +282,8 @@ static void loginFunc(void* conn)
|
|
|
char* ack_str = NULL ;
|
|
|
char g_token[64] = {0};
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_body_buf = msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_body_buf=hm->body.buf;
|
|
|
|
|
|
//用户信息创建-未析构
|
|
|
_User_Log *_newUserLogin = (_User_Log *)malloc(sizeof(_User_Log));
|
|
|
@@ -314,8 +356,8 @@ static void loginOutFunc(void* conn)
|
|
|
char* ack_str = NULL ;
|
|
|
char* g_token;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_body_buf = (char*)msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_body_buf = (char*)hm->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
if(json_to_User_loginOut_info(rx_body_buf,&g_token)!=0)
|
|
|
@@ -337,7 +379,6 @@ static void loginOutFunc(void* conn)
|
|
|
static void getUserInfo(void* conn)
|
|
|
{
|
|
|
char* ack_str = NULL ;
|
|
|
- char* rx_body_buf = NULL;
|
|
|
|
|
|
ack_str = user_info_to_json();
|
|
|
http_reply(conn, 200, ack_str);
|
|
|
@@ -353,8 +394,8 @@ static void getUserRouters(void* conn)
|
|
|
char* ack_str = NULL ;
|
|
|
char* g_token=NULL;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_Head_buf = (char*)msg->head.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_Head_buf = (char*)hm->head.buf;
|
|
|
|
|
|
// 查询用户信息
|
|
|
UserInfo User_list;
|
|
|
@@ -388,6 +429,15 @@ static void getUserRouters(void* conn)
|
|
|
cJSON_free((void*)ack_str);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+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 设备总体信息
|
|
|
/// @param stream
|
|
|
static void overallStatusMonitoring(void* conn)
|
|
|
@@ -398,17 +448,18 @@ static void overallStatusMonitoring(void* conn)
|
|
|
_Over_All_Sts_Monitor _over_all_sts_monitor={0};
|
|
|
_OverBackStsInfo _over_back_sts_info; //设备总体状态信息
|
|
|
_OverAllPwrAckInfo _over_all_pwr_back_info; //设备电源信息
|
|
|
+ _OverAllPwrAckInfo *pall=&webHandle.stt.all;
|
|
|
char* ack_str=NULL;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_body_buf = (char*)msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_body_buf = (char*)hm->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
cjson = json_to_overall_status_monitor(rx_body_buf,&_over_all_sts_monitor);
|
|
|
if(cjson==NULL)
|
|
|
{
|
|
|
- if (strstr(rx_body_buf,"type=export")) {
|
|
|
- download_handle(conn, 0);
|
|
|
+ if (strstr(hm->uri.buf,"type=export")) {
|
|
|
+ export_handle(conn, 0);
|
|
|
|
|
|
http_reply(conn, 200, ack_str);
|
|
|
}
|
|
|
@@ -611,7 +662,7 @@ static void overallStatusMonitoring(void* conn)
|
|
|
||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One
|
|
|
||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One_B)
|
|
|
{
|
|
|
- ack_str = over_all_data_t_ac_to_json(&_over_all_pwr_back_info,&_over_all_sts_monitor, TOTAL_VOLTAGE_TYPE);
|
|
|
+ ack_str = over_all_data_t_ac_to_json(pall,&_over_all_sts_monitor, TOTAL_VOLTAGE_TYPE);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -624,12 +675,12 @@ static void overallStatusMonitoring(void* conn)
|
|
|
#define TOTAL_COUNT 60
|
|
|
for(int i=0;i< TOTAL_COUNT;i++)
|
|
|
{
|
|
|
- strcpy(_over_all_pwr_back_info._total_voltage.xAxis[i],__globalPowerInfo._total_voltage.xAxis[i]);
|
|
|
- _over_all_pwr_back_info._total_voltage.ydata[i] = __globalPowerInfo._total_voltage.ydata[i];
|
|
|
+ strcpy(pall->_total_voltage.xAxis[i],__globalPowerInfo._total_voltage.xAxis[i]);
|
|
|
+ pall->_total_voltage.ydata[i] = __globalPowerInfo._total_voltage.ydata[i];
|
|
|
}
|
|
|
|
|
|
//返回电压统计
|
|
|
- ack_str = over_all_total_info_to_json(&_over_all_pwr_back_info,TOTAL_VOLTAGE_TYPE);
|
|
|
+ ack_str = over_all_total_info_to_json(pall,TOTAL_VOLTAGE_TYPE);
|
|
|
}
|
|
|
}
|
|
|
//电流统计
|
|
|
@@ -646,7 +697,7 @@ static void overallStatusMonitoring(void* conn)
|
|
|
||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One
|
|
|
||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One_B)
|
|
|
{
|
|
|
- ack_str = over_all_data_t_ac_to_json(&_over_all_pwr_back_info, &_over_all_sts_monitor, TOTAL_CURRENT_TYPE);
|
|
|
+ ack_str = over_all_data_t_ac_to_json(pall, &_over_all_sts_monitor, TOTAL_CURRENT_TYPE);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -658,12 +709,12 @@ static void overallStatusMonitoring(void* conn)
|
|
|
//传值给总管理结构体
|
|
|
for(int i=0;i< TOTAL_COUNT;i++)
|
|
|
{
|
|
|
- strcpy(_over_all_pwr_back_info._total_current.xAxis[i],__globalPowerInfo._total_current.xAxis[i]);
|
|
|
- _over_all_pwr_back_info._total_current.ydata[i] = __globalPowerInfo._total_current.ydata[i];
|
|
|
+ strcpy(pall->_total_current.xAxis[i],__globalPowerInfo._total_current.xAxis[i]);
|
|
|
+ pall->_total_current.ydata[i] = __globalPowerInfo._total_current.ydata[i];
|
|
|
}
|
|
|
|
|
|
//返回电流统计
|
|
|
- ack_str = over_all_total_info_to_json(&_over_all_pwr_back_info,TOTAL_CURRENT_TYPE);
|
|
|
+ ack_str = over_all_total_info_to_json(pall,TOTAL_CURRENT_TYPE);
|
|
|
}
|
|
|
}
|
|
|
//功率统计
|
|
|
@@ -680,7 +731,7 @@ static void overallStatusMonitoring(void* conn)
|
|
|
||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One
|
|
|
||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One_B)
|
|
|
{
|
|
|
- ack_str = over_all_data_t_ac_to_json(&_over_all_pwr_back_info, &_over_all_sts_monitor, TOTAL_POWER_TYPE);
|
|
|
+ ack_str = over_all_data_t_ac_to_json(pall, &_over_all_sts_monitor, TOTAL_POWER_TYPE);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -692,12 +743,12 @@ static void overallStatusMonitoring(void* conn)
|
|
|
//传值给总管理结构体
|
|
|
for(int i=0;i< TOTAL_COUNT;i++)
|
|
|
{
|
|
|
- strcpy(_over_all_pwr_back_info._total_power.xAxis[i],__globalPowerInfo._total_power.xAxis[i]);
|
|
|
- _over_all_pwr_back_info._total_power.ydata[i] = __globalPowerInfo._total_power.ydata[i];
|
|
|
+ strcpy(pall->_total_power.xAxis[i],__globalPowerInfo._total_power.xAxis[i]);
|
|
|
+ pall->_total_power.ydata[i] = __globalPowerInfo._total_power.ydata[i];
|
|
|
}
|
|
|
|
|
|
//返回功率统计
|
|
|
- ack_str = over_all_total_info_to_json(&_over_all_pwr_back_info,TOTAL_POWER_TYPE);
|
|
|
+ ack_str = over_all_total_info_to_json(pall,TOTAL_POWER_TYPE);
|
|
|
}
|
|
|
}
|
|
|
//耗电量统计
|
|
|
@@ -714,7 +765,7 @@ static void overallStatusMonitoring(void* conn)
|
|
|
||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One
|
|
|
||_over_all_sts_monitor.product_pwr_type==SmartPDU_Tree_AC_One_B)
|
|
|
{
|
|
|
- ack_str = over_all_data_t_ac_to_json(&_over_all_pwr_back_info, &_over_all_sts_monitor, TOTAL_POWER_CONS_TYPE);
|
|
|
+ ack_str = over_all_data_t_ac_to_json(pall, &_over_all_sts_monitor, TOTAL_POWER_CONS_TYPE);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -726,12 +777,12 @@ static void overallStatusMonitoring(void* conn)
|
|
|
//传值给总管理结构体
|
|
|
for(int i=0;i< TOTAL_COUNT;i++)
|
|
|
{
|
|
|
- strcpy(_over_all_pwr_back_info._total_consumption.xAxis[i],__globalPowerInfo._total_consumption.xAxis[i]);
|
|
|
- _over_all_pwr_back_info._total_consumption.ydata[i] = __globalPowerInfo._total_consumption.ydata[i];
|
|
|
+ strcpy(pall->_total_consumption.xAxis[i],__globalPowerInfo._total_consumption.xAxis[i]);
|
|
|
+ pall->_total_consumption.ydata[i] = __globalPowerInfo._total_consumption.ydata[i];
|
|
|
}
|
|
|
|
|
|
//返回耗电量统计
|
|
|
- ack_str = over_all_total_info_to_json(&_over_all_pwr_back_info,TOTAL_POWER_CONS_TYPE);
|
|
|
+ ack_str = over_all_total_info_to_json(pall,TOTAL_POWER_CONS_TYPE);
|
|
|
}
|
|
|
}
|
|
|
//查询系统总数情况
|
|
|
@@ -834,19 +885,20 @@ static void channelStatusMonitoring(void* conn)
|
|
|
cJSON *cjson;
|
|
|
cmd_data_t cmd;
|
|
|
_OverChnPwrRequest _over_chn_pwr_request;
|
|
|
- _OverAllPwrAckInfo _over_all_pwr_back_info; //设备电源信息
|
|
|
+ _OverAllPwrAckInfo _over_all_pwr_back_info;
|
|
|
+ _OverAllPwrAckInfo *pch=&webHandle.stt.chn;
|
|
|
char* ack_str = NULL ;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_body_buf=(char*)msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_body_buf=(char*)hm->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
memset(&_over_chn_pwr_request,0,sizeof(_OverChnPwrRequest));
|
|
|
cjson = json_to_chn_pwr_status_monitor(rx_body_buf,&_over_chn_pwr_request);
|
|
|
if(cjson==NULL)
|
|
|
{
|
|
|
- if (strstr(rx_body_buf,"type=export")) {
|
|
|
- download_handle(conn, 1);
|
|
|
+ if (strstr(hm->uri.buf,"type=export")) {
|
|
|
+ export_handle(conn, 1);
|
|
|
|
|
|
http_reply(conn, 200, ack_str);
|
|
|
}
|
|
|
@@ -1166,14 +1218,13 @@ static void channelStatusMonitoring(void* conn)
|
|
|
log_e("serach total voltage err.");
|
|
|
}
|
|
|
//传值给总管理结构体
|
|
|
- #define TOTAL_COUNT 60
|
|
|
for(int i=0;i< TOTAL_COUNT;i++)
|
|
|
{
|
|
|
- strcpy(_over_all_pwr_back_info._total_voltage.xAxis[i],__globalPowerInfo._total_voltage.xAxis[i]);
|
|
|
- _over_all_pwr_back_info._total_voltage.ydata[i] = __globalPowerInfo._total_voltage.ydata[i];
|
|
|
+ strcpy(pch->_total_voltage.xAxis[i],__globalPowerInfo._total_voltage.xAxis[i]);
|
|
|
+ pch->_total_voltage.ydata[i] = __globalPowerInfo._total_voltage.ydata[i];
|
|
|
}
|
|
|
//返回电压统计
|
|
|
- ack_str = over_all_total_info_to_json(&_over_all_pwr_back_info,TOTAL_VOLTAGE_TYPE);
|
|
|
+ ack_str = over_all_total_info_to_json(pch,TOTAL_VOLTAGE_TYPE);
|
|
|
#endif
|
|
|
}
|
|
|
//电流统计
|
|
|
@@ -1200,12 +1251,12 @@ static void channelStatusMonitoring(void* conn)
|
|
|
//传值给总管理结构体
|
|
|
for(int i=0;i< TOTAL_COUNT;i++)
|
|
|
{
|
|
|
- strcpy(_over_all_pwr_back_info._total_current.xAxis[i],__globalPowerInfo._total_current.xAxis[i]);
|
|
|
- _over_all_pwr_back_info._total_current.ydata[i] = __globalPowerInfo._total_current.ydata[i];
|
|
|
+ strcpy(pch->_total_current.xAxis[i],__globalPowerInfo._total_current.xAxis[i]);
|
|
|
+ pch->_total_current.ydata[i] = __globalPowerInfo._total_current.ydata[i];
|
|
|
}
|
|
|
|
|
|
//返回电流统计
|
|
|
- ack_str = over_all_total_info_to_json(&_over_all_pwr_back_info,TOTAL_CURRENT_TYPE);
|
|
|
+ ack_str = over_all_total_info_to_json(pch,TOTAL_CURRENT_TYPE);
|
|
|
}
|
|
|
//功率统计
|
|
|
else if(strcmp(_over_chn_pwr_request.type,"listGlTotalQuery")==0)
|
|
|
@@ -1231,12 +1282,12 @@ static void channelStatusMonitoring(void* conn)
|
|
|
//传值给总管理结构体
|
|
|
for(int i=0;i< TOTAL_COUNT;i++)
|
|
|
{
|
|
|
- strcpy(_over_all_pwr_back_info._total_power.xAxis[i],__globalPowerInfo._total_power.xAxis[i]);
|
|
|
- _over_all_pwr_back_info._total_power.ydata[i] = __globalPowerInfo._total_power.ydata[i];
|
|
|
+ strcpy(pch->_total_power.xAxis[i],__globalPowerInfo._total_power.xAxis[i]);
|
|
|
+ pch->_total_power.ydata[i] = __globalPowerInfo._total_power.ydata[i];
|
|
|
}
|
|
|
|
|
|
//返回功率统计
|
|
|
- ack_str = over_all_total_info_to_json(&_over_all_pwr_back_info,TOTAL_POWER_TYPE);
|
|
|
+ ack_str = over_all_total_info_to_json(pch,TOTAL_POWER_TYPE);
|
|
|
}
|
|
|
//耗电量统计
|
|
|
else if(strcmp(_over_chn_pwr_request.type,"listHdlTotalQuery")==0)
|
|
|
@@ -1262,12 +1313,12 @@ static void channelStatusMonitoring(void* conn)
|
|
|
//传值给总管理结构体
|
|
|
for(int i=0;i< TOTAL_COUNT;i++)
|
|
|
{
|
|
|
- strcpy(_over_all_pwr_back_info._total_consumption.xAxis[i],__globalPowerInfo._total_consumption.xAxis[i]);
|
|
|
- _over_all_pwr_back_info._total_consumption.ydata[i] = __globalPowerInfo._total_consumption.ydata[i];
|
|
|
+ strcpy(pch->_total_consumption.xAxis[i],__globalPowerInfo._total_consumption.xAxis[i]);
|
|
|
+ pch->_total_consumption.ydata[i] = __globalPowerInfo._total_consumption.ydata[i];
|
|
|
}
|
|
|
|
|
|
//返回耗电量统计
|
|
|
- ack_str = over_all_total_info_to_json(&_over_all_pwr_back_info,TOTAL_POWER_CONS_TYPE);
|
|
|
+ ack_str = over_all_total_info_to_json(pch,TOTAL_POWER_CONS_TYPE);
|
|
|
}
|
|
|
else if(strcmp(_over_chn_pwr_request.type,"threeTypeSave")==0)
|
|
|
{
|
|
|
@@ -1349,8 +1400,8 @@ static void sensorStatusMonitoring(void* conn)
|
|
|
GlobalSensorInfo _globalSensorInfo;
|
|
|
char* ack_str = NULL ;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_body_buf=(char*)msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_body_buf=(char*)hm->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
cjson = json_to_sensor_manage(rx_body_buf,&_over_all_sensor_request);
|
|
|
@@ -1846,8 +1897,8 @@ static void alarmProtect(void *conn)
|
|
|
char* ack_str = NULL ;
|
|
|
int nAlarmNumber=0;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_body_buf=(char*)msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_body_buf=(char*)hm->body.buf;
|
|
|
|
|
|
memset(&_alarm_request_info, 0, sizeof(_alarm_request_info));
|
|
|
//转换json参数
|
|
|
@@ -2116,8 +2167,8 @@ static void logInformation(void *conn)
|
|
|
_LogInformationRequestInfo __logInformationRequestInfo;
|
|
|
_AlarmAckInfo _alarm_ack_info; //填充数据
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_body_buf=(char*)msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_body_buf=(char*)hm->body.buf;
|
|
|
|
|
|
memset(&__logInformationRequestInfo,0,sizeof(_LogInformationRequestInfo));
|
|
|
cjson = json_to_loginformation_manage(rx_body_buf,&__logInformationRequestInfo);
|
|
|
@@ -2303,8 +2354,8 @@ static void communicationManagement(void *conn)
|
|
|
_CommunicationManageRequestInfo reqInfo;
|
|
|
GlobalDeviceInfo *devInfo=__globalDeviceManage._global_device_info;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_body_buf=(char*)msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_body_buf=(char*)hm->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
cjson = json_to_communication_manage(rx_body_buf,&reqInfo);
|
|
|
@@ -2411,8 +2462,8 @@ static void serviceManagement(void *conn)
|
|
|
_ServiceManageRequestInfo _serviceManageRequestInfo;
|
|
|
char* ack_str = NULL ;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_body_buf = (char*)msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_body_buf = (char*)hm->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
memset(&_serviceManageRequestInfo, 0, sizeof(_serviceManageRequestInfo));
|
|
|
@@ -3167,8 +3218,8 @@ static void systemManagent(void *conn)
|
|
|
_UserRoleManageInfo _UserRoleManageRequestInfo;
|
|
|
char* ack_str = NULL ;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_body_buf = (char*)msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_body_buf = (char*)hm->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
cjson = json_to_user_manage(rx_body_buf,&_UserRoleManageRequestInfo);
|
|
|
@@ -3340,8 +3391,8 @@ static void equipmentMintenance(void *conn)
|
|
|
_OverBackStsInfo _over_back_sts_info; //设备总体状态信息
|
|
|
_Equipment_Mintenance _Over_equipment_mintenance;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_body_buf = (char*)msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_body_buf = (char*)hm->body.buf;
|
|
|
|
|
|
//转换json参数
|
|
|
cjson = json_to_over_equipment_mintenance(rx_body_buf,&_Over_equipment_mintenance);
|
|
|
@@ -3449,18 +3500,17 @@ static void equipmentMintenanceUpload(void *conn)
|
|
|
int r = -1 ;
|
|
|
char* ack_str = NULL ;
|
|
|
mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
- struct mg_http_message *msg=s->ev_data;
|
|
|
- char *rx_body_buf = (char*)msg->body.buf;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
char path[200];
|
|
|
|
|
|
- if(strstr(msg->uri.buf, "uploadType=gjsj")) { //firmware upload
|
|
|
+ if(strstr(hm->uri.buf, "uploadType=gjsj")) { //firmware upload
|
|
|
sprintf(path, "%s/%s", DOWN_FOLDER, UPG_PKG_NAME);
|
|
|
r = upload_handle(conn, path);
|
|
|
if(r==0) {
|
|
|
upg_start();
|
|
|
}
|
|
|
}
|
|
|
- else if(strstr(msg->uri.buf, "uploadType=shfw")) { //logo upload
|
|
|
+ else if(strstr(hm->uri.buf, "uploadType=shfw")) { //logo upload
|
|
|
//char *save_logo="productNumber=Vq1&productVersion=undefined&uploadType=shfw&type=importData&token=b6cdd10e-e1a7-4bd9-8283-c6d6ecbae28c";
|
|
|
sprintf(path, "%s/%s", IMAGE_PATH, LOGO_FILE);
|
|
|
upload_handle(conn, path);
|
|
|
@@ -3469,6 +3519,22 @@ static void equipmentMintenanceUpload(void *conn)
|
|
|
http_reply(conn, 200, "操作成功");
|
|
|
}
|
|
|
|
|
|
+static void equipmentMintenanceExport(void *conn)
|
|
|
+{
|
|
|
+ int r = -1 ;
|
|
|
+ char* ack_str = NULL ;
|
|
|
+ mg_stream_t *s=(mg_stream_t*)conn;
|
|
|
+ struct mg_http_message *hm=s->ev_data;
|
|
|
+ char *rx_body_buf = (char*)hm->body.buf;
|
|
|
+ char path[200];
|
|
|
+
|
|
|
+ if(strstr(hm->uri.buf, "export=2")) {
|
|
|
+ //export_handle(conn, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ http_reply(conn, 200, "操作成功");
|
|
|
+}
|
|
|
+
|
|
|
static int webSetCallback(void)
|
|
|
{
|
|
|
httpAddCallback("/login", loginFunc);//登录
|
|
|
@@ -3487,6 +3553,8 @@ static int webSetCallback(void)
|
|
|
httpAddCallback("/pdu/system", systemManagent);//用户管理
|
|
|
httpAddCallback("/pdu/equipmentMintenance", equipmentMintenance);//设备重启
|
|
|
httpAddCallback("/pdu/equipmentMintenanceUpload", equipmentMintenanceUpload); //固件升级
|
|
|
+ httpAddCallback("/pdu/equipmentMintenanceExport", equipmentMintenanceExport);
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|