189 lines
4.1 KiB
C
189 lines
4.1 KiB
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifndef MY_GET_DATA_WITH_TYPE
|
|
#define MY_GET_DATA_WITH_TYPE(p, type) (*(type *)(p))
|
|
#endif
|
|
|
|
|
|
|
|
enum
|
|
{
|
|
_MMS_M_EVENT_ALL_CALL,
|
|
_MMS_M_EVENT_GI_CALL,
|
|
_MMS_M_EVENT_CO_SELECT,
|
|
_MMS_M_EVENT_CO_DIRECT,
|
|
_MMS_M_EVENT_CO_CANCEL,
|
|
_MMS_M_EVENT_AO_READ,
|
|
_MMS_M_EVENT_AO_WRITE,
|
|
_MMS_M_EVENT_PARAM_READ,
|
|
_MMS_M_EVENT_PARAM_WRITE,
|
|
_MMS_M_EVENT_END
|
|
};
|
|
|
|
#define MMS_M_DATA_STRING_LEN 128
|
|
|
|
#define MMS_M_STR_LEN 64
|
|
#define MMS_M_REF_LEN 128
|
|
|
|
#define MMS_M_ON_LINE 1
|
|
#define MMS_M_OFF_LINE 0
|
|
|
|
|
|
#define MMS_M_DEBUG_PRINT_OFF 0
|
|
#define MMS_M_DEBUG_PRINT_ON 1
|
|
|
|
typedef char MMS_STR[MMS_M_STR_LEN];
|
|
typedef char MMS_REF[MMS_M_REF_LEN];
|
|
|
|
#define MMS_M_MAX_VAL_NUM 16
|
|
|
|
typedef struct
|
|
{
|
|
int app_fd; // 61850客户端句柄
|
|
MMS_STR ied; // ied名称
|
|
MMS_STR saddr; // 信号短地址
|
|
uint8_t value_type; // 数据类型
|
|
char val[MMS_M_DATA_STRING_LEN];
|
|
uint8_t ctrl_type; // 遥控类型
|
|
int set_zone; // 定值区
|
|
void (*p_func)(void *arg, int ret); // 设置回调函数
|
|
}stru_mms_m_event;
|
|
|
|
|
|
|
|
typedef struct
|
|
{
|
|
int year;
|
|
int mon;
|
|
int day;
|
|
int hour;
|
|
int min;
|
|
int sec;
|
|
int msec;
|
|
}stru_mms_m_time;
|
|
|
|
typedef struct
|
|
{
|
|
int app_fd;
|
|
int reason;
|
|
int type;
|
|
int quality;
|
|
MMS_STR name;
|
|
MMS_STR desc;
|
|
MMS_REF reference;
|
|
void *p_value;
|
|
stru_mms_m_time time;
|
|
}stru_mms_m_out_value;
|
|
|
|
typedef void (*mms_m_out_status_cb)(int app_fd, int status);
|
|
typedef void (*mms_m_out_value_cb)(stru_mms_m_out_value *p_value);
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
{
|
|
int quality;
|
|
int val_num;
|
|
void *p_val[MMS_M_MAX_VAL_NUM];
|
|
void *p_default[MMS_M_MAX_VAL_NUM];
|
|
stru_mms_m_time time;
|
|
}stru_point_value;
|
|
|
|
typedef struct
|
|
{
|
|
MMS_STR desc;
|
|
MMS_STR host_ip;
|
|
uint16_t host_port;
|
|
MMS_STR ied;
|
|
}stru_para_page;
|
|
|
|
typedef struct
|
|
{
|
|
uint16_t no;
|
|
uint8_t type;
|
|
uint8_t fc;
|
|
uint8_t ctrl_model;
|
|
MMS_STR saddr;
|
|
MMS_STR desc;
|
|
MMS_STR ldev;
|
|
MMS_STR lnode;
|
|
MMS_STR doname;
|
|
MMS_REF reference;
|
|
stru_point_value value;
|
|
void *set_value;
|
|
void *control;
|
|
float min_value;
|
|
float max_value;
|
|
float step_value;
|
|
MMS_STR unit;
|
|
}stru_point_item;
|
|
|
|
typedef struct
|
|
{
|
|
MMS_STR desc;
|
|
int st_num;
|
|
int mx_num;
|
|
int co_num;
|
|
int ao_num;
|
|
int param_num;
|
|
stru_point_item *p_st;
|
|
stru_point_item *p_mx;
|
|
stru_point_item *p_co;
|
|
stru_point_item *p_ao;
|
|
stru_point_item *p_param;
|
|
}stru_point_page;
|
|
|
|
|
|
typedef struct
|
|
{
|
|
MMS_STR path;
|
|
stru_para_page para;
|
|
stru_point_page point;
|
|
}stru_cfg;
|
|
|
|
|
|
int mms_m_out_init(stru_cfg *p_cfg, int debug_print_flag, uint32_t connectionTimeout);
|
|
|
|
int mms_m_out_get_connect_status(int fd, mms_m_out_status_cb p_func);
|
|
|
|
int mms_m_out_debug_print_swicth(int id, int debug_print_flag);
|
|
|
|
int mms_m_out_do_set_yk_or_param(stru_mms_m_event *p_event);
|
|
|
|
int mms_m_out_read_params(int app_fd);
|
|
int mms_m_out_read_param(int app_fd, const char *param_name);
|
|
|
|
int mms_m_out_get_value(int app_fd, mms_m_out_value_cb p_func);
|
|
char *mms_m_out_reason_str(int reason);
|
|
|
|
|
|
void *mms_m_create_data_ptr(uint8_t type);
|
|
int mms_m_set_data_value(void *srt, void *dst, uint8_t type);
|
|
int mms_m_get_data_value_str(void *data, uint8_t type, char *str);
|
|
int mms_m_set_data_by_str(void *data, uint8_t type, const char *str);
|
|
|
|
|
|
typedef void (*mms_m_file_read_cb)(int fd, const char *fn, const uint8_t *d, int len, bool mf, int e);
|
|
typedef void (*mms_m_file_op_cb)(int fd, const char *fn, int e);
|
|
typedef void (*mms_m_server_cb)(int fd, const char *vendor, const char *model, const char *rev, int log_st, int phy_st, int e);
|
|
typedef void (*mms_m_sg_cb)(int fd, const char *ld, int act_sg, int num_sg, int e);
|
|
|
|
int mms_m_read_file(int fd, const char *rf, mms_m_file_read_cb cb);
|
|
int mms_m_delete_file(int fd, const char *rf, mms_m_file_op_cb cb);
|
|
int mms_m_query_server(int fd, mms_m_server_cb cb);
|
|
int mms_m_read_sg_info(int fd, const char *ld, mms_m_sg_cb cb);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|