9df7baaa597dc9e2404b43a6d394551676b30147.svn-base 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #ifndef ICE_BP_SHM_H
  2. #define ICE_BP_SHM_H
  3. //#include <QtCore>
  4. #include <stdbool.h>
  5. #include <sys/types.h>
  6. #include <sys/shm.h>
  7. #include <sys/ipc.h>
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #define SHM_PATH "/"
  11. #define SHM_PORT 8801
  12. #define APP_NAME "ytCore"
  13. #define DB_PATH "/opt/db"
  14. #define CONF_DB "/opt/db/yt_conf.db"
  15. #define STA_DB "/opt/db/yt_sta.db"
  16. #define REC_DB "/opt/db/yt_rec.db"
  17. #define CORE_MAIN 1
  18. #define DB_THREAD 2
  19. #define LOG_THREAD 3
  20. #define UPCOMM_THREAD 4
  21. #define DNCOMM_THREAD_0 5
  22. typedef struct {
  23. unsigned short YEAR;
  24. unsigned char MONTH;
  25. unsigned char DAY;
  26. unsigned char HOUR;
  27. unsigned char MINUTE;
  28. unsigned char SECOND;
  29. unsigned int TIMESTAMP;
  30. }CurrentTime,FullTime;
  31. typedef struct {
  32. unsigned char IDX; //线程编号(1~63)
  33. unsigned char ENABLED; //使能标识(0:不使能;1:使能)
  34. unsigned short WAITSEC; //缓冲时长(1~65535,秒)
  35. unsigned int LASTFEED; //末次喂狗时间(时间戳,单位秒)
  36. }DogTime;
  37. typedef struct {
  38. DogTime dogTime[64];
  39. }DogTimeList; //看门狗列表
  40. typedef struct {
  41. unsigned char IDX; //通信端口编号(0~3)
  42. unsigned char ENABLED; //使能标识(0:不使能;1:使能)
  43. unsigned short CommType; //通信类型(可作为多协议扩展使用)
  44. char PATH[255]; //端口路径(地址)
  45. unsigned char UNSAVED;
  46. }Comm;
  47. typedef struct {
  48. unsigned char STATUS; //当前状态
  49. unsigned int TIMESTAMP; //状态改变时间
  50. bool SENT; //告警发送标识
  51. unsigned char UNSAVED;
  52. }CommStatus;
  53. typedef struct {
  54. Comm comm[4];
  55. }CommList; //通信端口列表(嵌入式线程数量宜小于16)
  56. typedef struct {
  57. CommStatus commStatus[4];
  58. }CommStatusList;
  59. typedef struct {
  60. unsigned char COMM_IDX; //通信端口编号(0~3)
  61. unsigned char BUS_ADD; //总线内监控点(1~254,0、255保留)
  62. unsigned char ENABLED; //使能标识(0:不使能;1:使能)
  63. char NAME[220]; //监控点名词
  64. unsigned char PNO_TYPE; //监控点物理类型, 0为不监控,1为开关量输入,2为模拟量输入,3为开关量输出,4为模拟量输出
  65. unsigned char PNO_ALARM; //监控点告警级别,0为不告警,1为次要告警,2为重要告警
  66. unsigned char PNO_VALUE; //监控点数据类别,开关量输入时,0表示数值0为开或告警,1为关或正常;1表示数值1为开或告警,0为关或者正常。模拟量输入时,0表示无告警上下限,1表示只有告警上限,2表示只有告警下限,3表示有告警上下限。开关量输出时,0表示电平型,1表示脉冲型
  67. unsigned short PNO_DLY; //当监控点具有告警属性时,为告警延时0~65535秒,当监控点为脉冲型开关量输出时,为保持时间1~65535秒
  68. unsigned char PNO_AD; //监控点为模拟量输入、输出时,表示AD转换精度
  69. unsigned char OFFSET; //偏移量,对AD值进行修正,以减少误差
  70. unsigned char OFFSET_FLAG; //偏移方向,1为负,0为正
  71. float PNO_MAX; //当监控点为模拟量时,表示满量程AD值代表的实际最大值
  72. float PNO_MIN; //当监控点为模拟量时,表示AD值为最小时的实际最小值
  73. float ALARM_H; //模拟量监控点告警上限
  74. float ALARM_L; //模拟量监控点告警下限
  75. unsigned char UNSAVED;
  76. }SPoint;
  77. typedef struct {
  78. SPoint sPoint[4][256];
  79. }SPointList;
  80. typedef struct {
  81. float REALTIME_VALUE;
  82. unsigned int REALTIME_TIMESTAMP;
  83. unsigned char ALARM_STATUS;
  84. unsigned int ALARM_TIMESTAMP; //状态改变时间
  85. bool ALARM_SENT; //告警发送标识
  86. float MAX_VALUE;
  87. unsigned int MAX_TIMESTAMP;
  88. float MIN_VALUE;
  89. unsigned int MIN_TIMESTAMP;
  90. float TOTAL_VALUE;
  91. unsigned int COUNT;
  92. float AVE_VALUE;
  93. unsigned char UNSAVED;
  94. }SpStatus;
  95. typedef struct {
  96. SpStatus spStatus[4][256];
  97. }SpStatusList;
  98. typedef struct {
  99. CurrentTime currentTime;
  100. DogTimeList dogTimeList;
  101. CommList commList;
  102. SPointList sPointList;
  103. CommStatusList commStatusList;
  104. SpStatusList spStatusList;
  105. }YT_UNIT_SHM;
  106. #endif // ICE_BP_SHM_H