2025-04-30 16:24:29 +08:00

120 lines
3.3 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/****************************************************************************
文件名: smvapi.h
----------------------------------------------------------------------------
描述 : smvapi.c头文件
----------------------------------------------------------------------------
修改日志 :
日期 姓名 操作
----------------------------------------------------------------------------
2011-04-15 陈云洲 创建
****************************************************************************/
#ifndef _SMVAPI_H_
#define _SMVAPI_H_
#include "gse_clnp.h"
#include "gse_asn1.h"
#ifdef __cplusplus
extern "C" {
#endif
//数据类型长度见9-2表14
#define SV2_MAX_VSTRING_LEN 35
#define SV2_MAX_OBJREF_LEN 64
#define SV2_MAX_SVID_LEN 34
#define SV2_MAX_ASDU_NUM 10 //最大支持一个apdu中包含10个asdu
/**
* smv9-2初始化信息
*/
typedef struct
{
ST_INT eth_index;
ST_INT timeout;
ST_UINT16 appid;
ST_CHAR svID[SV2_MAX_SVID_LEN+1]; /**< svID用于区分采样值配置 */
}GSV_SV2RECV_INI;
typedef struct
{
ST_UINT16 smpCnt; /**< 采样值计数器 */
ST_UINT32 confRev; /**< 配置改变计数器 */
ST_UCHAR smpSynch; /**< 有0、1、2三个值,见9-2le7.2.2 */
ST_UCHAR *ds_buf; /**< 数据集缓冲区指针数组,格式见9-2le figure5 */
ST_INT buf_len; /**< ds_buf的长度 */
}SV2_ASDU_VAL;
typedef struct
{
ST_UCHAR *apdu;
ASN_1_UNIT smpCnt;
ASN_1_UNIT confRev;
ASN_1_UNIT smpSynch;
ASN_1_UNIT ds_buf;
ASN_1_UNIT svId;
}SV2_ASDU_AU;
typedef struct
{
char daRef[SV2_MAX_OBJREF_LEN+1];
char outVarName[SV2_MAX_OBJREF_LEN+1];
int entryIndex; //在数据集中的相对位置从1开始
int userIndex; //用户编号
float rating; //额定值,新增 2012-03-30
} SV2_ASDU_USER;
/**
* smv9-2控制结构用于保存收到的数据
*/
typedef struct
{
ST_INT eth_index; /**< 网卡序号 */
ST_UINT16 appid;
ST_UINT16 reserved1;
ST_UINT16 reserved2;
ST_CHAR svId[SV2_MAX_SVID_LEN+1];
SV2_ASDU_VAL *asdu_vals;
SV2_ASDU_AU *val_asdu_au;
ST_UINT8 asdu_num; /**< apdu中asdu的个数 */
ST_UINT16 apdu_len; /**< 用于判断报文或asdu个数是否变化 */
SV2_ASDU_USER *asdu_user; //hsj add 2012-03-27
int entryNumAct; //数据集中实际用到的数据个数,即上面指针数组长度
int entryNumDataset; //数据集中总个数
int delayPoint; //合并单元发送,延迟点数
int ctrlIndex; //控制块编号从0开始 add 2012-05-10
}GSV_SV2RECV_CTRL;
/**
* 由用户定义的回调收到9-2数据解析后调用将解析后的数据回传给用户用户从
* sv2_ctrl中的ds_buffs中取值
*/
typedef ST_VOID (*U_SMV2RECV_CALLBACK)(GSV_SV2RECV_CTRL *sv2_ctrl, ST_INT svIndex, ST_INT svNum, unsigned int recvTime );
ST_VOID smvapi_parse(const ST_UCHAR *msg, ST_INT msg_len, ST_INT svIndex, ST_INT svNum, unsigned int recvTime );
ST_VOID smvapi_recved_smv92(ST_UCHAR *buf, ST_INT svIndex, ST_INT svNum, unsigned int recvTime );
/** 初始化SMV采样值控制块在61850系统启动的时候会调用本函数*/
GSV_SV2RECV_INI * protect_get_smv_ini( unsigned int *smv92_recv_ini_num );
#if 1
int smvapi_release( void );
int smvapi_init( U_SMV2RECV_CALLBACK u_callback );
#endif
#ifdef __cplusplus
}
#endif
#endif