common.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. #include "common.h"
  2. #include "elog.h"
  3. #include <unistd.h>
  4. #include <sys/types.h>
  5. #include <sys/sysinfo.h>
  6. #include <sys/ioctl.h>
  7. #include <sys/socket.h>
  8. #include <net/if.h>
  9. #include <arpa/inet.h>
  10. #include <sys/vfs.h>
  11. #undef LOG_TAG
  12. #define LOG_TAG "main"
  13. GlobalDeviceManager __globalDeviceManage;
  14. GlobalDeviceManager __globalDeviceManage2;
  15. unsigned long __globalSxIdx;
  16. NTPClient* globalNTPclient;
  17. _User_Log _GlobalUserLoginInfo;
  18. UserInfo _GlobalUserInfoNew;
  19. char _GlobalUserToken[64];
  20. MenuAuthority _GlobalMenuAuthority;
  21. void printf_global_device_info(GlobalDeviceInfo* _globalDeviceInfo)
  22. {
  23. log_d("******global device info********* ");
  24. log_d("product_id:%d ", _globalDeviceInfo->product_id);
  25. log_d("product_number:%s ", _globalDeviceInfo->product_number);
  26. log_d("product_name:%s ", _globalDeviceInfo->product_name);
  27. log_d("product_type:%d ", _globalDeviceInfo->product_type);
  28. log_d("product_pwr_type:%d ", _globalDeviceInfo->product_pwr_type);
  29. log_d("product_version:%s ", _globalDeviceInfo->product_version);
  30. log_d("product_count:%d ", _globalDeviceInfo->product_count);
  31. log_d("product_samp_time:%d ", _globalDeviceInfo->product_samp_time);
  32. log_d("product_save_time:%d ", _globalDeviceInfo->product_save_time);
  33. log_d("product_modbus_type:%d ", _globalDeviceInfo->_gmodbus_info.product_modbus_type);
  34. log_d("product_modbus_baud:%d ", _globalDeviceInfo->_gmodbus_info.product_modbus_baud);
  35. log_d("product_modbus_addr:%d ", _globalDeviceInfo->_gmodbus_info.product_modbus_addr);
  36. log_d("product_relay_port:%s ", _globalDeviceInfo->_modbus_info.product_relay_ctrl_port);
  37. log_d("******************************** ");
  38. }
  39. void printf_global_power_manage_info(GlobalPowerManger* _globalPowerManger)
  40. {
  41. printf("******global power manage info********* ");
  42. printf("product_id:%d ", _globalPowerManger->product_id);
  43. printf("product_ch_id:%d ", _globalPowerManger->product_ch_id);
  44. printf("product_ch_name:%s ", _globalPowerManger->product_ch_name);
  45. printf("product_ch_type:%d ", _globalPowerManger->product_ch_type);
  46. printf("product_ch_status:%d ", _globalPowerManger->product_ch_status);
  47. printf("product_ch_NF_status:%d ", _globalPowerManger->product_ch_NF_status);
  48. printf("product_ch_start_delay:%d ", _globalPowerManger->product_ch_start_delay);
  49. printf("product_ch_stop_delay:%d ", _globalPowerManger->product_ch_stop_delay);
  50. printf("product_vol_upper_enable:%d ", _globalPowerManger->global_over_manager->product_vol_upper_enable);
  51. printf("product_vol_upper_threshold:%0.2f ", _globalPowerManger->global_over_manager->product_vol_upper_threshold);
  52. printf("product_vol_over_upper_threshold_ctrl:%d ", _globalPowerManger->global_over_manager->product_vol_over_upper_threshold_ctrl);
  53. printf("product_vol_over_upper_threshold_para:%d ", _globalPowerManger->global_over_manager->product_vol_over_upper_threshold_ctrl_para);
  54. printf("product_vol_lower_enable:%d ", _globalPowerManger->global_over_manager->product_vol_lower_enable);
  55. printf("product_vol_lower_threshold:%0.2f ", _globalPowerManger->global_over_manager->product_vol_lower_threshold);
  56. printf("product_vol_over_lower_threshold_ctrl:%d ", _globalPowerManger->global_over_manager->product_vol_over_lower_threshold_ctrl);
  57. printf("product_vol_over_lower_threshold_ctrl_para:%d ", _globalPowerManger->global_over_manager->product_vol_over_lower_threshold_ctrl_para);
  58. printf("product_cur_upper_enable:%d ", _globalPowerManger->global_over_manager->product_cur_upper_enable);
  59. printf("product_cur_upper_threshold:%0.2f ", _globalPowerManger->global_over_manager->product_cur_upper_threshold);
  60. printf("product_cur_over_upper_threshold_ctrl:%d ", _globalPowerManger->global_over_manager->product_cur_over_upper_threshold_ctrl);
  61. printf("product_cur_over_upper_threshold_ctrl_para:%d ", _globalPowerManger->global_over_manager->product_cur_over_upper_threshold_ctrl_para);
  62. printf("product_pwr_upper_enable:%d ", _globalPowerManger->global_over_manager->product_pwr_upper_enable);
  63. printf("product_pwr_upper_threshold:%0.2f ", _globalPowerManger->global_over_manager->product_pwr_upper_threshold);
  64. printf("product_pwr_over_upper_threshold_ctrl:%d ", _globalPowerManger->global_over_manager->product_pwr_over_upper_threshold_ctrl);
  65. printf("product_pwr_over_upper_threshold_ctrl_para:%d ", _globalPowerManger->global_over_manager->product_pwr_over_upper_threshold_ctrl_para);
  66. printf("product_pwrcon_upper_enable:%d ", _globalPowerManger->global_over_manager->product_pwrcon_upper_enable);
  67. printf("product_pwrcon_upper_threshold:%0.2f ", _globalPowerManger->global_over_manager->product_pwrcon_upper_threshold);
  68. printf("product_pwrcon_over_upper_threshold_ctrl:%d ", _globalPowerManger->global_over_manager->product_pwrcon_over_upper_threshold_ctrl);
  69. printf("product_pwrcon_over_upper_threshold_ctrl_para:%d ", _globalPowerManger->global_over_manager->product_pwrcon_over_upper_threshold_ctrl_para);
  70. printf("******************************** ");
  71. }
  72. //打印电源信息
  73. void printf_power_info(GlobalPowerInfo* _globalPowerInfo)
  74. {
  75. struct list_head *pos;
  76. GlobalPowerInfo* _temp;
  77. int i = 0;
  78. list_for_each_entry(_temp, &_globalPowerInfo->list, list)
  79. {
  80. printf("i:%d ", i++);
  81. printf("samp_time:%s ", _temp->samp_time);
  82. printf("product_id:%d ", _temp->product_id);
  83. }
  84. }
  85. void INIT_LIST_HEAD(struct list_head *list)
  86. {
  87. list->next = list->prev = list;
  88. }
  89. /**
  90. * EasyLogger demo
  91. */
  92. // void test_elog(void) {
  93. // uint8_t buf[256]= {0};
  94. // int i = 0;
  95. // for (i = 0; i < sizeof(buf); i++)
  96. // {
  97. // buf[i] = i;
  98. // }
  99. // while(true) {
  100. // /* test log output for all level */
  101. // log_a("Hello EasyLogger!");
  102. // log_e("Hello EasyLogger!");
  103. // log_w("Hello EasyLogger!");
  104. // log_i("Hello EasyLogger!");
  105. // log_d("Hello EasyLogger!");
  106. // log_v("Hello EasyLogger!");
  107. // // elog_raw("Hello EasyLogger!");
  108. // elog_hexdump("test", 16, buf, sizeof(buf));
  109. // sleep(5);
  110. // }
  111. // }
  112. #if(1)
  113. void initLogger(void)
  114. {
  115. setbuf(stdout, NULL);
  116. elog_init();
  117. elog_set_fmt(ELOG_LVL_ASSERT, ELOG_FMT_ALL);
  118. elog_set_fmt(ELOG_LVL_ERROR, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME);
  119. elog_set_fmt(ELOG_LVL_WARN, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME);
  120. elog_set_fmt(ELOG_LVL_INFO, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME);
  121. elog_set_fmt(ELOG_LVL_DEBUG, ELOG_FMT_ALL & ~ELOG_FMT_FUNC);
  122. elog_set_fmt(ELOG_LVL_VERBOSE, ELOG_FMT_ALL & ~ELOG_FMT_FUNC);
  123. elog_set_text_color_enabled(true);
  124. elog_start();
  125. log_i("Smart Pdu Application Running!");
  126. }
  127. #endif
  128. /// @brief 获取系统mem大小
  129. /// @param totalSize
  130. /// @return
  131. int getTotalMemorySize(unsigned int* totalSize)
  132. {
  133. struct sysinfo memInfo;
  134. if (sysinfo(&memInfo) != -1) {
  135. *totalSize = memInfo.totalram;
  136. // printf("Total RAM size: %lu bytes\n", memInfo.totalram);
  137. // printf("Free RAM size: %lu bytes\n", memInfo.freeram);
  138. }
  139. else
  140. {
  141. *totalSize = 0 ;
  142. return -1;
  143. }
  144. return 0;
  145. }
  146. /// @brief 返回设备IP地址
  147. /// @param dev 网口名
  148. /// @return
  149. char* getLocalIpAddress(char* dev)
  150. {
  151. int fd;
  152. struct ifreq ifr;
  153. static char ip_addr[64];
  154. fd = socket(AF_INET, SOCK_DGRAM, 0);
  155. ifr.ifr_addr.sa_family = AF_INET;
  156. strncpy(ifr.ifr_name, dev, IFNAMSIZ-1);
  157. ioctl(fd, SIOCGIFADDR, &ifr);
  158. close(fd);
  159. char *p=inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr);
  160. if(!p) {
  161. return NULL;
  162. }
  163. strcpy(ip_addr, p);
  164. return ip_addr;
  165. }
  166. // 获取MAC地址的函数
  167. char* get_mac_address(const char *iface_name)
  168. {
  169. int fd;
  170. struct ifreq ifr;
  171. unsigned char *mac;
  172. static char mac_str[32];
  173. snprintf(mac_str, sizeof(mac_str), "%02d:%02d:%02d:%02d:%02d:%02d",
  174. 0, 0,0, 0, 0, 0);
  175. // 创建一个socket
  176. if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
  177. perror("socket error");
  178. return strdup(mac_str);
  179. }
  180. // 设置接口名称
  181. strncpy(ifr.ifr_name, iface_name, IFNAMSIZ - 1);
  182. // 获取MAC地址
  183. if (ioctl(fd, SIOCGIFHWADDR, &ifr) == -1) {
  184. perror("ioctl error");
  185. close(fd);
  186. return strdup(mac_str);
  187. }
  188. // ifr.ifr_hwaddr.sa_data是一个包含硬件地址的字节数组
  189. mac = (unsigned char *)ifr.ifr_hwaddr.sa_data;
  190. // 将MAC地址转换为字符串格式
  191. snprintf(mac_str, sizeof(mac_str), "%02X:%02X:%02X:%02X:%02X:%02X",
  192. mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  193. // 关闭socket
  194. close(fd);
  195. // 成功返回0
  196. return strdup(mac_str);
  197. }
  198. /// @brief 获取磁盘使用率
  199. /// @param reused
  200. void get_disk_occupy(char ** reused)
  201. {
  202. const unsigned short MAXBUFSIZE = 1024;
  203. char currentDirectoryPath[ MAXBUFSIZE ];
  204. getcwd(currentDirectoryPath, MAXBUFSIZE);
  205. //printf("当前目录:%s\n",currentDirectoryPath);
  206. char cmd[50] = "df ";
  207. strcat(cmd, currentDirectoryPath);
  208. //printf("%s\n",cmd);
  209. char buffer[MAXBUFSIZE];
  210. FILE* pipe = popen(cmd, "r");
  211. char fileSys[20];
  212. char blocks[20];
  213. char used[20];
  214. char free[20];
  215. char percent[10];
  216. char moment[20];
  217. if (!pipe)
  218. {
  219. return;
  220. }
  221. if (fgets(buffer, sizeof(buffer), pipe) != NULL)
  222. {
  223. sscanf(buffer, "%s %s %s %s %s %s", fileSys, blocks, used, free, percent, moment);
  224. }
  225. if (fgets(buffer, sizeof(buffer), pipe) != NULL)
  226. {
  227. sscanf(buffer, "%s %s %s %s %s %s", fileSys, blocks, used, free, percent, moment);
  228. }
  229. //printf("desk used:%s\n",percent);
  230. strcpy(*reused, percent);
  231. return;
  232. }
  233. int set_local_timeandzone(struct tm* t, int zone)
  234. {
  235. char buf[128];
  236. struct timeval tv;
  237. switch(zone)
  238. {
  239. case -11: //Midway
  240. sprintf(buf, "ln -sf /usr/share/zoneinfo/Pacific/Midway /etc/localtime");
  241. break;
  242. case -10: //夏威夷
  243. sprintf(buf, "ln -sf /usr/share/zoneinfo/HST /etc/localtime");
  244. break;
  245. case -9: //Adak
  246. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Adak /etc/localtime");
  247. break;
  248. case -8: //Los Angeles
  249. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Boise /etc/localtime");
  250. break;
  251. case -7: //MST
  252. sprintf(buf, "ln -sf /usr/share/zoneinfo/MST /etc/localtime");
  253. break;
  254. case -6: //Chicago
  255. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime");
  256. break;
  257. case -5: //Detroit
  258. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Detroit /etc/localtime");
  259. break;
  260. case -4: //Halifax
  261. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Halifax /etc/localtime");
  262. break;
  263. case -3: //Maceio
  264. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Maceio /etc/localtime");
  265. break;
  266. case -2: //Noronha
  267. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Noronha /etc/localtime");
  268. break;
  269. case -1: //Scoresbysund
  270. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Scoresbysund /etc/localtime");
  271. break;
  272. case 0: //Mexico_City
  273. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Mexico_City /etc/localtime");
  274. break;
  275. case 1: //Belgrade
  276. sprintf(buf, "ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime");
  277. break;
  278. case 2:
  279. break;
  280. case 3:
  281. break;
  282. case 4:
  283. break;
  284. case 5:
  285. break;
  286. case 6:
  287. break;
  288. case 7:
  289. break;
  290. case 8:
  291. sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Chongqing /etc/localtime");
  292. break;
  293. case 9:
  294. break;
  295. case 10:
  296. break;
  297. case 11:
  298. break;
  299. case 12:
  300. break;
  301. }
  302. system("ln -sf /usr/share/zoneinfo/UTC /etc/localtime");
  303. //t += zone * 3600;
  304. //struct tm* ptm = localtime(&t);
  305. memset(buf, 0, sizeof(buf));
  306. //sprintf(buf, "echo \"Hello\"");
  307. sprintf(buf, "date -s \"%04d-%02d-%02d %02d:%02d:%02d\" && hwclock -w -f /dev/rtc0 ", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
  308. log_i("%s",buf);
  309. system(buf);
  310. return 0;
  311. }
  312. char* getUserNamebyToken(char* Token)
  313. {
  314. char* userName = NULL;
  315. if (Token==NULL)
  316. {
  317. return NULL;
  318. }
  319. _User_Log *_UserInfoTemp = NULL;
  320. list_for_each_entry(_UserInfoTemp, &_GlobalUserLoginInfo.list, list)
  321. {
  322. if (_UserInfoTemp == NULL)
  323. break;
  324. if (strcmp(_UserInfoTemp->user_token, Token) == 0)
  325. {
  326. userName=_UserInfoTemp->user_name;
  327. }
  328. }
  329. return userName;
  330. }
  331. int is_process_running(const char *process_name)
  332. {
  333. DIR *dir;
  334. struct dirent *entry;
  335. char path[1035]; // /proc/[pid]/cmdline 的最大路径长度(/proc/ + PID(最多5位) + /cmdline + \0)
  336. char buffer[4096]; // 假设cmdline不会超过这个长度
  337. FILE *file;
  338. dir = opendir("/proc");
  339. if (dir == NULL) {
  340. perror("opendir");
  341. return -1;
  342. }
  343. while ((entry = readdir(dir)) != NULL) {
  344. // 忽略非数字目录(即非进程目录)
  345. if (!isdigit(entry->d_name[0])) {
  346. continue;
  347. }
  348. // 构造cmdline文件的完整路径
  349. snprintf(path, sizeof(path), "/proc/%s/cmdline", entry->d_name);
  350. // 打开cmdline文件
  351. file = fopen(path, "r");
  352. if (file == NULL) {
  353. continue; // 忽略无法打开的文件
  354. }
  355. // 读取cmdline文件的内容
  356. if (fgets(buffer, sizeof(buffer), file) != NULL) {
  357. // 去除cmdline中的空字符(进程名与参数间用空字符分隔)
  358. size_t len = strlen(buffer);
  359. while (len > 0 && buffer[len - 1] == '\0') {
  360. buffer[--len] = '\0';
  361. }
  362. // 比较进程名(这里假设process_name是完整的命令行,但你可以修改逻辑来仅比较进程名)
  363. if (strstr(buffer, process_name) != NULL) {
  364. fclose(file);
  365. closedir(dir);
  366. return 1; // 进程已启动
  367. }
  368. }
  369. fclose(file);
  370. }
  371. closedir(dir);
  372. return 0; // 进程未启动
  373. }
  374. bool CheckLoginStatus(char* Token)
  375. {
  376. //return true;//先不处理401授权错误,待前端处理后再加 20240625 lyz
  377. // 没有用户登录
  378. int nLoginNum=0;
  379. _User_Log *_UserInfoTemp = NULL;
  380. list_for_each_entry(_UserInfoTemp, &_GlobalUserLoginInfo.list, list)
  381. {
  382. if (_UserInfoTemp == NULL)
  383. break;
  384. nLoginNum++;
  385. }
  386. if (nLoginNum==0)
  387. {
  388. return false;
  389. }
  390. // 根据Token查询不到登录的用户
  391. if (Token != NULL && strcmp(Token, "") != 0 && getUserNamebyToken(Token) == NULL)
  392. {
  393. return false;
  394. }
  395. return true;
  396. // return __globalDeviceManage._globalDevInfo.login_status;
  397. }
  398. // 辅助函数:判断是否是闰年
  399. int is_leap_year(int year) {
  400. return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
  401. }
  402. // 辅助函数:获取某月的天数
  403. int days_in_month(int year, int month) {
  404. int days_per_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  405. if (month == 2 && is_leap_year(year)) return 29;
  406. return days_per_month[month];
  407. }
  408. // 函数:增加一天到日期
  409. void add_day_to_date(char *date_str, int *year, int *month, int *day) {
  410. (*day)++;
  411. if (*day > days_in_month(*year, *month)) {
  412. (*day) = 1;
  413. (*month)++;
  414. if (*month > 12) {
  415. (*month) = 1;
  416. (*year)++;
  417. }
  418. }
  419. sprintf(date_str, "%04d-%02d-%02d", *year, *month, *day);
  420. }
  421. void SetMenuAuthority(int RoleID)
  422. {
  423. //超级管理员
  424. if (RoleID == 1)
  425. {
  426. _GlobalMenuAuthority.PowerEnabled = true;
  427. _GlobalMenuAuthority.SensorEnabled = true;
  428. _GlobalMenuAuthority.AlarmEnabled = true;
  429. _GlobalMenuAuthority.LogEnabled = true;
  430. _GlobalMenuAuthority.UserInfoEnabled = true;
  431. _GlobalMenuAuthority.CommEnabled = true;
  432. _GlobalMenuAuthority.ServiceEnabled = true;
  433. _GlobalMenuAuthority.MaintenanceEnabled = true;
  434. // 1、电源监控菜单
  435. _GlobalMenuAuthority.MonitorallEnabled = true;
  436. _GlobalMenuAuthority.ChannelstatusEnabled = true;
  437. _GlobalMenuAuthority.SwitchtatusEnabled = true;
  438. _GlobalMenuAuthority.MonitorhistoryEnabled = true;
  439. // 2、传感器管理菜单
  440. _GlobalMenuAuthority.SensorStatusEnabled = true;
  441. _GlobalMenuAuthority.SensorHistorylEnabled = true;
  442. // 3、告警管理菜单
  443. _GlobalMenuAuthority.XtjgEnabled = true;
  444. _GlobalMenuAuthority.YzszEnabled = true;
  445. // 4、日志信息菜单
  446. _GlobalMenuAuthority.CzrzEnabled = true;
  447. _GlobalMenuAuthority.YxrzEnabled = true;
  448. // 5、用户管理菜单
  449. _GlobalMenuAuthority.UserEnabled = true;
  450. _GlobalMenuAuthority.RoleEnabled = false;
  451. _GlobalMenuAuthority.MenuEnabled = false;
  452. // 6、通信管理菜单
  453. _GlobalMenuAuthority.WkszEnabled = true;
  454. _GlobalMenuAuthority.RsszEnabled = true;
  455. // 7、服务管理菜单
  456. _GlobalMenuAuthority.SmtpszEnabled = true;
  457. _GlobalMenuAuthority.SnmpszEnabled = true;
  458. _GlobalMenuAuthority.MqszEnabled = true;
  459. _GlobalMenuAuthority.NtpszEnabled = true;
  460. _GlobalMenuAuthority.DsszEnabled = true;
  461. _GlobalMenuAuthority.SxszEnabled = true;
  462. _GlobalMenuAuthority.FzszEnabled = true;
  463. // 8、设备维护菜单
  464. _GlobalMenuAuthority.SbcqEnabled = true;
  465. _GlobalMenuAuthority.GjsjEnabled = true;
  466. _GlobalMenuAuthority.HhccszEnabled = true;
  467. _GlobalMenuAuthority.PzdrdcEnabled = true;
  468. _GlobalMenuAuthority.ShfwEnabled = true;
  469. _GlobalMenuAuthority.GysbEnabled = true;
  470. }
  471. // 管理员
  472. else if (RoleID == 2)
  473. {
  474. _GlobalMenuAuthority.PowerEnabled = true;
  475. _GlobalMenuAuthority.SensorEnabled = true;
  476. _GlobalMenuAuthority.AlarmEnabled = true;
  477. _GlobalMenuAuthority.LogEnabled = true;
  478. _GlobalMenuAuthority.UserInfoEnabled = true;
  479. _GlobalMenuAuthority.CommEnabled = true;
  480. _GlobalMenuAuthority.ServiceEnabled = true;
  481. _GlobalMenuAuthority.MaintenanceEnabled = true;
  482. // 1、电源监控菜单
  483. _GlobalMenuAuthority.MonitorallEnabled = true;
  484. _GlobalMenuAuthority.ChannelstatusEnabled = true;
  485. _GlobalMenuAuthority.SwitchtatusEnabled = false;
  486. _GlobalMenuAuthority.MonitorhistoryEnabled = true;
  487. // 2、传感器管理菜单
  488. _GlobalMenuAuthority.SensorStatusEnabled = true;
  489. _GlobalMenuAuthority.SensorHistorylEnabled = true;
  490. // 3、告警管理菜单
  491. _GlobalMenuAuthority.XtjgEnabled = true;
  492. _GlobalMenuAuthority.YzszEnabled = true;
  493. // 4、日志信息菜单
  494. _GlobalMenuAuthority.CzrzEnabled = false;
  495. _GlobalMenuAuthority.YxrzEnabled = true;
  496. // 5、用户管理菜单
  497. _GlobalMenuAuthority.UserEnabled = true;
  498. _GlobalMenuAuthority.RoleEnabled = false;
  499. _GlobalMenuAuthority.MenuEnabled = false;
  500. // 6、通信管理菜单
  501. _GlobalMenuAuthority.WkszEnabled = false;
  502. _GlobalMenuAuthority.RsszEnabled = true;
  503. // 7、服务管理菜单
  504. _GlobalMenuAuthority.SmtpszEnabled = false;
  505. _GlobalMenuAuthority.SnmpszEnabled = false;
  506. _GlobalMenuAuthority.MqszEnabled = false;
  507. _GlobalMenuAuthority.NtpszEnabled = true;
  508. _GlobalMenuAuthority.DsszEnabled = true;
  509. _GlobalMenuAuthority.SxszEnabled = true;
  510. _GlobalMenuAuthority.FzszEnabled = true;
  511. // 8、设备维护菜单
  512. _GlobalMenuAuthority.SbcqEnabled = true;
  513. _GlobalMenuAuthority.GjsjEnabled = true;
  514. _GlobalMenuAuthority.HhccszEnabled = false;
  515. _GlobalMenuAuthority.PzdrdcEnabled = true;
  516. _GlobalMenuAuthority.ShfwEnabled = false;
  517. _GlobalMenuAuthority.GysbEnabled = true;
  518. }
  519. //普通用户
  520. else
  521. {
  522. _GlobalMenuAuthority.PowerEnabled = true;
  523. _GlobalMenuAuthority.SensorEnabled = true;
  524. _GlobalMenuAuthority.AlarmEnabled = false;
  525. _GlobalMenuAuthority.LogEnabled = false;
  526. _GlobalMenuAuthority.UserInfoEnabled = false;
  527. _GlobalMenuAuthority.CommEnabled = false;
  528. _GlobalMenuAuthority.ServiceEnabled = false;
  529. _GlobalMenuAuthority.MaintenanceEnabled = false;
  530. // 1、电源监控菜单
  531. _GlobalMenuAuthority.MonitorallEnabled = true;
  532. _GlobalMenuAuthority.ChannelstatusEnabled = true;
  533. _GlobalMenuAuthority.SwitchtatusEnabled = false;
  534. _GlobalMenuAuthority.MonitorhistoryEnabled = false;
  535. // 2、传感器管理菜单
  536. _GlobalMenuAuthority.SensorStatusEnabled = true;
  537. _GlobalMenuAuthority.SensorHistorylEnabled = false;
  538. // 3、告警管理菜单
  539. _GlobalMenuAuthority.XtjgEnabled = false;
  540. _GlobalMenuAuthority.YzszEnabled = false;
  541. // 4、日志信息菜单
  542. _GlobalMenuAuthority.CzrzEnabled = false;
  543. _GlobalMenuAuthority.YxrzEnabled = false;
  544. // 5、用户管理菜单
  545. _GlobalMenuAuthority.UserEnabled = false;
  546. _GlobalMenuAuthority.RoleEnabled = false;
  547. _GlobalMenuAuthority.MenuEnabled = false;
  548. // 6、通信管理菜单
  549. _GlobalMenuAuthority.WkszEnabled = false;
  550. _GlobalMenuAuthority.RsszEnabled = false;
  551. // 7、服务管理菜单
  552. _GlobalMenuAuthority.SmtpszEnabled = false;
  553. _GlobalMenuAuthority.SnmpszEnabled = false;
  554. _GlobalMenuAuthority.MqszEnabled = false;
  555. _GlobalMenuAuthority.NtpszEnabled = false;
  556. _GlobalMenuAuthority.DsszEnabled = false;
  557. _GlobalMenuAuthority.SxszEnabled = false;
  558. _GlobalMenuAuthority.FzszEnabled = false;
  559. // 8、设备维护菜单
  560. _GlobalMenuAuthority.SbcqEnabled = false;
  561. _GlobalMenuAuthority.GjsjEnabled = false;
  562. _GlobalMenuAuthority.HhccszEnabled = false;
  563. _GlobalMenuAuthority.PzdrdcEnabled = false;
  564. _GlobalMenuAuthority.ShfwEnabled = false;
  565. _GlobalMenuAuthority.GysbEnabled = false;
  566. }
  567. }