common.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. int OperAllowFlag; //操作允许标志
  50. port_info_t port; //
  51. }PowerInfo;
  52. //电源部分报警信息
  53. typedef struct
  54. {
  55. bool w_voltage_up ;//电压上限报警
  56. bool w_voltage_down ;//电压下限报警
  57. bool w_current ;//电流上限报警
  58. bool w_power ;//功率
  59. bool w_consumption ;//耗电量
  60. bool w_phase_lossA; // 缺相报警
  61. bool w_phase_lossB; // 缺相报警
  62. bool w_phase_lossC; // 缺相报警
  63. }PowerWarningInfo;
  64. //超限管理表
  65. typedef struct
  66. {
  67. int product_vol_upper_enable ;//电压上限使能
  68. float product_vol_upper_threshold ;//电压上限值
  69. int product_vol_over_upper_threshold_ctrl ;//电压超限动作
  70. int product_vol_over_upper_threshold_ctrl_para ;//电压超限关联参数
  71. int product_vol_lower_enable ;//电压下限使能
  72. float product_vol_lower_threshold ;//电压下限值
  73. int product_vol_over_lower_threshold_ctrl ;//电压超限动作
  74. int product_vol_over_lower_threshold_ctrl_para ;//电压超限动作
  75. int product_cur_upper_enable ;//电流下限使能
  76. float product_cur_upper_threshold ;//电流下限值
  77. float product_cur_lower_threshold; //
  78. int product_cur_over_upper_threshold_ctrl ;//电流超限动作
  79. int product_cur_over_upper_threshold_ctrl_para ;//电流超限动作
  80. int product_pwr_upper_enable ;//功率上限使能
  81. float product_pwr_upper_threshold ;//功率上限值
  82. int product_pwr_over_upper_threshold_ctrl ;//功率超限动作
  83. int product_pwr_over_upper_threshold_ctrl_para ;//功率超限动作
  84. int product_pwrcon_upper_enable ;//耗电量上限使能
  85. float product_pwrcon_upper_threshold ;//耗电量上限值
  86. int product_pwrcon_over_upper_threshold_ctrl ;//耗电量超限动作
  87. int product_pwrcon_over_upper_threshold_ctrl_para ;//耗电量超限动作
  88. }GlobalOverManager;
  89. typedef struct
  90. {
  91. int firingSortno; //启动序号
  92. int closeSortno; //关闭序号
  93. }_PowerSXManage_t;
  94. //电源通道管理总表(输入)
  95. typedef struct
  96. {
  97. int product_id ;//产品ID
  98. //20240225 add
  99. char product_saddr ;//modbus地址记录
  100. char product_saddr_name[32] ;//输入名称
  101. char product_saddr_type ;//输入类型
  102. GlobalOverManager global_over_manager ;//超限管理
  103. PowerInfo _PowerInfo[3]; //存储最新的数据(兼容三项输入)
  104. PowerWarningInfo _PowerWarninginfo[3]; //存储报警数据(兼容三项输入)
  105. time_t product_log_time; //存储最新时间
  106. int product_MissingPH[3]; //缺相报警
  107. }GlobalPowerInManger;
  108. //电源控制板计数
  109. typedef struct
  110. {
  111. char product_saddr ;//modbus地址记录
  112. int product_number; //数量
  113. int product_type; //类型
  114. PowerInfo _PowerInfo[AC_SINGLE_S_MAX_CHN_NUM]; //存储最新的数据
  115. PowerWarningInfo _PowerWarninginfo[AC_SINGLE_S_MAX_CHN_NUM] ;//存储报警数据
  116. struct list_head list; //存储具有的通道指针
  117. GlobalPowerInManger _globalPowerInManger; //总输入数据
  118. int nLeft_phType; //左半边相类型
  119. int nRight_phType; //右半边相类型
  120. }GlobalPowerCtrlBoard;
  121. #endif // COMMON_H