common.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. #ifndef __COMMON_H_
  2. #define __COMMON_H_
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <unistd.h>
  7. #include <stdbool.h>
  8. #include "sqlite3.h"
  9. #include "pthread.h"
  10. #include "list.h"
  11. #include "modbus_handle.h"
  12. #include "elog.h"
  13. #include "language_hashmap.h"
  14. #include "hlw8110_handle.h"
  15. #define RS485_TYPE
  16. //是否在OS环境下运行
  17. #define OS_HANDWARE 1
  18. #define MAX_CHN_COUNT 16
  19. #define DATABASE_NAME "pdu_dat.db"
  20. #define SNMP_MIB_NAME "pduMIB"
  21. #define INTERL_MODBUS_PORT "/dev/ttyAS5"
  22. #define INTERL_MODBUS_BAUD 115200
  23. //485温湿度传感器 选择串口1
  24. // #define INTERL_485_SENSOR_MODBUS_PORT "/dev/ttyS1"
  25. // #define INTERL_485_SENSOR_MODBUS_BAUD 9600
  26. #define INTERL_SENSOR_MODBUS_PORT "/dev/ttyS1"
  27. #define INTERL_SENSOR_MODBUS_BAUD 9600
  28. //继电器接口级联
  29. // #define INTERL_SENSOR_MODBUS_PORT "/dev/ttyAS2"
  30. // #define INTERL_SENSOR_MODBUS_BAUD 9600
  31. #define CASCADE_MODBUS_PORT "/dev/ttyS5"
  32. #define CASCADE_MODBUS_BAUD 115200
  33. //485级联选择串口5
  34. // #define INTERL_485_CASCADE_PORT "/dev/ttyS5"
  35. // #define INTERL_485_CASCADE_BAUD 115200
  36. #define AC_SINGLE_S_CUR_CHN_NUM 8
  37. #define AC_SINGLE_B_CUR_CHN_NUM 4
  38. #define AC_SINGLE_S_MAX_CHN_NUM 10 //单个控制板最大数量
  39. #define AC_SINGLE_S_MAX_ADDRESS_NUM 16 //控制板最大数量
  40. #define AC_MAX_VOLTAGE_VAL 400
  41. #define AC_MAX_CURRENT_VAL 100
  42. #define AC_MAX_POWER_VAL 20000
  43. enum
  44. {
  45. TOTAL_VOLTAGE_TYPE = 0,//统计电压类型
  46. TOTAL_CURRENT_TYPE = 1,//统计电流类型
  47. TOTAL_POWER_TYPE = 2,//统计功率类型
  48. TOTAL_POWER_CONS_TYPE = 3 //统计耗电量类型
  49. };
  50. enum
  51. {
  52. POWER_MERITORIOUS_TYPE = 0,//有功功率类型
  53. POWER_REACTIVE_TYPE = 1,//无功功率类型
  54. POWER_APPARENT_TYPE = 2 //视在功率类型
  55. };
  56. enum
  57. {
  58. SENSOR_TYPE_TEMPERATURE = 0 , //温度传感器
  59. SENSOR_TYPE_SMOKE = 1 , //烟雾传感器
  60. SENSOR_TYPE_WATER = 2 , //水浸传感器
  61. SENSOR_TYPE_DOOR = 3 , //门禁传感器
  62. SENSOR_TYPE_GAS = 4 , //气体传感器
  63. SENSOR_TYPE_AIR_PRESS = 5 //气体、气压传感器
  64. };
  65. enum
  66. {
  67. SENSOR_TYPE_VALUE = 0 , //传感器类型0、4、5
  68. SENSOR_TYPE_LIST =1 //传感器类型1、2、3
  69. };
  70. /// @brief 按位标记
  71. enum BIT_CTRL
  72. {
  73. BIT_00 = 1 ,
  74. BIT_01 = 2 ,
  75. BIT_02 = 4 ,
  76. BIT_03 = 8 ,
  77. BIT_04 = 16,
  78. BIT_05 = 32,
  79. BIT_06 = 64,
  80. BIT_07 = 128,
  81. BIT_08 = 256,
  82. BIT_09 = 512,
  83. BIT_10 = 1024,
  84. BIT_11 = 2048,
  85. BIT_12 = 4096,
  86. BIT_13 = 8192,
  87. BIT_14 = 16384,
  88. BIT_15 = 32768,
  89. };
  90. /// @brief 使能位
  91. enum ENABLE_BIT_CTRL
  92. {
  93. ENABLE_V_UP = 2 ,
  94. ENABLE_V_DOWN = 8 ,
  95. ENABLE_A_UP = 32,
  96. ENABLE_W_UP = 128,
  97. ENABLE_P_UP = 512,
  98. };
  99. /// @brief 使能位三项
  100. enum ENABLE_TreeAC_CTRL
  101. {
  102. ENABLE_TAC_V_UP = BIT_01,
  103. ENABLE_TAC_V_DOWN = BIT_02,
  104. ENABLE_TAC_A_UP = BIT_03,
  105. ENABLE_TAC_W_UP = BIT_04,
  106. ENABLE_TAC_P_UP = BIT_05,
  107. ENABLE_TAC_STIME = BIT_06,
  108. ENABLE_TAC_ETIME = BIT_07,
  109. };
  110. /// @brief 报警位
  111. enum WARNING_BIT_CTRL
  112. {
  113. WARNING_V_UP = 4 ,
  114. WARNING_V_DOWN = 16 ,
  115. WARNING_A_UP = 64,
  116. WARNING_W_UP = 256,
  117. WARNING_P_UP = 1024,
  118. };
  119. ///////////////////////////////////////////////////////////////////////////////////
  120. ///////////////////////////////////////////////////////////////////////////////////
  121. //modbus信息管理
  122. typedef struct
  123. {
  124. bool product_modbus_type ; //modbus模式
  125. unsigned int product_modbus_baud ; //波特率
  126. unsigned char product_modbus_addr ;//从Modbus地址信息
  127. char product_relay_ctrl_port[32] ;//继电器modbus控制端口
  128. }ModbusInfo_t;
  129. typedef struct
  130. {
  131. int mode; //dhcp模式
  132. char ip_address[16] ; //ip地址
  133. char mask[16]; //子网掩码
  134. char gateway[16]; //网关
  135. char dns1[16]; //dns1
  136. char dns2[16]; //dns2
  137. }NetworkInfo_t;
  138. /// @brief 用户登录
  139. typedef struct
  140. {
  141. char user_name[64];
  142. char user_password[64];
  143. char user_uuid[64];
  144. char user_token[64];
  145. struct list_head list;
  146. }_User_Log;
  147. //设备总体管理表
  148. typedef struct
  149. {
  150. int product_id ;//产品ID
  151. char product_number[16] ;//产品编号
  152. char product_name[32] ;//产品名称
  153. char product_status[32] ;//产品状态
  154. unsigned char product_type ;//产品类型
  155. unsigned char product_pwr_type ;//电源类型
  156. unsigned char product_version[8] ;//软件版本
  157. unsigned char product_language ; //多国语言
  158. unsigned char product_count ;//级联设备数
  159. unsigned short product_samp_time ;//采集周期 单位ms
  160. unsigned short product_save_time ;//采集周期 单位ms
  161. ModbusInfo_t _modbus_info ;//继电器控制端口
  162. NetworkInfo_t _network_info ; ;//网络信息
  163. ModbusInfo_t _gmodbus_info ;//级联端口
  164. float consumer ;
  165. }GlobalDeviceInfo;
  166. ///////////////////////////////////////////////////////////////////////////////////
  167. ///////////////////////////////////////////////////////////////////////////////////
  168. //自定义共享内存类
  169. typedef struct
  170. {
  171. //电源数据
  172. int bPDUSet;
  173. int nSelectPowerCH;
  174. int nMaxCh;
  175. float fV;
  176. float fA;
  177. float fW;
  178. float fF;
  179. float fS;
  180. int nStatus;
  181. //传感器数据
  182. int nSelectSensor;
  183. float fT;//温度
  184. float fH;//湿度
  185. } smartPDU_shm_data;
  186. ///////////////////////////////////////////////////////////////////////////////////
  187. ///////////////////////////////////////////////////////////////////////////////////
  188. //超限管理表
  189. typedef struct
  190. {
  191. char product_vol_upper_enable ;//电压上限使能
  192. float product_vol_upper_threshold ;//电压上限值
  193. char product_vol_over_upper_threshold_ctrl ;//电压超限动作
  194. char product_vol_over_upper_threshold_ctrl_para ;//电压超限关联参数
  195. char product_vol_lower_enable ;//电压下限使能
  196. float product_vol_lower_threshold ;//电压下限值
  197. char product_vol_over_lower_threshold_ctrl ;//电压超限动作
  198. char product_vol_over_lower_threshold_ctrl_para ;//电压超限动作
  199. char product_cur_upper_enable ;//电流下限使能
  200. float product_cur_upper_threshold ;//电流下限值
  201. float product_cur_lower_threshold; //
  202. char product_cur_over_upper_threshold_ctrl ;//电流超限动作
  203. char product_cur_over_upper_threshold_ctrl_para ;//电流超限动作
  204. char product_pwr_upper_enable ;//功率上限使能
  205. float product_pwr_upper_threshold ;//功率上限值
  206. char product_pwr_over_upper_threshold_ctrl ;//功率超限动作
  207. char product_pwr_over_upper_threshold_ctrl_para ;//功率超限动作
  208. char product_pwrcon_upper_enable ;//耗电量上限使能
  209. float product_pwrcon_upper_threshold ;//耗电量上限值
  210. char product_pwrcon_over_upper_threshold_ctrl ;//耗电量超限动作
  211. char product_pwrcon_over_upper_threshold_ctrl_para ;//耗电量超限动作
  212. }GlobalOverManager;
  213. /// @brief 定时管理
  214. typedef struct
  215. {
  216. char set_date[16]; //设置日期
  217. char ds_date[16]; //设置时间
  218. char ds_time[16]; //设置时间
  219. char set_stats; //状态
  220. struct list_head list;
  221. }_PowerDSManage_t;
  222. typedef struct
  223. {
  224. int firingSortno; //启动序号
  225. int closeSortno; //关闭序号
  226. }_PowerSXManage_t;
  227. typedef struct
  228. {
  229. int product_id;
  230. int mode;
  231. char* ntpName;
  232. char* ntpaddress;
  233. int port;
  234. char* time;
  235. int weekday;
  236. int tzone;
  237. }NTPManager;
  238. NTPManager _globalNTPManager;
  239. typedef struct
  240. {
  241. int product_id;
  242. int mode;
  243. int version;
  244. char* public;
  245. int trapmode;
  246. }SNMPManager;
  247. SNMPManager _globalSNMPManager;
  248. //分组管理
  249. typedef struct
  250. {
  251. int product_id;
  252. int GroupID;
  253. char GroupName[64];
  254. char GroupChList[512];
  255. struct list_head list;
  256. }GroupInfo;
  257. typedef struct {
  258. int id;
  259. int up;
  260. char ip[48];
  261. char mac[24];
  262. char desc[64];
  263. }port_info_t;
  264. //电源部分
  265. typedef struct
  266. {
  267. float voltage ;//电压
  268. float current ;//电流
  269. float power ;//功率
  270. float freq ;//频率
  271. float consumption ;//耗电量
  272. float factor ;//功率因素
  273. unsigned short status ;//开关状态
  274. float tempratue ;
  275. float humidity ;
  276. port_info_t port;
  277. }PowerInfo;
  278. //电源部分报警信息
  279. typedef struct
  280. {
  281. bool w_voltage_up ;//电压上限报警
  282. bool w_voltage_down ;//电压下限报警
  283. bool w_current ;//电流上限报警
  284. bool w_power ;//功率
  285. bool w_consumption ;//耗电量
  286. bool w_phase_lossA; // 缺相报警
  287. bool w_phase_lossB; // 缺相报警
  288. bool w_phase_lossC; // 缺相报警
  289. }PowerWarningInfo;
  290. //三项数据
  291. typedef struct
  292. {
  293. int product_id;
  294. int product_ch_id;
  295. int product_ph_id;
  296. int product_ph_type;//0:A相 1:B相 2:C相
  297. int product_saddr;
  298. int product_ch_addr;
  299. int product_ph_outputType;//三相控制方式1,三项2单项
  300. int product_ph_outputStatus;//该相是否输出,1输出2不输出
  301. PowerInfo _PowerInfo; //存储最新的数据(兼容三项输入)
  302. GlobalOverManager* global_over_manager ;//超限管理
  303. PowerWarningInfo _PowerWarninginfo; //存储报警数据(兼容三项输入)
  304. time_t product_log_time; //存储最新时间
  305. struct list_head list_Tree_AC; //存储三项数据指针
  306. }GlobalTreeACManager;
  307. //电源通道管理总表(输出)
  308. typedef struct
  309. {
  310. int product_id ;//产品ID
  311. //20240225 add
  312. char product_saddr ;//modbus地址记录
  313. char product_ch_id ;//通道号
  314. char product_ch_addr ;//通道号实际地址
  315. char product_ch_name[32] ;//通道名称
  316. char product_ch_type ;//通道类型
  317. char product_ch_status ;//通道状态
  318. char product_ch_NF_status ;//通道零线状态(三相)
  319. unsigned short product_ch_start_delay ;//通道延时
  320. unsigned short product_ch_stop_delay ;//通道延时
  321. GlobalOverManager* global_over_manager ;//超限管理
  322. _PowerDSManage_t* _powerDsManage ;//定时设置
  323. _PowerSXManage_t* _PowerSXManage; //时序管理
  324. PowerInfo _PowerInfo; //存储最新的数据
  325. PowerWarningInfo _PowerWarninginfo ; //存储报警数据
  326. time_t product_log_time; //存储最新时间
  327. struct list_head list_Tree_AC; //存储三项数据指针
  328. struct list_head list;
  329. } GlobalPowerManger;
  330. //电源通道管理总表(输入)
  331. typedef struct
  332. {
  333. int product_id ;//产品ID
  334. //20240225 add
  335. char product_saddr ;//modbus地址记录
  336. char product_saddr_name[32] ;//输入名称
  337. char product_saddr_type ;//输入类型
  338. GlobalOverManager* global_over_manager ;//超限管理
  339. PowerInfo _PowerInfo[3]; //存储最新的数据(兼容三项输入)
  340. PowerWarningInfo _PowerWarninginfo[3]; //存储报警数据(兼容三项输入)
  341. time_t product_log_time; //存储最新时间
  342. }GlobalPowerInManger;
  343. //电源控制板计数
  344. typedef struct
  345. {
  346. char product_saddr ;//modbus地址记录
  347. int product_number; //数量
  348. int product_type; //类型
  349. PowerInfo _PowerInfo[AC_SINGLE_S_MAX_CHN_NUM]; //存储最新的数据
  350. PowerWarningInfo _PowerWarninginfo[AC_SINGLE_S_MAX_CHN_NUM] ;//存储报警数据
  351. struct list_head list; //存储具有的通道指针
  352. }GlobalPowerCtrlBoard;
  353. ///////////////////////////////////////////////////////////////////////////////////
  354. ///////////////////////////////////////////////////////////////////////////////////
  355. //电源信息统计
  356. typedef struct
  357. {
  358. float ydata[60]; //value
  359. char xAxis[60][32];//时间点
  360. }GetTotalInfo;
  361. //系统总数信息
  362. typedef struct
  363. {
  364. int channel_total ;//通道总数
  365. int warn_total ;//告警总数
  366. int sensor_total ;//传感器总数
  367. int log_total ;//运行日志总数
  368. }SystemTotalInfo;
  369. //功率趋势接口
  370. typedef struct
  371. {
  372. float ydata[3][60] ;//0:有功功率;1:无功功率;2:视在功率;
  373. char xAxis[60][32] ;//时间点
  374. }PowerTrendInfo;
  375. ///////////////////////////////////////////////////////////////////////////////////
  376. ///////////////////////////////////////////////////////////////////////////////////
  377. //电源监控
  378. typedef struct
  379. {
  380. int product_id ;//产品ID
  381. char product_ch_id ;//电源通道
  382. unsigned short product_status ;//当前状态
  383. PowerInfo _power_info ;//采集值
  384. char samp_time[32] ;//采集时间
  385. GetTotalInfo _total_voltage ;//统计电压
  386. GetTotalInfo _total_current ;//统计电流
  387. GetTotalInfo _total_power ;//统计功率
  388. GetTotalInfo _total_consumption ;//统计耗电量
  389. SystemTotalInfo _system_total_info ;//系统总数信息
  390. PowerTrendInfo _power_trend_info ;//功率趋势图
  391. struct list_head list;
  392. }GlobalPowerInfo;
  393. ///////////////////////////////////////////////////////////////////////////////////
  394. ///////////////////////////////////////////////////////////////////////////////////
  395. ///////////////////////////////////////////////////////////////////////////////////
  396. ///////////////////////////////////////////////////////////////////////////////////
  397. //传感器值
  398. typedef struct
  399. {
  400. char samp_time[32] ;//采集时间
  401. int product_id ;//产品ID
  402. char sensor_id ;//传感器ID
  403. float val1 ;//值1
  404. float val2 ;//值2
  405. time_t product_log_time; //存储最新时间
  406. struct list_head list;
  407. }GlobalSensorInfo;
  408. typedef struct
  409. {
  410. bool sensor_val1_upper_enabled ;//
  411. float sensor_val1_upper_threshold;
  412. char sensor_val1_upper_threshold_ctrl;
  413. char sensor_val1_upper_threshold_ctrl_para;
  414. bool sensor_val1_lower_enabled ;//
  415. float sensor_val1_lower_threshold;
  416. char sensor_val1_lower_threshold_ctrl;
  417. char sensor_val1_lower_threshold_ctrl_para;
  418. bool sensor_val2_upper_enabled ;//
  419. float sensor_val2_upper_threshold;
  420. char sensor_val2_upper_threshold_ctrl;
  421. char sensor_val2_upper_threshold_ctrl_para;
  422. bool sensor_val2_lower_enabled ;//
  423. float sensor_val2_lower_threshold;
  424. char sensor_val2_lower_threshold_ctrl;
  425. char sensor_val2_lower_threshold_ctrl_para;
  426. }GlobalSensorOverManage;
  427. //传感器管理总表
  428. typedef struct
  429. {
  430. int product_id ;//产品ID
  431. char sensor_id ;//传感器ID
  432. char sensor_type ;//传感器类型
  433. char sensor_interface_type; //接口类型
  434. char sensor_name[64] ;//传感器名称
  435. char sensor_port_name[32] ;//传感器端口号
  436. int sensor_baud ;//波特率
  437. char sensor_addr ;//modbus地址
  438. int sensor_status ;//传感器状态
  439. char sensor_val_count ;//传感器值个数
  440. int sensor_node_number ;//节点号
  441. GlobalSensorOverManage* over_manager ;//超限管理
  442. struct list_head list;
  443. }GlobalSensorManger;
  444. ///////////////////////////////////////////////////////////////////////////////////
  445. ///////////////////////////////////////////////////////////////////////////////////
  446. ///////////////////////////////////////////////////////////////////////////////////
  447. ///////////////////////////////////////////////////////////////////////////////////
  448. ///温湿度数据信息管理
  449. typedef struct
  450. {
  451. float temperature;
  452. float humidity;
  453. }SenorTempVal;
  454. //采集KB值
  455. typedef struct
  456. {
  457. float voltage_k;//电压K
  458. float voltage_b;//电压B
  459. float current_k;//电流K
  460. float current_b;//电流B
  461. }SwitchKbVal;
  462. ///////////////////////////////////////////////////////////////////////////////////
  463. ///////////////////////////////////////////////////////////////////////////////////
  464. //SMTP管理
  465. typedef struct
  466. {
  467. int idx;
  468. char* receive_account;
  469. char* receive_account_info;
  470. struct list_head list;
  471. }SMTPreceiveAccount;
  472. typedef struct
  473. {
  474. int product_id;
  475. int mode; //状态
  476. char* account; //用户账号
  477. char* password; //用户密码
  478. char* server; //服务器
  479. int port; //端口
  480. char auth[16]; //认证方式
  481. SMTPreceiveAccount* receive_account; //接收账号列表
  482. }SMTPManager;
  483. SMTPManager globalSMTPManager;
  484. typedef struct
  485. {
  486. int product_id;
  487. int userID; //用户ID
  488. char* userName; //用户名-登录
  489. char* userPW; //用户密码
  490. char* nickName; //用户名称
  491. int roleID; //角色ID
  492. char* createTime; //用户创建时间
  493. struct list_head list;
  494. }UserInfo;
  495. typedef struct
  496. {
  497. int product_id;
  498. int roleID; //角色ID
  499. char* roleName; //角色名称
  500. int roleLevel; //角色等级
  501. int roleAuthority; //角色权限
  502. int roleSort; //显示顺序
  503. char* createTime; //创建时间
  504. struct list_head list;
  505. }RoleInfo;
  506. typedef struct threshold_485{
  507. float votage_max_threshold; //电压最大阈值
  508. float votage_min_threshold; //电压最小阈值
  509. float current_max_threshold; //电流最大阈值
  510. float power_max_threshold; //功率最大阈值
  511. float electricity_max;
  512. }Threshould_485;
  513. typedef struct For85_Data{
  514. uint16_t addr; //current addr;
  515. uint16_t dev_cnt;
  516. uint16_t temprature;
  517. uint16_t humnate;
  518. uint16_t sensor_status;
  519. uint16_t breaker_status;
  520. uint32_t voltage;
  521. uint32_t current;
  522. uint32_t power;
  523. uint32_t consumer;
  524. uint32_t freq;
  525. uint32_t factor;
  526. uint32_t angle;
  527. }For85_Data_t;
  528. struct modbus_slave_read_reg{
  529. uint16_t deveice_type; //设备类型
  530. uint16_t slave_addr; //设备地址
  531. uint32_t voltage; //当前电压
  532. uint32_t current; //当前电流
  533. uint32_t power; //当前功率
  534. uint32_t consumption_cur; //耗电量
  535. uint32_t freq; //频率
  536. uint32_t factor; //功率因素
  537. uint32_t temprature; //温度值
  538. uint32_t humidity; //湿度值
  539. uint32_t warning; //告警
  540. uint16_t power_supplay_status; //供电状态
  541. uint16_t sencor_status; //传感器状态
  542. // uint32_t Warinfo;
  543. // uint16_t sercor_type;
  544. };
  545. struct modbus_slave_write_reg{
  546. uint16_t voltage_high_enable:1; //电压高阈值检测使能
  547. uint16_t voltage_low_enable:1; //电压低阈值检测使能
  548. uint16_t current_enable:1; //电流阈值使能
  549. uint16_t power_enable:1; //功率阈值使能
  550. uint16_t consumption_cur_enable:1; //功耗阈值使能
  551. uint32_t voltage_upper_threshold; //
  552. uint32_t voltage_lower_threshold;
  553. uint32_t current_upper_threshold;
  554. uint32_t power_upper_threshold;
  555. uint32_t consumption_threshold;
  556. };
  557. //设备总体管理
  558. typedef struct
  559. {
  560. sqlite3* db; //数据库接口
  561. pthread_t appweb_thread; //appweb线程
  562. pthread_t dev_samp_thread;//电源采集与控制线程
  563. unsigned char view_page ; //前端切换页面 1->总体信息 2->通道信息
  564. pthread_t dev_update_thread;//电源采集与控制线程
  565. pthread_t io_thread; //IO采集线程
  566. pthread_t sensor_thread; //传感器采集现成
  567. bool dev_samp_flag ; //电源采集线程标志
  568. GlobalDeviceInfo* _global_device_info; //设备管理信息
  569. GlobalPowerManger _globalPowerManger; //电源管理表
  570. GlobalPowerInManger _globalPowerInManger; //电源输入表
  571. GlobalSensorManger _globalSensorManger; //传感器管理表
  572. Modbus_Manger sensor_modbus_manager; //通信接口管理
  573. unsigned int useSlaveCount ; //有效地址
  574. Modbus_Manger _globalRelaySampManger; //内部继电器使用
  575. unsigned char uart_init_flag[6] ; //
  576. bool ws_isok; //ws准备好
  577. struct mg_connection *ws_client; //websocket管理信息
  578. HashTable* _global_alarmLanguage; //全局的报警映射
  579. pthread_t snmp_agent_thread;//SNMP代理线程
  580. bool _ReloadChm_flag; //重新加载端口数据
  581. GlobalPowerCtrlBoard _all_ctrl_board[16]; //所有控制板
  582. LowConf* _RS485LowConfData;//485Data
  583. pthread_t replay_thread;
  584. Modbus_Manger _global_Slave_Modbus;
  585. struct modbus_slave_read_reg g_modebus_read;
  586. For85_Data_t for85_data;
  587. struct modbus_slave_write_reg g_modebus_write;
  588. smartPDU_shm_data* g_shm_Data;
  589. pthread_t shm_thread; //共享内存线程
  590. }GlobalDeviceManager;
  591. GlobalDeviceManager __globalDeviceManage;
  592. //NTPClient* globalNTPclient;
  593. //bool bStopNTPthread;
  594. //pthread_t NTPthread;
  595. unsigned long __globalSxIdx;
  596. _User_Log _GlobalUserLoginInfo;//全局用户登录信息
  597. UserInfo _GlobalUserInfoNew;////最近登录的信息
  598. char _GlobalUserToken[64];////最近登录的信息
  599. void initLogger(void);
  600. //打印设备信息结构
  601. void printf_global_device_info(GlobalDeviceInfo* _globalDeviceInfo);
  602. //打印设备超限电源管理
  603. void printf_global_power_manage_info(GlobalPowerManger* _globalPowerManger);
  604. //打印设备超限电源通道管理
  605. //void printf_global_power_chn_manage_info(GlobalPowerChnManger* _globalPowerChnManger);
  606. void printf_power_info(GlobalPowerInfo* _globalPowerInfo);
  607. int getTotalMemorySize(unsigned int* totalSize);
  608. char* getLocalIpAddress(char* dev);
  609. void get_disk_occupy(char ** reused);
  610. int set_local_timeandzone(struct tm* t, int zone);
  611. char* getUserNamebyToken(char* Token);
  612. int is_process_running(const char *process_name);
  613. pthread_mutex_t WSlock;
  614. #endif