#include "common.h" #include "elog.h" #include #include #include #include #include #include #include #include #include #include #undef LOG_TAG #define LOG_TAG "main" GlobalDeviceManager __globalDeviceManage={0}; GlobalDeviceManager __globalDeviceManage2={0}; int ntp_sync_flag=0; unsigned long __globalSxIdx; _User_Log _GlobalUserLoginInfo; UserInfo _GlobalUserInfoNew; char _GlobalUserToken[64]; MenuAuthority _GlobalMenuAuthority; NTPManager _globalNTPManager; void printf_global_device_info(GlobalDeviceInfo* _globalDeviceInfo) { log_d("******global device info********* "); log_d("product_id:%d ", _globalDeviceInfo->product_id); log_d("product_number:%s ", _globalDeviceInfo->product_number); log_d("product_name:%s ", _globalDeviceInfo->product_name); log_d("product_type:%d ", _globalDeviceInfo->product_type); log_d("product_pwr_type:%d ", _globalDeviceInfo->product_pwr_type); log_d("product_version:%s ", _globalDeviceInfo->product_version); log_d("product_count:%d ", _globalDeviceInfo->product_count); log_d("product_samp_time:%d ", _globalDeviceInfo->product_samp_time); log_d("product_save_time:%d ", _globalDeviceInfo->product_save_time); log_d("product_modbus_type:%d ", _globalDeviceInfo->_gmodbus_info.product_modbus_type); log_d("product_modbus_baud:%d ", _globalDeviceInfo->_gmodbus_info.product_modbus_baud); log_d("product_modbus_addr:%d ", _globalDeviceInfo->_gmodbus_info.product_modbus_addr); log_d("product_relay_port:%s ", _globalDeviceInfo->_modbus_info.product_relay_ctrl_port); log_d("******************************** "); } void printf_global_power_manage_info(GlobalPowerManger* _globalPowerManger) { printf("******global power manage info********* "); printf("product_id:%d ", _globalPowerManger->product_id); printf("product_ch_id:%d ", _globalPowerManger->product_ch_id); printf("product_ch_name:%s ", _globalPowerManger->product_ch_name); printf("product_ch_type:%d ", _globalPowerManger->product_ch_type); printf("product_ch_status:%d ", _globalPowerManger->product_ch_status); printf("product_ch_NF_status:%d ", _globalPowerManger->product_ch_NF_status); printf("product_ch_start_delay:%d ", _globalPowerManger->product_ch_start_delay); printf("product_ch_stop_delay:%d ", _globalPowerManger->product_ch_stop_delay); printf("product_vol_upper_enable:%d ", _globalPowerManger->global_over_manager->product_vol_upper_enable); printf("product_vol_upper_threshold:%0.2f ", _globalPowerManger->global_over_manager->product_vol_upper_threshold); printf("product_vol_over_upper_threshold_ctrl:%d ", _globalPowerManger->global_over_manager->product_vol_over_upper_threshold_ctrl); printf("product_vol_over_upper_threshold_para:%d ", _globalPowerManger->global_over_manager->product_vol_over_upper_threshold_ctrl_para); printf("product_vol_lower_enable:%d ", _globalPowerManger->global_over_manager->product_vol_lower_enable); printf("product_vol_lower_threshold:%0.2f ", _globalPowerManger->global_over_manager->product_vol_lower_threshold); printf("product_vol_over_lower_threshold_ctrl:%d ", _globalPowerManger->global_over_manager->product_vol_over_lower_threshold_ctrl); printf("product_vol_over_lower_threshold_ctrl_para:%d ", _globalPowerManger->global_over_manager->product_vol_over_lower_threshold_ctrl_para); printf("product_cur_upper_enable:%d ", _globalPowerManger->global_over_manager->product_cur_upper_enable); printf("product_cur_upper_threshold:%0.2f ", _globalPowerManger->global_over_manager->product_cur_upper_threshold); printf("product_cur_over_upper_threshold_ctrl:%d ", _globalPowerManger->global_over_manager->product_cur_over_upper_threshold_ctrl); printf("product_cur_over_upper_threshold_ctrl_para:%d ", _globalPowerManger->global_over_manager->product_cur_over_upper_threshold_ctrl_para); printf("product_pwr_upper_enable:%d ", _globalPowerManger->global_over_manager->product_pwr_upper_enable); printf("product_pwr_upper_threshold:%0.2f ", _globalPowerManger->global_over_manager->product_pwr_upper_threshold); printf("product_pwr_over_upper_threshold_ctrl:%d ", _globalPowerManger->global_over_manager->product_pwr_over_upper_threshold_ctrl); printf("product_pwr_over_upper_threshold_ctrl_para:%d ", _globalPowerManger->global_over_manager->product_pwr_over_upper_threshold_ctrl_para); printf("product_pwrcon_upper_enable:%d ", _globalPowerManger->global_over_manager->product_pwrcon_upper_enable); printf("product_pwrcon_upper_threshold:%0.2f ", _globalPowerManger->global_over_manager->product_pwrcon_upper_threshold); printf("product_pwrcon_over_upper_threshold_ctrl:%d ", _globalPowerManger->global_over_manager->product_pwrcon_over_upper_threshold_ctrl); printf("product_pwrcon_over_upper_threshold_ctrl_para:%d ", _globalPowerManger->global_over_manager->product_pwrcon_over_upper_threshold_ctrl_para); printf("******************************** "); } //打印电源信息 void printf_power_info(GlobalPowerInfo* _globalPowerInfo) { struct list_head *pos; GlobalPowerInfo* _temp; int i = 0; list_for_each_entry(_temp, &_globalPowerInfo->list, list) { printf("i:%d ", i++); printf("samp_time:%s ", _temp->samp_time); printf("product_id:%d ", _temp->product_id); } } void INIT_LIST_HEAD(struct list_head *list) { list->next = list->prev = list; } /** * EasyLogger demo */ // void test_elog(void) { // uint8_t buf[256]= {0}; // int i = 0; // for (i = 0; i < sizeof(buf); i++) // { // buf[i] = i; // } // while(true) { // /* test log output for all level */ // log_a("Hello EasyLogger!"); // log_e("Hello EasyLogger!"); // log_w("Hello EasyLogger!"); // log_i("Hello EasyLogger!"); // log_d("Hello EasyLogger!"); // log_v("Hello EasyLogger!"); // // elog_raw("Hello EasyLogger!"); // elog_hexdump("test", 16, buf, sizeof(buf)); // sleep(5); // } // } #if(1) void initLogger(void) { setbuf(stdout, NULL); elog_init(); elog_set_fmt(ELOG_LVL_ASSERT, ELOG_FMT_ALL); elog_set_fmt(ELOG_LVL_ERROR, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME); elog_set_fmt(ELOG_LVL_WARN, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME); elog_set_fmt(ELOG_LVL_INFO, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME); elog_set_fmt(ELOG_LVL_DEBUG, ELOG_FMT_ALL & ~ELOG_FMT_FUNC); elog_set_fmt(ELOG_LVL_VERBOSE, ELOG_FMT_ALL & ~ELOG_FMT_FUNC); elog_set_text_color_enabled(true); elog_start(); log_i("Smart Pdu Application Running!"); } #endif /// @brief 获取系统mem大小 /// @param totalSize /// @return int getTotalMemorySize(unsigned int* totalSize) { struct sysinfo memInfo; if (sysinfo(&memInfo) != -1) { *totalSize = memInfo.totalram; // printf("Total RAM size: %lu bytes\n", memInfo.totalram); // printf("Free RAM size: %lu bytes\n", memInfo.freeram); } else { *totalSize = 0 ; return -1; } return 0; } /// @brief 返回设备IP地址 /// @param dev 网口名 /// @return char* getLocalIpAddress(char* dev) { int fd; struct ifreq ifr; static char ip_addr[64]; fd = socket(AF_INET, SOCK_DGRAM, 0); ifr.ifr_addr.sa_family = AF_INET; strncpy(ifr.ifr_name, dev, IFNAMSIZ-1); ioctl(fd, SIOCGIFADDR, &ifr); close(fd); char *p=inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr); if(!p) { return NULL; } strcpy(ip_addr, p); return ip_addr; } // 获取MAC地址的函数 char* get_mac_address(const char *iface_name) { int fd; struct ifreq ifr; unsigned char *mac; static char mac_str[32]; snprintf(mac_str, sizeof(mac_str), "%02d:%02d:%02d:%02d:%02d:%02d", 0, 0,0, 0, 0, 0); // 创建一个socket if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { perror("socket error"); return strdup(mac_str); } // 设置接口名称 strncpy(ifr.ifr_name, iface_name, IFNAMSIZ - 1); // 获取MAC地址 if (ioctl(fd, SIOCGIFHWADDR, &ifr) == -1) { perror("ioctl error"); close(fd); return strdup(mac_str); } // ifr.ifr_hwaddr.sa_data是一个包含硬件地址的字节数组 mac = (unsigned char *)ifr.ifr_hwaddr.sa_data; // 将MAC地址转换为字符串格式 snprintf(mac_str, sizeof(mac_str), "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); // 关闭socket close(fd); // 成功返回0 return strdup(mac_str); } /// @brief 获取磁盘使用率 /// @param reused void get_disk_occupy(char ** reused) { const unsigned short MAXBUFSIZE = 1024; char currentDirectoryPath[ MAXBUFSIZE ]; getcwd(currentDirectoryPath, MAXBUFSIZE); //printf("当前目录:%s\n",currentDirectoryPath); char cmd[50] = "df "; strcat(cmd, currentDirectoryPath); //printf("%s\n",cmd); char buffer[MAXBUFSIZE]; FILE* pipe = popen(cmd, "r"); char fileSys[20]; char blocks[20]; char used[20]; char free[20]; char percent[10]; char moment[20]; if (!pipe) { return; } if (fgets(buffer, sizeof(buffer), pipe) != NULL) { sscanf(buffer, "%s %s %s %s %s %s", fileSys, blocks, used, free, percent, moment); } if (fgets(buffer, sizeof(buffer), pipe) != NULL) { sscanf(buffer, "%s %s %s %s %s %s", fileSys, blocks, used, free, percent, moment); } //printf("desk used:%s\n",percent); strcpy(*reused, percent); return; } static int set_rtc(time_t t) { int r=0,fd; struct rtc_time *rtc; struct tm *tm = gmtime(&t); fd = open("/dev/rtc0", O_RDONLY); if (fd < 0) { perror("open rtc failed\n"); return -1; } rtc = (struct rtc_time*)tm; if (ioctl(fd, RTC_SET_TIME, rtc) < 0) { perror("ioctl RTC_SET_TIME failed\n"); r = -1; } else { printf("set rtc ok!\n"); } close(fd); return r; //system("hwclock -w -f /dev/rtc0"); // return 0; } #define MY_MINUTE 60 #define MY_HOUR (60*MY_MINUTE) #define MY_DAY (24*MY_HOUR) #define MY_YEAR (365*MY_DAY) static int my_month[12] = { 0, MY_DAY*(31), MY_DAY*(31+29), MY_DAY*(31+29+31), MY_DAY*(31+29+31+30), MY_DAY*(31+29+31+30+31), MY_DAY*(31+29+31+30+31+30), MY_DAY*(31+29+31+30+31+30+31), MY_DAY*(31+29+31+30+31+30+31+31), MY_DAY*(31+29+31+30+31+30+31+31+30), MY_DAY*(31+29+31+30+31+30+31+31+30+31), MY_DAY*(31+29+31+30+31+30+31+31+30+31+30) }; time_t mktime2(struct tm *t, int zone) { time_t res,year; year = t->tm_year - 70; /* magic offsets (y+1) needed to get leapyears right.*/ res = MY_YEAR*year + MY_DAY*((year+1)/4); res += my_month[t->tm_mon]; /* and (y+2) here. If it wasn't a leap-year, we have to adjust */ if (t->tm_mon>1 && ((year+2)%4)) res -= MY_DAY; res += MY_DAY*(t->tm_mday-1); res += MY_HOUR*t->tm_hour; res += MY_MINUTE*t->tm_min; res += t->tm_sec; res -= zone*3600; return res; } time_t mktime0(void) { struct tm t; t.tm_year = 70; t.tm_mon = 0; t.tm_mday = 1; t.tm_hour = 0; t.tm_min = 0; t.tm_sec = 0; return mktime(&t); } int set_time(struct tm *t, int zone) { if(!t) { return -1; } t->tm_year -= 1900; t->tm_mon -= 1; time_t utc = mktime2(t, zone); stime(&utc); set_rtc(utc); return 0; } int set_utctime(time_t t) { stime(&t); set_rtc(t); sleep(1); //system("hwclock -w -f /dev/rtc0"); //system("hwclock -w"); //system("hwclock --show"); //system("hwclock -s"); return 0; } int set_zone(int zone) { char buf[256]; #if 0 switch(zone) { case -11: sprintf(buf, "ln -sf /usr/share/zoneinfo/Pacific/Midway /etc/localtime"); break; case -10: sprintf(buf, "ln -sf /usr/share/zoneinfo/HST /etc/localtime"); break; case -9: sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Adak /etc/localtime"); break; case -8: sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Boise /etc/localtime"); break; case -7: sprintf(buf, "ln -sf /usr/share/zoneinfo/MST /etc/localtime"); break; case -6: sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime"); break; case -5: sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Detroit /etc/localtime"); break; case -4: sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Halifax /etc/localtime"); break; case -3: sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Maceio /etc/localtime"); break; case -2: sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Noronha /etc/localtime"); break; case -1: sprintf(buf, "ln -sf /usr/share/zoneinfo/America/Scoresbysund /etc/localtime"); break; case 0: sprintf(buf, "ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime"); break; case 1: sprintf(buf, "ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime"); break; case 2: sprintf(buf, "ln -sf /usr/share/zoneinfo/EET /etc/localtime"); break; case 3: sprintf(buf, "ln -sf /usr/share/zoneinfo/Europe/Moscow /etc/localtime"); break; case 4: sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Amman /etc/localtime"); break; case 5: sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Karachi /etc/localtime"); break; case 6: sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Dhaka /etc/localtime"); break; case 7: sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Bangkok /etc/localtime"); break; case 8: sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Chongqing /etc/localtime"); break; case 9: sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime"); break; case 10: sprintf(buf, "ln -sf /usr/share/zoneinfo/Australia/Sydney /etc/localtime"); break; case 11: sprintf(buf, "ln -sf /usr/share/zoneinfo/Asia/Sakhalin /etc/localtime"); break; case 12: sprintf(buf, "ln -sf /usr/share/zoneinfo/Pacific/Fiji /etc/localtime"); break; default: return -1; } #else sprintf(buf, "ln -sf /usr/share/zoneinfo/GMT%s%d /etc/localtime", (zone<0)?"+":"-", abs(zone)); #endif log_i("set_zone: %s", buf); return system(buf); } void print_time(char *s, struct tm *tm) { printf("___%s___, %04d-%02d-%02d %02d:%02d:%02d\n", s, tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); } void print_utc(char *s, time_t t) { struct tm *tm=gmtime(&t); tm->tm_year += 1900; tm->tm_mon += 1; print_time(s, tm); } int set_time_zone(struct tm *t, int zone) { int r; if(!t) { return -1; } r = set_zone(zone); if(r) { log_e("__1__ set_zone failed\n"); } print_time("111", t); r = set_time(t, zone); if(r) { log_e("__1__ set_time failed\n"); } print_utc("222", time(NULL)); return r; } int set_utctime_zone(time_t t, int zone) { int r; r = set_zone(zone); if(r) { log_e("__2__ set_zone failed\n"); } r = set_utctime(t); if(r) { log_e("__2__ set_time failed\n"); } return r; } int get_time_str(char *s, int len, time_t t) { struct tm *tm=localtime(&t); return snprintf(s, len, "%04d-%02d-%02d %02d:%02d:%02d.000",tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec); } int get_time_str2(char *s, int len, time_t t) { struct tm *tm=localtime(&t); return snprintf(s, len, "%04d%02d%02d%02d%02d%02d", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec); } char* getUserNamebyToken(char* Token) { char* userName = NULL; if (Token==NULL) { return NULL; } _User_Log *_UserInfoTemp = NULL; list_for_each_entry(_UserInfoTemp, &_GlobalUserLoginInfo.list, list) { if (_UserInfoTemp == NULL) break; if (strcmp(_UserInfoTemp->user_token, Token) == 0) { userName=_UserInfoTemp->user_name; } } return userName; } typedef struct { uint16_t year; uint8_t mon; uint8_t day; uint8_t hour; uint8_t min; uint8_t sec; }datetime_t; int get_bldtime(char *buf, int len) { char mon[10]={0}; datetime_t dt; char *mon2[12]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; sscanf(__DATE__, "%s %hhu %hu", mon,&dt.day,&dt.year); sscanf(__TIME__, "%hhu:%hhu:%hhu", &dt.hour,&dt.min,&dt.sec); for(int i=0;i<12;i++) { if(strcmp(mon, mon2[i])==0) { dt.mon = i+1; break; } } return snprintf(buf,len,"%04hu/%02hhu/%02hhu %02hhu:%02hhu:%02hhu",dt.year,dt.mon,dt.day,dt.hour,dt.min,dt.sec); } int is_process_running(const char *process_name) { DIR *dir; struct dirent *entry; char path[1035]; // /proc/[pid]/cmdline 的最大路径长度(/proc/ + PID(最多5位) + /cmdline + \0) char buffer[4096]; // 假设cmdline不会超过这个长度 FILE *file; dir = opendir("/proc"); if (dir == NULL) { perror("opendir"); return -1; } while ((entry = readdir(dir)) != NULL) { // 忽略非数字目录(即非进程目录) if (!isdigit(entry->d_name[0])) { continue; } // 构造cmdline文件的完整路径 snprintf(path, sizeof(path), "/proc/%s/cmdline", entry->d_name); // 打开cmdline文件 file = fopen(path, "r"); if (file == NULL) { continue; // 忽略无法打开的文件 } // 读取cmdline文件的内容 if (fgets(buffer, sizeof(buffer), file) != NULL) { // 去除cmdline中的空字符(进程名与参数间用空字符分隔) size_t len = strlen(buffer); while (len > 0 && buffer[len - 1] == '\0') { buffer[--len] = '\0'; } // 比较进程名(这里假设process_name是完整的命令行,但你可以修改逻辑来仅比较进程名) if (strstr(buffer, process_name) != NULL) { fclose(file); closedir(dir); return 1; // 进程已启动 } } fclose(file); } closedir(dir); return 0; // 进程未启动 } bool CheckLoginStatus(char* Token) { //return true;//先不处理401授权错误,待前端处理后再加 20240625 lyz // 没有用户登录 int nLoginNum=0; _User_Log *_UserInfoTemp = NULL; list_for_each_entry(_UserInfoTemp, &_GlobalUserLoginInfo.list, list) { if (_UserInfoTemp == NULL) break; nLoginNum++; } if (nLoginNum==0) { return false; } // 根据Token查询不到登录的用户 if (Token != NULL && strcmp(Token, "") != 0 && getUserNamebyToken(Token) == NULL) { return false; } return true; // return __globalDeviceManage._globalDevInfo.login_status; } // 辅助函数:判断是否是闰年 int is_leap_year(int year) { return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); } // 辅助函数:获取某月的天数 int days_in_month(int year, int month) { int days_per_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; if (month == 2 && is_leap_year(year)) return 29; return days_per_month[month]; } // 函数:增加一天到日期 void add_day_to_date(char *date_str, int *year, int *month, int *day) { (*day)++; if (*day > days_in_month(*year, *month)) { (*day) = 1; (*month)++; if (*month > 12) { (*month) = 1; (*year)++; } } sprintf(date_str, "%04d-%02d-%02d", *year, *month, *day); } void SetMenuAuthority(int RoleID) { //超级管理员 if (RoleID == 1) { _GlobalMenuAuthority.PowerEnabled = true; _GlobalMenuAuthority.SensorEnabled = true; _GlobalMenuAuthority.AlarmEnabled = true; _GlobalMenuAuthority.LogEnabled = true; _GlobalMenuAuthority.UserInfoEnabled = true; _GlobalMenuAuthority.CommEnabled = true; _GlobalMenuAuthority.ServiceEnabled = true; _GlobalMenuAuthority.MaintenanceEnabled = true; // 1、电源监控菜单 _GlobalMenuAuthority.MonitorallEnabled = true; _GlobalMenuAuthority.ChannelstatusEnabled = true; _GlobalMenuAuthority.SwitchtatusEnabled = true; _GlobalMenuAuthority.MonitorhistoryEnabled = true; // 2、传感器管理菜单 _GlobalMenuAuthority.SensorStatusEnabled = true; _GlobalMenuAuthority.SensorHistorylEnabled = false; // 3、告警管理菜单 _GlobalMenuAuthority.XtjgEnabled = true; _GlobalMenuAuthority.YzszEnabled = true; // 4、日志信息菜单 _GlobalMenuAuthority.CzrzEnabled = true; _GlobalMenuAuthority.YxrzEnabled = true; // 5、用户管理菜单 _GlobalMenuAuthority.UserEnabled = true; _GlobalMenuAuthority.RoleEnabled = false; _GlobalMenuAuthority.MenuEnabled = false; // 6、通信管理菜单 _GlobalMenuAuthority.WkszEnabled = true; _GlobalMenuAuthority.RsszEnabled = true; // 7、服务管理菜单 _GlobalMenuAuthority.SmtpszEnabled = true; _GlobalMenuAuthority.SnmpszEnabled = true; _GlobalMenuAuthority.MqszEnabled = true; _GlobalMenuAuthority.NtpszEnabled = true; _GlobalMenuAuthority.DsszEnabled = true; _GlobalMenuAuthority.SxszEnabled = true; _GlobalMenuAuthority.FzszEnabled = true; // 8、设备维护菜单 _GlobalMenuAuthority.SbcqEnabled = true; _GlobalMenuAuthority.GjsjEnabled = true; _GlobalMenuAuthority.HhccszEnabled = true; _GlobalMenuAuthority.PzdrdcEnabled = true; _GlobalMenuAuthority.ShfwEnabled = true; _GlobalMenuAuthority.GysbEnabled = true; } // 管理员 else if (RoleID == 2) { _GlobalMenuAuthority.PowerEnabled = true; _GlobalMenuAuthority.SensorEnabled = true; _GlobalMenuAuthority.AlarmEnabled = true; _GlobalMenuAuthority.LogEnabled = true; _GlobalMenuAuthority.UserInfoEnabled = true; _GlobalMenuAuthority.CommEnabled = true; _GlobalMenuAuthority.ServiceEnabled = true; _GlobalMenuAuthority.MaintenanceEnabled = true; // 1、电源监控菜单 _GlobalMenuAuthority.MonitorallEnabled = true; _GlobalMenuAuthority.ChannelstatusEnabled = true; _GlobalMenuAuthority.SwitchtatusEnabled = false; _GlobalMenuAuthority.MonitorhistoryEnabled = true; // 2、传感器管理菜单 _GlobalMenuAuthority.SensorStatusEnabled = true; _GlobalMenuAuthority.SensorHistorylEnabled = false; // 3、告警管理菜单 _GlobalMenuAuthority.XtjgEnabled = true; _GlobalMenuAuthority.YzszEnabled = true; // 4、日志信息菜单 _GlobalMenuAuthority.CzrzEnabled = false; _GlobalMenuAuthority.YxrzEnabled = true; // 5、用户管理菜单 _GlobalMenuAuthority.UserEnabled = true; _GlobalMenuAuthority.RoleEnabled = false; _GlobalMenuAuthority.MenuEnabled = false; // 6、通信管理菜单 _GlobalMenuAuthority.WkszEnabled = false; _GlobalMenuAuthority.RsszEnabled = true; // 7、服务管理菜单 _GlobalMenuAuthority.SmtpszEnabled = false; _GlobalMenuAuthority.SnmpszEnabled = false; _GlobalMenuAuthority.MqszEnabled = false; _GlobalMenuAuthority.NtpszEnabled = true; _GlobalMenuAuthority.DsszEnabled = true; _GlobalMenuAuthority.SxszEnabled = true; _GlobalMenuAuthority.FzszEnabled = true; // 8、设备维护菜单 _GlobalMenuAuthority.SbcqEnabled = true; _GlobalMenuAuthority.GjsjEnabled = true; _GlobalMenuAuthority.HhccszEnabled = false; _GlobalMenuAuthority.PzdrdcEnabled = true; _GlobalMenuAuthority.ShfwEnabled = false; _GlobalMenuAuthority.GysbEnabled = true; } //普通用户 else { _GlobalMenuAuthority.PowerEnabled = true; _GlobalMenuAuthority.SensorEnabled = true; _GlobalMenuAuthority.AlarmEnabled = false; _GlobalMenuAuthority.LogEnabled = false; _GlobalMenuAuthority.UserInfoEnabled = false; _GlobalMenuAuthority.CommEnabled = false; _GlobalMenuAuthority.ServiceEnabled = false; _GlobalMenuAuthority.MaintenanceEnabled = false; // 1、电源监控菜单 _GlobalMenuAuthority.MonitorallEnabled = true; _GlobalMenuAuthority.ChannelstatusEnabled = true; _GlobalMenuAuthority.SwitchtatusEnabled = false; _GlobalMenuAuthority.MonitorhistoryEnabled = false; // 2、传感器管理菜单 _GlobalMenuAuthority.SensorStatusEnabled = true; _GlobalMenuAuthority.SensorHistorylEnabled = false; // 3、告警管理菜单 _GlobalMenuAuthority.XtjgEnabled = false; _GlobalMenuAuthority.YzszEnabled = false; // 4、日志信息菜单 _GlobalMenuAuthority.CzrzEnabled = false; _GlobalMenuAuthority.YxrzEnabled = false; // 5、用户管理菜单 _GlobalMenuAuthority.UserEnabled = false; _GlobalMenuAuthority.RoleEnabled = false; _GlobalMenuAuthority.MenuEnabled = false; // 6、通信管理菜单 _GlobalMenuAuthority.WkszEnabled = false; _GlobalMenuAuthority.RsszEnabled = false; // 7、服务管理菜单 _GlobalMenuAuthority.SmtpszEnabled = false; _GlobalMenuAuthority.SnmpszEnabled = false; _GlobalMenuAuthority.MqszEnabled = false; _GlobalMenuAuthority.NtpszEnabled = false; _GlobalMenuAuthority.DsszEnabled = false; _GlobalMenuAuthority.SxszEnabled = false; _GlobalMenuAuthority.FzszEnabled = false; // 8、设备维护菜单 _GlobalMenuAuthority.SbcqEnabled = false; _GlobalMenuAuthority.GjsjEnabled = false; _GlobalMenuAuthority.HhccszEnabled = false; _GlobalMenuAuthority.PzdrdcEnabled = false; _GlobalMenuAuthority.ShfwEnabled = false; _GlobalMenuAuthority.GysbEnabled = false; } }