#ifndef __JSON_HANDLE_H #define __JSON_HANDLE_H #include #include #include #include #include #include "list.h" #include "common.h" #include "cJSON.h" /// @brief 获取用户信息 typedef struct { char* user_token; }_Get_Info_Request; /// @brief 电压、电流、功率、耗电量统计接口 typedef struct { float ydata[60]; //value char xAxis[60][32];//时间点 }_Get_Total_Value; /// @brief 系统总数信息 typedef struct { int channel_total ;//通道总数 int warn_total ;//告警总数 int sensor_total ;//传感器总数 int log_total ;//运行日志总数 }_Get_System_Total; //功率趋势接口 typedef struct { float ydata[3][60] ;//0:有功功率;1:无功功率;2:视在功率; char xAxis[60][32] ;//时间点 }_Power_Trend_Info; /// @brief 总体设备信息 typedef struct { char* user_token; char* type; //listInfoQuery listQuery open close listHisQuery char* product_name; int product_id; char* product_number; char* start_time; char* end_time; char* page_num; char* page_size; int product_pwr_type; char* product_phOrder; char* lType; //L1 L2 L3 }_Over_All_Sts_Monitor; /// @brief 总设备信息返回 typedef struct { char *product_name; int product_id; char *product_number; char *product_Code; char *product_type; int product_type_id; char *productVersion; // 固件版本 char *product_status; char *product_sysTime; char *product_runTime; char *productPwrType; char *productAddr; // IP地址 char *product_mac; int product_RS485Addr; int productMemory; // 内存 char *occupancyRate; // 磁盘占用率 char productCount; // 级联设备数 _Get_System_Total system_total; }_OverBackStsInfo; /// @brief breaker device information typedef struct { char *product_name; int product_id; char *product_number; char product_type; }_OverBackBreakerInfo; /// @brief breaker channel list information typedef struct { char product_name[32]; int product_id; char product_number[32]; char product_ch_name[32]; int product_ch_id; struct list_head list; }_OverBreakerChnInfo; /// @brief breaker channel switch information typedef struct { char productName[32]; char product_number[32]; int product_id; char product_ch_name[32]; int product_ch_id; int status; int switch_id; char switch_name[64]; char cjfs[20]; char comkh[20]; char cjdz[20]; char jdh[20]; char productChids[64]; struct list_head list; }_OverBreakerSwitchInfo; /// @brief 电源总体监控请求信息 typedef struct { char* user_token; char* type; char* product_name; char* product_number; }_OverAllPwrRequest; /// @brief 电源通道监控请求信息 typedef struct { char* user_token; char* type; char* lType; char* product_name; int product_id; char* productChName; int productChId; char* start_time; char* end_time; char* pageNum; char* pageSize; char* ChannelLoadType; int productType; char* productPhOrder; int outputType; char* Zerotype; char* strProductChIds; }_OverChnPwrRequest; /// @brief 总体电源返回信息 typedef struct { char* product_name; char* product_number; int product_id; char* productChName; char productChId; int status; int NF_status; char* mac_addr; char* ip_addr; float voltage ;//电压 float current ;//电流 float power ;//功率 float freq ;//频率 float consumption ;//耗电量 float factor ; unsigned short product_ch_start_delay ;//通道延时 unsigned short product_ch_stop_delay ;//通道延时 int product_type; //通道类型 int product_phType; //三相类型 float ph_voltage ;//电压 float ph_current ;//电流 float ph_power ;//功率 float ph_consumption ;//耗电量 int ph_outputType ;//输出类型 int ph_outputStatus ;//输出状态-该通道是否输出 #if IS_IP float temperature; float humidity; #endif struct list_head list; }_OverChnPwrAckInfo; /// @brief 总体电源返回信息 typedef struct { char* product_name; char* product_number; int product_id; float voltage ;//电压 float current ;//电流 float power ;//功率 float freq ;//频率 float consumption ;//耗电量 float factor ;//功率因素 _Get_Total_Value _total_voltage ;//电压统计 _Get_Total_Value _total_current ;//电流统计 _Get_Total_Value _total_power ;//功率统计 _Get_Total_Value _total_consumption ;//耗电量统计 _Power_Trend_Info _Power_Trend_Info ;//有功、无功、视在功率统计 }_OverAllPwrAckInfo; /// @brief 传感器总体请求信息 typedef struct { float ydata[2][60] ;//0:温度,1:湿度; char xAxis[60][32] ;//时间点 }_Sensor_Temp_Humi_Icon; typedef struct { float ydata[60] ;//气体值 char xAxis[60][32] ;//时间点 }_Sensor_Gas_Icon; typedef struct { float ydata[2][60] ;//0:气流,1:气压; char xAxis[60][32] ;//时间点 }_Sensor_Air_Press_Icon; typedef struct { char* user_token; char* type; char* productName; char* productNumber; char* productChName; char* productChId; char* startTime; char* endTime; char* page_num; char* page_size; int sensorId; char* sensorType; char* sensorName; char* comSlogan; char* cgqtd; char* sensorAddr; char* sensorBaud; char* connectionStatus; }_OverSensorRequest; /// @brief 传感器应答状态 typedef struct { int accessControlStatus; char sensorAddr; int nodeNumber; float airPressureValue; float airflowValue; int alarmStatus; int sensorBaud; char comSlogan[32]; int connectionStatus; float gasConcentration; float humidityValue; float temperatureValue; char sensorName[64]; char sensorId; char sensorType; int waterImmersionState; char sensorvaluech[32]; float temperatureValue2; _Sensor_Temp_Humi_Icon temp_humi_sensor; _Sensor_Gas_Icon gas_sensor; _Sensor_Air_Press_Icon air_press_sensor; struct list_head list; }_OverSensorBackInfo; /// @brief 电源类阈值设置 typedef struct { char* alarmContentUpperValue; char* currentUpperValue; char* powerUpperValue; char productChId; char* productChName; char* voltageDownValue; char* voltageUpperValue; bool bUpdatealarmContentUpperValue; bool bUpdatecurrentUpperValue; bool bUpdatepowerUpperValue; bool bUpdatevoltageDownValue; bool bUpdatevoltageUpperValue; char* currentUpperAction; char* voltageUpperAction; char*voltageDownAction; char* powerUpperAction; char* alarmContentUpperAction; }_Power_AlarmRequestInfo; /// @brief 传感器类阈值设置 typedef struct { char* connectionStatus ; int sensorId; char* sensorName; char* sensorType; char* thresholdType; char* thresholdDownValue; char* thresholdUpperValue; char *thresholdDownAction; char *thresholdUpperAction; char *thresholdUpperChanel; char *thresholdDownChanel; }_Sensor_AlarmRequestInfo; /// @brief 告警信息查询 typedef struct { char* user_token; char* type; int pagenum; int pagesize; _Power_AlarmRequestInfo _pwr_info; _Sensor_AlarmRequestInfo _sensor_info; char* strProductChIds; }_AlarmRequestInfo; /// @brief 告警响应信息 typedef struct { char alarmNumber[16]; char alarmDate[32]; char alarmType; char deviceNumber[16]; char deviceName[32]; char alarmContent[128]; struct list_head list; }_AlarmAckInfo; /// @brief SMPT服务信息 typedef struct { char* mode; char* account; char* password; char* server; char* port; char* auth; char* recvAccount[SMTP_RECV_MAX]; }_SMTP_ServerRequestInfo; /// @brief SNMP信息 typedef struct { char *mode; char *version; char *public; char *trapmode; char *user; char *auth_alg; char *auth_passwd; char *priv_alg; char *priv_passwd; char *nms_IP; }_SNMP_ServerRequestInfo; /// @brief SNMP TRAP信息 typedef struct { char* mode; char* stType; }_SNMPTRAP_ServerRequestInfo; /// @brief NTP信息 typedef struct { char* mode; char* ntpName; char* ntpaddress; char* port; char* time; char* weekday; char* tzone; }_NTP_ServiceRequestInfo; /// @brief 定时设置 typedef struct { char* productChName; char* productChId; int productChIds[64]; char* idx[64]; char* channelDate; char* StartDate; char* Enddate; char* channelTime; char* setStatus; }_DS_ServiceRequestInfo; /// @brief 时序设置 typedef struct { char* productId; char* productChName; char* productChId; char* firingInterval; char* closeInterval; // char* firingInterval; // char* closeInterval; }_POSIX_ServiceRequestInfo; /// @brief 分组设置 typedef struct { char* mode; char* xlnumber; char* jgnumber; char* opergroupid; }_GROUP_ServiceRequestInfo; /// @brief 服务信息查询 typedef struct { char* user_token; char* type; _SMTP_ServerRequestInfo _smtp_info ; _SNMP_ServerRequestInfo _snmp_info ; _SNMPTRAP_ServerRequestInfo _snmp_trap_info; _NTP_ServiceRequestInfo _ntp_info ; _DS_ServiceRequestInfo _ds_info; _POSIX_ServiceRequestInfo _posix_info; _GROUP_ServiceRequestInfo _group_info; }_ServiceManageRequestInfo; /// @brief 网络参数配置 typedef struct { char* mode; char* ipaddr; char* maskaddr; char* gateway; char* dns1; char* dns2; }_NET_CommunicationRequestInfo; /// @brief RS参数配置 typedef struct { char* mode; char* baud; char* addr; }_RS_CommunicationRequestInfo; /// @brief 通信信息查询 typedef struct { char* user_token; char* type; _NET_CommunicationRequestInfo _net_info; _RS_CommunicationRequestInfo _rs_info; }_CommunicationManageRequestInfo; /// @brief日志信息查询 typedef struct { char* user_token; char* type; char* alarmType; char* beginTime; char* endtime; int pagenum; int pagesize; char* openName; }_LogInformationRequestInfo; /// @brief 日志应答类容 typedef struct { char* alarm_number; char* alarm_date; char alarm_type; int product_id; char product_name[32]; char alarmContent[64]; }_LogInformationAckInfo; /// @brief 设备维护 typedef struct { char* user_token; char* type; char* product_name; char* product_id; char* product_number; /// @brief breaker infomation char* cjfs; char* comkh; char* cjdz; char* jdh; char* productChids; ///// int switchId; char* switchName; char* cleanSelectItem; }_Equipment_Mintenance; /// @brief 用户角色管理 typedef struct { char* user_token; char* type; char* createTime; int userId; char* userName; char* nickName;//用途不明? bool delFlag;//用途不明? int roleId; char* roleName; char* password; int userIds; int pagenum; int pagesize; }_UserRoleManageInfo; char* ctrl_sts_ack_to_json(void); char* ctrl_breaker_err_ack_to_json(char *string); void get_rand_str(char* s,int num); char* json_to_Token_info(const char* strHead); int json_to_User_login_info(const char* str,_User_Log* _newUserLogin); int json_to_User_loginOut_info(const char* str,char** _UserLoginOutToken); char* log_info_to_json(const char* token); char* log_LoginFailedinfo_to_json(); char* log_AthFailedinfo_to_json(); char* user_info_to_json(void); char* user_routers_info_to_json(void); char* json_to_system_config_info(void); cJSON* json_to_overall_status_monitor(const char* str,_Over_All_Sts_Monitor* _over_all_sts_monitor); char* over_all_monitor_to_json(_OverBackStsInfo* _over_back_sts_info); char* overall_power_history_to_json(GlobalPowerInfo* _globalPowerInfo,GlobalDeviceInfo* _globalDeviceInfo); char* over_channel_power_history_to_json(GlobalPowerInfo* _globalPowerInfo,GlobalDeviceInfo* _globalDeviceInfo,char* chn_name,char chn); cJSON* json_to_overall_pwr_status_monitor(const char* str,_OverAllPwrRequest* _over_all_pwr_request); cJSON* json_to_over_equipment_mintenance(const char* str,_Equipment_Mintenance* _over_equipment_mintenance); char* over_product_list_info_to_json(GlobalDeviceManager *dm, _OverBackStsInfo* _over_back_sts_info,bool curFlag); char* vendor_info_to_json(GlobalDeviceInfo *dev); char* over_all_pwr_monitor_to_json(int phaseType,_OverAllPwrAckInfo* _over_all_pwr_back_info); char* over_all_pwr_monitor_Tree_AC_to_json(_OverAllPwrAckInfo* _over_all_pwr_back_info_L1,_OverAllPwrAckInfo* _over_all_pwr_back_info_L2,_OverAllPwrAckInfo* _over_all_pwr_back_info_L3); char* over_all_total_info_to_json(_OverAllPwrAckInfo* _over_all_pwr_back_info, int total_type); void over_all_total_info_t_ac_to_json(_OverAllPwrAckInfo* _over_all_pwr_back_info,cJSON* dataJson,cJSON* AxisJson, int total_type); int over_init_data_t_ac_to_json(cJSON* pAllJson,cJSON* dataJson[],cJSON* AxisJson,int total_type); char* over_all_data_t_ac_to_json(_OverAllPwrAckInfo* _over_all_pwr_back_info, _Over_All_Sts_Monitor* _over_all_sts_monitor,int total_type); char* over_system_total_monitor_to_json(_OverBackStsInfo* _over_back_system_info); char* over_power_trend_to_json(_OverAllPwrAckInfo* _over_all_pwr_back_info); cJSON* json_to_chn_pwr_status_monitor(const char* str,_OverChnPwrRequest* _over_chn_pwr_request); char* over_chn_pwr_monitor_to_json(_OverChnPwrAckInfo* _over_chn_pwr_back_info); int json_to_overall_sensor_status(const char* str,_OverSensorRequest* _over_all_sensor_request); char* over_all_sensor_info_to_json(_OverSensorBackInfo* _over_all_sensor_back_info,int nWSType); char* ws_sensor_status_ack_to_json(GlobalSensorManger* _globalSensorManger); char* over_sensor_history_info_to_json(_OverSensorBackInfo* _over_all_sensor_back_info, int sensor_type); char* alarm_info_to_json(_AlarmAckInfo* _alarm_ack_info,int nAllNumber); char* alarm_type_info_to_json(_AlarmAckInfo* _alarm_ack_info,int nAllNumber); char* alarm_ctrl_type_info_to_json(_AlarmAckInfo* _alarm_ack_info,int nAlarmNum); char* alarm_power_threshold_to_json(GlobalPowerManger* _globalPowerManger); char* alarm_sensor_threshold_to_json(GlobalSensorManger* _globalSensorManger); char* communication_net_ack_to_json(NetworkInfo_t* _networkInfo_t); char* communication_rs_ack_to_json(ModbusInfo_t* _modbusInfo_t); char* service_ds_ack_to_json(char* chn_name,char* chn_id,_PowerDSManage_t* __powerDSManage_t); char* service_ds_all_ack_to_json(char* pDate,char* Name,char* nchID,GlobalPowerManger* __powerDSManage_t); char* service_sx_ack_to_json(int product_id, GlobalPowerManger * __PowerManage_t); char* service_ntp_ack_to_json(NTPManager* __NTPManager_t); char* service_snmp_ack_to_json(SNMPManager* sm); char* service_smtp_ack_to_json(smtp_info_t* info); char* service_mqtt_ack_to_json(mqtt_info_t* info); char* service_group_ack_to_json(GroupInfo* _globalgroupInfo); ///请求管理 cJSON* json_to_sensor_manage(const char* str,_OverSensorRequest* _overSensorRequest); cJSON* json_to_alarm_manage(const char* str,_AlarmRequestInfo* _alarm_request_info); cJSON* json_to_loginformation_manage(const char* str,_LogInformationRequestInfo* _logInformationRequestInfo); cJSON* json_to_communication_manage(const char* str,_CommunicationManageRequestInfo* _communicationRequestInfo); cJSON* json_to_service_manage(const char* str,_ServiceManageRequestInfo* _serviceManageRequestInfo); cJSON* json_to_user_manage(const char* str,_UserRoleManageInfo* _UserRoleManageRequestInfo); char* ws_over_status_ack_to_json(int type,_OverAllPwrAckInfo* _over_all_pwr_back_info); char* ws_chn_status_ack_to_json(int type,_OverChnPwrAckInfo* _over_chn_pwr_back_info,GlobalDeviceManager *gdm); int json_to_switch_language(const char* str); int InitHashTable(GlobalDeviceManager *gdm); char* mem_info_to_json(); int GetRoleIDByUserName(char* _userName,UserInfo* __UserInfo_t); int GetRoleLevelByID(int _RoleID,RoleInfo* __RoleInfo_t); char* GetRoleNameByID(int _RoleID,RoleInfo* __RoleInfo_t); int GetRoleIDByName(char* _RoleName,RoleInfo* __RoleInfo_t); char* service_userQuery_ack_to_json(char* _userName,UserInfo* __UserInfo_t,RoleInfo* __RoleInfo_t,char* _SelName,int pagenum,int pagesize); char* service_userRole_ack_to_json(char* _userName,UserInfo* __UserInfo_t,RoleInfo* __RoleInfo_t); char* over_breaker_product_list_info_to_json(GlobalDeviceManager *dm,_OverBackBreakerInfo* _over_back_sts_info,bool curFlag); char* over_all_breaker_chn_info_to_json(_OverBreakerChnInfo* _over_all_breaker_back_info,int nWSType); char* over_all_breaker_switch_info_to_json(_OverBreakerSwitchInfo* _over_all_breaker_switch_info,int nWSType); char *breaker_status_ack_to_json(GlobalDeviceManager *gm,int slave); int dev_get_all_profuct_chid_from_power_mgr(sqlite3 *db,uint8_t *cannnel); #endif