You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

285 lines
10 KiB
C

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef __PD_HF_H__
#define __PD_HF_H__
#ifdef CFG_DEV_TYPE_LAND_PD
/* Includes ------------------------------------------------------------------*/
#include "pd_dau.h"
#define HF_DATA_LEN (1300)
/*趋势上送数据报文头c语言定义*/
enum HF_TREND_TYPE
{
HF_TREND_TYPE_PRPD = 0, // 累计PRPD
HF_TREND_TYPE_ORIG, // 原始波形
HF_TREND_TYPE_PRPS, // 后10秒PRPS
HF_TREND_TYPE_STAT, // 统计数据
HF_TREND_TYPE_MAX,
};
/* 点位数据 */
typedef struct
{
uint16_t index; // 点位
int16_t data; // 数据
} hf_data_point_t;
/* 一般应答 */
typedef struct
{
uint8_t result; // 应答结果. 0:失败 1:成功
uint8_t slot; // slot id
uint8_t reserved[2]; // 保留
} hf_ack_t;
/* 设备信息 */
typedef struct
{
uint8_t type_m; // 主设备号
uint8_t type_s; // 次设备号
uint8_t reserved1[2]; // 保留
uint32_t dev_id; // 设备ID
char hostname[FILE_NAME_LEN]; // 设备名 128byte
uint32_t factory_date; // 出厂日期.
uint32_t deployment_date; // 部署日期.
uint8_t app_version[DEV_VERSION_STR_LEN]; // 软件版本
uint8_t app_compile_time[DEV_VERSION_STR_LEN]; // 软件编译时间
uint8_t hardware_version[DEV_VERSION_STR_LEN]; // 硬件版本
uint8_t FPGA_version[DEV_VERSION_STR_LEN]; // fpga版本
uint32_t ip; // 本机 IP.
uint32_t mask; // 本机 MASK.
uint32_t gw; // 本机网关
uint8_t mac[6]; // MAC地址.
uint16_t server_port; // 服务器端口号.
uint32_t server_ipv4; // 服务器 IP.
} hf_dev_info_t;
/* 心跳报文. */
typedef struct
{
float freq; // 实测同步源工频频率.
uint8_t dau_state[4]; // 采集模块的状态.
uint8_t out_sync; // 外接调频同步 1: 有效 0: 无效.
uint8_t pt_sync; // PT同步 1: 有效 0: 无效.
uint8_t in_sync; // 内同步 1: 有效 0: 无效.
uint8_t reserved1; // 预留 字节对齐.
uint8_t port_link_alarm[PD_PORT_SUM]; // 通道传感器连接状态 断线告警.
uint8_t dau_port_num[4]; // 采集板端口数量.
} hf_heartbeat_t;
/* 全局配置 */
typedef struct
{
uint16_t power_frequency; // 工频频率, 单位: 0.1Hz
uint16_t trend_period; // 趋势数据上送周期, 单位: 秒.
uint8_t sync_mode; // 同步方式 1: PT 同步 2: 内同步(默认) 3: 外接信号同步.
uint8_t heartbeat_period; // 心跳包周期, 单位: 分钟.
uint8_t pps_mode; // pps 主从模式 PD_PPS_XXX.
uint8_t protocol_type; // 0:朗德协议 1:南网协议
uint16_t trend_storage; // 趋势存储文件数量阈值
uint16_t event_storage; // 事件存储文件数量阈值
} hf_cfg_t;
/* 端口配置 */
typedef struct
{
uint8_t vport; // 通道编号.
uint8_t port_type; // 采集通道类型 , 1 表示特高频局放 2 表示超声局放 3 表示 TEV 4 表示高频.
uint8_t filter; // 滤波器类型 1: 低频段 2: 全频段 3: 窄频段 4: 高频段
uint8_t sensor_type; // 0: 无配置; 1: UHF信号传感器; 2: UHF噪声传感器 ; 3: UHF信号传感器, 关联噪声降噪.
uint8_t is_auto_noise; // 是否自动调整降噪等级.
uint8_t denoise_type; // 0-无配置 1-自动 2-手动降噪
uint16_t denoise_variance; // 方差降噪系数, 单位: 1%
uint32_t event_counter_h; // 事件次数阀值高.
uint16_t event_sec_h; // 事件每秒次数阀值高.
uint16_t event_thr_h; // 事件值阈值高.
uint32_t event_counter_thr_h; // 事件值阈值高的次数.
uint32_t event_counter_l; // 事件次数阀值低.
uint16_t event_sec_l; // 事件每秒次数阀值低.
uint16_t event_thr_l; // 事件值阈值低.
uint32_t event_counter_thr_l; // 事件值阈值低的次数.
uint8_t burst_time; // 事件突发计算时间
uint8_t reserved1[1];
uint16_t burst_thr; // 事件突发阈值
int16_t denoise_manual; // 手动底噪等级
int16_t denoise_auto; // 自动降噪水平
} hf_cfg_port_t;
/* 端口配置回复 */
typedef struct
{
uint8_t vport; // 通道编号.
uint8_t result; // 应答结果. 0:失败 1:成功
uint8_t slot; // slot id
uint8_t reserved[1]; // 保留
} hf_cfg_port_ack_t;
/* 实时图谱关注 */
typedef struct
{
uint8_t vport; // 通道编号 1 ~ 8
uint8_t is_concern; // 关注 1: 关注 0: 取消关注
uint8_t filter; // 滤波器类型
uint8_t denoise_correlation; // 关联降噪 1: 关联噪声去噪
uint8_t denoise_type; // 0-无配置 1-自动 2-手动降噪
uint8_t reserved[1];
uint16_t denoise_manual; // 手动降噪等级
} hf_prps_get_t;
/* 实时图谱报文头 */
typedef struct
{
uint16_t index; // 每10包传完之后自动自加用于区分当前包结束.
uint8_t pkt_sum; // 总包数 10.
uint8_t pkt_index; // 当前包数 0 ~ 9.
uint16_t fre_cnt; // 工频周期计数.
uint8_t vport; // 通道编号.
uint8_t reserved1[1];
int16_t max;
int16_t avg;
uint32_t cnt;
uint32_t utc;
float freq; // 频率.
uint32_t len;
} hf_prps_head_t;
/* 实时图谱结构体 */
typedef struct
{
hf_prps_head_t head;
int16_t prps[PD_PRPS_NUM_MAX]; // 1s prps 降噪数据.
} hf_prps_t;
/* 趋势头 */
typedef struct
{
uint16_t index; // 包索引
uint16_t sum; // 总包数
uint8_t type; // 数据类型 0prpd 1:原始波形 210秒prps 3:统计数据
uint8_t vport; // 通道号
uint8_t boosterpack; // 是否补包 0否 1
uint8_t reserved[1]; // 保留
uint32_t identifier; // 数据编号
uint32_t utc; // 同步时间
uint32_t len; // 当前包长度
} hf_trend_head_t;
/* 趋势应答 */
typedef struct
{
uint32_t index;
uint8_t result;
uint8_t boosterpack; // 是否补包 0:否 1:是
uint8_t reserve[2];
} hf_trend_ack_t;
/* 趋势统计 */
typedef struct
{
uint16_t data_cnt; // 数据计数
int16_t max; // 通道的最大值
uint16_t reserved; // 保留
uint16_t avg; // 通道的平均值
uint32_t cnt; // 通道的计数值
uint32_t phase; // 放电相位
uint32_t noise; // 趋势数据中的底噪值: 单位 dBm
uint32_t event_cnt; // 趋势数据中的的事件数量记录
} hf_trend_stat;
/* 趋势统计结构体 */
typedef struct
{
uint32_t index; // 数据编号: 0 - (2^32-1) 循环.
uint32_t utc; // UTC 时标.
hf_trend_stat port[PD_DAU_PORT_SUM]; // 通道 0 - 15 的计算及测量数据.
} hf_trend_col_t;
/* 趋势 PRPD 结构体 */
typedef struct
{
uint16_t data[PD_PHASE_NUM][PD_VAULE_NUM];
} hf_trend_prpd_port_t;
/* 趋势 PRPD 结构体 */
typedef struct
{
pd_trend_prpd_port_t port[PD_DAU_PORT_SUM];
} hf_trend_prpd_t;
/* 趋势 PRPS 结构体 */
typedef struct
{
uint32_t point_cnt; // 数据累计点数.
hf_data_point_t point[PD_TREND_POINT_MAX];
} hf_trend_prps_port_t;
/* 趋势 PRPS 结构体 */
typedef struct
{
hf_trend_prps_port_t port[PD_DAU_PORT_SUM];
} hf_trend_prps_t;
/* 高频趋势数据 */
typedef struct
{
hf_trend_col_t col;
hf_trend_prpd_t prpd;
hf_trend_prps_t prps;
} hf_trend_t;
/* 事件头 */
typedef struct
{
uint16_t index; // 包索引
uint16_t sum; // 总包数
uint8_t vport; // 通道号
uint8_t boosterpack; // 是否补包 0否 1
int16_t max; // 通道的最大值.
uint32_t power_fre; // 工频周期.
uint8_t type; // 事件类型.
uint8_t reserved[3]; // 保留
uint32_t identifier; // 数据编号: 0 - (2^32-1) 循环.
uint32_t utc; // UTC 时标.
uint32_t cnt; // 通道每秒脉冲计数值.
uint16_t avg_o; // 通道原始信号 (降噪前) 的平均值.
uint16_t avg; // 脉冲平均值.
uint32_t point_cnt; // 数据累计点数
uint32_t len; // 当前包长度
} hf_event_head_t;
/* 事件应答 */
typedef struct
{
uint32_t index;
uint8_t result;
uint8_t boosterpack; // 是否补包 0: 否 1: 是
uint8_t reserve[2];
} hf_event_ack_t;
/* 高频事件数据 */
typedef struct
{
hf_event_head_t head;
hf_data_point_t point[PD_EVENT_POINT_MAX];
} hf_event_t;
/* 高频私有数据 */
typedef struct
{
hf_heartbeat_t run_status;
hf_event_t event;
hf_prps_t *prps;
hf_trend_t trend;
} hf_data_t;
extern int32_t hf_recv_process(uint8_t slot, char *pkt, uint16_t len);
extern int32_t hf_send_process(uint8_t slot, uint8_t type, void *data);
extern void* hf_data_malloc(void);
#endif
#endif