emcp/document/gui_1.h
2026-06-12 10:37:57 +08:00

206 lines
4.9 KiB
C
Raw 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.

#ifndef __GUI_H
#define __GUI_H
#include "time.h"
#define LINE_TOTAL_NUM 4 //总测量线路数量
#define ANALOG_CH_NUM 12 //模拟量通道数
/***********************************************************************小核数据 -> 大核****************************************************************************/
//实时量
typedef struct
{
//三相电压
float Ua; //A相电压
float Ub; //B相电压
float Uc; //C相电压
//三相电流
float Ia; //A相电流
float Ib; //B相电流
float Ic; //C相电流
//有功功率
float Pa;
float Pb;
float Pc;
float Pt; //总有功功率
//无功功率
float Qa;
float Qb;
float Qc;
float Qt; //总无功功率
//视在功率
float Sa;
float Sb;
float Sc;
float St; //总视在功率
//功率因数
float PFa;
float PFb;
float PFc;
float PFt; //总功率因数
//线电压
float Uab;
float Ubc;
float Uca;
//频率
float frq;
}measure_unit_t;
//B码对时时间数据
typedef union
{
uint8_t b_code[6];
struct
{
uint8_t ascii_s_unit : 4;
uint8_t ascii_s_ten : 4;
uint8_t ascii_min_unit : 4;
uint8_t ascii_min_ten : 4;
uint8_t ascii_hour_unit : 4;
uint8_t ascii_hour_ten : 4;
uint8_t ascii_m_day_unit: 4;
uint8_t ascii_m_day_ten : 4;
uint8_t ascii_month_unit: 4; //4bit
uint8_t ascii_month_ten : 4; //4bit
uint8_t ascii_year_unit : 4; //4bit
uint8_t ascii_year_ten : 4; //4bit
}time;
}b_code_t;
//事件标志
typedef struct
{
uint32_t timestamp; //事件发生时间,时间戳
uin16_t ms; //事件发生的毫秒时刻
uint8_t line_num; //线路号0 = 其它1 = 1路2 =2路 3 = 3路 4 = 4路
uint8_t type; //事件类型1 = pt 断线, 2 = CT断线其它事件依次编号
}event_t;
// //波形数据
// typedef struct
// { uint32_t stamp; //时标
// int16_t ch[8]; //4路波形数据时8个通道ua、ub、uc, ia、ib、ic、频率系数、开入量
// //AI波形数据时 8个通道对应各个输入点
// }ch_data_t;
// //波形数据
// typedef struct
// {
// uint8_t line_index; //线路号 0 ~ 3 = 4路电压电流采样数据4 = AI采集数据
// ch_data_t dot[64]; //64个点组成一个周波
// }waveform_data_t;
//小核数据 -> 大核
typedef struct
{
measure_unit_t measure_unit[LINE_TOTAL_NUM];//总共4条线路按序排列
float d_in[8]; //模拟量输入
b_code_t b_code; //B码对时
uint16_t a_in; //数字量,开入
uint16_t evt_f; //事件标志,读取到时间标志后,再读取保持寄存器里的事件内容
}gui_in_04reg_t;//读输入寄存器数据
typedef struct
{
event_t event;
}gui_in_03reg_t;//读保持寄存器事件数据
typedef struct
{
uint16_t a_in; //数字量,开入
}gui_in_02reg_t;//读离散输入寄存器数据
/***********************************************************************大核数据 -> 小核****************************************************************************/
//串口参数设置
typedef struct
{
uint32_t baud_tate; //波特率 9600 115200默认
uint8_t parity; //校验位 0 = 无校验, 1 = 奇校验, 2 = 偶校验
uint8_t data; //数据位 0 = 8位
uint8_t stop; //停止位 0 = 1位 1 = 2位
uint8_t protocol; //通讯协议 0 = 无协议1 = modbus
}com_param_t;
//模拟通道参数值
typedef struct
{
uint8_t sig_type;//信号类型 0 = 4~20ma信号 1 = 1~5V信号
uint8_t line_sub;//所属线路 1 = 线路1 2 = 线路2 3 =线路3 4 = 线路4 0 = 装置
uint8_t att; //类别 : 0 = UA, 1 = UB, 2 = UC, 3 = UAB, 4 = UBC, 5 = UCA, 6 = P, 7 = Q, 8 = F
uint8_t u_limit; //上限值 :
uint8_t d_limit; //下限值 :
}analog_ch_param_t;
//线路定值
typedef struct
{
// uint8_t index; //线路号: 1 = 线路1, 2 = 线路2 3 = 线路3, 4 = 线路4
uint8_t limit; //限值:
uint8_t delay; //延时: [1 ~ 10秒]
uint8_t out_num; //输出节点: [1 = 开出1、 2 = 开出2、...]
uint8_t select; //投退: [0 = 不投, 1 = 投入]
}line_param_t;
typedef struct
{
line_param_t type[7]; //7个类别电压电流差流, 功率频率PT断线CT断线
}line_type_t;
//AI 报警
typedef struct
{
uint8_t u_limit; //上限值 :
uint8_t d_limit; //下限值 :
uint8_t delay; //延时: [1 ~ 10秒]
uint8_t out_num; //输出节点: [1 = 开出1、 2 = 开出2、...]
uint8_t select; //投退: [0 = 不投, 1 = 投入]
}ai_alarm_param_t;
//大核数据 -> 小核
//设置模拟量,数字量输出
typedef struct
{
uint32_t timestamp; //时间戳,设置时间
com_param_t com_param[4]; //串口参数设置: 小核串口FPGA串口
line_type_t line_param[4]; //线路定值设置: 4路定值一起下发
analog_ch_param_t a_in_param[12]; //12路模拟输入通道设置
analog_ch_param_t a_out_param[12]; //12路模拟输出通道设置
ai_alarm_param_t ai_alarm_param[12];//12路模拟输入 报警参数设置
}gui_out_03reg_t;//放入保持寄存器中的参数
typedef struct
{
uint16_t a_in; //数字量,开出
}gui_out_01reg_t;//放入线圈寄存器中的数
#endif