common.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #ifndef COMMON_H
  2. #define COMMON_H
  3. #include <sys/time.h>
  4. #include "list.h"
  5. #define AC_SINGLE_S_MAX_CHN_NUM 10 //单个控制板最大数量
  6. #define AC_SINGLE_S_MAX_ADDRESS_NUM 16 //控制板最大数量
  7. enum {
  8. ALARM_TYPE_POWER=0,
  9. ALARM_TYPE_SENSOR,
  10. ALARM_TYPE_NETWORK,
  11. ALARM_TYPE_OPRATION,
  12. ALARM_TYPE_RUNNING,
  13. };
  14. //消息队列头结构体定义
  15. enum
  16. {
  17. Msg_Ch_Ctrl=1, //通道控制
  18. Msg_All_Ctrl=2, //整体控制
  19. Msg_Threshold_Set=3, //阈值设置
  20. Msg_Threshold_Update=4, //阈值更新
  21. };
  22. #pragma pack(push, 1) // 强制1字节对齐
  23. typedef struct {
  24. long MsgType; //消息方向1:Qt->PDU 2:pdu->Qt
  25. int CtrlType; //控制类型
  26. int nValue[2];
  27. // double fValue[10];
  28. }MsgData;
  29. #pragma pack(pop) // 恢复默认对齐
  30. //地址部分
  31. typedef struct {
  32. int id;
  33. int up;
  34. char ip[48];
  35. char mac[24];
  36. char desc[64];
  37. }port_info_t;
  38. //电源部分
  39. typedef struct
  40. {
  41. float voltage ;//电压
  42. float current ;//电流
  43. float power ;//功率
  44. float freq ;//频率
  45. float consumption ;//耗电量
  46. float factor ;//功率因素
  47. unsigned short status ;//开关状态
  48. unsigned short NF_status ;//零线状态
  49. port_info_t port; //
  50. }PowerInfo;
  51. //电源部分报警信息
  52. typedef struct
  53. {
  54. bool w_voltage_up ;//电压上限报警
  55. bool w_voltage_down ;//电压下限报警
  56. bool w_current ;//电流上限报警
  57. bool w_power ;//功率
  58. bool w_consumption ;//耗电量
  59. bool w_phase_lossA; // 缺相报警
  60. bool w_phase_lossB; // 缺相报警
  61. bool w_phase_lossC; // 缺相报警
  62. }PowerWarningInfo;
  63. //超限管理表
  64. typedef struct
  65. {
  66. int product_vol_upper_enable ;//电压上限使能
  67. float product_vol_upper_threshold ;//电压上限值
  68. int product_vol_over_upper_threshold_ctrl ;//电压超限动作
  69. int product_vol_over_upper_threshold_ctrl_para ;//电压超限关联参数
  70. int product_vol_lower_enable ;//电压下限使能
  71. float product_vol_lower_threshold ;//电压下限值
  72. int product_vol_over_lower_threshold_ctrl ;//电压超限动作
  73. int product_vol_over_lower_threshold_ctrl_para ;//电压超限动作
  74. int product_cur_upper_enable ;//电流下限使能
  75. float product_cur_upper_threshold ;//电流下限值
  76. float product_cur_lower_threshold; //
  77. int product_cur_over_upper_threshold_ctrl ;//电流超限动作
  78. int product_cur_over_upper_threshold_ctrl_para ;//电流超限动作
  79. int product_pwr_upper_enable ;//功率上限使能
  80. float product_pwr_upper_threshold ;//功率上限值
  81. int product_pwr_over_upper_threshold_ctrl ;//功率超限动作
  82. int product_pwr_over_upper_threshold_ctrl_para ;//功率超限动作
  83. int product_pwrcon_upper_enable ;//耗电量上限使能
  84. float product_pwrcon_upper_threshold ;//耗电量上限值
  85. int product_pwrcon_over_upper_threshold_ctrl ;//耗电量超限动作
  86. int product_pwrcon_over_upper_threshold_ctrl_para ;//耗电量超限动作
  87. }GlobalOverManager;
  88. typedef struct
  89. {
  90. int firingSortno; //启动序号
  91. int closeSortno; //关闭序号
  92. }_PowerSXManage_t;
  93. //电源通道管理总表(输入)
  94. typedef struct
  95. {
  96. int product_id ;//产品ID
  97. //20240225 add
  98. char product_saddr ;//modbus地址记录
  99. char product_saddr_name[32] ;//输入名称
  100. char product_saddr_type ;//输入类型
  101. GlobalOverManager global_over_manager ;//超限管理
  102. PowerInfo _PowerInfo[3]; //存储最新的数据(兼容三项输入)
  103. PowerWarningInfo _PowerWarninginfo[3]; //存储报警数据(兼容三项输入)
  104. time_t product_log_time; //存储最新时间
  105. int product_MissingPH[3]; //缺相报警
  106. }GlobalPowerInManger;
  107. //电源控制板计数
  108. typedef struct
  109. {
  110. char product_saddr ;//modbus地址记录
  111. int product_number; //数量
  112. int product_type; //类型
  113. PowerInfo _PowerInfo[AC_SINGLE_S_MAX_CHN_NUM]; //存储最新的数据
  114. PowerWarningInfo _PowerWarninginfo[AC_SINGLE_S_MAX_CHN_NUM] ;//存储报警数据
  115. struct list_head list; //存储具有的通道指针
  116. GlobalPowerInManger _globalPowerInManger; //总输入数据
  117. }GlobalPowerCtrlBoard;
  118. #endif // COMMON_H