common.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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 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 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. return mac_str;
  196. }
  197. /// @brief 获取磁盘使用率
  198. /// @param reused
  199. void get_disk_occupy(char ** reused)
  200. {
  201. const unsigned short MAXBUFSIZE = 1024;
  202. char currentDirectoryPath[ MAXBUFSIZE ];
  203. getcwd(currentDirectoryPath, MAXBUFSIZE);
  204. //printf("当前目录:%s\n",currentDirectoryPath);
  205. char cmd[50] = "df ";
  206. strcat(cmd, currentDirectoryPath);
  207. //printf("%s\n",cmd);
  208. char buffer[MAXBUFSIZE];
  209. FILE* pipe = popen(cmd, "r");
  210. char fileSys[20];
  211. char blocks[20];
  212. char used[20];
  213. char free[20];
  214. char percent[10];
  215. char moment[20];
  216. if (!pipe)
  217. {
  218. return;
  219. }
  220. if (fgets(buffer, sizeof(buffer), pipe) != NULL)
  221. {
  222. sscanf(buffer, "%s %s %s %s %s %s", fileSys, blocks, used, free, percent, moment);
  223. }
  224. if (fgets(buffer, sizeof(buffer), pipe) != NULL)
  225. {
  226. sscanf(buffer, "%s %s %s %s %s %s", fileSys, blocks, used, free, percent, moment);
  227. }
  228. //printf("desk used:%s\n",percent);
  229. strcpy(*reused, percent);
  230. return;
  231. }
  232. int set_local_timeandzone(struct tm* t, int zone)
  233. {
  234. char buf[128];
  235. struct timeval tv;
  236. switch(zone)
  237. {
  238. case -11: //Midway
  239. sprintf(buf, "ln -sf /usr/share/zoneinfo/Pacific/Midway /etc/localtime");
  240. break;
  241. case -10: //夏威夷
  242. sprintf(buf, "ln -sf /usr/share/zoneinfo/HST /etc/localtime");
  243. break;
  244. case -9: //Adak
  245. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Adak /etc/localtime");
  246. break;
  247. case -8: //Los Angeles
  248. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Boise /etc/localtime");
  249. break;
  250. case -7: //MST
  251. sprintf(buf, "ln -sf /usr/share/zoneinfo/MST /etc/localtime");
  252. break;
  253. case -6: //Chicago
  254. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime");
  255. break;
  256. case -5: //Detroit
  257. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Detroit /etc/localtime");
  258. break;
  259. case -4: //Halifax
  260. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Halifax /etc/localtime");
  261. break;
  262. case -3: //Maceio
  263. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Maceio /etc/localtime");
  264. break;
  265. case -2: //Noronha
  266. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Noronha /etc/localtime");
  267. break;
  268. case -1: //Scoresbysund
  269. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Scoresbysund /etc/localtime");
  270. break;
  271. case 0: //Mexico_City
  272. sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Mexico_City /etc/localtime");
  273. break;
  274. case 1: //Belgrade
  275. sprintf(buf, "ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime");
  276. break;
  277. case 2:
  278. break;
  279. case 3:
  280. break;
  281. case 4:
  282. break;
  283. case 5:
  284. break;
  285. case 6:
  286. break;
  287. case 7:
  288. break;
  289. case 8:
  290. sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Chongqing /etc/localtime");
  291. break;
  292. case 9:
  293. break;
  294. case 10:
  295. break;
  296. case 11:
  297. break;
  298. case 12:
  299. break;
  300. }
  301. system("ln -sf /usr/share/zoneinfo/UTC /etc/localtime");
  302. //t += zone * 3600;
  303. //struct tm* ptm = localtime(&t);
  304. memset(buf, 0, sizeof(buf));
  305. //sprintf(buf, "echo \"Hello\"");
  306. 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);
  307. log_i("%s",buf);
  308. system(buf);
  309. return 0;
  310. }
  311. char* getUserNamebyToken(char* Token)
  312. {
  313. char* userName = NULL;
  314. if (Token==NULL)
  315. {
  316. return NULL;
  317. }
  318. _User_Log *_UserInfoTemp = NULL;
  319. list_for_each_entry(_UserInfoTemp, &_GlobalUserLoginInfo.list, list)
  320. {
  321. if (_UserInfoTemp == NULL)
  322. break;
  323. if (strcmp(_UserInfoTemp->user_token, Token) == 0)
  324. {
  325. userName=_UserInfoTemp->user_name;
  326. }
  327. }
  328. return userName;
  329. }
  330. int is_process_running(const char *process_name)
  331. {
  332. DIR *dir;
  333. struct dirent *entry;
  334. char path[1035]; // /proc/[pid]/cmdline 的最大路径长度(/proc/ + PID(最多5位) + /cmdline + \0)
  335. char buffer[4096]; // 假设cmdline不会超过这个长度
  336. FILE *file;
  337. dir = opendir("/proc");
  338. if (dir == NULL) {
  339. perror("opendir");
  340. return -1;
  341. }
  342. while ((entry = readdir(dir)) != NULL) {
  343. // 忽略非数字目录(即非进程目录)
  344. if (!isdigit(entry->d_name[0])) {
  345. continue;
  346. }
  347. // 构造cmdline文件的完整路径
  348. snprintf(path, sizeof(path), "/proc/%s/cmdline", entry->d_name);
  349. // 打开cmdline文件
  350. file = fopen(path, "r");
  351. if (file == NULL) {
  352. continue; // 忽略无法打开的文件
  353. }
  354. // 读取cmdline文件的内容
  355. if (fgets(buffer, sizeof(buffer), file) != NULL) {
  356. // 去除cmdline中的空字符(进程名与参数间用空字符分隔)
  357. size_t len = strlen(buffer);
  358. while (len > 0 && buffer[len - 1] == '\0') {
  359. buffer[--len] = '\0';
  360. }
  361. // 比较进程名(这里假设process_name是完整的命令行,但你可以修改逻辑来仅比较进程名)
  362. if (strstr(buffer, process_name) != NULL) {
  363. fclose(file);
  364. closedir(dir);
  365. return 1; // 进程已启动
  366. }
  367. }
  368. fclose(file);
  369. }
  370. closedir(dir);
  371. return 0; // 进程未启动
  372. }
  373. bool CheckLoginStatus(char* Token)
  374. {
  375. //return true;//先不处理401授权错误,待前端处理后再加 20240625 lyz
  376. // 没有用户登录
  377. int nLoginNum=0;
  378. _User_Log *_UserInfoTemp = NULL;
  379. list_for_each_entry(_UserInfoTemp, &_GlobalUserLoginInfo.list, list)
  380. {
  381. if (_UserInfoTemp == NULL)
  382. break;
  383. nLoginNum++;
  384. }
  385. if (nLoginNum==0)
  386. {
  387. return false;
  388. }
  389. // 根据Token查询不到登录的用户
  390. if (Token != NULL && strcmp(Token, "") != 0 && getUserNamebyToken(Token) == NULL)
  391. {
  392. return false;
  393. }
  394. return true;
  395. // return __globalDeviceManage._globalDevInfo.login_status;
  396. }
  397. // 辅助函数:判断是否是闰年
  398. int is_leap_year(int year) {
  399. return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
  400. }
  401. // 辅助函数:获取某月的天数
  402. int days_in_month(int year, int month) {
  403. int days_per_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  404. if (month == 2 && is_leap_year(year)) return 29;
  405. return days_per_month[month];
  406. }
  407. // 函数:增加一天到日期
  408. void add_day_to_date(char *date_str, int *year, int *month, int *day) {
  409. (*day)++;
  410. if (*day > days_in_month(*year, *month)) {
  411. (*day) = 1;
  412. (*month)++;
  413. if (*month > 12) {
  414. (*month) = 1;
  415. (*year)++;
  416. }
  417. }
  418. sprintf(date_str, "%04d-%02d-%02d", *year, *month, *day);
  419. }
  420. void SetMenuAuthority(int RoleID)
  421. {
  422. //超级管理员
  423. if (RoleID == 1)
  424. {
  425. _GlobalMenuAuthority.PowerEnabled = true;
  426. _GlobalMenuAuthority.SensorEnabled = true;
  427. _GlobalMenuAuthority.AlarmEnabled = true;
  428. _GlobalMenuAuthority.LogEnabled = true;
  429. _GlobalMenuAuthority.UserInfoEnabled = true;
  430. _GlobalMenuAuthority.CommEnabled = true;
  431. _GlobalMenuAuthority.ServiceEnabled = true;
  432. _GlobalMenuAuthority.MaintenanceEnabled = true;
  433. // 1、电源监控菜单
  434. _GlobalMenuAuthority.MonitorallEnabled = true;
  435. _GlobalMenuAuthority.ChannelstatusEnabled = true;
  436. _GlobalMenuAuthority.SwitchtatusEnabled = true;
  437. _GlobalMenuAuthority.MonitorhistoryEnabled = true;
  438. // 2、传感器管理菜单
  439. _GlobalMenuAuthority.SensorStatusEnabled = true;
  440. _GlobalMenuAuthority.SensorHistorylEnabled = true;
  441. // 3、告警管理菜单
  442. _GlobalMenuAuthority.XtjgEnabled = true;
  443. _GlobalMenuAuthority.YzszEnabled = true;
  444. // 4、日志信息菜单
  445. _GlobalMenuAuthority.CzrzEnabled = true;
  446. _GlobalMenuAuthority.YxrzEnabled = true;
  447. // 5、用户管理菜单
  448. _GlobalMenuAuthority.UserEnabled = true;
  449. _GlobalMenuAuthority.RoleEnabled = false;
  450. _GlobalMenuAuthority.MenuEnabled = false;
  451. // 6、通信管理菜单
  452. _GlobalMenuAuthority.WkszEnabled = true;
  453. _GlobalMenuAuthority.RsszEnabled = true;
  454. // 7、服务管理菜单
  455. _GlobalMenuAuthority.SmtpszEnabled = true;
  456. _GlobalMenuAuthority.SnmpszEnabled = true;
  457. _GlobalMenuAuthority.MqszEnabled = true;
  458. _GlobalMenuAuthority.NtpszEnabled = true;
  459. _GlobalMenuAuthority.DsszEnabled = true;
  460. _GlobalMenuAuthority.SxszEnabled = true;
  461. _GlobalMenuAuthority.FzszEnabled = true;
  462. // 8、设备维护菜单
  463. _GlobalMenuAuthority.SbcqEnabled = true;
  464. _GlobalMenuAuthority.GjsjEnabled = true;
  465. _GlobalMenuAuthority.HhccszEnabled = true;
  466. _GlobalMenuAuthority.PzdrdcEnabled = true;
  467. _GlobalMenuAuthority.ShfwEnabled = true;
  468. _GlobalMenuAuthority.GysbEnabled = true;
  469. }
  470. // 管理员
  471. else if (RoleID == 2)
  472. {
  473. _GlobalMenuAuthority.PowerEnabled = true;
  474. _GlobalMenuAuthority.SensorEnabled = true;
  475. _GlobalMenuAuthority.AlarmEnabled = true;
  476. _GlobalMenuAuthority.LogEnabled = true;
  477. _GlobalMenuAuthority.UserInfoEnabled = true;
  478. _GlobalMenuAuthority.CommEnabled = true;
  479. _GlobalMenuAuthority.ServiceEnabled = true;
  480. _GlobalMenuAuthority.MaintenanceEnabled = true;
  481. // 1、电源监控菜单
  482. _GlobalMenuAuthority.MonitorallEnabled = true;
  483. _GlobalMenuAuthority.ChannelstatusEnabled = true;
  484. _GlobalMenuAuthority.SwitchtatusEnabled = false;
  485. _GlobalMenuAuthority.MonitorhistoryEnabled = true;
  486. // 2、传感器管理菜单
  487. _GlobalMenuAuthority.SensorStatusEnabled = true;
  488. _GlobalMenuAuthority.SensorHistorylEnabled = true;
  489. // 3、告警管理菜单
  490. _GlobalMenuAuthority.XtjgEnabled = true;
  491. _GlobalMenuAuthority.YzszEnabled = true;
  492. // 4、日志信息菜单
  493. _GlobalMenuAuthority.CzrzEnabled = false;
  494. _GlobalMenuAuthority.YxrzEnabled = true;
  495. // 5、用户管理菜单
  496. _GlobalMenuAuthority.UserEnabled = true;
  497. _GlobalMenuAuthority.RoleEnabled = false;
  498. _GlobalMenuAuthority.MenuEnabled = false;
  499. // 6、通信管理菜单
  500. _GlobalMenuAuthority.WkszEnabled = false;
  501. _GlobalMenuAuthority.RsszEnabled = true;
  502. // 7、服务管理菜单
  503. _GlobalMenuAuthority.SmtpszEnabled = false;
  504. _GlobalMenuAuthority.SnmpszEnabled = false;
  505. _GlobalMenuAuthority.MqszEnabled = false;
  506. _GlobalMenuAuthority.NtpszEnabled = true;
  507. _GlobalMenuAuthority.DsszEnabled = true;
  508. _GlobalMenuAuthority.SxszEnabled = true;
  509. _GlobalMenuAuthority.FzszEnabled = true;
  510. // 8、设备维护菜单
  511. _GlobalMenuAuthority.SbcqEnabled = true;
  512. _GlobalMenuAuthority.GjsjEnabled = true;
  513. _GlobalMenuAuthority.HhccszEnabled = false;
  514. _GlobalMenuAuthority.PzdrdcEnabled = true;
  515. _GlobalMenuAuthority.ShfwEnabled = false;
  516. _GlobalMenuAuthority.GysbEnabled = true;
  517. }
  518. //普通用户
  519. else
  520. {
  521. _GlobalMenuAuthority.PowerEnabled = true;
  522. _GlobalMenuAuthority.SensorEnabled = true;
  523. _GlobalMenuAuthority.AlarmEnabled = false;
  524. _GlobalMenuAuthority.LogEnabled = false;
  525. _GlobalMenuAuthority.UserInfoEnabled = false;
  526. _GlobalMenuAuthority.CommEnabled = false;
  527. _GlobalMenuAuthority.ServiceEnabled = false;
  528. _GlobalMenuAuthority.MaintenanceEnabled = false;
  529. // 1、电源监控菜单
  530. _GlobalMenuAuthority.MonitorallEnabled = true;
  531. _GlobalMenuAuthority.ChannelstatusEnabled = true;
  532. _GlobalMenuAuthority.SwitchtatusEnabled = false;
  533. _GlobalMenuAuthority.MonitorhistoryEnabled = false;
  534. // 2、传感器管理菜单
  535. _GlobalMenuAuthority.SensorStatusEnabled = true;
  536. _GlobalMenuAuthority.SensorHistorylEnabled = false;
  537. // 3、告警管理菜单
  538. _GlobalMenuAuthority.XtjgEnabled = false;
  539. _GlobalMenuAuthority.YzszEnabled = false;
  540. // 4、日志信息菜单
  541. _GlobalMenuAuthority.CzrzEnabled = false;
  542. _GlobalMenuAuthority.YxrzEnabled = false;
  543. // 5、用户管理菜单
  544. _GlobalMenuAuthority.UserEnabled = false;
  545. _GlobalMenuAuthority.RoleEnabled = false;
  546. _GlobalMenuAuthority.MenuEnabled = false;
  547. // 6、通信管理菜单
  548. _GlobalMenuAuthority.WkszEnabled = false;
  549. _GlobalMenuAuthority.RsszEnabled = false;
  550. // 7、服务管理菜单
  551. _GlobalMenuAuthority.SmtpszEnabled = false;
  552. _GlobalMenuAuthority.SnmpszEnabled = false;
  553. _GlobalMenuAuthority.MqszEnabled = false;
  554. _GlobalMenuAuthority.NtpszEnabled = false;
  555. _GlobalMenuAuthority.DsszEnabled = false;
  556. _GlobalMenuAuthority.SxszEnabled = false;
  557. _GlobalMenuAuthority.FzszEnabled = false;
  558. // 8、设备维护菜单
  559. _GlobalMenuAuthority.SbcqEnabled = false;
  560. _GlobalMenuAuthority.GjsjEnabled = false;
  561. _GlobalMenuAuthority.HhccszEnabled = false;
  562. _GlobalMenuAuthority.PzdrdcEnabled = false;
  563. _GlobalMenuAuthority.ShfwEnabled = false;
  564. _GlobalMenuAuthority.GysbEnabled = false;
  565. }
  566. }