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.

800 lines
35 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 __CA_MAIN_H__
#define __CA_MAIN_H__
#ifdef CFG_DEV_TYPE_LAND_CA
/* Includes ------------------------------------------------------------------*/
#include "cmd.h"
/* Define --------------------------------------------------------------------*/
typedef unsigned char U8;
typedef unsigned short U16;
typedef unsigned int U32;
typedef unsigned long long int U64;
typedef char I8; // 8-bit
typedef short I16; // 16-bit
typedef int I32; // 32-bit
typedef long long int I64; // 64-bit
typedef float F32;
typedef double D64;
typedef long double LD64;
#define CA_CHANNEL_NUM 8
#define MAX_CAU_CHANNEL (8)
#define PORT_MAX_COUNT (30) //最大端口数量
#define ENV_CH_COUNT (7)//环境变量设备数量
#define DEV_MAX_COUNT (12) //最大设备数量
#define STR_BUF_LEN (32) //字符串长度
#define CONFIG_FILE "/home/Cable/config.json"
#define BACK_CONFIG_FILE "/home/root/config.json"
#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 HARDWARE_VERSON "GIS6.0"
#define SHIQUCHA (57600) //16*3600
#define ON 1
#define OFF 0
#define CSG_SERVER_ADDRESS_DEFAULT "106.13.28.133"
#define CSG_SERVER_PORT_DEFAULT 1883
#define CSG_DEVICE_ID_DEFAULT "LD40110058"
#define CSG_USER_NAME_DEFAULT "60E2CEEF393B45ADA76F3030B9FE5590"
#define CSG_PASSWORD_DEFAULT "D40110058aaaaaaaaaaa"
#define CSG_CLIENT_ID_DEFAULT "D73873598291bInxP"
#define CSG_SERVICE_ID_DEFAULT "currentData"
#define CSG_KEEP_LIVE_TIME_DEFAULT (120)
/* 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_POINT,
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;
/* 设备配置的 PPS 同步模式. */
typedef enum
{
PD_PPS_AUTO = 0,
PD_PPS_MASTER,
PD_PPS_SLAVE,
} PD_PPS_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]; // 通道数据.
} 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 {
uint16_t index; // 点位.
int16_t data; // 数据.
} pd_data_point_t;
/* 1s prps 数据结构体. */
typedef struct {
int16_t max; // 通道的最大值.
int16_t avg_o; // 通道原始信号 (降噪前) 的平均值.
int16_t avg; // 通道的平均值.
int16_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]; // 通道的周波相位计数值 .
pd_data_point_t point[PD_PRPS_NUM]; // 通道数据.
uint8_t is_event; // 是否产生事件.
uint8_t is_timing; // 是否产生定时数据.
} pd_prps_data_point_t;
typedef struct {
uint32_t index; // 数据编号.
uint32_t utc; // UTC 时标.
pd_prps_data_point_t data[PD_DAU_SUM][PD_DAU_PORT_SUM]; // 16 个通道的数据.
} pd_prps_point_t;
typedef struct {
uint8_t vport; // 通道编号.
uint8_t reserved[3]; // 预留.
uint32_t index; // 数据编号: 0 - (2^32-1) 循环.
uint32_t utc; // UTC 时标.
int16_t max; // 通道的最大值.
int16_t avg_o; // 通道原始信号 (降噪前) 的平均值.
int16_t avg; // 通道的平均值.
int16_t cnt; // 通道的计数值.
} 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_point_t *real; // 实时数据指针.
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 filter_cfg; // 端口配置的滤波类型, 在实时波形中使用.
uint16_t manual_noise_reduction; // 手动降噪, 单位: 0.1dBm, 在实时波形中使用.
uint8_t is_auto_noise; // 是否自动调整降噪等级.
} pd_port_config_t;
#pragma pack(1)
typedef struct{
uint32_t StartFlag1; //设备ID 0x40110304=ID=40110304
uint8_t FarmeType; //帧类型: 0x00 定时发送
uint32_t RunSecCnt; //系统运行时间 0x01020304=16909060秒
uint16_t Local_Vbat; //本机电池电压 0x1965= 6505/1000=6.501V
int16_t RoomIn_Temp; //本机温度 0x0C02=(3074/10)-273.1=34.3摄氏度
float RMS_Ia; //CH1:A相接地电流
float RMS_Ib; //CH2:B相接地电流
float RMS_Ic; //CH3:C相接地电流
float RMS_In; //CH4: [主缆电流]
float RMS_Ground; //CH5: [总接地电流]
float RMS_rIa; //CH6:A相运行电流
float RMS_rIb; //CH7:B相运行电流
float RMS_rIc; //CH8:C相运行电流
int16_t RoomOut_Temp; //环境温度 0x0C02=(3074/10)-273.1=34.3摄氏度
uint16_t I16A_Gx; //A相接头振动X轴 0x6655=26197-16000=10197mg
uint16_t I16A_Gy; //A相接头振动Y轴 0x6655=26197-16000=10197mg
uint16_t I16A_Gz; //A相接头振动Z轴 0x6655=26197-16000=10197mg
uint16_t I16A_Temp1; //A相电缆接头温度 0x0C02=(3074/10)-273.1=34.3摄氏度
uint16_t I16A_Temp2; //A相电缆表面温度 同上
uint16_t I16B_Gx; //B相接头振动X轴 0x6655=26197-16000=10197mg
uint16_t I16B_Gy; //B相接头振动Y轴 0x6655=26197-16000=10197mg
uint16_t I16B_Gz; //B相接头振动Z轴 0x6655=26197-16000=10197mg
uint16_t I16B_Temp1; //B相接头温度 0x0C02=(3074/10)-273.1=34.3摄氏度
uint16_t I16B_Temp2; //B相电缆表面温度 同上
uint16_t I16C_Gx; //C相接头振动X轴 0x6655=26197-16000=10197mg
uint16_t I16C_Gy; //C相接头振动Y轴 0x6655=26197-16000=10197mg
uint16_t I16C_Gz; //C相接头振动Z轴 0x6655=26197-16000=10197mg
uint16_t I16C_Temp1; //C相接头温度 0x0C02=(3074/10)-273.1=34.3摄氏度
uint16_t I16C_Temp2; //C相电缆表面温度 同上
uint8_t Status_AG; //A相姿态告警 0x01 告警 0x00正常 复归 故障
uint8_t Status_BG; //B相姿态告警 0x01 故障 0x00正常
uint8_t Status_CG; //C相姿态告警 0x01故障 0x00正常
uint8_t Status_A_OT; //A相温度超限告警 0x01故障 0x00正常
uint8_t Status_B_OT; //B相温度超限告警 0x01故障 0x00正常
uint8_t Status_C_OT; //C相温度超限告警 0x01故障 0x00正常
uint8_t Status_Bat; //电池电路硬件状态0x01故障 0x00正常
uint8_t Error_AT; //A相温度硬件状态 0x01故障 0x00正常
uint8_t Error_BT; //B相温度硬件状态 0x01故障 0x00正常
uint8_t Error_CT; //C相温度硬件状态 0x01故障 0x00正常
uint8_t Error_AG; //A相ADXL硬件状态 0x01故障 0x00正常
uint8_t Error_BG; //B相ADXL硬件状态 0x01故障 0x00正常
uint8_t Error_CG; //C相ADXL硬件状态 0x01故障 0x00正常
uint8_t Error_ROT; //环境温度硬件状态 0x01故障 0x00正常
uint16_t WaterLevel; //水位 0x20=32cm
uint16_t RoomOut_Humidity; //环境湿度 0x0321 = (801/10) = 80.1%
uint8_t Error_Humidity; //环境湿度硬件状态 1:告警0:正常
uint32_t Gas_O2; //氧气浓度 0x000100013= 0x0013=19 %VOL
uint32_t Gas_CH4; //甲烷浓度 同上
uint32_t Gas_H2s; //硫化氢浓度 同上
uint32_t Gas_CO; //一氧化碳浓度 同上
float RMS_Va; //A相电压
float RMS_Vb; //B相电压
float RMS_Vc; //C相电压
uint16_t reserve; //保留
uint16_t endFlag; //值0X0D 0X0A 结束符 “/r/n”
}RtdPack_t;//实时数据报文 128 Byte
typedef struct{
uint32_t StartFlag1; // 设备ID 0x40110304=ID=40110304
uint8_t FarmeType; //帧类型: 0x01 告警发送
uint32_t RunSecCnt; //系统运行时间 0x01020304=16909060秒
uint8_t WaveNum; //当前的录波物理编号:最新的文件 值:[0-127]
uint8_t RMS_Ig_Err; //总接地电流告 0x01 告警 0x00正常
uint16_t RMS_Ig_Before; //总接地电流变化前 0x0533=1331/10=133.1A
uint16_t RMS_Ig_After; //总接地电流变化后 0x0533=1331/10=133.1A
uint8_t RMS_Ia_Err; //A相电流告警 0x01 告警 0x00正常
uint16_t RMS_Ia_Before; //A相电流变化前 0x0533=1331/10=133.1A
uint16_t RMS_Ia_After; //A相电流变化后 0x0533=1331/10=133.1A
uint8_t Sanke_a_Err; //A相振动告警 0x01 告警 0x00正常
uint16_t Sanke_a_x; //A相X振动值
uint16_t Sanke_a_y; //A相Y振动值
uint16_t Sanke_a_z; //A相Z振动值
uint8_t Temper_a_Err; //A相温度告警 0x01 告警 0x00正常
uint8_t Temper_a_Change; //A相温度变化值 0x02 升高了2度
uint16_t Temper_a_Before; //A相温度前 0x0C02=(3074/10)-273.1=34.3摄氏度
uint16_t Temper_a_After; //A相温度后 0x0C02=(3074/10)-273.1=34.3摄氏度
uint8_t RMS_Ib_Err; //B相电流告警 0x01 告警 0x00正常
uint16_t RMS_Ib_Before; //B相电流变化前 0x0533=1331/10=133.1A
uint16_t RMS_Ib_After; //B相电流变化后 0x0533=1331/10=133.1A
uint8_t Sanke_b_Err; //B相振动告警 0x01 告警 0x00正常
uint16_t Sanke_b_x; //B相X振动值
uint16_t Sanke_b_y; //B相Y振动值
uint16_t Sanke_b_z; //B相Z振动值
uint8_t Temper_b_Err; //B相温度告警 0x01 告警 0x00正常
uint8_t Temper_b_Change; //B相温度变化值 0x02 升高了2度
uint16_t Temper_b_Before; //B相温度前 0x0C02=(3074/10)-273.1=34.3摄氏度
uint16_t Temper_b_After; //B相温度后 0x0C02=(3074/10)-273.1=34.3摄氏度
uint8_t RMS_Ic_Err; //C相电流告警 0x01 告警 0x00正常
uint16_t RMS_Ic_Before; //C相电流变化前 0x0533=1331/10=133.1A
uint16_t RMS_Ic_After; //C相电流变化后 0x0533=1331/10=133.1A
uint8_t Sanke_c_Err; //C相振动告警 0x01 告警 0x00正常
uint16_t Sanke_c_x; //C相X振动值
uint16_t Sanke_c_y; //C相Y振动值
uint16_t Sanke_c_z; //C相Z振动值
uint8_t Temper_c_Err; //C相温度告警 0x01 告警 0x00正常
uint8_t Temper_c_Change; //C相温度变化值 0x02 升高了2度
uint16_t Temper_c_Before; //C相温度前 0x0C02=(3074/10)-273.1=34.3摄氏度
uint16_t Temper_c_After; //C相温度后 0x0C02=(3074/10)-273.1=34.3摄氏度
uint16_t endFlag; //值0X0D 0X0A 结束符 “/r/n”
}WarringPack_t;//告警数据 71Byte
typedef struct{
uint32_t StatusA;//24个通道的温度数据的正确性判断 Bit24 0 开关量正常 1开关量报警
int16_t TempA[24];//测温带的温度 I16/16【原始值】
uint32_t StatusB;
int16_t TempB[24];
uint32_t StatusC;
int16_t TempC[24];
}MultiTempPack_t;//测温带数据 156 Byte
typedef struct{
uint32_t proVer;//协议版本号 0x00000363
uint32_t utc;
RtdPack_t rtd;//
uint32_t reslved1;//调试工具 用来存历史数据条数
WarringPack_t war;
uint8_t reslved2;
MultiTempPack_t mul;
uint32_t reslved3;
uint32_t powertatus;
uint32_t vbat;
uint32_t vout;
uint32_t batteryStatus;
float Gpslatitude;
float Gpslongitude;
uint8_t PowerFail[8];//电源故障 485
uint32_t vsc;
uint8_t reslved4[104];
}debug_pkt_realdata_t; //512Byte
#pragma pack()
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;
uint8_t pps_mode;
} pd_config_t;
typedef struct
{
uint8_t state;
uint8_t sync;
} pd_state_t;
typedef struct
{
uint32_t devType;//温度振动类型 1 温度振动 2 测温带 3 振动
I32 TempLimit;
I32 ShakeLimit;
}TempSnakeCfg_t;
typedef struct
{
uint32_t enable;
uint32_t RS485Ch;//485通道1~6
uint32_t di;//关联DI序号 1,2
uint32_t trigger;//触发方式 1常开触发 0 闭合触发
uint32_t delay;//延时 单位s 0~100
uint32_t size;//照片大小 1:(160*128) 2:(320*240) 3:(640*480)
}CameraCfg_t;//摄像头相关配置
typedef struct{
U8 RestartTime[3];
U8 HeartbearTimes;
U16 SamplingTimes;
U16 SleepTime;
U16 OnlineTime;
U8 Passwd[4];
U8 Ciphertext[4];
U8 DevID[6];
U8 ContactTimes;
U8 TimingTimes;
U8 ServerCardNum[6];
U16 ProtocolVersion;
}CSGCfg_t; //南网协议配置报文结构体 4+1+2+2+2+3+4+6+1+1+6+2 = 34
typedef struct
{
unsigned char client_id[64];
unsigned char server_addr[64];
unsigned int server_port;
unsigned char device_id[32];
unsigned char password[64];
unsigned char user_name[96];
unsigned int keep_live_time;
} mqtt_param_t;
typedef struct
{
char equipmentId[64]; //设备标识SN码
char equipmentName[128]; //设备名称
int deviceType; //监测类型 12代表护层环流
char manufacture[128]; //生产厂家
char equipmentType[64]; //设备型号
char manufNo[64]; //出厂编号
char manufDate[20]; //出厂年月
int communicationMode; //通讯方式 0: 有线 1无线
int communicationProtocol; //通讯协议 0输电南网规约 1mqtt 2: http/https
int Positioning; //定位系统 0GPS 1:北斗
}BasePropertues_t;
typedef struct
{
char MasterIP[64]; //服务器域名IP
int MasterPort; //服务器端口
char clientId[64]; //客户端ID
char UserName[128]; //连接用户名
char Password[128]; //连接密码
char DeviceId[64]; //设备ID
int MQTTVer; //物模型版本
int HeartbeatInterval; //心跳间隔,分钟/次
char NcommMode[32]; //北向通讯方式 有线/无线
char NcommProtocol[32]; //北向通讯协议 0:MQTT 1:COAP
int PowerMode; //取电模式 0太阳能板 1CT
char DeviceVoltage[32]; //设备工作电压 DC12/DC24/AC220
int DevicePower; //设备功率
}technicalParam_t;
typedef struct
{
char Password[16];
int timingType; //对时类型 0手动校时 1平台自动校时 2运营商校时
int heartbeatInterval; //心跳间隔 分钟
int sampleInterval; //采集间隔 分钟
int sleepDuration; //休眠时长 分钟
int onlineInterval; //在线时长 分钟
int day; //硬件重启时间点 日 0-28为0代表每天都重启
int hour; //月 00-23
int minute; //分钟 00-59
char ipAddr[64]; //平台IP
int port; //平台端口
char httpIP[128]; //http的ip
int httpPort; //http的端口
int PwrMode; //设备当前供电模式
int batteryNumber; //电池编号
}demandServices_t;
typedef struct
{
/* BaseProperties */
BasePropertues_t BaseParam; //基础信息
/* technicalproperties */
technicalParam_t technicalParam; //技术参数
/* demandServices */
demandServices_t demandParam; //服务参数
}csgMQTTCfg_t; //南网MQTT协议配置结构体
typedef struct{
U8 obj_type[STR_BUF_LEN];
U8 delay[STR_BUF_LEN];
U8 port_name[STR_BUF_LEN*2];
U8 pool_time;
}PortCfg_t;
typedef struct
{
U32 enable;
U32 RS485Ch;
U32 Addr;
}EnvDevCfg_t;//环境传感器配置
typedef struct
{
uint8_t DeviceNum[16]; //设备编号
uint8_t LocalIP1[4]; //本机IP
uint8_t LocalIP1_V6[16]; //预留IPV6 //未使用
uint32_t CommunicationMode;//协议类型 1:朗德 2:南网 3 MQTT协议 4:智能接地箱 5: 南网MQTT送检
uint8_t ServerIP1[4]; //服务器IP1
uint8_t ServerIP2[4]; //服务器IP2 //未使用
uint32_t ServerIP1_Port; //服务器IP1端口号
uint32_t ServerIP2_Port; //服务器IP2端口号 //未使用
uint32_t radioType;//无线类型 0有线网络 1: 移远4G 2: simcom4G 3: simcom5G
uint8_t apn[16];
uint32_t uploadSpace;//上送间隔 实时数据主动上送间隔 单位s 默认300
uint32_t EnGPS;//北斗模块使能1 开启0关闭
uint32_t vBatChangeStart;//大于此值开始充电默认3200mV
uint32_t vBatChangeEnd;//大于此值结束充电默认4200mV
uint32_t vscValue;//超级电容临界值默认4500 mV大于等于此值进入正常模式小于此值进入节能模式
uint8_t Switch[8]; //八路开关量
uint8_t reserved[920];//最后多余的空间用来存软件版本号与编译日期(如果此结构体需要扩展,版本号依然放在最后)
}GateWay_t;//系统配置 1024B
typedef struct
{
uint32_t enable;
uint32_t space;//采集间隔
uint32_t level;//优先级
uint8_t devName[STR_BUF_LEN];
uint8_t comProtocol[STR_BUF_LEN];
uint8_t portName[256];
}DevCfg_t;
typedef struct
{
uint32_t hfEn;//高频录播使能 1开启 0 关闭 和CAU3二选一
uint32_t hfLeven;//优先级 12
uint8_t hfReslved[40];//
uint32_t cau1En;//
uint32_t cau1level;
uint32_t cau1Space;
uint32_t cau1Ch1;
uint32_t cau1Ch2;
uint32_t cau1Ch3;
uint32_t cau1Ch4;
uint32_t cau1Ch5;
uint32_t cau1Ch6;
uint32_t cau1Ch7;
uint32_t cau1Ch8;
uint8_t cau1Reslved[40];//
uint32_t cau2En;//
uint32_t cau2level;
uint32_t cau2Space;
uint32_t cau2Ch1;
uint32_t cau2Ch2;
uint32_t cau2Ch3;
uint32_t cau2Ch4;
uint32_t cau2Ch5;
uint32_t cau2Ch6;
uint32_t cau2Ch7;
uint32_t cau2Ch8;
uint8_t cau2Reslved[40];//
uint32_t cau3En;//
uint32_t cau3level;
uint32_t cau3Space;
uint32_t cau3Ch1;
uint32_t cau3Ch2;
uint32_t cau3Ch3;
uint32_t cau3Ch4;
uint32_t cau3Ch5;
uint32_t cau3Ch6;
uint32_t cau3Ch7;
uint32_t cau3Ch8;
uint8_t cau3Reslved[40];//
uint32_t tempsnakeEn;
uint32_t tempsnakelevel;
uint32_t tempsnakeSpace;
uint32_t tempsnakeType;
uint32_t tempLimit;
uint32_t snakeLimit;
uint8_t tempSnakeReslved[40];//
uint32_t enDevLevel;
uint32_t enDevSpace;
uint32_t thEn;//温湿度使能 1开启 0 关闭
uint32_t thRs485Ch;//485通道1~6
uint32_t thAddr;//设备地址1~256
uint8_t thReslved[8];//预留
uint32_t waterEn;
uint32_t waterRs485Ch;
uint32_t waterAddr;
uint8_t waterReslved[8];//
uint32_t o2En;
uint32_t o2Rs485Ch;
uint32_t o2Addr;
uint8_t o2Reslved[8];//
uint32_t ch4En;
uint32_t ch4Rs485Ch;
uint32_t ch4Addr;
uint8_t ch4Reslved[8];//
uint32_t h2sEn;
uint32_t h2sRs485Ch;
uint32_t h2sAddr;
uint8_t h2sReslved[8];//
uint32_t co2En;
uint32_t co2Rs485Ch;
uint32_t co2Addr;
uint8_t co2Reslved[8];//
uint32_t cameraEn;//摄像头相关配置
uint32_t camera485Ch;
uint32_t cameraDi;
uint32_t cameraTriger;
uint32_t cameraDelay;
uint32_t cameraSize;
uint8_t cameraReslved[40];//
uint8_t otherReslved[468];//
}LandDevCfg_t;//朗德设备配置报文结构体
typedef struct
{
float Range;//量程
float Ratio;//变比
float ZeroPoint;//零点
float ChangeThreshold;//突变阈值
float HighLimit;
float LowLimit;
uint32_t reslved[2];
}CAUInitHexCfg_t;//朗德协议字节码
typedef struct
{
float Range; //量程
float Ratio; //变比
float ZeroPoint; //零点
float ChangeThreshold; //突变阈值
float HighLimit;
float LowLimit;
U32 chSwitch;//通道选择
}cau_param_t;
typedef struct
{
U32 portSize;
U32 devSize;
GateWay_t gateway;
TempSnakeCfg_t tempSnakeCfg;
CameraCfg_t cameraCfg;
CSGCfg_t csgcfg;
//HWMQTTCfg_t mqttCfg;
mqtt_param_t mqttCfg;
csgMQTTCfg_t csgMQTTCfg; //南网MQTT 2023
PortCfg_t ports[PORT_MAX_COUNT];
DevCfg_t devs[DEV_MAX_COUNT];
cau_param_t cauParam[MAX_CAU_CHANNEL*3];
EnvDevCfg_t envDevCfg[ENV_CH_COUNT];
LandDevCfg_t landHexCfg;
} ca_param_config_t;
typedef struct{
float param[15];//分段点1~5 + 校准系数a1 b1 a2 b2 a3 b3 a4 b4 a5 b5
float span;//量程
float ratio;//变比
}Parameter_t;//系数
typedef struct{
U32 inAdjust;// 0 运行 1 校准 2获取参数 3 初始化系数为1
U32 isLink;
U32 cauBoard;// CAU1:1 CAU2:2 CAU3:3
U32 err;// 1 未知板卡 2 CAU启动异常 3:CAU参数固化错误
U32 chClose[8];
U32 isVoltage;//电压校准
Parameter_t chOld[8];
Parameter_t chNew[8];
float sample[5];//校准采样值
float turns; //砸数 ?????????? int or float
}Parameters_t;//所有通道的校准系数
typedef struct
{
time_t start_time;
unsigned int dev_hex_id;
} sys_ctrl_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 ca_param_config_t *pparam_config;
extern sys_ctrl_t sysctrl;
/* 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_pps_mode_set(void);
extern void pd_wdg_clr(void);
extern void pd_prps_show(void);
extern void pd_show(void);
#endif
#endif