common.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344
  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 "mongoose.h"
  14. #include "ntpclient.h"
  15. #include <net-snmp/net-snmp-config.h>
  16. #include <net-snmp/net-snmp-includes.h>
  17. #include <net-snmp/agent/net-snmp-agent-includes.h>
  18. #include "pduMIB_form.h"
  19. #include "pduMIB_scalar.h"
  20. #include "pduMIB_trap.h"
  21. #include "language_hashmap.h"
  22. #include "hlw8110_habdle.h"
  23. #include "language_common.h"
  24. #include <sys/shm.h>
  25. #include "cfg.h"
  26. #define MAX_RELAY_CHN 100
  27. //是否在OS环境下运行
  28. #define OS_HANDWARE 1
  29. #define WEB_ROOT "../web"
  30. #define PARAS_FILE "pduParas"
  31. #define DATABASE_NAME "pdu_dat.db"
  32. #define DATABASE_BAK_NAME "pdu_dat_bak.db"
  33. #define SNMP_MIB_NAME "pduMIB"
  34. #define INI_FILE_NAME "smartPDU.ini"
  35. #define INI_FILE_BAK_NAME "smartPDU_bak.ini"
  36. #define CHANGES_NAME "changes.txt"
  37. #define SERV_CFG_NAME "service.ini"
  38. #define SENSOR_CFG_NAME "sensor.ini"
  39. #define ALARM_CFG_NAME "alarm.ini"
  40. #define INFO_FILE_PATH "/usr/share/PDUInfo.txt"
  41. #if (CHIP_TYPE == CHIP_T113s)
  42. //控制板通信串口
  43. #define INTERL_MODBUS_PORT "/dev/ttyS4"
  44. #define INTERL_MODBUS_BAUD 115200
  45. //表头级联通讯串口
  46. #define CASCADE_MODBUS_PORT "/dev/ttyS5"
  47. #define CASCADE_MODBUS_BAUD 115200
  48. //传感器通信串口
  49. #define INTERL_SENSOR_MODBUS_PORT "/dev/ttyS1"
  50. #define INTERL_SENSOR_MODBUS_BAUD 9600
  51. #else
  52. //高配表头串口定义-----------------------------------------------
  53. //控制板通信串口
  54. #define INTERL_MODBUS_PORT "/dev/ttyAS5"
  55. #define INTERL_MODBUS_BAUD 115200
  56. //表头级联通讯串口
  57. #define CASCADE_MODBUS_PORT "/dev/ttyAS4"
  58. #ifdef NORTH_USER_SPECILS
  59. #define CASCADE_MODBUS_BAUD 9600
  60. #else
  61. #define CASCADE_MODBUS_BAUD 115200
  62. #endif
  63. //传感器通信串口
  64. #define INTERL_SENSOR_MODBUS_PORT "/dev/ttyAS2"
  65. #define INTERL_SENSOR_MODBUS_BAUD 9600
  66. #endif
  67. #define IMAGE_FOLDER "image"
  68. #define LOGO_FILE "logo.png"
  69. #define QRCODE_FILE "qrcode.png"
  70. #define CERT_FILE "ca.cert"
  71. #define AC_SINGLE_S_CUR_CHN_NUM 8
  72. #define AC_SINGLE_B_CUR_CHN_NUM 4
  73. #define AC_SINGLE_S_MAX_CHN_NUM 10 //单个控制板最大数量
  74. #define AC_SINGLE_S_MAX_ADDRESS_NUM 16 //控制板最大数量
  75. #define AC_MAX_VOLTAGE_VAL 500
  76. #define AC_MAX_CURRENT_VAL 100
  77. #define AC_MAX_POWER_VAL 100
  78. enum{
  79. BREAKER_DIO = 0,
  80. BREAKER_RS485
  81. };
  82. enum
  83. {
  84. TOTAL_VOLTAGE_TYPE = 0,//统计电压类型
  85. TOTAL_CURRENT_TYPE = 1,//统计电流类型
  86. TOTAL_POWER_TYPE = 2,//统计功率类型
  87. TOTAL_POWER_CONS_TYPE = 3 //统计耗电量类型
  88. };
  89. enum
  90. {
  91. POWER_MERITORIOUS_TYPE = 0,//有功功率类型
  92. POWER_REACTIVE_TYPE = 1,//无功功率类型
  93. POWER_APPARENT_TYPE = 2 //视在功率类型
  94. };
  95. enum
  96. {
  97. SENSOR_TYPE_TEMP_HUMI = 0 , //温湿度传感器
  98. SENSOR_TYPE_SMOKE = 1 , //烟雾传感器
  99. SENSOR_TYPE_WATER = 2 , //水浸传感器
  100. SENSOR_TYPE_ACCESS = 3 , //门禁传感器
  101. SENSOR_TYPE_GAS = 4 , //气体传感器
  102. SENSOR_TYPE_AIR_PRESS = 5 , //气压传感器
  103. SENSOR_TYPE_AIR_COND = 6, //空条传感器
  104. SENSOR_TYPE_LEAK = 7, //泄漏传感器
  105. SENSOR_TYPE_TEMP = 8, //温度传感器
  106. SENSOR_TYPE_TEMP_DOUBLE = 9, //双温度传感器
  107. SENSOR_TYPE_PRESS = 10, //压力传感器
  108. SENSOR_TYPE_MAX,
  109. };
  110. enum {
  111. SENSOR_TYPE_TEMP_HUMI_RSWSN01PVC=0,
  112. SENSOR_TYPE_TEMP_HUMI_HKSHT301T1H536VRS485,
  113. SENSOR_TYPE_TEMP_HUMI_MAX
  114. };
  115. enum {
  116. SENSOR_TYPE_TEMP_DOUBLE_DL10BM485V24D2=0,
  117. SENSOR_TYPE_TEMP_DOUBLE_MAX
  118. };
  119. enum {
  120. SENSOR_TYPE_TEMP_BTG50H8EL3200=0,
  121. SENSOR_TYPE_TEMP_MAX
  122. };
  123. enum {
  124. SENSOR_TYPE_LEAK_XWDC01A=0,
  125. SENSOR_TYPE_LEAK_MAX
  126. };
  127. enum
  128. {
  129. SENSOR_VAL1_UPPER = 0,
  130. SENSOR_VAL1_LOWER,
  131. SENSOR_VAL2_UPPER,
  132. SENSOR_VAL2_LOWER,
  133. };
  134. enum
  135. {
  136. SENSOR_TYPE_VALUE = 0 , //传感器类型0、4、5
  137. SENSOR_TYPE_LIST //传感器类型1、2、3
  138. };
  139. /// @brief 板子类型
  140. enum MODBUS_BOARD_TYPE
  141. {
  142. AC_SINGLE_S_TYPE=1,
  143. AC_SINGLE_B_TYPE,
  144. AC_MULTI_S_TYPE,
  145. AC_MULTI_B_TYPE,
  146. DC_OUT_TYPE,
  147. DC_IN_TYPE,
  148. DCPDU_TYPE,
  149. TREE_AC_TYPE, //三相进三项出
  150. };
  151. enum AppProductType
  152. {
  153. SmartPDU_AC=0,
  154. SmartPDU_DC=1,
  155. SmartPDU_Tree_AC_Tree=3,
  156. SmartPDU_Tree_AC_One=4,
  157. SmartPDU_Tree_AC_One_B=5,
  158. };
  159. /// @brief 三相网页数据
  160. static char* g_product_t_ac_type_str[3] = {
  161. "L1",
  162. "L2",
  163. "L3",
  164. };
  165. /// @brief 按位标记
  166. enum BIT_CTRL
  167. {
  168. BIT_00 = 1 ,
  169. BIT_01 = 2 ,
  170. BIT_02 = 4 ,
  171. BIT_03 = 8 ,
  172. BIT_04 = 16,
  173. BIT_05 = 32,
  174. BIT_06 = 64,
  175. BIT_07 = 128,
  176. BIT_08 = 256,
  177. BIT_09 = 512,
  178. BIT_10 = 1024,
  179. BIT_11 = 2048,
  180. BIT_12 = 4096,
  181. BIT_13 = 8192,
  182. BIT_14 = 16384,
  183. BIT_15 = 32768,
  184. };
  185. /// @brief 使能位
  186. enum ENABLE_BIT_CTRL
  187. {
  188. ENABLE_V_UP = 2 ,
  189. ENABLE_V_DOWN = 8 ,
  190. ENABLE_A_UP = 32,
  191. ENABLE_W_UP = 128,
  192. ENABLE_P_UP = 512,
  193. ENABLE_ALL_UP = BIT_11,
  194. ENABLE_ALL_DOWN = BIT_12,
  195. };
  196. /// @brief 使能位三项
  197. enum ENABLE_TreeAC_CTRL
  198. {
  199. ENABLE_TAC_V_UP = BIT_01,
  200. ENABLE_TAC_V_DOWN = BIT_02,
  201. ENABLE_TAC_A_UP = BIT_03,
  202. ENABLE_TAC_W_UP = BIT_04,
  203. ENABLE_TAC_P_UP = BIT_05,
  204. ENABLE_TAC_STIME = BIT_06,
  205. ENABLE_TAC_ETIME = BIT_07,
  206. };
  207. /// @brief 报警位
  208. enum WARNING_BIT_CTRL
  209. {
  210. WARNING_V_UP = 4 ,
  211. WARNING_V_DOWN = 16 ,
  212. WARNING_A_UP = 64,
  213. WARNING_W_UP = 256,
  214. WARNING_P_UP = 1024,
  215. };
  216. enum {
  217. ALARM_TYPE_POWER=0,
  218. ALARM_TYPE_SENSOR,
  219. ALARM_TYPE_NETWORK,
  220. ALARM_TYPE_OPRATION,
  221. ALARM_TYPE_RUNNING,
  222. };
  223. enum {
  224. NETWORK_MAC_CHANGED=0,
  225. NETWORK_IP_CHANGED,
  226. };
  227. /// @brief 报警动作
  228. enum ALARM_CTRL
  229. {
  230. ALARM_CTRL_CLOSE_CH = 1 ,
  231. ALARM_CTRL_ALARM_ONLY = 2 ,
  232. ALARM_CTRL_CLOSE_ALLCH = 3 ,
  233. };
  234. enum {
  235. MODBUS_MASTER=0,
  236. MODBUS_SLAVE,
  237. };
  238. enum {
  239. LANG_ID_CHINESE=0,
  240. LANG_ID_ENGLISH,
  241. LANG_ID_RUSSIAN,
  242. LANG_ID_SPANISH,
  243. LANG_ID_PORTYGYESE,
  244. LANG_ID_GERMAN,
  245. LANG_ID_FRENCH,
  246. LANG_ID_ITALIAN,
  247. LANG_ID_JAPANESE,
  248. LANG_ID_MAX
  249. };
  250. ///////////////////////////////////////////////////////////////////////////////////
  251. typedef struct {
  252. int id;
  253. int up;
  254. char ip[48];
  255. char mac[24];
  256. char desc[64];
  257. }port_info_t;
  258. typedef struct {
  259. #define SW_PORT_MAX 28
  260. port_info_t port[SW_PORT_MAX];
  261. }netswitch_info_t;
  262. ///////////////////////////////////////////////////////////////////////////////////
  263. //modbus信息管理
  264. typedef struct
  265. {
  266. bool mode ; //0: master 1slave
  267. unsigned char addr;
  268. unsigned int baudrate ; //波特率
  269. char path[32] ; //device path
  270. }ModbusInfo_t;
  271. typedef struct
  272. {
  273. int mode; //0:dhcp 1:static
  274. char ip_address[64] ; //ip地址
  275. char mask[64]; //子网掩码
  276. char gateway[64]; //网关
  277. char dns1[64]; //dns1
  278. char dns2[64]; //dns2
  279. }NetworkInfo_t;
  280. /// @brief 用户登录
  281. typedef struct
  282. {
  283. char user_name[64];
  284. char user_password[64];
  285. char user_uuid[64];
  286. char user_token[64];
  287. struct list_head list;
  288. }_User_Log;
  289. typedef struct {
  290. uint32_t id; //产品ID
  291. char pname[32]; //产品名称
  292. char pnumber[32]; //产品编号
  293. char status[32]; //产品状态
  294. char name[32]; //设备名称
  295. char number[32]; //设备编号
  296. char date[32]; //设备生产日期
  297. char batch[32]; //设备生产批次
  298. uint8_t type; //产品类型
  299. uint8_t pwr_type; //电源类型
  300. char version[8]; //软件版本
  301. uint8_t language; //多国语言
  302. uint8_t count; //级联设备数
  303. uint32_t samp_time; //采集周期 单位ms
  304. uint32_t save_time; //采集周期 单位ms
  305. uint16_t ph_group; //三组相数
  306. uint16_t ch_delay; //通道延时
  307. }ProductInfo_t;
  308. typedef struct {
  309. int monway; //1:总检测 2:分监分控 3:分监不控
  310. int netsw;
  311. int nwire;
  312. int ipv4;
  313. int ipv6;
  314. }WebcfgInfo_t;
  315. typedef struct {
  316. int watchdog;
  317. int flip_time;
  318. int led;
  319. int beep;
  320. int rotate;
  321. }MiscInfo_t;
  322. typedef struct {
  323. char name[256];
  324. char site[256];
  325. char mail[256];
  326. char addr[256];
  327. char tele[32];
  328. }ServiceInfo_t;
  329. typedef struct
  330. {
  331. int voltage;
  332. int current;
  333. int power;
  334. int brdMax;
  335. }PowerTotal_t;
  336. // WIFI信息
  337. typedef struct
  338. {
  339. int mode; // WIFI模块启用状态
  340. bool Link_status; // wifi网络连接状态
  341. char WIFI_ip[64]; // wifi ip address
  342. char WIFI_name[64];// WIFI网络SSID名称
  343. char WIFI_code[64];// WIFI密码
  344. } WIFIManager;
  345. typedef struct
  346. {
  347. ModbusInfo_t relay; //继电器控制端口
  348. NetworkInfo_t network; //网络信息
  349. ModbusInfo_t cascade; //级联端口
  350. ProductInfo_t product; //产品信息
  351. PowerTotal_t ptotal;
  352. WebcfgInfo_t webcfg;
  353. ServiceInfo_t service; //服务信息
  354. MiscInfo_t misc;
  355. int cell;
  356. WIFIManager wifi;
  357. }GlobalDeviceInfo;
  358. ///////////////////////////////////////////////////////////////////////////////////
  359. //自定义共享内存类
  360. typedef struct
  361. {
  362. //电源数据
  363. int bPDUSet;
  364. int nSelectPowerCH;
  365. int nMaxCh;
  366. float fV;
  367. float fA;
  368. float fW;
  369. float fF;
  370. float fS;
  371. int nStatus;
  372. //传感器数据
  373. int nSelectSensor;
  374. float fT;//温度
  375. float fH;//湿度
  376. //三项数据
  377. int bT_ACType;//三相类型
  378. int nSelectPh;//当前通道的三相ph参数:0:A相 1:B相 2:C相 -1通道总计
  379. } smartPDU_shm_data;
  380. ///////////////////////////////////////////////////////////////////////////////////
  381. ///////////////////////////////////////////////////////////////////////////////////
  382. //超限管理表
  383. typedef struct
  384. {
  385. int product_vol_upper_enable ;//电压上限使能
  386. float product_vol_upper_threshold ;//电压上限值
  387. int product_vol_over_upper_threshold_ctrl ;//电压超限动作
  388. int product_vol_over_upper_threshold_ctrl_para ;//电压超限关联参数
  389. int product_vol_lower_enable ;//电压下限使能
  390. float product_vol_lower_threshold ;//电压下限值
  391. int product_vol_over_lower_threshold_ctrl ;//电压超限动作
  392. int product_vol_over_lower_threshold_ctrl_para ;//电压超限动作
  393. int product_cur_upper_enable ;//电流下限使能
  394. float product_cur_upper_threshold ;//电流下限值
  395. float product_cur_lower_threshold; //
  396. int product_cur_over_upper_threshold_ctrl ;//电流超限动作
  397. int product_cur_over_upper_threshold_ctrl_para ;//电流超限动作
  398. int product_pwr_upper_enable ;//功率上限使能
  399. float product_pwr_upper_threshold ;//功率上限值
  400. int product_pwr_over_upper_threshold_ctrl ;//功率超限动作
  401. int product_pwr_over_upper_threshold_ctrl_para ;//功率超限动作
  402. int product_pwrcon_upper_enable ;//耗电量上限使能
  403. float product_pwrcon_upper_threshold ;//耗电量上限值
  404. int product_pwrcon_over_upper_threshold_ctrl ;//耗电量超限动作
  405. int product_pwrcon_over_upper_threshold_ctrl_para ;//耗电量超限动作
  406. }GlobalOverManager;
  407. /// @brief 定时管理
  408. typedef struct
  409. {
  410. char set_date[16]; //设置日期
  411. char ds_date[16]; //设置时间
  412. char ds_time[16]; //设置时间
  413. int set_stats; //状态
  414. int ds_is_triggered; //是否已触发
  415. struct list_head list;
  416. }_PowerDSManage_t;
  417. typedef struct
  418. {
  419. int firingSortno; //启动序号
  420. int closeSortno; //关闭序号
  421. }_PowerSXManage_t;
  422. typedef struct
  423. {
  424. int product_id;
  425. int mode;
  426. char ntpName[64];
  427. char ntpaddress[64];
  428. int port;
  429. char time[64];
  430. int weekday;
  431. int tzone;
  432. }NTPManager;
  433. enum {
  434. SNMP_AUTH_NONE=0,
  435. SNMP_AUTH_MD5,
  436. SNMP_AUTH_SHA,
  437. SNMP_AUTH_MAX
  438. };
  439. enum {
  440. SNMP_ENCYPT_NONE=0,
  441. SNMP_ENCYPT_DES,
  442. SNMP_ENCYPT_AES,
  443. SNMP_ENCYPT_MAX
  444. };
  445. typedef struct {
  446. char alg[12];
  447. char passwd[64];
  448. }crypt_data_t;
  449. typedef struct {
  450. char user[32];
  451. crypt_data_t auth;
  452. crypt_data_t priv;
  453. }crypt_t;
  454. typedef struct
  455. {
  456. int product_id;
  457. int mode;
  458. int version;
  459. char public[64];
  460. int trapmode;
  461. crypt_t crypt;
  462. char nmsIP[64];
  463. }SNMPManager;
  464. //分组管理
  465. typedef struct
  466. {
  467. int product_id;
  468. int GroupID;
  469. char GroupName[64];
  470. char GroupChList[512];
  471. struct list_head list;
  472. }GroupInfo;
  473. // 4G网络及GPS信息
  474. typedef struct
  475. {
  476. int mode; // 4G模块启用状态
  477. bool Link_status; // 4G网络连接状态
  478. bool RS_status; // 4G模组串口访问状态
  479. int RS_fd; // 4G模组串口访问状态
  480. float Signal_strength; // 信号强度
  481. char Cellular_name[64];// 4G网络名称
  482. char Cellular_APN[64];// APN接入点名称
  483. char Cellular_Num[64];// 电话号码
  484. bool GPS_status; // GPS功能启用
  485. char GPS_utc[64];// UTC时间
  486. float GPS_latitude;// 纬度,范围-89.99999~89.99999
  487. float GPS_longitude;// 精度,范围-179.99999~179.99999
  488. float GPS_altitude;// 海拔高度,单位m
  489. float GPS_speed;//地面速率,单位km/h
  490. int GPS_nsat;//卫星数量
  491. bool SMS_status; // 短信功能启用
  492. } CellularManager;
  493. //电源部分
  494. typedef struct
  495. {
  496. float voltage ;//电压
  497. float current ;//电流
  498. float power ;//功率
  499. float freq ;//频率
  500. float consumption ;//耗电量
  501. float factor ;//功率因素
  502. unsigned short status ;//开关状态
  503. unsigned short NF_status ;//零线状态
  504. port_info_t port; //
  505. }PowerInfo;
  506. //电源部分报警信息
  507. typedef struct
  508. {
  509. bool w_voltage_up ;//电压上限报警
  510. bool w_voltage_down ;//电压下限报警
  511. bool w_current ;//电流上限报警
  512. bool w_power ;//功率
  513. bool w_consumption ;//耗电量
  514. bool w_phase_lossA; // 缺相报警
  515. bool w_phase_lossB; // 缺相报警
  516. bool w_phase_lossC; // 缺相报警
  517. }PowerWarningInfo;
  518. //三项数据
  519. typedef struct
  520. {
  521. int product_id;
  522. int product_ch_id;
  523. int product_ph_id;
  524. int product_ph_type;//0:A相 1:B相 2:C相
  525. int product_saddr;
  526. int product_ch_addr;
  527. int product_ph_outputType;//三相控制方式1,三项2单项
  528. int product_ph_outputStatus;//该相是否输出,1输出2不输出
  529. char samp_time[64]; //采集时间
  530. PowerInfo _PowerInfo; //存储最新的数据(兼容三项输入)
  531. GlobalOverManager global_over_manager; //超限管理
  532. PowerWarningInfo _PowerWarninginfo; //存储报警数据(兼容三项输入)
  533. time_t product_log_time; //存储最新时间
  534. struct list_head list_Tree_AC; //存储三项数据指针
  535. }GlobalTreeACManager;
  536. //电源通道管理总表(输出)
  537. typedef struct
  538. {
  539. int product_id ;//产品ID
  540. //20240225 add
  541. int product_saddr ;//modbus地址记录
  542. int product_ch_id ;//通道号
  543. int product_ch_addr ;//通道号实际地址
  544. char product_ch_name[32] ;//通道名称
  545. int product_ch_type ;//通道类型
  546. int product_ch_status ;//通道状态
  547. int product_ch_NF_status ;//通道零线状态(三相)
  548. int product_ch_start_delay ;//通道延时
  549. int product_ch_stop_delay ;//通道延时
  550. GlobalOverManager global_over_manager ;//超限管理
  551. struct list_head list_DS; //定时设置
  552. _PowerSXManage_t* _PowerSXManage; //时序管理
  553. PowerInfo _PowerInfo; //存储最新的数据
  554. PowerWarningInfo _PowerWarninginfo ; //存储报警数据
  555. time_t product_log_time; //存储最新时间
  556. struct list_head list_Tree_AC; //存储三项数据指针
  557. struct list_head list;
  558. } GlobalPowerManger;
  559. //电源通道管理总表(输入)
  560. typedef struct
  561. {
  562. int product_id ;//产品ID
  563. //20240225 add
  564. char product_saddr ;//modbus地址记录
  565. char product_saddr_name[32] ;//输入名称
  566. char product_saddr_type ;//输入类型
  567. GlobalOverManager global_over_manager ;//超限管理
  568. PowerInfo _PowerInfo[3]; //存储最新的数据(兼容三项输入)
  569. PowerWarningInfo _PowerWarninginfo[3]; //存储报警数据(兼容三项输入)
  570. time_t product_log_time; //存储最新时间
  571. int product_MissingPH[3]; //缺相报警
  572. }GlobalPowerInManger;
  573. //电源控制板计数
  574. typedef struct
  575. {
  576. char product_saddr ;//modbus地址记录
  577. int product_number; //数量
  578. int product_type; //类型
  579. PowerInfo _PowerInfo[AC_SINGLE_S_MAX_CHN_NUM]; //存储最新的数据
  580. PowerWarningInfo _PowerWarninginfo[AC_SINGLE_S_MAX_CHN_NUM] ;//存储报警数据
  581. struct list_head list; //存储具有的通道指针
  582. GlobalPowerInManger _globalPowerInManger; //总输入数据
  583. }GlobalPowerCtrlBoard;
  584. ///////////////////////////////////////////////////////////////////////////////////
  585. ///////////////////////////////////////////////////////////////////////////////////
  586. //电源信息统计
  587. typedef struct
  588. {
  589. float ydata[60]; //value
  590. char xAxis[60][32];//时间点
  591. }GetTotalInfo;
  592. //系统总数信息
  593. typedef struct
  594. {
  595. int channel_total ;//通道总数
  596. int warn_total ;//告警总数
  597. int sensor_total ;//传感器总数
  598. int log_total ;//运行日志总数
  599. }SystemTotalInfo;
  600. //功率趋势接口
  601. typedef struct
  602. {
  603. float ydata[3][60] ;//0:有功功率;1:无功功率;2:视在功率;
  604. char xAxis[60][32] ;//时间点
  605. }PowerTrendInfo;
  606. ///////////////////////////////////////////////////////////////////////////////////
  607. ///////////////////////////////////////////////////////////////////////////////////
  608. //电源监控
  609. typedef struct
  610. {
  611. int product_id ;//产品ID
  612. char product_ch_id ;//电源通道
  613. unsigned short product_status ;//当前状态
  614. PowerInfo _power_info ;//采集值
  615. char samp_time[64] ;//采集时间
  616. GetTotalInfo _total_voltage ;//统计电压
  617. GetTotalInfo _total_current ;//统计电流
  618. GetTotalInfo _total_power ;//统计功率
  619. GetTotalInfo _total_consumption ;//统计耗电量
  620. SystemTotalInfo _system_total_info ;//系统总数信息
  621. PowerTrendInfo _power_trend_info ;//功率趋势图
  622. struct list_head list;
  623. }GlobalPowerInfo;
  624. ///////////////////////////////////////////////////////////////////////////////////
  625. ///////////////////////////////////////////////////////////////////////////////////
  626. ///////////////////////////////////////////////////////////////////////////////////
  627. ///////////////////////////////////////////////////////////////////////////////////
  628. //传感器值
  629. typedef struct
  630. {
  631. char samp_time[64] ;//采集时间
  632. int product_id ;//产品ID
  633. char sensor_id ;//传感器ID
  634. float val1 ;//值1
  635. float val2 ;//值2
  636. time_t product_log_time; //存储最新时间
  637. struct list_head list;
  638. }GlobalSensorInfo;
  639. typedef struct
  640. {
  641. int sensor_val1_upper_enabled ;//
  642. float sensor_val1_upper_threshold;
  643. int sensor_val1_upper_threshold_ctrl;
  644. char sensor_val1_upper_threshold_ctrl_para[512];
  645. int sensor_val1_lower_enabled ;//
  646. float sensor_val1_lower_threshold;
  647. int sensor_val1_lower_threshold_ctrl;
  648. char sensor_val1_lower_threshold_ctrl_para[512];
  649. int sensor_val2_upper_enabled ;//
  650. float sensor_val2_upper_threshold;
  651. int sensor_val2_upper_threshold_ctrl;
  652. char sensor_val2_upper_threshold_ctrl_para[512];
  653. int sensor_val2_lower_enabled ;//
  654. float sensor_val2_lower_threshold;
  655. int sensor_val2_lower_threshold_ctrl;
  656. char sensor_val2_lower_threshold_ctrl_para[512];
  657. }GlobalSensorOverManage;
  658. //传感器报警状态表
  659. typedef struct
  660. {
  661. int sensor_val1_upper;
  662. int sensor_val1_lower;
  663. int sensor_val2_upper;
  664. int sensor_val2_lower;
  665. }GlobalSensorOverInfo;
  666. //传感器管理总表
  667. typedef struct
  668. {
  669. int product_id ;//产品ID
  670. int sensor_id ;//传感器ID
  671. int sensor_type ;//传感器类型
  672. int sensor_interface_type; //接口类型
  673. char sensor_name[64] ;//传感器名称
  674. char sensor_port_name[32] ;//传感器端口号
  675. int sensor_baud ;//波特率
  676. int sensor_addr ;//modbus地址
  677. int sensor_status ;//传感器状态
  678. int sensor_val_count ;//传感器值个数
  679. int sensor_node_number ;//节点号
  680. GlobalSensorInfo Cur_sensor_info ;
  681. GlobalSensorOverManage over_manager ;//超限管理
  682. GlobalSensorOverInfo warning_status;//报警状态
  683. struct list_head list;
  684. }GlobalSensorManger;
  685. ///////////////////////////////////////////////////////////////////////////////////
  686. ///////////////////////////////////////////////////////////////////////////////////
  687. ///////////////////////////////////////////////////////////////////////////////////
  688. ///////////////////////////////////////////////////////////////////////////////////
  689. ///温湿度数据信息管理
  690. typedef struct
  691. {
  692. float temperature;
  693. float humidity;
  694. }SenorTempVal;
  695. //采集KB值
  696. typedef struct
  697. {
  698. float voltage_k;//电压K
  699. float voltage_b;//电压B
  700. float current_k;//电流K
  701. float current_b;//电流B
  702. }SwitchKbVal;
  703. ///////////////////////////////////////////////////////////////////////////////////
  704. ///////////////////////////////////////////////////////////////////////////////////
  705. //MAIL管理
  706. typedef struct
  707. {
  708. int id;
  709. int use;
  710. char account[64];
  711. }mail_recv_t;
  712. typedef struct
  713. {
  714. int id;
  715. int mode; //0: open 1: close
  716. char account[64]; //用户账号
  717. char password[24]; //用户密码
  718. char server[64]; //服务器
  719. char port[10]; //端口
  720. char auth[16]; //认证方式
  721. char ca[8196]; //ca cert
  722. }mail_send_t;
  723. typedef struct
  724. {
  725. mail_send_t send;
  726. #define MAIL_RECV_MAX 10
  727. mail_recv_t recv[MAIL_RECV_MAX]; //接收账号列表
  728. }mail_info_t;
  729. enum {
  730. MQTT_PLAT_EMQX=0,
  731. MQTT_PLAT_ALIYUN,
  732. MQTT_PLAT_MAX
  733. };
  734. typedef struct {
  735. int id; //id
  736. int plat; //0: emqx 1: aliyun
  737. int mode; //0: open 1: close
  738. char proto[16]; //mqtt, mqtts, ws, wss
  739. char name[32]; //server name
  740. char server[512]; //server ip
  741. char port[10]; //server port
  742. char cid[64]; //client ID
  743. char user[64]; //
  744. char password[64];
  745. char cert[8200];
  746. int status;
  747. }mqtt_server_t;
  748. typedef struct {
  749. #define MQTT_SER_MAX 5
  750. mqtt_server_t ser[MQTT_SER_MAX];
  751. }mqtt_info_t;
  752. typedef struct
  753. {
  754. int product_id;
  755. int userID; //用户ID
  756. char userName[32]; //用户名-登录
  757. char userPW[32]; //用户密码
  758. char nickName[32]; //用户名称
  759. int roleID; //角色ID
  760. char createTime[32]; //用户创建时间
  761. struct list_head list;
  762. }UserInfo;
  763. typedef struct
  764. {
  765. int product_id;
  766. int roleID; //角色ID
  767. char roleName[32]; //角色名称
  768. int roleLevel; //角色等级
  769. char roleAuthority[32]; //角色权限
  770. int roleSort; //显示顺序
  771. char createTime[32]; //创建时间
  772. struct list_head list;
  773. }RoleInfo;
  774. typedef struct MenuAuthority{
  775. bool PowerEnabled;
  776. bool SensorEnabled;
  777. bool AlarmEnabled;
  778. bool LogEnabled;
  779. bool UserInfoEnabled;
  780. bool CommEnabled;
  781. bool ServiceEnabled;
  782. bool MaintenanceEnabled;
  783. //1、电源监控菜单
  784. bool MonitorallEnabled;
  785. bool ChannelstatusEnabled;
  786. bool SwitchtatusEnabled;
  787. bool MonitorhistoryEnabled;
  788. //2、传感器管理菜单
  789. bool SensorStatusEnabled;
  790. bool SensorHistorylEnabled;
  791. //3、告警管理菜单
  792. bool XtjgEnabled;
  793. bool YzszEnabled;
  794. //4、日志信息菜单
  795. bool CzrzEnabled;
  796. bool YxrzEnabled;
  797. //5、用户管理菜单
  798. bool UserEnabled;
  799. bool RoleEnabled;
  800. bool MenuEnabled;
  801. //6、通信管理菜单
  802. bool WkszEnabled;
  803. bool RsszEnabled;
  804. bool CellularEnabled;
  805. bool WifiEnabled;
  806. //7、服务管理菜单
  807. bool SmtpszEnabled;
  808. bool SnmpszEnabled;
  809. bool MqszEnabled;
  810. bool NtpszEnabled;
  811. bool DsszEnabled;
  812. bool SxszEnabled;
  813. bool FzszEnabled;
  814. //8、设备维护菜单
  815. bool SbcqEnabled;
  816. bool GjsjEnabled;
  817. bool KzbsjEnabled;
  818. bool HhccszEnabled;
  819. bool PzdrdcEnabled;
  820. bool ShfwEnabled;
  821. bool GysbEnabled;
  822. }MenuAuthority;
  823. typedef struct CascadeDevices{
  824. int product_id; //级联设备ID modbus地址
  825. int type; //
  826. char device_name[20]; //接连设备名;
  827. float valtage; //485
  828. float current;
  829. float power;
  830. float factor;
  831. float freq;
  832. float consumption;
  833. }CascadeDevices;
  834. struct modbus_slave_read_reg{
  835. uint16_t deveice_type; //设备类型
  836. uint16_t slave_addr; //设备地址
  837. uint32_t voltage; //当前电压
  838. uint32_t current; //当前电流
  839. uint32_t power; //当前功率
  840. uint32_t consumption_cur; //耗电量
  841. uint32_t freq; //频率
  842. uint32_t factor; //功率因素
  843. uint32_t temprature; //温度值
  844. uint32_t humidity; //湿度值
  845. uint32_t warning; //告警
  846. uint16_t power_supplay_status; //供电状态
  847. uint16_t sencor_status; //传感器状态
  848. uint32_t temprature2; //温度值2
  849. // uint32_t Warinfo;
  850. // uint16_t sercor_type;
  851. };
  852. typedef struct cascade_pw_info{
  853. uint32_t voltage ;//电压
  854. uint32_t current ;//电流
  855. uint32_t power ;//功率
  856. uint32_t freq ;//频率
  857. uint32_t consumption ;//耗电量
  858. uint32_t factor ;//功率因素
  859. }cascade_single_chn_info; //siggle hell
  860. typedef struct temp_hum{
  861. uint16_t temperature;
  862. uint16_t humidity;
  863. }temp_hum_t;
  864. typedef uint32_t sensor_t;
  865. typedef uint16_t dry_node_t;
  866. typedef struct cascade_sensor{
  867. sensor_t s_1;
  868. sensor_t s_2;
  869. }cascade_sensor_t;
  870. #pragma pack (1)
  871. typedef struct cascade_single_mmap{
  872. uint16_t dev_chn;
  873. cascade_single_chn_info all_ch[128];
  874. uint32_t total_valtage;
  875. uint32_t total_current;
  876. uint32_t total_power;
  877. uint32_t total_consumer;
  878. temp_hum_t total_temp;
  879. uint16_t chn_status[64];
  880. uint16_t open_delay[64];
  881. uint16_t close_delay[64];
  882. //uint16_t reservers[29];
  883. cascade_sensor_t cas_sensor[4];
  884. dry_node_t d_node[4];
  885. uint16_t reservers[9];
  886. uint16_t set_chn_open_delay[64];
  887. uint16_t set_chn_close_delay[64];
  888. uint16_t set_chn_switch_status[64];
  889. uint16_t set_chn_all_switch_status;
  890. }cascade_single_mmap_t;
  891. #ifdef NORTH_USER_SPECILS
  892. typedef struct cascade_north_user{
  893. uint32_t total_elec_energy;
  894. uint16_t frequency;
  895. uint16_t wire_voltage[3];
  896. uint16_t wire_current[3];
  897. uint16_t total_power;
  898. uint16_t status_1_16;
  899. uint16_t status_17_32;
  900. uint16_t status_33_48;
  901. uint16_t status_49_64;
  902. uint16_t total_wanning;
  903. uint16_t current_wanning;
  904. uint16_t fault_1_16;
  905. uint16_t fault_17_32;
  906. uint16_t fault_33_48;
  907. uint16_t fault_49_64;
  908. uint16_t set_1_16;
  909. uint16_t set_17_32;
  910. uint16_t set_33_48;
  911. uint16_t set_49_64;
  912. }cascade_north_user_t;
  913. #endif
  914. #pragma pack ()
  915. #pragma pack (1)
  916. #define MAX_CHN 64
  917. typedef struct cascade_triphasic_pw_out{
  918. uint32_t o_voltage;
  919. uint32_t o_current;
  920. uint32_t o_power;
  921. uint32_t o_consumption;
  922. uint32_t o_status;
  923. }cascade_triphasic_pw_out_t;
  924. typedef struct cascade_triphasic_pw_o_chn{
  925. cascade_triphasic_pw_out_t chn[3]; // A B C
  926. }cascade_triphasic_pw_o_chn_t;
  927. typedef struct cascade_triphasic_pw_in{
  928. uint32_t i_total_voltage;
  929. uint32_t i_total_current;
  930. uint32_t i_total_power;
  931. uint32_t i_total_consumption;
  932. }cascade_triphasic_pw_in_t;
  933. typedef struct cascade_triphasic_pw_i_total{
  934. cascade_triphasic_pw_in_t pw_i_total[3]; // A B C
  935. }cascade_triphasic_pw_i_total_t;
  936. typedef struct cascade_triphasic_chn_info{
  937. uint32_t chn_power;
  938. uint32_t chn_freq;
  939. uint32_t chn_consumption;
  940. uint32_t chn_factor;
  941. uint32_t chn_type;
  942. }cascade_triphasic_chn_info_t;
  943. typedef struct cascade_triphasic_mmap{
  944. uint16_t dev_chn;
  945. cascade_triphasic_pw_i_total_t i_total;
  946. cascade_triphasic_chn_info_t chn_info[MAX_CHN];
  947. cascade_triphasic_pw_o_chn_t pw_o_chn[MAX_CHN];
  948. uint16_t temperature;
  949. uint16_t humidity;
  950. uint16_t chn_status[MAX_CHN];
  951. uint16_t open_delay[MAX_CHN];
  952. uint16_t close_delay[MAX_CHN];
  953. cascade_sensor_t cas_sensor[4];
  954. dry_node_t d_node[4];
  955. uint16_t set_chn_open_delay[MAX_CHN];
  956. uint16_t set_chn_close_delay[MAX_CHN];
  957. uint16_t set_chn_switch_status[MAX_CHN];
  958. uint16_t set_chn_all_switch_status;
  959. }cascade_triphasic_mmap_t;
  960. typedef struct
  961. {
  962. modbus_t *ctx;
  963. char ip[64];
  964. uint16_t port;
  965. uint8_t slave_id;
  966. uint8_t power_type;
  967. modbus_mapping_t *map;
  968. int connection;
  969. //pthread_mutex_t mutex;
  970. }Modbus_Manger_Tcp;
  971. #pragma pack ()
  972. struct modbus_slave_write_reg{
  973. uint16_t voltage_high_enable:1; //电压高阈值检测使能
  974. uint16_t voltage_low_enable:1; //电压低阈值检测使能
  975. uint16_t current_enable:1; //电流阈值使能
  976. uint16_t power_enable:1; //功率阈值使能
  977. uint16_t consumption_cur_enable:1; //功耗阈值使能
  978. uint32_t voltage_upper_threshold; //
  979. uint32_t voltage_lower_threshold;
  980. uint32_t current_upper_threshold;
  981. uint32_t power_upper_threshold;
  982. uint32_t consumption_threshold;
  983. };
  984. enum
  985. {
  986. DI,
  987. RS485
  988. };
  989. enum{
  990. SWITCH_CONNETCTED,
  991. SWITCH_DISCONNETCTED,
  992. SWITCH_OFFLINE
  993. };
  994. #define SWITCH_CHN_1_SET (1<<0)
  995. #define SWITCH_CHN_2_SET (1<<1)
  996. #define SWITCH_CHN_3_SET (1<<2)
  997. #define SWITCH_CHN_4_SET (1<<3)
  998. #define SWITCH_CHN_5_SET (1<<4)
  999. #define SWITCH_CHN_6_SET (1<<5)
  1000. #define SWITCH_CHN_DI_1_SET (1<<6)
  1001. #define SWITCH_CHN_DI_2_SET (1<<7)
  1002. typedef struct {
  1003. int id;
  1004. int type;
  1005. char date[32];
  1006. char content[128];
  1007. }alarm_data_t;
  1008. typedef struct {
  1009. int ch;
  1010. char date[16];
  1011. char time[16];
  1012. int status;
  1013. int triggered;
  1014. }timer_data_t;
  1015. typedef struct {
  1016. int addr;
  1017. char name[32];
  1018. char ver[32];
  1019. char date[32];
  1020. int dev_id;
  1021. int brd_id;
  1022. int channels;
  1023. int status;
  1024. }board_info_t;
  1025. typedef struct breaker_switch_sta{
  1026. uint16_t status;
  1027. uint16_t gather;
  1028. char com[30];
  1029. uint8_t product_name[256];
  1030. }breaker_switch_sta_t;
  1031. typedef struct GlobalBreakerManger{
  1032. uint32_t all_count;
  1033. uint32_t online_count;
  1034. uint32_t mask;
  1035. uint8_t saddr;
  1036. void *manager;
  1037. breaker_switch_sta_t sta[8]; // 6 + 2
  1038. pthread_mutex_t b_mutex;
  1039. }GlobalBreakerManger;
  1040. typedef struct GlobalBreakerManager{
  1041. uint32_t product_id;
  1042. uint32_t breaker_id;
  1043. uint32_t breaker_chn;
  1044. uint32_t breaker_status;
  1045. uint32_t breaker_gather_addr;
  1046. char breaker_switch_name[128];
  1047. char breaker_com[64];
  1048. char breaker_gather_type[64];
  1049. char breaker_chns_name[128];
  1050. struct list_head list;
  1051. }GlobalBreakerManager;
  1052. //设备总体管理
  1053. typedef struct
  1054. {
  1055. sqlite3* db; //数据库接口
  1056. pthread_mutex_t dbThreadlock; //写入线程锁
  1057. pthread_t appweb_thread; //appweb线程
  1058. pthread_t dev_samp_thread;//电源采集与控制线程
  1059. pthread_t dev_update_thread;//电源采集与控制线程
  1060. pthread_t io_thread; //IO采集线程
  1061. pthread_t sensor_thread; //传感器采集现成
  1062. bool dev_samp_flag ; //电源采集线程标志
  1063. GlobalDeviceInfo _globalDevInfo; //设备管理信息
  1064. GlobalPowerManger _globalPowerManger; //电源管理表
  1065. GlobalSensorManger _globalSensorManger; //传感器管理表
  1066. Modbus_Manger sensor_modbus_manager; //通信接口管理
  1067. unsigned int useSlaveCount ; //有效地址
  1068. Modbus_Manger _globalRelaySampManger; //内部继电器使用
  1069. unsigned char uart_init_flag[6] ; //
  1070. bool ws_isok; //ws准备好
  1071. struct mg_connection *ws_client; //websocket管理信息
  1072. HashTable* alarmTab; //全局的报警映射
  1073. int nTreeACLshow; //三项总数据显示L1=0,L2=1,L3=2
  1074. pthread_t snmp_agent_thread;//SNMP代理线程
  1075. bool _ReloadChm_flag; //重新加载端口数据
  1076. int brdMax;
  1077. GlobalPowerCtrlBoard *pCtrlBoard; //所有控制板
  1078. LowConf* _RS485LowConfData;//485Data
  1079. //传感器
  1080. struct modbus_slave_read_reg g_modebus_read;
  1081. struct modbus_slave_write_reg g_modebus_write;
  1082. smartPDU_shm_data* g_shm_Data;
  1083. pthread_mutex_t _power_ds; //定时器锁
  1084. pthread_mutex_t _power_update; //数据刷新锁
  1085. pthread_mutex_t _sensor_update; //传感器刷新锁
  1086. pthread_mutex_t _breaker_mutex; // breaker info
  1087. cascade_single_mmap_t *single_mmap;
  1088. cascade_triphasic_mmap_t *triphasic_mmap;
  1089. GlobalBreakerManager g_new_global_breaker;
  1090. mail_info_t mailInfo;
  1091. mqtt_info_t mqttInfo;
  1092. Modbus_Manger_Tcp *md_tcp;
  1093. #ifdef NORTH_USER_SPECILS
  1094. cascade_north_user_t north_user;
  1095. #endif
  1096. }GlobalDeviceManager;
  1097. extern GlobalDeviceManager __globalDeviceManage;
  1098. extern GlobalDeviceManager __globalDeviceManage2;
  1099. extern int ntp_sync_flag;
  1100. extern unsigned long __globalSxIdx;
  1101. extern _User_Log _GlobalUserLoginInfo;//全局用户登录信息
  1102. extern UserInfo _GlobalUserInfoNew;////最近登录的信息
  1103. extern char _GlobalUserToken[64];////最近登录的信息
  1104. extern MenuAuthority _GlobalMenuAuthority;////角色菜单权限
  1105. extern NTPManager _globalNTPManager;
  1106. extern SNMPManager _globalSNMPManager;
  1107. extern CellularManager _globalCellularManager;
  1108. extern WIFIManager _globalWIFIManager;
  1109. void initLogger(void);
  1110. //打印设备信息结构
  1111. void printf_global_device_info(GlobalDeviceInfo* _globalDeviceInfo);
  1112. //打印设备超限电源管理
  1113. void printf_global_power_manage_info(GlobalPowerManger* _globalPowerManger);
  1114. //打印设备超限电源通道管理
  1115. //void printf_global_power_chn_manage_info(GlobalPowerChnManger* _globalPowerChnManger);
  1116. void printf_power_info(GlobalPowerInfo* _globalPowerInfo);
  1117. int getTotalMemorySize(unsigned int* totalSize);
  1118. char* getLocalIpAddress(char* dev);
  1119. char* get_mac_address(const char *iface_name) ;
  1120. void get_disk_occupy(char ** reused);
  1121. int get_tzone(void);
  1122. int set_tzone(int tzone);
  1123. int set_time(struct tm *t, int tzone);
  1124. int set_utctime(time_t t);
  1125. int set_time_zone(struct tm *t, int tzone);
  1126. int set_utctime_zone(time_t t, int tzone);
  1127. time_t mktime0(void);
  1128. time_t mktime2(struct tm *t, int tzone);
  1129. int get_time_str(char *s, int len, time_t t);
  1130. int get_time_str2(char *s, int len, time_t t);
  1131. int get_curtime_str(char *s, int len);
  1132. int get_curtime_str2(char *s, int len);
  1133. int get_bldtime(char *buf, int len);
  1134. int get_bldtime2(char *dst, char *ori);
  1135. void print_time(char *s, struct tm *tm);
  1136. void print_utc(char *s, time_t t);
  1137. char* getUserNamebyToken(char* Token);
  1138. int is_process_running(const char *process_name);
  1139. bool CheckLoginStatus(char* Token);
  1140. // 辅助函数:判断是否是闰年
  1141. int is_leap_year(int year);
  1142. // 辅助函数:获取某月的天数
  1143. int days_in_month(int year, int month);
  1144. // 函数:增加一天到日期
  1145. void add_day_to_date(char *date_str, int *year, int *month, int *day);
  1146. void SetMenuAuthority(int RoleID);
  1147. void InitCellularManager();
  1148. #endif