|
|
@@ -3,6 +3,7 @@
|
|
|
#include "elog.h"
|
|
|
#include <string.h>
|
|
|
#include <time.h>
|
|
|
+#include "common.h"
|
|
|
|
|
|
//如果是在一个程序的循环中不断调用这个函数,那么是没有效果的
|
|
|
//虽然也是使用的系统的时间函数来初始化随机数发生器,但程序的
|
|
|
@@ -679,31 +680,41 @@ int json_to_overall_status_monitor(const char* str,_Over_All_Sts_Monitor* _over_
|
|
|
return -1;
|
|
|
}
|
|
|
cJSON* cjson_token = cJSON_GetObjectItem(cjson,"token");
|
|
|
- cJSON* cjson_type = cJSON_GetObjectItem(cjson,"type");
|
|
|
- // cJSON* cjson_name = cJSON_GetObjectItem(cjson,"productName");
|
|
|
- // cJSON* cjson_number = cJSON_GetObjectItem(cjson,"productNumber");
|
|
|
-
|
|
|
- if(cjson_token->valuestring!=NULL)
|
|
|
+ if(cjson_token!=NULL)
|
|
|
_over_all_sts_monitor->user_token = cjson_token->valuestring;
|
|
|
- if(cjson_type->valuestring!=NULL)
|
|
|
+
|
|
|
+ cJSON* cjson_type = cJSON_GetObjectItem(cjson,"type");
|
|
|
+ if(cjson_type!=NULL)
|
|
|
_over_all_sts_monitor->type = cjson_type->valuestring;
|
|
|
- // if(cjson_name->valuestring!=NULL)
|
|
|
- // _over_all_sts_monitor->product_name = cjson_name->valuestring;
|
|
|
- // if(cjson_number->valuestring!=NULL)
|
|
|
- // _over_all_sts_monitor->product_number = cjson_number->valuestring;
|
|
|
|
|
|
- if(strcmp(_over_all_sts_monitor->type,"listHisQuery")==0)
|
|
|
- {
|
|
|
- // cJSON* cjson_start_time = cJSON_GetObjectItem(cjson,"startTime");
|
|
|
- // cJSON* cjson_end_time = cJSON_GetObjectItem(cjson,"endTime");
|
|
|
- // cJSON* cjson_page_num = cJSON_GetObjectItem(cjson,"pageNum");
|
|
|
- // cJSON* cjson_page_size = cJSON_GetObjectItem(cjson,"pageSize");
|
|
|
-
|
|
|
- // _over_all_sts_monitor->start_time = cjson_start_time->valuestring;
|
|
|
- // _over_all_sts_monitor->end_time = cjson_end_time->valuestring;
|
|
|
- // _over_all_sts_monitor->page_num = cjson_page_num->valuestring;
|
|
|
- // _over_all_sts_monitor->page_size = cjson_page_size->valuestring;
|
|
|
- }
|
|
|
+ cJSON* cjson_productName = cJSON_GetObjectItem(cjson,"productName");
|
|
|
+ if(cjson_productName!=NULL)
|
|
|
+ _over_all_sts_monitor->product_name = cjson_productName->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_product_id = cJSON_GetObjectItem(cjson,"product_id");
|
|
|
+ if(cjson_product_id->valuestring!=NULL)
|
|
|
+ _over_all_sts_monitor->product_id = cjson_product_id->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_productNumber = cJSON_GetObjectItem(cjson,"productNumber");
|
|
|
+ if(cjson_productNumber->valuestring!=NULL)
|
|
|
+ _over_all_sts_monitor->product_number = cjson_productNumber->valuestring;
|
|
|
+
|
|
|
+
|
|
|
+ cJSON* cjson_start_time = cJSON_GetObjectItem(cjson,"startTime");
|
|
|
+ if(cjson_start_time!=NULL)
|
|
|
+ _over_all_sts_monitor->start_time = cjson_start_time->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_end_time = cJSON_GetObjectItem(cjson,"endTime");
|
|
|
+ if(cjson_end_time!=NULL)
|
|
|
+ _over_all_sts_monitor->end_time = cjson_end_time->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_page_num = cJSON_GetObjectItem(cjson,"pageNum");
|
|
|
+ if(cjson_page_num!=NULL)
|
|
|
+ _over_all_sts_monitor->page_num = cjson_page_num->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_page_size = cJSON_GetObjectItem(cjson,"pageSize");
|
|
|
+ if(cjson_page_size!=NULL)
|
|
|
+ _over_all_sts_monitor->page_size = cjson_page_size->valuestring;
|
|
|
|
|
|
return 0 ;
|
|
|
}
|
|
|
@@ -789,25 +800,46 @@ int json_to_chn_pwr_status_monitor(const char* str,_OverChnPwrRequest* _over_chn
|
|
|
return -1;
|
|
|
}
|
|
|
cJSON* cjson_token = cJSON_GetObjectItem(cjson,"token");
|
|
|
- cJSON* cjson_type = cJSON_GetObjectItem(cjson,"type");
|
|
|
- cJSON* cjson_chn_id = cJSON_GetObjectItem(cjson,"productChId");
|
|
|
- //cJSON* cjson_name = cJSON_GetObjectItem(cjson,"productName");
|
|
|
- //cJSON* cjson_chn_name = cJSON_GetObjectItem(cjson,"productChName");
|
|
|
-
|
|
|
-
|
|
|
if(cjson_token!=NULL)
|
|
|
_over_chn_pwr_request->user_token = cjson_token->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_type = cJSON_GetObjectItem(cjson,"type");
|
|
|
if(cjson_type!=NULL)
|
|
|
_over_chn_pwr_request->type = cjson_type->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_chn_id = cJSON_GetObjectItem(cjson,"productChId");
|
|
|
if(cjson_chn_id!=NULL) //通道
|
|
|
- _over_chn_pwr_request->productChId = cjson_chn_id->valueint ;
|
|
|
+ _over_chn_pwr_request->productChId = cjson_chn_id->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_product_name = cJSON_GetObjectItem(cjson,"productName");
|
|
|
+ if(cjson_product_name!=NULL) //通道
|
|
|
+ _over_chn_pwr_request->product_name = cjson_product_name->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_productChName = cJSON_GetObjectItem(cjson,"productChName");
|
|
|
+ if(cjson_productChName!=NULL) //通道
|
|
|
+ _over_chn_pwr_request->productChName = cjson_productChName->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_start_time = cJSON_GetObjectItem(cjson,"start_time");
|
|
|
+ if(cjson_start_time!=NULL) //通道
|
|
|
+ _over_chn_pwr_request->start_time = cjson_start_time->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_end_time = cJSON_GetObjectItem(cjson,"end_time");
|
|
|
+ if(cjson_end_time!=NULL) //通道
|
|
|
+ _over_chn_pwr_request->end_time = cjson_end_time->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_pageNum = cJSON_GetObjectItem(cjson,"pageNum");
|
|
|
+ if(cjson_end_time!=NULL) //通道
|
|
|
+ _over_chn_pwr_request->pageNum = cjson_pageNum->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_pageSize = cJSON_GetObjectItem(cjson,"pageNum");
|
|
|
+ if(cjson_pageSize!=NULL) //通道
|
|
|
+ _over_chn_pwr_request->pageSize = cjson_pageSize->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_ChannelLoadType= cJSON_GetObjectItem(cjson,"ChannelLoadType");
|
|
|
+ if(cjson_ChannelLoadType!=NULL) //通道
|
|
|
+ _over_chn_pwr_request->ChannelLoadType = cjson_ChannelLoadType->valuestring ;
|
|
|
|
|
|
|
|
|
- // _over_chn_pwr_request->user_token = cjson_token->valuestring;
|
|
|
- // _over_chn_pwr_request->type = cjson_type->valuestring;
|
|
|
- // _over_chn_pwr_request->product_name = cjson_name->valuestring;
|
|
|
- // _over_chn_pwr_request->productChName = cjson_chn_name->valuestring;
|
|
|
- // _over_chn_pwr_request->productChId = cjson_chn_id->valuestring;
|
|
|
return 0 ;
|
|
|
}
|
|
|
|
|
|
@@ -832,6 +864,106 @@ char* ctrl_sts_ack_to_json(void)
|
|
|
}
|
|
|
|
|
|
|
|
|
+/// @brief 返回历史信息
|
|
|
+/// @param _globalPowerInfo
|
|
|
+/// @param _globalDeviceInfo
|
|
|
+/// @return
|
|
|
+char* overall_power_history_to_json(GlobalPowerInfo* _globalPowerInfo,GlobalDeviceInfo* _globalDeviceInfo)
|
|
|
+{
|
|
|
+ GlobalPowerInfo* __globalPowerInfoTemp;
|
|
|
+ char* str = NULL;
|
|
|
+ char temp[32] = {0};
|
|
|
+ // 添加基本键值对
|
|
|
+ cJSON_AddNumberToObject(root, "code", 200);
|
|
|
+ //创建数据
|
|
|
+ cJSON* data_root_array = cJSON_CreateArray();
|
|
|
+
|
|
|
+ list_for_each_entry(__globalPowerInfoTemp, &_globalPowerInfo.list, list)
|
|
|
+ {
|
|
|
+ //添加第一条记录
|
|
|
+ cJSON* data_filed = cJSON_CreateObject();
|
|
|
+ cJSON_AddStringToObject(data_filed,"productName",_globalDeviceInfo->product_name);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productNumber",_globalDeviceInfo->product_number);
|
|
|
+ cJSON_AddNumberToObject(data_filed,"productId",_globalDeviceInfo->product_id);
|
|
|
+ sprintf(temp,"%0.3f", __globalPowerInfoTemp->_power_info.voltage);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productVoltage",temp);
|
|
|
+ sprintf(temp,"%0.3f", __globalPowerInfoTemp->_power_info.current);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productCurrent",temp);
|
|
|
+ sprintf(temp,"%0.3f",__globalPowerInfoTemp->_power_info.power);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productPower",temp);
|
|
|
+ sprintf(temp,"%0.3f",__globalPowerInfoTemp->_power_info.freq);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productPowerFreq",temp);
|
|
|
+ sprintf(temp,"%0.3f",__globalPowerInfoTemp->_power_info.consumption);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productConsumption",temp);
|
|
|
+ sprintf(temp,"%0.3f",__globalPowerInfoTemp->_power_info.factor);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productPowerFactor",temp);
|
|
|
+ cJSON_AddItemToObject(data_root_array, "data", data_filed);
|
|
|
+ }
|
|
|
+ //添加汇总
|
|
|
+ cJSON_AddItemToObject(root, "data", data_root_array);
|
|
|
+ //添加结果
|
|
|
+ cJSON_AddStringToObject(root, "msg", "操作成功");
|
|
|
+ //转换
|
|
|
+ str = cJSON_Print(root);
|
|
|
+ //释放资源
|
|
|
+ cJSON_Delete(root);
|
|
|
+ return str;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/// @brief 返回通道历史信息
|
|
|
+/// @param _globalPowerInfo
|
|
|
+/// @param _globalDeviceInfo
|
|
|
+/// @return
|
|
|
+char* over_channel_power_history_to_json(GlobalPowerInfo* _globalPowerInfo,GlobalDeviceInfo* _globalDeviceInfo,char* chn_name,char chn)
|
|
|
+{
|
|
|
+ GlobalPowerInfo* __globalPowerInfoTemp;
|
|
|
+ char* str = NULL;
|
|
|
+ char temp[32] = {0};
|
|
|
+ // 添加基本键值对
|
|
|
+ cJSON_AddNumberToObject(root, "code", 200);
|
|
|
+ //创建数据
|
|
|
+ cJSON* data_root_array = cJSON_CreateArray();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ list_for_each_entry(__globalPowerInfoTemp, &_globalPowerInfo.list, list)
|
|
|
+ {
|
|
|
+ //添加第一条记录
|
|
|
+ cJSON* data_filed = cJSON_CreateObject();
|
|
|
+ cJSON_AddStringToObject(data_filed,"productName",_globalDeviceInfo->product_name);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productNumber",_globalDeviceInfo->product_number);
|
|
|
+ cJSON_AddNumberToObject(data_filed,"productId",_globalDeviceInfo->product_id);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productChName",chn_name);
|
|
|
+ cJSON_AddNumberToObject(data_filed,"productChId",chn);
|
|
|
+ sprintf(temp,"%0.3f", __globalPowerInfoTemp->_power_info.voltage);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productVoltage",temp);
|
|
|
+ sprintf(temp,"%0.3f", __globalPowerInfoTemp->_power_info.current);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productCurrent",temp);
|
|
|
+ sprintf(temp,"%0.3f",__globalPowerInfoTemp->_power_info.power);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productPower",temp);
|
|
|
+ sprintf(temp,"%0.3f",__globalPowerInfoTemp->_power_info.freq);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productPowerFreq",temp);
|
|
|
+ sprintf(temp,"%0.3f",__globalPowerInfoTemp->_power_info.consumption);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productConsumption",temp);
|
|
|
+ sprintf(temp,"%0.3f",__globalPowerInfoTemp->_power_info.factor);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productPowerFactor",temp);
|
|
|
+ cJSON_AddStringToObject(data_filed,"productChStatus",_globalDeviceInfo->product_id);
|
|
|
+ cJSON_AddItemToObject(data_root_array, "data", data_filed);
|
|
|
+ }
|
|
|
+ //添加汇总
|
|
|
+ cJSON_AddItemToObject(root, "data", data_root_array);
|
|
|
+ //添加结果
|
|
|
+ cJSON_AddStringToObject(root, "msg", "操作成功");
|
|
|
+ //转换
|
|
|
+ str = cJSON_Print(root);
|
|
|
+ //释放资源
|
|
|
+ cJSON_Delete(root);
|
|
|
+ return str;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/// @brief 返回监控总信息
|
|
|
/// @param _over_back_sts_info
|
|
|
/// @return
|
|
|
@@ -955,7 +1087,7 @@ char* over_chn_pwr_monitor_to_json(_OverChnPwrAckInfo* _over_chn_pwr_back_info)
|
|
|
/// @param str
|
|
|
/// @param _over_all_sensor_request
|
|
|
/// @return
|
|
|
-int json_to_overall_sensor_status(const char* str,_OverSensorRequest* _over_all_sensor_request)
|
|
|
+int json_to_sensor_manage(const char* str,_OverSensorRequest* _overSensorRequest)
|
|
|
{
|
|
|
cJSON* cjson = NULL;
|
|
|
cjson = cJSON_Parse(str);
|
|
|
@@ -965,12 +1097,66 @@ int json_to_overall_sensor_status(const char* str,_OverSensorRequest* _over_all_
|
|
|
return -1;
|
|
|
}
|
|
|
cJSON* cjson_token = cJSON_GetObjectItem(cjson,"token");
|
|
|
+ if(cjson_token!=NULL)
|
|
|
+ _over_all_sensor_request->user_token = cjson_token->valuestring;
|
|
|
+
|
|
|
cJSON* cjson_type = cJSON_GetObjectItem(cjson,"type");
|
|
|
- cJSON* cjson_name = cJSON_GetObjectItem(cjson,"productName");
|
|
|
- cJSON* cjson_number = cJSON_GetObjectItem(cjson,"productNumber");
|
|
|
+ if(cjson_type!=NULL)
|
|
|
+ _over_all_sensor_request->type = cjson_type->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_productName = cJSON_GetObjectItem(cjson,"productName");
|
|
|
+ if(cjson_productName!=NULL)
|
|
|
+ _over_all_sensor_request->productName = cjson_productName->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_productChName = cJSON_GetObjectItem(cjson,"productChName");
|
|
|
+ if(cjson_tcjson_productChNameype!=NULL)
|
|
|
+ _over_all_sensor_request->productChName = cjson_productChName->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_productChId = cJSON_GetObjectItem(cjson,"productChId");
|
|
|
+ if(cjson_productChId!=NULL)
|
|
|
+ _over_all_sensor_request->productChId = cjson_productChId->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_startTime = cJSON_GetObjectItem(cjson,"startTime");
|
|
|
+ if(cjson_startTime!=NULL)
|
|
|
+ _over_all_sensor_request->startTime = cjson_startTime->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_endTime = cJSON_GetObjectItem(cjson,"endTime");
|
|
|
+ if(cjson_endTime!=NULL)
|
|
|
+ _over_all_sensor_request->endTime = cjson_endTime->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_sensorId = cJSON_GetObjectItem(cjson,"sensorId");
|
|
|
+ if(cjson_sensorId!=NULL)
|
|
|
+ _over_all_sensor_request->sensorId = cjson_sensorId->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_sensorType = cJSON_GetObjectItem(cjson,"sensorType");
|
|
|
+ if(sensorType!=NULL)
|
|
|
+ _over_all_sensor_request->sensorType = sensorType->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_sensorName = cJSON_GetObjectItem(cjson,"sensorName");
|
|
|
+ if(cjson_sensorName!=NULL)
|
|
|
+ _over_all_sensor_request->sensorName = cjson_sensorName->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_comSlogan = cJSON_GetObjectItem(cjson,"comSlogan");
|
|
|
+ if(cjson_comSlogan!=NULL)
|
|
|
+ _over_all_sensor_request->comSlogan = cjson_comSlogan->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_sensorAddr = cJSON_GetObjectItem(cjson,"sensorAddr");
|
|
|
+ if(cjson_sensorAddr!=NULL)
|
|
|
+ _over_all_sensor_request->sensorAddr = cjson_sensorAddr->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_sensorBaud = cJSON_GetObjectItem(cjson,"sensorBaud");
|
|
|
+ if(cjson_sensorBaud!=NULL)
|
|
|
+ _over_all_sensor_request->sensorBaud = cjson_sensorBaud->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_connectionStatus = cJSON_GetObjectItem(cjson,"connectionStatus");
|
|
|
+ if(cjson_connectionStatus!=NULL)
|
|
|
+ _over_all_sensor_request->connectionStatus = cjson_connectionStatus->valuestring;
|
|
|
+
|
|
|
+
|
|
|
+ cJSON* cjson_connectionStatus = cJSON_GetObjectItem(cjson,"connectionStatus");
|
|
|
+ if(cjson_connectionStatus!=NULL)
|
|
|
+ _over_all_sensor_request->connectionStatus = cjson_connectionStatus->valuestring;
|
|
|
|
|
|
- _over_all_sensor_request->user_token = cjson_token->valuestring;
|
|
|
- _over_all_sensor_request->type = cjson_type->valuestring;
|
|
|
return 0 ;
|
|
|
}
|
|
|
|
|
|
@@ -1021,35 +1207,7 @@ char* over_all_sensor_info_to_json(_OverSensorBackInfo* _over_all_sensor_back_in
|
|
|
}
|
|
|
|
|
|
|
|
|
-/// @brief 告警信息请求
|
|
|
-/// @param str
|
|
|
-/// @param _over_all_sensor_request
|
|
|
-/// @return
|
|
|
-int json_to_alarm_request(const char* str,_AlarmRequestInfo* _alarm_request_info)
|
|
|
-{
|
|
|
- cJSON* cjson = NULL;
|
|
|
- cjson = cJSON_Parse(str);
|
|
|
- if(cjson==NULL)
|
|
|
- {
|
|
|
- //log_e("Invalid JSON!");
|
|
|
- return -1;
|
|
|
- }
|
|
|
- cJSON* cjson_token = cJSON_GetObjectItem(cjson,"token");
|
|
|
- cJSON* cjson_type = cJSON_GetObjectItem(cjson,"type");
|
|
|
- cJSON* cjson_alarmType = cJSON_GetObjectItem(cjson,"alarmType");
|
|
|
|
|
|
- //cJSON_GetArrayItem
|
|
|
-
|
|
|
- cJSON* cjson_begin_time = cJSON_GetObjectItem(cjson,"beginTime");
|
|
|
- cJSON* cjson_end_time = cJSON_GetObjectItem(cjson,"endTime");
|
|
|
-
|
|
|
- _alarm_request_info->user_token = cjson_token->valuestring;
|
|
|
- _alarm_request_info->type = cjson_type->valuestring;
|
|
|
- _alarm_request_info->alarmType = cjson_type->valuestring;
|
|
|
- _alarm_request_info->begin_time = cjson_begin_time->valuestring;
|
|
|
- _alarm_request_info->end_time = cjson_end_time->valuestring;
|
|
|
- return 0 ;
|
|
|
-}
|
|
|
|
|
|
|
|
|
/// @brief 返回传感器信息
|
|
|
@@ -1093,4 +1251,273 @@ char* alarm_info_to_json(_AlarmAckInfo* _alarm_ack_info)
|
|
|
//释放资源
|
|
|
cJSON_Delete(root);
|
|
|
return str;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/// @brief 告警信息请求
|
|
|
+/// @param str
|
|
|
+/// @param _over_all_sensor_request
|
|
|
+/// @return
|
|
|
+int json_to_alarm_manage(const char* str,_AlarmRequestInfo* _alarm_request_info)
|
|
|
+{
|
|
|
+ cJSON* cjson = NULL;
|
|
|
+ cjson = cJSON_Parse(str);
|
|
|
+ if(cjson==NULL)
|
|
|
+ {
|
|
|
+ //log_e("Invalid JSON!");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ cJSON* cjson_token = cJSON_GetObjectItem(cjson,"token");
|
|
|
+ if(cjson_token!=NULL)
|
|
|
+ _alarm_request_info->user_token = cjson_token->valuestring;
|
|
|
+
|
|
|
+ cJSON* cjson_type = cJSON_GetObjectItem(cjson,"type");
|
|
|
+ if(cjson_type!=NULL)
|
|
|
+ _alarm_request_info->type = cjson_type->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_alarmContentUpperValue = cJSON_GetObjectItem(cjson,"alarmContentUpperValue");
|
|
|
+ if(cjson_alarmContentUpperValue!=NULL)
|
|
|
+ _alarm_request_info->_pwr_info->alarmContentUpperValue = cjson_alarmContentUpperValue->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_currentUpperValue = cJSON_GetObjectItem(cjson,"currentUpperValue");
|
|
|
+ if(cjson_currentUpperValue!=NULL)
|
|
|
+ _alarm_request_info->_pwr_info->currentUpperValue = cjson_currentUpperValue->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_powerUpperValue = cJSON_GetObjectItem(cjson,"powerUpperValue");
|
|
|
+ if(cjson_powerUpperValue!=NULL)
|
|
|
+ _alarm_request_info->_pwr_info->powerUpperValue = cjson_powerUpperValue->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_productChId = cJSON_GetObjectItem(cjson,"productChId");
|
|
|
+ if(cjson_productChId!=NULL)
|
|
|
+ _alarm_request_info->_pwr_info->productChId = cjson_productChId->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_productChName = cJSON_GetObjectItem(cjson,"productChName");
|
|
|
+ if(cjson_productChName!=NULL)
|
|
|
+ _alarm_request_info->_pwr_info->productChName = cjson_productChName->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_voltageDownValue = cJSON_GetObjectItem(cjson,"voltageDownValue");
|
|
|
+ if(cjson_voltageDownValue!=NULL)
|
|
|
+ _alarm_request_info->_pwr_info->voltageDownValue = cjson_voltageDownValue->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_voltageUpperValue = cJSON_GetObjectItem(cjson,"voltageUpperValue");
|
|
|
+ if(cjson_voltageUpperValue!=NULL)
|
|
|
+ _alarm_request_info->_pwr_info->voltageUpperValue = cjson_voltageUpperValue->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_connectionStatus = cJSON_GetObjectItem(cjson,"connectionStatus");
|
|
|
+ if(cjson_connectionStatus!=NULL)
|
|
|
+ _alarm_request_info->_sensor_info->connectionStatus = cjson_connectionStatus->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_sensorId = cJSON_GetObjectItem(cjson,"sensorId");
|
|
|
+ if(cjson_sensorId!=NULL)
|
|
|
+ _alarm_request_info->_sensor_info->sensorId = cjson_sensorId->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_sensorName = cJSON_GetObjectItem(cjson,"sensorName");
|
|
|
+ if(cjson_sensorName!=NULL)
|
|
|
+ _alarm_request_info->_sensor_info->sensorName = cjson_sensorName->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_sensorType = cJSON_GetObjectItem(cjson,"sensorType");
|
|
|
+ if(cjson_sensorType!=NULL)
|
|
|
+ _alarm_request_info->_sensor_info->sensorType = cjson_sensorType->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_thresholdDownValue = cJSON_GetObjectItem(cjson,"thresholdDownValue");
|
|
|
+ if(cjson_thresholdDownValue!=NULL)
|
|
|
+ _alarm_request_info->_sensor_info->thresholdDownValue = cjson_thresholdDownValue->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_thresholdUpperValue = cJSON_GetObjectItem(cjson,"thresholdUpperValue");
|
|
|
+ if(cjson_thresholdUpperValue!=NULL)
|
|
|
+ _alarm_request_info->_sensor_info->thresholdUpperValue = cjson_thresholdUpperValue->valuestring ;
|
|
|
+
|
|
|
+ return 0 ;
|
|
|
+}
|
|
|
+
|
|
|
+/// @brief 日志信息查询
|
|
|
+/// @param str
|
|
|
+/// @param _logInformationRequestInfo
|
|
|
+/// @return
|
|
|
+int json_to_loginformation_manage(const char* str,_LogInformationRequestInfo* _logInformationRequestInfo)
|
|
|
+{
|
|
|
+ cJSON* cjson = NULL;
|
|
|
+ cjson = cJSON_Parse(str);
|
|
|
+ if(cjson==NULL)
|
|
|
+ {
|
|
|
+ //log_e("Invalid JSON!");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ cJSON* cjson_token = cJSON_GetObjectItem(cjson,"token");
|
|
|
+ if(cjson_token!=NULL)
|
|
|
+ _logInformationRequestInfo->user_token = cjson_token->valuestring;
|
|
|
+ cJSON* cjson_type = cJSON_GetObjectItem(cjson,"type");
|
|
|
+ if(cjson_type!=NULL)
|
|
|
+ _logInformationRequestInfo->type = cjson_type->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_alarm_type = cJSON_GetObjectItem(cjson,"alarmType");
|
|
|
+ if(cjson_alarm_type!=NULL)
|
|
|
+ _logInformationRequestInfo->alarmType = cjson_alarm_type->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_begin_time = cJSON_GetObjectItem(cjson,"beginTime");
|
|
|
+ if(cjson_begin_time!=NULL)
|
|
|
+ _logInformationRequestInfo->beginTime = cjson_begin_time->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_end_time = cJSON_GetObjectItem(cjson,"endTime");
|
|
|
+ if(cjson_end_time!=NULL)
|
|
|
+ _logInformationRequestInfo->endtime = cjson_end_time->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_pagenum = cJSON_GetObjectItem(cjson,"pageNum");
|
|
|
+ if(cjson_pagenum!=NULL)
|
|
|
+ _logInformationRequestInfo->pagenum = cjson_pagenum->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_pagesize = cJSON_GetObjectItem(cjson,"pageSize");
|
|
|
+ if(cjson_pagesize!=NULL)
|
|
|
+ _logInformationRequestInfo->pagesize = cjson_pagenum->valuestring ;
|
|
|
+
|
|
|
+ cJSON* cjson_openName = cJSON_GetObjectItem(cjson,"operName");
|
|
|
+ if(cjson_openName!=NULL)
|
|
|
+ _logInformationRequestInfo->openName = cjson_openName->valuestring ;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+/// @brief 通信管理
|
|
|
+/// @param str
|
|
|
+/// @param _communicationRequestInfo
|
|
|
+/// @return
|
|
|
+int json_to_communication_manage(const char* str,_CommunicationManageRequestInfo* _communicationRequestInfo)
|
|
|
+{
|
|
|
+ cJSON* cjson = NULL;
|
|
|
+ cjson = cJSON_Parse(str);
|
|
|
+ if(cjson==NULL)
|
|
|
+ {
|
|
|
+ //log_e("Invalid JSON!");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ cJSON* cjson_token = cJSON_GetObjectItem(cjson,"token");
|
|
|
+ if(cjson_token!=NULL)
|
|
|
+ _communicationRequestInfo->user_token = cjson_token->valuestring;
|
|
|
+ cJSON* cjson_type = cJSON_GetObjectItem(cjson,"type");
|
|
|
+ if(cjson_type!=NULL)
|
|
|
+ _communicationRequestInfo->type = cjson_type->valuestring ;
|
|
|
+ //网络配置上传参数
|
|
|
+ if(strcmp(_communicationRequestInfo->type,"WkSave")==0)
|
|
|
+ {
|
|
|
+ cJSON* cjson_net_mode = cJSON_GetObjectItem(cjson,"mode");
|
|
|
+ cJSON* cjson_net_ipaddr = cJSON_GetObjectItem(cjson,"ipaddress");
|
|
|
+ cJSON* cjson_net_mask = cJSON_GetObjectItem(cjson,"mask");
|
|
|
+ cJSON* cjson_net_gateway = cJSON_GetObjectItem(cjson,"gateway");
|
|
|
+ cJSON* cjson_net_dns1 = cJSON_GetObjectItem(cjson,"dns1");
|
|
|
+ cJSON* cjson_net_dns2 = cJSON_GetObjectItem(cjson,"dns2");
|
|
|
+ cJSON* cjson_net_mac = cJSON_GetObjectItem(cjson,"mac");
|
|
|
+
|
|
|
+ if(cjson_net_mode!=NULL)
|
|
|
+ _communicationRequestInfo->_net_info->mode = cjson_net_mode->valuestring ;
|
|
|
+ if(cjson_net_ipaddr!=NULL)
|
|
|
+ _communicationRequestInfo->_net_info->ipaddr = cjson_net_ipaddr->valuestring ;
|
|
|
+ if(cjson_net_mask!=NULL)
|
|
|
+ _communicationRequestInfo->_net_info->maskaddr = cjson_net_mask->valuestring ;
|
|
|
+ if(cjson_net_gateway!=NULL)
|
|
|
+ _communicationRequestInfo->_net_info->gateway = cjson_net_gateway->valuestring ;
|
|
|
+ if(cjson_net_dns1!=NULL)
|
|
|
+ _communicationRequestInfo->_net_info->dns1 = cjson_net_dns1->valuestring ;
|
|
|
+ if(cjson_net_dns2!=NULL)
|
|
|
+ _communicationRequestInfo->_net_info->dns2 = cjson_net_dns2->valuestring ;
|
|
|
+ }
|
|
|
+ //RS485配置
|
|
|
+ if(strcmp(_communicationRequestInfo->type,"RsSave")==0)
|
|
|
+ {
|
|
|
+ cJSON* cjson_rs_mode = cJSON_GetObjectItem(cjson,"mode");
|
|
|
+ cJSON* cjson_rs_baud = cJSON_GetObjectItem(cjson,"sensorBaud");
|
|
|
+ if(cjson_rs_mode!=NULL)
|
|
|
+ _communicationRequestInfo->_rs_info->mode = cjson_rs_mode->valuestring ;
|
|
|
+ if(cjson_rs_baud!=NULL)
|
|
|
+ _communicationRequestInfo->_rs_info->baud = cjson_rs_baud->valuestring ;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+/// @brief JSON服务参数获取
|
|
|
+/// @param str
|
|
|
+/// @param _serviceManageRequestInfo
|
|
|
+/// @return
|
|
|
+int json_to_service_manage(const char* str,_ServiceManageRequestInfo* _serviceManageRequestInfo)
|
|
|
+{
|
|
|
+ cJSON* cjson = NULL;
|
|
|
+ cjson = cJSON_Parse(str);
|
|
|
+ if(cjson==NULL)
|
|
|
+ {
|
|
|
+ //log_e("Invalid JSON!");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ cJSON* cjson_token = cJSON_GetObjectItem(cjson,"token");
|
|
|
+ if(cjson_token!=NULL)
|
|
|
+ _serviceManageRequestInfo->user_token = cjson_token->valuestring;
|
|
|
+ cJSON* cjson_type = cJSON_GetObjectItem(cjson,"type");
|
|
|
+ if(cjson_type!=NULL)
|
|
|
+ _serviceManageRequestInfo->type = cjson_type->valuestring ;
|
|
|
+
|
|
|
+ ///SMTP上传参数
|
|
|
+ if(strcmp(_serviceManageRequestInfo->type,"SmtpSave")==0)
|
|
|
+ {
|
|
|
+ cJSON* cjson_smtp_mode = cJSON_GetObjectItem(cjson,"mode");
|
|
|
+ cJSON* cjson_smtp_account = cJSON_GetObjectItem(cjson,"smtpAccount");
|
|
|
+ cJSON* cjson_smtp_passwd = cJSON_GetObjectItem(cjson,"passWord");
|
|
|
+ cJSON* cjson_smtp_server = cJSON_GetObjectItem(cjson,"server");
|
|
|
+ cJSON* cjson_smtp_port = cJSON_GetObjectItem(cjson,"port");
|
|
|
+ cJSON* cjson_smtp_auth = cJSON_GetObjectItem(cjson,"auth");
|
|
|
+ cJSON* cjson_smtp_receive_account = cJSON_GetObjectItem(cjson,"receiveAccount");
|
|
|
+ if(cjson_smtp_mode!=NULL)
|
|
|
+ _serviceManageRequestInfo->_smtp_info->mode = cjson_smtp_mode->valuestring ;
|
|
|
+ if(cjson_smtp_account!=NULL)
|
|
|
+ _serviceManageRequestInfo->_smtp_info->smtpAccount = cjson_smtp_account->valuestring ;
|
|
|
+ if(cjson_smtp_passwd!=NULL)
|
|
|
+ _serviceManageRequestInfo->_smtp_info->passWord = cjson_smtp_passwd->valuestring ;
|
|
|
+ if(cjson_smtp_server!=NULL)
|
|
|
+ _serviceManageRequestInfo->_smtp_info->server = cjson_smtp_server->valuestring ;
|
|
|
+ if(cjson_smtp_port!=NULL)
|
|
|
+ _serviceManageRequestInfo->_smtp_info->port = cjson_smtp_port->valuestring ;
|
|
|
+ if(cjson_smtp_auth!=NULL)
|
|
|
+ _serviceManageRequestInfo->_smtp_info->auth = cjson_smtp_auth->valuestring ;
|
|
|
+ if(cjson_smtp_receive_account!=NULL)
|
|
|
+ _serviceManageRequestInfo->_smtp_info->receiveAccount = cjson_smtp_receive_account->valuestring ;
|
|
|
+ }
|
|
|
+ //SNMP上传参数
|
|
|
+ else if(strcmp(_serviceManageRequestInfo->type,"SnmpSave")==0)
|
|
|
+ {
|
|
|
+ cJSON* cjson_snmp_mode = cJSON_GetObjectItem(cjson,"mode");
|
|
|
+ cJSON* cjson_snmp_port = cJSON_GetObjectItem(cjson,"port");
|
|
|
+
|
|
|
+ if(cjson_snmp_mode!=NULL)
|
|
|
+ _serviceManageRequestInfo->_snmp_info->mode = cjson_snmp_mode->valuestring ;
|
|
|
+ if(cjson_snmp_port!=NULL)
|
|
|
+ _serviceManageRequestInfo->_snmp_info->port = cjson_snmp_port->valuestring ;
|
|
|
+ }
|
|
|
+ //SNMP TRAP参数
|
|
|
+ else if(strcmp(_serviceManageRequestInfo->type,"StSave")==0)
|
|
|
+ {
|
|
|
+ cJSON* cjson_snmp_trap_mode = cJSON_GetObjectItem(cjson,"mode");
|
|
|
+ cJSON* cjson_snmp_trap__port = cJSON_GetObjectItem(cjson,"stType");
|
|
|
+
|
|
|
+ if(cjson_snmp_trap_mode!=NULL)
|
|
|
+ _serviceManageRequestInfo->_snmp_trap_info->mode = cjson_snmp_trap_mode->valuestring ;
|
|
|
+ if(cjson_snmp_trap__port!=NULL)
|
|
|
+ _serviceManageRequestInfo->_snmp_trap_info->port = cjson_snmp_trap__port->valuestring ;
|
|
|
+ }
|
|
|
+ //NTP参数
|
|
|
+ else if(strcmp(_serviceManageRequestInfo->type,"NtpSave")==0)
|
|
|
+ {
|
|
|
+ cJSON* cjson_ntp_mode = cJSON_GetObjectItem(cjson,"mode");
|
|
|
+ cJSON* cjson_ntp_name = cJSON_GetObjectItem(cjson,"ntpName");
|
|
|
+ cJSON* cjson_ntp_address = cJSON_GetObjectItem(cjson,"ntpadress");
|
|
|
+ cJSON* cjson_ntp_port = cJSON_GetObjectItem(cjson,"port");
|
|
|
+ cJSON* cjson_ntp_datetime = cJSON_GetObjectItem(cjson,"time");
|
|
|
+ if(cjson_ntp_mode!=NULL)
|
|
|
+ _serviceManageRequestInfo->_ntp_info->mode = cjson_ntp_mode->valuestring ;
|
|
|
+ if(cjson_ntp_name!=NULL)
|
|
|
+ _serviceManageRequestInfo->_ntp_info->ntpName = cjson_ntp_name->valuestring ;
|
|
|
+ if(cjson_ntp_address!=NULL)
|
|
|
+ _serviceManageRequestInfo->_ntp_info->ntpadress = cjson_ntp_address->valuestring ;
|
|
|
+ if(cjson_ntp_port!=NULL)
|
|
|
+ _serviceManageRequestInfo->_ntp_info->port = cjson_ntp_port->valuestring ;
|
|
|
+ if(cjson_ntp_datetime!=NULL)
|
|
|
+ _serviceManageRequestInfo->_ntp_info->datetime = cjson_ntp_datetime->valuestring ;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
}
|