|
|
/*****************************************************************************
|
|
|
* file include/pd_main.h
|
|
|
* author YuLiang
|
|
|
* version 1.0.0
|
|
|
* date 07-Feb-2023
|
|
|
* brief This file provides all the headers of the partial discharge functions.
|
|
|
******************************************************************************
|
|
|
* Attention
|
|
|
*
|
|
|
* <h2><center>© COPYRIGHT(c) 2021 LandPower</center></h2>
|
|
|
*
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
* and/or other materials provided with the distribution.
|
|
|
* 3. Neither the name of LandPower nor the names of its contributors may be used to
|
|
|
* endorse or promote products derived from this software without specific
|
|
|
* prior written permission.
|
|
|
*
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
*
|
|
|
******************************************************************************/
|
|
|
|
|
|
#ifndef __PD_MAIN_H__
|
|
|
#define __PD_MAIN_H__
|
|
|
|
|
|
#ifdef CFG_DEV_TYPE_LAND_PD
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
|
#include "cmd.h"
|
|
|
|
|
|
/* Define --------------------------------------------------------------------*/
|
|
|
#define PD_DAU_SUM 2
|
|
|
#define PD_DAU_PORT_SUM 8
|
|
|
#define PD_PORT_SUM 16
|
|
|
#define PD_PORT_PROMPT_LEN 64 // DAU 端口节点前标长度.
|
|
|
|
|
|
#define PD_DEV_NUM_LEN 16
|
|
|
#define PD_DEV_TYPE_LEN 8
|
|
|
|
|
|
#define PD_POWER_FRE 50
|
|
|
#define PD_PHASE_NUM 128
|
|
|
#define PD_PRPS_NUM 6400
|
|
|
#define PD_PRPS_DATA_LEN 12800
|
|
|
|
|
|
#define PD_GIS_MIN_VALUE (-800) // 特高频局放的采集数值下限 -800 (-80.0dBm).
|
|
|
|
|
|
#define DEBUG_DAU_FILE "PDMonitor_DAU"
|
|
|
#define UPGRADE_SOFTWARE "upgrade.sw"
|
|
|
|
|
|
/* Exported types ------------------------------------------------------------*/
|
|
|
/* 用于命令行模式节点注册配置保存函数 */
|
|
|
typedef int pd_port_cmd_save_config_f(vty_t*, uint8_t, uint8_t);
|
|
|
|
|
|
/* 向服务器发送消息的类型. */
|
|
|
typedef enum
|
|
|
{
|
|
|
PD_SEND_TYPE_PRPS = 1,
|
|
|
PD_SEND_TYPE_TREND,
|
|
|
PD_SEND_TYPE_EVENT,
|
|
|
PD_SEND_TYPE_COUNT
|
|
|
} PD_SEND_TYPE_E;
|
|
|
|
|
|
/* 端口类型. */
|
|
|
typedef enum
|
|
|
{
|
|
|
PD_PORT_TYPE_UHF = 1,
|
|
|
PD_PORT_TYPE_AE,
|
|
|
PD_PORT_TYPE_TEV,
|
|
|
PD_PORT_TYPE_HF,
|
|
|
PD_PORT_TYPE_COUNT
|
|
|
} PD_PORT_TYPE_E;
|
|
|
|
|
|
/* 设备配置的主备类型. */
|
|
|
typedef enum
|
|
|
{
|
|
|
PD_DAU_MODE_AUTO = 0,
|
|
|
PD_DAU_MODE_MASTER,
|
|
|
PD_DAU_MODE_SLAVE,
|
|
|
PD_DAU_MODE_COUNT
|
|
|
} PD_DAU_MODE_E;
|
|
|
|
|
|
/* 设备配置的滤波类型. */
|
|
|
typedef enum
|
|
|
{
|
|
|
PD_FILTER_TYPE_HF = 3,
|
|
|
PD_FILTER_TYPE_LF = 6,
|
|
|
PD_FILTER_TYPE_FR = 9,
|
|
|
PD_FILTER_TYPE_FF = 12
|
|
|
} PD_FILTER_TYPE_E;
|
|
|
|
|
|
/* 端口类型. */
|
|
|
typedef enum
|
|
|
{
|
|
|
PD_SEN_TYPE_NONE = 0,
|
|
|
PD_SEN_TYPE_SIG,
|
|
|
PD_SEN_TYPE_NOISE,
|
|
|
PD_SEN_TYPE_SIG_NOISE,
|
|
|
PD_SEN_TYPE_COUNT
|
|
|
} PD_SEN_TYPE_E;
|
|
|
|
|
|
/* 设备配置的滤波类型. */
|
|
|
typedef enum
|
|
|
{
|
|
|
PD_SYNC_PT = 1,
|
|
|
PD_SYNC_POWER = 2,
|
|
|
PD_SYNC_OUTSIDE = 4,
|
|
|
} PD_SYNC_MODE_E;
|
|
|
|
|
|
/* 端口节点配置优先级 */
|
|
|
typedef enum
|
|
|
{
|
|
|
PD_PORT_CMD_PRI_DAU = 0,
|
|
|
PD_PORT_CMD_PRI_COUNT
|
|
|
} PD_PORT_CMD_PRI_E;
|
|
|
|
|
|
/* 1s prps 数据结构体. */
|
|
|
typedef struct {
|
|
|
int16_t avg_o; // 通道原始信号 (降噪前) 的平均值.
|
|
|
int16_t max; // 通道的最大值.
|
|
|
int16_t avg; // 通道的平均值.
|
|
|
uint32_t cnt; // 通道的计数值.
|
|
|
int32_t phase_sum[PD_PHASE_NUM]; // 通道的周波放电相位累加值.
|
|
|
int16_t phase_max[PD_PHASE_NUM]; // 通道的周波相位最大值.
|
|
|
int16_t phase_avg[PD_PHASE_NUM]; // 通道的周波相位平均值.
|
|
|
uint16_t phase_cnt[PD_PHASE_NUM]; // 通道的周波相位计数值 .
|
|
|
int16_t data[PD_PRPS_NUM]; // 通道数据.
|
|
|
uint8_t is_valid; // prps 数据是否有效.
|
|
|
} pd_prps_data_t;
|
|
|
|
|
|
typedef struct {
|
|
|
uint32_t index; // 数据编号.
|
|
|
uint32_t utc; // UTC 时标.
|
|
|
uint32_t is_denoise; // 是否降噪的标记: 1-已经降噪 0-原始没有降噪.
|
|
|
void *reserve; // 与 GIS5.0 设备的结构体同步.
|
|
|
pd_prps_data_t data[PD_DAU_SUM][PD_DAU_PORT_SUM]; // 16 个通道的数据.
|
|
|
} pd_prps_t;
|
|
|
|
|
|
typedef struct {
|
|
|
uint32_t index; // 数据编号: 0 - (2^32-1) 循环.
|
|
|
uint32_t utc; // UTC 时标.
|
|
|
|
|
|
uint8_t vport; // 通道编号.
|
|
|
uint8_t level; // 事件等级.
|
|
|
uint8_t type; // 放电类型识别结果: 每种放电类型的比较的概率.
|
|
|
uint8_t second; // 当前事件记录的时间秒数.
|
|
|
|
|
|
int16_t max; // 通道的最大值.
|
|
|
int32_t avg; // 通道的平均值.
|
|
|
int32_t cnt; // 通道的计数值.
|
|
|
float type_per[8]; // 放电类型识别结果.
|
|
|
|
|
|
uint16_t PositionEfficiency; // 定位信息: 有效性 0: 无效 1:有效.
|
|
|
uint16_t PositionOtherChNum; // 定位信息: 对端传感器通道号 范围 [1-16].
|
|
|
uint32_t PositionDistance; // 定位信息: 距离本传感器的距离.
|
|
|
uint32_t RatioOutValue; // 定位信息: 实际比率 配对上 / 超过阀值的计数.
|
|
|
|
|
|
int32_t phase_sum[PD_PHASE_NUM]; // 通道的周波相位累加值.
|
|
|
int16_t phase_max[PD_PHASE_NUM]; // 通道的周波相位最大值.
|
|
|
int16_t phase_avg[PD_PHASE_NUM]; // 通道的周波相位平均值.
|
|
|
int32_t phase_cnt[PD_PHASE_NUM]; // 通道的周波相位计数值.
|
|
|
|
|
|
int16_t data[PD_PRPS_NUM]; // 通道 n 的测量数据.
|
|
|
} pd_event_t;
|
|
|
|
|
|
typedef struct {
|
|
|
int16_t max; // 通道的最大值.
|
|
|
int64_t avg; // 通道的平均值.
|
|
|
int32_t cnt; // 通道的计数值.
|
|
|
float phase; // 放电相位 .
|
|
|
float noise; // 趋势数据中的底噪值: 单位 dBm .
|
|
|
uint32_t event_cnt; // 趋势数据中的的事件数量记录.
|
|
|
int64_t phase_sum[PD_PHASE_NUM]; // 通道的周波放电相位累加值.
|
|
|
int16_t phase_max[PD_PHASE_NUM]; // 通道的周波相位最大值.
|
|
|
int16_t phase_avg[PD_PHASE_NUM]; // 通道的周波相位平均值.
|
|
|
int32_t phase_cnt[PD_PHASE_NUM]; // 通道的周波相位计数值.
|
|
|
} pd_trend_data_t;
|
|
|
|
|
|
typedef struct {
|
|
|
uint32_t index; // 数据编号: 0 - (2^32-1) 循环.
|
|
|
uint32_t utc; // UTC 时标.
|
|
|
pd_trend_data_t data[PD_DAU_SUM][PD_DAU_PORT_SUM]; // 通道 0 - 15 的计算及测量数据.
|
|
|
} pd_trend_t;
|
|
|
|
|
|
typedef struct {
|
|
|
pd_prps_t *denoise; // PRPS 数据指针.
|
|
|
pd_prps_t real; // 实时数据指针.
|
|
|
pd_event_t event[PD_DAU_SUM][PD_DAU_PORT_SUM]; // 端口事件指针.
|
|
|
pd_trend_t trend; // 趋势数据.
|
|
|
} pd_data_t;
|
|
|
|
|
|
typedef struct {
|
|
|
uint32_t type;
|
|
|
void *data;
|
|
|
} pd_csg_msg_t;
|
|
|
|
|
|
typedef struct {
|
|
|
uint8_t vport; // 通道编号.
|
|
|
uint8_t filter; // 滤波器类型 1: 低频段 2: 全频段 3: 窄频段 4: 高频段
|
|
|
uint8_t sensor_type; // 0: 无配置; 1: UHF信号传感器; 2: UHF噪声传感器 ; 3: UHF信号传感器, 关联噪声降噪.
|
|
|
uint8_t phase_sequence; // 对应相序 1A 2B 3C.
|
|
|
|
|
|
uint16_t NearSensor1_Number; //关联监测点1
|
|
|
uint16_t NearSensor1_Distance; //与监测点1距离
|
|
|
uint16_t Signal1_AttenuationRatio; //衰减 dBm/m 20200717
|
|
|
uint16_t NearSensor2_Number; //关联监测点2
|
|
|
|
|
|
uint16_t NearSensor2_Distance; //与监测点2距离
|
|
|
uint16_t Signal2_AttenuationRatio; //衰减 dBm/m 20200717
|
|
|
uint16_t NearSensor3_Number; //关联监测点3
|
|
|
uint16_t NearSensor3_Distance; //与监测点3距离
|
|
|
|
|
|
uint16_t Signal3_AttenuationRatio; //衰减 dBm/m 20200717
|
|
|
uint16_t NearSensor4_Number; //关联监测点4
|
|
|
uint16_t NearSensor4_Distance; //与监测点4距离
|
|
|
uint16_t Signal4_AttenuationRatio; //衰减 dBm/m 20200717
|
|
|
|
|
|
int16_t event_threshold; // 事件触发阀值 0.1dBm.
|
|
|
uint16_t event_counter; // 事件次数阀值.
|
|
|
int16_t env_noise; // 环境底噪, 单位: dBm 0~100 100-自动降噪.
|
|
|
int16_t noise_reduction; // 降噪水平, 单位: 0.1dBm.
|
|
|
|
|
|
int16_t UpperLimitOfDischargeAmplitude; //放电幅值上限 未使用
|
|
|
int16_t WaveTriggerThreshold; //波形触发阀值 (-32768~32768)
|
|
|
uint16_t PrescalerSampleValue; //通道采样抽点数值 未使用
|
|
|
uint16_t reserved1;
|
|
|
|
|
|
uint32_t SamplePointsTotalTriggered; //脉冲波形一次完整记录的采样点数 未使用
|
|
|
uint32_t RecordStartAdr; //波形记录:本通道的SDR/DDR的缓冲区起始地址 未使用
|
|
|
uint32_t RecordStopAdr; //波形记录:本通道的SDR/DDR的缓冲区结束地址 未使用
|
|
|
uint32_t sample_rate; //数据采样频率 Hz
|
|
|
uint32_t BeforeTriggerTime; //触发前采样时间 10ns
|
|
|
uint32_t AfterTriggerTime; //触发后采样时间 10ns
|
|
|
uint32_t storage_event; //事件存储文件数量阈值
|
|
|
uint32_t storage_wave; //波形存储文件数量阈值
|
|
|
uint8_t reserved[4]; //预留
|
|
|
}pd_port_config_old_t;
|
|
|
|
|
|
typedef struct{
|
|
|
uint8_t power_frequency; // 工频频率 未使用
|
|
|
uint8_t sync_mode; // 同步方式 1: PT 同步 2: 电源同步(默认) 4: 外接信号同步.
|
|
|
uint8_t TimingSyncMode; // 对时方式 1:网卡对时 2:GPS对时 4:外部对时 8:FPGA内部对时
|
|
|
uint8_t real_period; // 定时数据上送周期, 单位: 分钟.
|
|
|
uint8_t trend_period; // 趋势数据上送周期, 单位: 分钟.
|
|
|
uint8_t heartbeat_period; // 心跳包周期.
|
|
|
uint16_t NumberWindowsOfPhase; // 相位窗数 //未使用
|
|
|
uint32_t SyncTime; // 对时数据 //未使用
|
|
|
uint16_t AlarmPeriod; // 报警观察周期 //未使用
|
|
|
uint16_t TimePrpsStrategy; // 定时数据存储策略 0 全部存储 1 未上传存储.
|
|
|
uint32_t storage_trend; // 趋势存储文件数量阈值.
|
|
|
uint32_t StorageAlarm; // 告警存储文件数量阈值.
|
|
|
uint32_t StorageRun; // 运行状态存储文件数量阈值.
|
|
|
uint32_t storage_real; // 定时PRPS存储文件数量阈值.
|
|
|
uint32_t limit_event_time; // 事件频繁判断时间.
|
|
|
uint32_t limit_event_cnt; // 事件频繁判断个数.
|
|
|
uint32_t limit_event_interval; // 事件频繁后存储间隔.
|
|
|
uint32_t is_prps_save; // 实时PRPS存储使能.
|
|
|
uint8_t Reserved[52]; // 预留 .
|
|
|
}pd_config_old_t;
|
|
|
|
|
|
/* 局放配置. */
|
|
|
typedef struct {
|
|
|
pd_port_config_old_t config; // 为了兼容原先的协议.
|
|
|
uint8_t is_concern; // 是否被关注, 在实时波形中使用..
|
|
|
uint8_t r_noise_reduction; // 是否启动关联降噪, 在实时波形中使用..
|
|
|
uint8_t auto_noise_reduction; // 是否自动降噪, 在实时波形中使用..
|
|
|
uint8_t manual_noise_reduction; // 手动降噪, 单位: 0.1dBm, 在实时波形中使用..
|
|
|
uint8_t filter_cfg; // 端口配置的滤波类型, 在实时波形中使用.
|
|
|
} pd_port_config_t;
|
|
|
|
|
|
typedef struct{
|
|
|
uint8_t dev_num[PD_DEV_NUM_LEN]; // 设备编号.
|
|
|
uint8_t dev_type[PD_DEV_TYPE_LEN]; // 设备型号.
|
|
|
uint32_t factory_date; // 出厂日期.
|
|
|
uint32_t deployment_date; // 部署日期.
|
|
|
uint32_t ipv4; // 本机 IP.
|
|
|
uint8_t ipv6[16]; // 预留 IPV6 , 未使用.
|
|
|
uint8_t mac[MAC_ADDR_LEN]; // MAC地址.
|
|
|
uint8_t LocalIP2[4]; // 本机 IP, 未使用.
|
|
|
uint8_t LocalIP2_V6[16]; // 预留 IPV6 , 未使用.
|
|
|
uint8_t LocalMacAddress2[6]; // MAC 地址, 未使用.
|
|
|
uint32_t server_ipv4; // 服务器 IP.
|
|
|
uint8_t server_ipv6[16]; // 预留 IPV6, 未使用.
|
|
|
uint8_t ServerIP2[4]; // 服务器 IP, 未使用.
|
|
|
uint8_t ServerIP2_V6[16]; // 预留 IPV6 , 未使用.
|
|
|
uint16_t server_port; // 服务器端口号.
|
|
|
uint16_t ServerIP2_Port; // 服务器端口号, 未使用.
|
|
|
uint8_t port_type[PD_PORT_SUM]; // 采集通道类型 , 1 表示特高频局放 2 表示超声局放 3 表示 TEV 4 表示高频.
|
|
|
uint8_t Reserved[12]; // 预留.
|
|
|
uint32_t runTime; // 运行时间, 未使用.
|
|
|
uint32_t devVoltage; // 设备电压, 未使用.
|
|
|
uint32_t devTemperature; // 设备温度, 未使用.
|
|
|
uint32_t devSleepTime; // 设备休眠时长, 未使用.
|
|
|
uint32_t devPasswd; // 设备密码, 未使用.
|
|
|
uint8_t batteryVoltage; // 电池电压, 未使用.
|
|
|
uint8_t linkStatus; // 通讯状态, 未使用.
|
|
|
}pd_factory_old_t;
|
|
|
|
|
|
typedef struct {
|
|
|
pd_factory_old_t factory;
|
|
|
pd_config_old_t config;
|
|
|
pd_port_config_t port_config[PD_DAU_SUM][PD_DAU_PORT_SUM]; // 端口配置.
|
|
|
uint32_t concern_bitmap;
|
|
|
} pd_config_t;
|
|
|
|
|
|
typedef struct {
|
|
|
uint8_t sync;
|
|
|
} pd_state_t;
|
|
|
|
|
|
/* Exported macro ------------------------------------------------------------*/
|
|
|
|
|
|
/* Extern global variables ---------------------------------------------------*/
|
|
|
extern pd_data_t pd_data;
|
|
|
extern pd_config_t pd_config;
|
|
|
extern pd_state_t pd_state;
|
|
|
extern cmd_node_t pd_port_node;
|
|
|
|
|
|
/* Extern functions ----------------------------------------------------------*/
|
|
|
extern int32_t pd_main(void);
|
|
|
extern int32_t pd_port_cmd_config_register(int32_t pri, pd_port_cmd_save_config_f *func);
|
|
|
extern void pd_sync_mode_set(void);
|
|
|
extern void pd_sync_state_get(void);
|
|
|
extern void pd_wdg_clr(void);
|
|
|
extern void pd_prps_show(void);
|
|
|
extern void pd_show(void);
|
|
|
#endif
|
|
|
#endif
|
|
|
/************************ (C) COPYRIGHT LandPower ***** END OF FILE ****/
|