| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681 |
- #ifndef __JSON_HANDLE_H
- #define __JSON_HANDLE_H
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
- #include <stdbool.h>
- #include "list.h"
- #include "common.h"
- #include "cJSON.h"
- #include "xlist.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 ;//输出状态-该通道是否输出
- 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[60] ;//气体值
- char xAxis[60][32] ;//时间点
- }_Sensor_Temp_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;
- int leakStatus;
- 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;
- _Sensor_Temp_Icon temp_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;
- char *startTime;
- char *endTime;
- _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[MAIL_RECV_MAX];
- }_MAIL_ServerRequestInfo;
- typedef struct
- {
- int idx;
- int mode;
- char* sid;
- char* name;
- char* server;
- char* port;
- char* cid;
- char* user;
- char* password;
- char* status; //connect status
- }_MQTT_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;
- char* updategroupName;
- }_GROUP_ServiceRequestInfo;
- /// @brief 服务信息查询
- typedef struct
- {
- char* user_token;
- char* type;
- _MQTT_ServerRequestInfo _mqtt_info;
- _MAIL_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;
- char* productName;
- }_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 4G和WiFi参数配置
- typedef struct
- {
- int Cellular_mode;
- int WIFI_mode;
- char WIFI_name[64];
- char WIFI_code[64];
- }_4G_WIFI_CommunicationRequestInfo;
- /// @brief 通信信息查询
- typedef struct
- {
- char* user_token;
- char* type;
- _NET_CommunicationRequestInfo _net_info;
- _RS_CommunicationRequestInfo _rs_info;
- _4G_WIFI_CommunicationRequestInfo _4g_wifi_info;
- }_CommunicationManageRequestInfo;
- /// @brief日志信息查询
- typedef struct
- {
- char* user_token;
- char* type;
- char* alarmType;
- char* startTime;
- 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(int tls);
- 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* communication_4G_ack_to_json(CellularManager* _CellularManagerTemp,int nWSType);
- char* communication_WIFI_ack_to_json(WIFIManager* _WIFIManagertemp,int nWSType);
- 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_mail_ack_to_json(mail_info_t* info);
- char* service_mqtt_ack_to_json(mqtt_info_t* info);
- char* mqtt_status_to_json(int mode);
- 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 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);
- char *threshold_status_ack_to_json(GlobalDeviceManager *dm);
- char* upgrade_to_json(void);
- char* board_to_json(handle_t l, int is_ws);
- char *upg_chk_to_json(int r);
- #endif
|