Beispiel #1
0
        public static string RangeCurrent(DevModelConfig devcfg, string sType, int selNo = 0, string fmt = "F1")
        {
            System.Collections.Generic.List <stru_CommRange> currentThresholds = devcfg.devThresholds.currentThresholds;
            string format = string.Concat(new string[]
            {
                "({0:",
                fmt,
                "}~{1:",
                fmt,
                "})"
            });

            if (currentThresholds != null)
            {
                foreach (stru_CommRange current in currentThresholds)
                {
                    if (string.Compare(current.type, sType, true) == 0)
                    {
                        int num  = System.Convert.ToInt32(devcfgUtil.Rang_min(current.id));
                        int num2 = System.Convert.ToInt32(devcfgUtil.Rang_max(current.id));
                        if (num <= selNo && selNo <= num2)
                        {
                            return(string.Format(format, CultureTransfer.ToSingle(devcfgUtil.Rang_min(current.range)), CultureTransfer.ToSingle(devcfgUtil.Rang_max(current.range))));
                        }
                    }
                }
            }
            return(string.Format(format, 0.0, 20.0));
        }
Beispiel #2
0
        private bool devConfigCheck()
        {
            string value     = this.labDevModel.Tag.ToString();
            string fmwareVer = this.labDevIp.Tag.ToString();

            System.Convert.ToInt32(value);
            DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(this.labDevModel.Text, fmwareVer);
            bool           flag = false;

            if (this.tbRefVoltage.Visible)
            {
                Ecovalidate.checkTextIsNull(this.tbRefVoltage, ref flag);
                if (flag)
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[]
                    {
                        this.lbRefVoltage.Text
                    }));
                    return(false);
                }
                if (!Ecovalidate.RangeDouble(this.tbRefVoltage, 90.0, 260.0))
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Range, new string[]
                    {
                        this.lbRefVoltage.Text,
                        "90",
                        "260"
                    }));
                    return(false);
                }
            }
            flag = true;
            int num = devcfgUtil.UIThresholdEditFlg(deviceModelConfig, "dev");

            Ecovalidate.checkThresholdValue(this.tbMinCurrent, this.labMaxCurrentBound, (num & 256) == 0, ref flag);
            Ecovalidate.checkThresholdValue(this.tbMaxCurrent, this.labMaxCurrentBound, (num & 512) == 0, ref flag);
            Ecovalidate.checkThresholdValue(this.tbMinVoltage, this.labMaxVoltageBound, (num & 1024) == 0, ref flag);
            Ecovalidate.checkThresholdValue(this.tbMaxVoltage, this.labMaxVoltageBound, (num & 2048) == 0, ref flag);
            Ecovalidate.checkThresholdValue(this.tbMinPower, this.labMaxPowerBound, (num & 4096) == 0, ref flag);
            Ecovalidate.checkThresholdValue(this.tbMaxPower, this.labMaxPowerBound, (num & 8192) == 0, ref flag);
            Ecovalidate.checkThresholdValue(this.tbMinPowerDiss, this.labMaxPowerDisBound, (num & 16384) == 0, ref flag);
            Ecovalidate.checkThresholdValue(this.tbMaxPowerDiss, this.labMaxPowerDisBound, (num & 32768) == 0, ref flag);
            if (!flag)
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_Thresholdinvalid, new string[0]));
                return(false);
            }
            Ecovalidate.checkThresholdMaxMixValue(this.tbMaxCurrent, this.tbMinCurrent, ref flag);
            Ecovalidate.checkThresholdMaxMixValue(this.tbMaxVoltage, this.tbMinVoltage, ref flag);
            Ecovalidate.checkThresholdMaxMixValue(this.tbMaxPower, this.tbMinPower, ref flag);
            Ecovalidate.checkThresholdMaxMixValue(this.tbMaxPowerDiss, this.tbMinPowerDiss, ref flag);
            if (!flag)
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdMinMax, new string[0]));
                return(false);
            }
            return(true);
        }
Beispiel #3
0
        private void FillData_Line(TreeNode denode, DataSet ds, string id, DevModelConfig devcfg)
        {
            if (devcfg.perlineReading == Constant.NO)
            {
                return;
            }
            DataTable dataTable = ds.Tables[4].Clone();

            DataRow[] array = ds.Tables[4].Select("device_id= " + id);
            for (int i = 0; i < array.Length; i++)
            {
                dataTable.ImportRow(array[i]);
            }
            int uIthEdidflg = devcfgUtil.UIThresholdEditFlg(devcfg, "line");

            for (int j = 0; j < dataTable.Rows.Count; j++)
            {
                bool     flag     = true;
                double   maxV     = ecoConvert.f2d(dataTable.Rows[j]["max_power"]);
                double   minV     = ecoConvert.f2d(dataTable.Rows[j]["min_power"]);
                double   maxV2    = ecoConvert.f2d(dataTable.Rows[j]["max_current"]);
                double   minV2    = ecoConvert.f2d(dataTable.Rows[j]["min_current"]);
                double   maxV3    = ecoConvert.f2d(dataTable.Rows[j]["max_voltage"]);
                double   minV3    = ecoConvert.f2d(dataTable.Rows[j]["min_voltage"]);
                TreeNode treeNode = new TreeNode();
                treeNode.Name               = "Line" + System.Convert.ToString(dataTable.Rows[j]["line_number"]);
                treeNode.ToolTipText        = treeNode.Name;
                treeNode.Text               = treeNode.Name;
                treeNode.ToolTipText        = treeNode.Text;
                treeNode.ImageIndex         = 34;
                treeNode.SelectedImageIndex = 34;
                TreeNode treeNode2 = this.genTreeNode(uIthEdidflg, 3, EcoLanguage.getMsg(LangRes.Title_Power, new string[0]), ecoConvert.f2d(dataTable.Rows[j]["power_value"]), minV, maxV, "F4", "W", 13, 15, 14, 12, ref flag);
                TreeNode treeNode3 = this.genTreeNode(uIthEdidflg, 2, EcoLanguage.getMsg(LangRes.Title_Voltage, new string[0]), ecoConvert.f2d(dataTable.Rows[j]["voltage_value"]), minV3, maxV3, "F2", "V", 25, 27, 26, 24, ref flag);
                TreeNode treeNode4 = this.genTreeNode(uIthEdidflg, 1, EcoLanguage.getMsg(LangRes.Title_Current, new string[0]), ecoConvert.f2d(dataTable.Rows[j]["current_value"]), minV2, maxV2, "F2", "A", 3, 5, 4, 2, ref flag);
                if (!flag)
                {
                    if (treeNode2 != null)
                    {
                        treeNode.Nodes.Add(treeNode2);
                    }
                    if (treeNode3 != null)
                    {
                        treeNode.Nodes.Add(treeNode3);
                    }
                    if (treeNode4 != null)
                    {
                        treeNode.Nodes.Add(treeNode4);
                    }
                    denode.Nodes.Add(treeNode);
                    denode.Expand();
                    treeNode.Expand();
                }
            }
        }
Beispiel #4
0
 private void lineConfigPageControlInit(DevModelConfig devcfg)
 {
     if (devcfg.perlineReading == Constant.YES)
     {
         this.gbThreshold.Show();
         this.butLineAssign.Visible = true;
         return;
     }
     this.gbThreshold.Hide();
     this.butLineAssign.Visible = false;
 }
Beispiel #5
0
 private void bankConfigPageControlInit(DevModelConfig devcfg)
 {
     this.tbBankNm.BackColor = Color.White;
     if (devcfg.perbankReading == 2)
     {
         this.gbThreshold.Show();
         this.butBankAssign.Visible = true;
         return;
     }
     this.gbThreshold.Hide();
     this.butBankAssign.Visible = false;
 }
Beispiel #6
0
 public static double ampMax(DevModelConfig devcfg, string sType)
 {
     System.Collections.Generic.List <stru_CommRange> ampcapicity = devcfg.ampcapicity;
     foreach (stru_CommRange current in ampcapicity)
     {
         if (string.Compare(current.type, sType, true) == 0)
         {
             return(CultureTransfer.ToDouble(devcfgUtil.Rang_max(current.range)));
         }
     }
     return(0.0);
 }
Beispiel #7
0
 public static int ThresholdFlg(DevModelConfig devcfg, string sType)
 {
     System.Collections.Generic.List <ThresholdFlg> thresholdsFlg = devcfg.devThresholds.ThresholdsFlg;
     foreach (ThresholdFlg current in thresholdsFlg)
     {
         if (string.Compare(current.type, sType, true) == 0)
         {
             return(current.flg);
         }
     }
     return(0);
 }
Beispiel #8
0
        private void setBankConfigData(DeviceInfo pCurDev, int bankID)
        {
            string         text              = this.labDevModel.Text;
            string         value             = bankID.ToString();
            BankInfo       bankInfoByID      = DeviceOperation.GetBankInfoByID(bankID);
            DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, pCurDev.FWVersion);
            int            selNo             = System.Convert.ToInt32(bankInfoByID.PortLists);

            this.labBankNo.Text = selNo.ToString();
            System.Collections.Generic.List <BankInfo> bankInfo = pCurDev.GetBankInfo();
            for (int i = 1; i <= bankInfo.Count; i++)
            {
                Control[] array = this.gbBankConfig.Controls.Find("butBank" + i, false);
                if (array.Length > 0)
                {
                    string text2 = ((Button)array[0]).Tag.ToString();
                    if (!text2.Equals(value))
                    {
                        ((Button)array[0]).BackColor = Color.PaleTurquoise;
                    }
                    else
                    {
                        ((Button)array[0]).BackColor = Color.DarkCyan;
                    }
                }
            }
            this.tbBankNm.Text = bankInfoByID.BankName;
            int num = devcfgUtil.UIThresholdEditFlg(deviceModelConfig, "bank");

            if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU)
            {
                this.labMaxPortCurrentBound.Text = ((!this.tbOMinCurrent.ReadOnly || !this.tbOMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "bank", selNo, "F0") : "");
                ThresholdUtil.SetUIEdit(this.tbOMinCurrent, (num & 1) == 0, bankInfoByID.Min_current, 0, "F0");
                ThresholdUtil.SetUIEdit(this.tbOMaxCurrent, (num & 2) == 0, bankInfoByID.Max_current, 0, "F0");
            }
            else
            {
                this.labMaxPortCurrentBound.Text = ((!this.tbOMinCurrent.ReadOnly || !this.tbOMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "bank", selNo, "F1") : "");
                ThresholdUtil.SetUIEdit(this.tbOMinCurrent, (num & 1) == 0, bankInfoByID.Min_current, 0, "F1");
                ThresholdUtil.SetUIEdit(this.tbOMaxCurrent, (num & 2) == 0, bankInfoByID.Max_current, 0, "F1");
            }
            ThresholdUtil.SetUIEdit(this.tbOMinVoltage, (num & 4) == 0, bankInfoByID.Min_voltage, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbOMaxVoltage, (num & 8) == 0, bankInfoByID.Max_voltage, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbOMinPower, (num & 16) == 0, bankInfoByID.Min_power, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbOMaxPower, (num & 32) == 0, bankInfoByID.Max_power, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbOMinPowerDiss, (num & 64) == 0, bankInfoByID.Min_power_diss, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbOMaxPowerDiss, (num & 128) == 0, bankInfoByID.Max_power_diss, 0, "F1");
            this.labMaxVoltageBound.Text  = ((!this.tbOMinVoltage.ReadOnly || !this.tbOMaxVoltage.ReadOnly) ? devcfgUtil.RangeVoltage(deviceModelConfig, "bank", selNo) : "");
            this.labMaxPowerBound.Text    = ((!this.tbOMinPower.ReadOnly || !this.tbOMaxPower.ReadOnly) ? devcfgUtil.RangePower(deviceModelConfig, "bank", selNo, 1.0) : "");
            this.labMaxPowerDisBound.Text = ((!this.tbOMinPowerDiss.ReadOnly || !this.tbOMaxPowerDiss.ReadOnly) ? devcfgUtil.RangePowerDiss(deviceModelConfig, "bank", selNo) : "");
            this.tbBankNm.BackColor       = Color.White;
        }
Beispiel #9
0
        private bool bankCheck(DevModelConfig devcfg)
        {
            string text = this.tbBankNm.Text.Trim();

            this.tbBankNm.Text = text;
            string text2 = this.labBankNo.Text;
            int    num   = System.Convert.ToInt32(text2);
            bool   flag  = false;

            if (((ulong)devcfg.bankOpt_nameempty & (ulong)(1L << (num - 1 & 31))) != 0uL)
            {
                Ecovalidate.checkTextIsNull(this.tbBankNm, ref flag);
                if (flag)
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[]
                    {
                        this.lbBankNm.Text
                    }));
                    this.tbBankNm.BackColor = Color.Red;
                    return(false);
                }
                this.tbBankNm.BackColor = Color.White;
            }
            if (this.gbThreshold.Visible)
            {
                flag = true;
                int num2 = devcfgUtil.UIThresholdEditFlg(devcfg, "bank");
                Ecovalidate.checkThresholdValue(this.tbOMinCurrent, this.labMaxPortCurrentBound, (num2 & 256) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbOMaxCurrent, this.labMaxPortCurrentBound, (num2 & 512) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbOMinVoltage, this.labMaxVoltageBound, (num2 & 1024) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbOMaxVoltage, this.labMaxVoltageBound, (num2 & 2048) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbOMinPower, this.labMaxPowerBound, (num2 & 4096) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbOMaxPower, this.labMaxPowerBound, (num2 & 8192) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbOMinPowerDiss, this.labMaxPowerDisBound, (num2 & 16384) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbOMaxPowerDiss, this.labMaxPowerDisBound, (num2 & 32768) == 0, ref flag);
                if (!flag)
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_Thresholdinvalid, new string[0]));
                    return(false);
                }
                Ecovalidate.checkThresholdMaxMixValue(this.tbOMaxCurrent, this.tbOMinCurrent, ref flag);
                Ecovalidate.checkThresholdMaxMixValue(this.tbOMaxVoltage, this.tbOMinVoltage, ref flag);
                Ecovalidate.checkThresholdMaxMixValue(this.tbOMaxPower, this.tbOMinPower, ref flag);
                Ecovalidate.checkThresholdMaxMixValue(this.tbOMaxPowerDiss, this.tbOMinPowerDiss, ref flag);
                if (!flag)
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdMinMax, new string[0]));
                    return(false);
                }
            }
            return(true);
        }
Beispiel #10
0
        private void butBank_Click(object sender, System.EventArgs e)
        {
            string         text              = this.labDevModel.Text;
            string         value             = this.labDevModel.Tag.ToString();
            int            l_id              = System.Convert.ToInt32(value);
            DeviceInfo     deviceByID        = DeviceOperation.getDeviceByID(l_id);
            DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, deviceByID.FWVersion);

            this.bankConfigPageControlInit(deviceModelConfig);
            string value2 = ((Button)sender).Tag.ToString();

            ((Button)sender).BackColor = Color.DarkCyan;
            this.setBankConfigData(deviceByID, System.Convert.ToInt32(value2));
        }
Beispiel #11
0
        private bool devConfigCheck()
        {
            string value     = this.labDevModel.Tag.ToString();
            string fmwareVer = this.labDevIp.Tag.ToString();

            System.Convert.ToInt32(value);
            DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(this.labDevModel.Text, fmwareVer);
            bool           flag = true;

            if (this.gbPop.Visible && this.cbPopEnable.Checked && this.rbPopUsrdef.Checked)
            {
                flag = false;
                Ecovalidate.checkTextIsNull(this.tbPopThreshold, ref flag);
                if (flag)
                {
                    this.tbPopThreshold.Focus();
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[]
                    {
                        this.rbPopUsrdef.Text
                    }));
                    return(false);
                }
                float num = 0f;
                try
                {
                    num = System.Convert.ToSingle(this.tbPopThreshold.Text);
                }
                catch (System.Exception)
                {
                    this.tbPopThreshold.Focus();
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Comm_invalidNumber, new string[0]));
                    bool result = false;
                    return(result);
                }
                if (num > (float)deviceModelConfig.popUdefmax)
                {
                    this.tbPopThreshold.Focus();
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Range, new string[]
                    {
                        this.rbPopUsrdef.Text,
                        "0",
                        deviceModelConfig.popUdefmax.ToString()
                    }));
                    return(false);
                }
                return(true);
            }
            return(true);
        }
Beispiel #12
0
 public static double ampMax(DevModelConfig devcfg, string sType, int selNo)
 {
     System.Collections.Generic.List <stru_CommRange> ampcapicity = devcfg.ampcapicity;
     foreach (stru_CommRange current in ampcapicity)
     {
         if (string.Compare(current.type, sType, true) == 0)
         {
             int num  = System.Convert.ToInt32(devcfgUtil.Rang_min(current.id));
             int num2 = System.Convert.ToInt32(devcfgUtil.Rang_max(current.id));
             if (num <= selNo && selNo <= num2)
             {
                 return(CultureTransfer.ToDouble(devcfgUtil.Rang_max(current.range)));
             }
         }
     }
     return(0.0);
 }
Beispiel #13
0
 public static float fmaxCurrent(DevModelConfig devcfg, string sType, int selNo = 0)
 {
     System.Collections.Generic.List <stru_CommRange> currentThresholds = devcfg.devThresholds.currentThresholds;
     foreach (stru_CommRange current in currentThresholds)
     {
         if (string.Compare(current.type, sType, true) == 0)
         {
             int num  = CultureTransfer.ToInt32(devcfgUtil.Rang_min(current.id));
             int num2 = CultureTransfer.ToInt32(devcfgUtil.Rang_max(current.id));
             if (num <= selNo && selNo <= num2)
             {
                 return(CultureTransfer.ToSingle(devcfgUtil.Rang_max(current.range)));
             }
         }
     }
     return(-300f);
 }
Beispiel #14
0
 public static int UIThresholdEditFlg(DevModelConfig devcfg, string sType)
 {
     System.Collections.Generic.List <ThresholdFlg> uIEditFlg = devcfg.devThresholds.UIEditFlg;
     if (uIEditFlg != null)
     {
         foreach (ThresholdFlg current in uIEditFlg)
         {
             if (string.Compare(current.type, sType, true) == 0)
             {
                 return(current.flg);
             }
         }
     }
     if (sType.Equals("ss"))
     {
         return(0);
     }
     return(81);
 }
Beispiel #15
0
        public static string RangeTemp(DevModelConfig devcfg, string sType, int selNo = 0, string fmt = "F1")
        {
            System.Collections.Generic.List <stru_CommRange> tempThresholds = devcfg.devThresholds.tempThresholds;
            string format = string.Concat(new string[]
            {
                "({0:",
                fmt,
                "}~{1:",
                fmt,
                "})"
            });

            if (tempThresholds != null)
            {
                foreach (stru_CommRange current in tempThresholds)
                {
                    if (string.Compare(current.type, sType, true) == 0)
                    {
                        int num  = System.Convert.ToInt32(devcfgUtil.Rang_min(current.id));
                        int num2 = System.Convert.ToInt32(devcfgUtil.Rang_max(current.id));
                        if (num <= selNo && selNo <= num2)
                        {
                            string result;
                            if (EcoGlobalVar.TempUnit == 0)
                            {
                                result = string.Format(format, CultureTransfer.ToSingle(devcfgUtil.Rang_min(current.range)), CultureTransfer.ToSingle(devcfgUtil.Rang_max(current.range)));
                                return(result);
                            }
                            result = string.Format(format, RackStatusAll.CtoFdegrees((double)CultureTransfer.ToSingle(devcfgUtil.Rang_min(current.range))), RackStatusAll.CtoFdegrees((double)CultureTransfer.ToSingle(devcfgUtil.Rang_max(current.range))));
                            return(result);
                        }
                    }
                }
            }
            string temperature = devcfg.devThresholds.commonThresholds.temperature;

            if (EcoGlobalVar.TempUnit == 0)
            {
                return(string.Format(format, CultureTransfer.ToSingle(devcfgUtil.Rang_min(temperature)), CultureTransfer.ToSingle(devcfgUtil.Rang_max(temperature))));
            }
            return(string.Format(format, RackStatusAll.CtoFdegrees((double)CultureTransfer.ToSingle(devcfgUtil.Rang_min(temperature))), RackStatusAll.CtoFdegrees((double)CultureTransfer.ToSingle(devcfgUtil.Rang_max(temperature)))));
        }
Beispiel #16
0
        private void setLineConfigData(DeviceInfo pCurDev, int lineID)
        {
            string         text              = this.labDevModel.Text;
            string         value             = lineID.ToString();
            LineInfo       lineInfoByID      = DeviceOperation.GetLineInfoByID(lineID);
            DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, pCurDev.FWVersion);
            int            selNo             = System.Convert.ToInt32(lineInfoByID.LineNumber);

            this.labLineNo.Text = selNo.ToString();
            System.Collections.Generic.List <LineInfo> lineInfo = pCurDev.GetLineInfo();
            for (int i = 1; i <= lineInfo.Count; i++)
            {
                Control[] array = this.gbLineConfig.Controls.Find("butLine" + i, false);
                if (array.Length > 0)
                {
                    string text2 = ((Button)array[0]).Tag.ToString();
                    if (!text2.Equals(value))
                    {
                        ((Button)array[0]).BackColor = Color.PaleTurquoise;
                    }
                    else
                    {
                        ((Button)array[0]).BackColor = Color.DarkCyan;
                    }
                }
            }
            int num = devcfgUtil.UIThresholdEditFlg(deviceModelConfig, "line");

            this.labMaxCurrentBound.Text = ((!this.tbLMinCurrent.ReadOnly || !this.tbLMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "line", selNo, "F1") : "");
            ThresholdUtil.SetUIEdit(this.tbLMinCurrent, (num & 1) == 0, lineInfoByID.Min_current, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbLMaxCurrent, (num & 2) == 0, lineInfoByID.Max_current, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbLMinVoltage, (num & 4) == 0, lineInfoByID.Min_voltage, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbLMaxVoltage, (num & 8) == 0, lineInfoByID.Max_voltage, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbLMinPower, (num & 16) == 0, lineInfoByID.Min_power, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbLMaxPower, (num & 32) == 0, lineInfoByID.Max_power, 0, "F1");
            this.labMaxVoltageBound.Text  = ((!this.tbLMinVoltage.ReadOnly || !this.tbLMaxVoltage.ReadOnly) ? devcfgUtil.RangeVoltage(deviceModelConfig, "line", selNo) : "");
            this.labMaxPowerBound.Text    = ((!this.tbLMinPower.ReadOnly || !this.tbLMaxPower.ReadOnly) ? devcfgUtil.RangePower(deviceModelConfig, "line", selNo, 1.0) : "");
            this.labMaxPowerDisBound.Text = ((!this.tbLMinPowerDiss.ReadOnly || !this.tbLMaxPowerDiss.ReadOnly) ? devcfgUtil.RangePowerDiss(deviceModelConfig, "line", selNo) : "");
        }
Beispiel #17
0
        public static string RangePress(DevModelConfig devcfg, string sType, int selNo = 0)
        {
            System.Collections.Generic.List <stru_CommRange> pressThresholds = devcfg.devThresholds.PressThresholds;
            if (pressThresholds != null)
            {
                foreach (stru_CommRange current in pressThresholds)
                {
                    if (string.Compare(current.type, sType, true) == 0)
                    {
                        int num  = System.Convert.ToInt32(devcfgUtil.Rang_min(current.id));
                        int num2 = System.Convert.ToInt32(devcfgUtil.Rang_max(current.id));
                        if (num <= selNo && selNo <= num2)
                        {
                            return(string.Format("({0:F1}~{1:F1})", CultureTransfer.ToSingle(devcfgUtil.Rang_min(current.range)), CultureTransfer.ToSingle(devcfgUtil.Rang_max(current.range))));
                        }
                    }
                }
            }
            string pressure = devcfg.devThresholds.commonThresholds.pressure;

            return(string.Format("({0:F1}~{1:F1})", CultureTransfer.ToSingle(devcfgUtil.Rang_min(pressure)), CultureTransfer.ToSingle(devcfgUtil.Rang_max(pressure))));
        }
Beispiel #18
0
        public static float fMaxPowerD(DevModelConfig devcfg, string sType, int selNo = 0)
        {
            System.Collections.Generic.List <stru_CommRange> powerDissThresholds = devcfg.devThresholds.powerDissThresholds;
            if (powerDissThresholds != null)
            {
                foreach (stru_CommRange current in powerDissThresholds)
                {
                    if (string.Compare(current.type, sType, true) == 0)
                    {
                        int num  = System.Convert.ToInt32(devcfgUtil.Rang_min(current.id));
                        int num2 = System.Convert.ToInt32(devcfgUtil.Rang_max(current.id));
                        if (num <= selNo && selNo <= num2)
                        {
                            return(CultureTransfer.ToSingle(devcfgUtil.Rang_max(current.range)));
                        }
                    }
                }
            }
            DevCommonThreshold commonThresholds = devcfg.devThresholds.commonThresholds;

            return(CultureTransfer.ToSingle(devcfgUtil.Rang_max(commonThresholds.powerDissipation)));
        }
Beispiel #19
0
        public System.Collections.Generic.Dictionary <string, bool> SetDeviceThresholds(System.Collections.Generic.List <DevSnmpConfig> configs, DeviceThreshold deviceThreshold)
        {
            DevAccessCfg instance = DevAccessCfg.GetInstance();

            System.Collections.Generic.List <SnmpConfiger> list = new System.Collections.Generic.List <SnmpConfiger>();
            foreach (DevSnmpConfig current in configs)
            {
                DevModelConfig deviceModelConfig = instance.getDeviceModelConfig(current.modelName, current.fmwareVer);
                SnmpConfiger   item = new SnmpConfiger(instance.getSnmpConfig(current), deviceModelConfig, current.devMac, current.devID);
                list.Add(item);
            }
            System.Collections.Generic.List <string>             list2      = new AppSnmpExecutors(list).SetDevThresholds(deviceThreshold);
            System.Collections.Generic.Dictionary <string, bool> dictionary = new System.Collections.Generic.Dictionary <string, bool>();
            foreach (string current2 in list2)
            {
                string[] array = current2.Split(new char[]
                {
                    ':'
                });
                dictionary.Add(array[0], System.Convert.ToBoolean(array[1]));
            }
            return(dictionary);
        }
Beispiel #20
0
        private bool lineCheck(DevModelConfig devcfg)
        {
            string text = this.labLineNo.Text;

            System.Convert.ToInt32(text);
            bool flag = false;

            if (this.gbThreshold.Visible)
            {
                flag = true;
                int num = devcfgUtil.UIThresholdEditFlg(devcfg, "line");
                Ecovalidate.checkThresholdValue(this.tbLMinCurrent, this.labMaxCurrentBound, (num & 256) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbLMaxCurrent, this.labMaxCurrentBound, (num & 512) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbLMinVoltage, this.labMaxVoltageBound, (num & 1024) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbLMaxVoltage, this.labMaxVoltageBound, (num & 2048) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbLMinPower, this.labMaxPowerBound, (num & 4096) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbLMaxPower, this.labMaxPowerBound, (num & 8192) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbLMinPowerDiss, this.labMaxPowerDisBound, (num & 16384) == 0, ref flag);
                Ecovalidate.checkThresholdValue(this.tbLMaxPowerDiss, this.labMaxPowerDisBound, (num & 32768) == 0, ref flag);
                if (!flag)
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_Thresholdinvalid, new string[0]));
                    return(false);
                }
                Ecovalidate.checkThresholdMaxMixValue(this.tbLMaxCurrent, this.tbLMinCurrent, ref flag);
                Ecovalidate.checkThresholdMaxMixValue(this.tbLMaxVoltage, this.tbLMinVoltage, ref flag);
                Ecovalidate.checkThresholdMaxMixValue(this.tbLMaxPower, this.tbLMinPower, ref flag);
                Ecovalidate.checkThresholdMaxMixValue(this.tbLMaxPowerDiss, this.tbLMinPowerDiss, ref flag);
                if (!flag)
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdMinMax, new string[0]));
                    return(false);
                }
            }
            return(true);
        }
Beispiel #21
0
        private void filteronlinedev()
        {
            this.dgvFwDevice.Rows.Clear();
            this.cbsel.Checked = true;
            string text  = null;
            string strB  = null;
            string text2 = null;
            string text3 = "";
            string text4 = "";

            if (this.tbFileNm.Text.Length > 0)
            {
                System.IO.FileInfo fileInfo = new System.IO.FileInfo(this.tbFileNm.Text);
                text  = fileInfo.Name.ToUpper();
                text2 = fileInfo.Extension;
                if (text2 != null)
                {
                    text2 = text2.ToUpper();
                }
                strB = this.getDevFWflg(this.tbFileNm.Text, ref text3, ref text4);
            }
            DevAccessCfg instance = DevAccessCfg.GetInstance();

            if (text4.Length == 0)
            {
                using (System.Collections.Generic.List <string[]> .Enumerator enumerator = this.m_allRows.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string[] current = enumerator.Current;
                        string   text5   = current[6];
                        string   text6   = current[7];
                        string   text7   = current[4];
                        if (text != null)
                        {
                            DevModelConfig deviceModelConfig = instance.getDeviceModelConfig(current[3], text7);
                            if (deviceModelConfig.FWvalidate != 0)
                            {
                                if ((deviceModelConfig.FWnms.Length > 0 && !text.StartsWith(deviceModelConfig.FWnms)) || (deviceModelConfig.FWext.Length > 0 && (text2 == null || !text2.Equals(deviceModelConfig.FWext))))
                                {
                                    continue;
                                }
                                switch (deviceModelConfig.FWvalidate)
                                {
                                case 1:
                                    if (!text3.Equals("ATEN") || (this.cbMainFw.Checked && text7.CompareTo(strB) >= 0))
                                    {
                                        continue;
                                    }
                                    break;
                                }
                            }
                        }
                        string[] obj = new string[]
                        {
                            "1",
                            current[1],
                            current[2],
                            current[3],
                            text7,
                            current[5],
                            text5,
                            text6
                        };
                        ControlAccess.ConfigControl config = delegate(Control control, object param)
                        {
                            DataGridView dataGridView = control as DataGridView;
                            string[]     array2       = param as string[];
                            dataGridView.Rows.Add(new object[]
                            {
                                true,
                                array2[1],
                                array2[2],
                                array2[3],
                                array2[4],
                                array2[5],
                                array2[6],
                                array2[7]
                            });
                        };
                        ControlAccess controlAccess = new ControlAccess(this, config);
                        controlAccess.Access(this.dgvFwDevice, obj);
                    }
                    goto IL_37E;
                }
            }
            string[] array = text4.Split(new char[]
            {
                '/'
            });
            foreach (string[] current2 in this.m_allRows)
            {
                string text5 = current2[6];
                string text6 = current2[7];
                string text7 = current2[4];
                if (text != null)
                {
                    bool flag = false;
                    for (int i = 0; i < array.Length; i++)
                    {
                        string text8 = array[i];
                        int    num   = text8.IndexOf("*");
                        if (num >= 0)
                        {
                            text8 = text8.Substring(0, num);
                            if (current2[3].IndexOf(text8) >= 0)
                            {
                                flag = true;
                                break;
                            }
                        }
                        else
                        {
                            if (current2[3].Equals(array[i]))
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (!flag || (this.cbMainFw.Checked && text7.CompareTo(strB) >= 0))
                    {
                        continue;
                    }
                }
                string[] obj2 = new string[]
                {
                    "1",
                    current2[1],
                    current2[2],
                    current2[3],
                    text7,
                    current2[5],
                    text5,
                    text6
                };
                ControlAccess.ConfigControl config2 = delegate(Control control, object param)
                {
                    DataGridView dataGridView = control as DataGridView;
                    string[]     array2       = param as string[];
                    dataGridView.Rows.Add(new object[]
                    {
                        true,
                        array2[1],
                        array2[2],
                        array2[3],
                        array2[4],
                        array2[5],
                        array2[6],
                        array2[7]
                    });
                };
                ControlAccess controlAccess2 = new ControlAccess(this, config2);
                controlAccess2.Access(this.dgvFwDevice, obj2);
            }
            IL_37E :
            ControlAccess.ConfigControl config3 = delegate(Control control, object param)
            {
                this.cbMainFw.Enabled  = true;
                this.butBrowse.Enabled = true;
                this.butUpdate.Enabled = true;
                this.cbsel.Enabled     = true;
            };
            ControlAccess controlAccess3 = new ControlAccess(this, config3);

            controlAccess3.Access(this.dgvFwDevice, null);
        }
Beispiel #22
0
        private object initFWDevProc(object aaa)
        {
            System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice();
            DevAccessCfg.GetInstance();
            foreach (DeviceInfo current in allDevice)
            {
                if (ClientAPI.IsDeviceOnline(current.DeviceID))
                {
                    string         text              = current.DeviceID.ToString();
                    string         modelNm           = current.ModelNm;
                    DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(modelNm, current.FWVersion);
                    if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDU_M2 && deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold && deviceModelConfig.commonThresholdFlag != Constant.APC_PDU)
                    {
                        DevSnmpConfig  sNMPpara       = commUtil.getSNMPpara(current);
                        string         mac            = current.Mac;
                        DevAccessAPI   devAccessAPI   = new DevAccessAPI(sNMPpara);
                        DevServiceInfo devServiceInfo = devAccessAPI.GetDevServiceInfo(mac);
                        int            httpPort       = devServiceInfo.httpPort;
                        if (httpPort != 0)
                        {
                            string[] obj = new string[]
                            {
                                "1",
                                current.DeviceName,
                                current.DeviceIP,
                                current.ModelNm,
                                devServiceInfo.fwVersion,
                                "",
                                text,
                                httpPort.ToString()
                            };
                            ControlAccess.ConfigControl config = delegate(Control control, object param)
                            {
                                DataGridView dataGridView = control as DataGridView;
                                string[]     array        = param as string[];
                                dataGridView.Rows.Add(new object[]
                                {
                                    true,
                                    array[1],
                                    array[2],
                                    array[3],
                                    array[4],
                                    array[5],
                                    array[6],
                                    array[7]
                                });
                                this.m_allRows.Add(array);
                            };
                            ControlAccess controlAccess = new ControlAccess(this, config);
                            controlAccess.Access(this.dgvFwDevice, obj);
                        }
                    }
                }
            }
            ControlAccess.ConfigControl config2 = delegate(Control control, object param)
            {
                this.cbMainFw.Enabled  = true;
                this.butBrowse.Enabled = true;
                this.butUpdate.Enabled = true;
                this.cbsel.Enabled     = true;
            };
            ControlAccess controlAccess2 = new ControlAccess(this, config2);

            controlAccess2.Access(this.dgvFwDevice, null);
            return(0);
        }
Beispiel #23
0
 private void butSave_Click(object sender, System.EventArgs e)
 {
     try
     {
         if (this.devConfigCheck())
         {
             string         text              = this.labDevModel.Text;
             string         value             = this.labDevModel.Tag.ToString();
             int            l_id              = System.Convert.ToInt32(value);
             DeviceInfo     deviceByID        = DeviceOperation.getDeviceByID(l_id);
             DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, deviceByID.FWVersion);
             if (this.gbPop2.Visible)
             {
                 if (this.pop2_cbOutlet.Visible)
                 {
                     deviceByID.OutletPOPMode = (this.pop2_cbOutlet.Checked ? 2 : 1);
                 }
                 if (this.pop2_cbBankLIFO.Visible)
                 {
                     deviceByID.BankPOPLIFOMode = (this.pop2_cbBankLIFO.Checked ? 2 : 1);
                 }
                 deviceByID.BankPOPPriorityMode = (this.pop2_cbBankPriority.Checked ? 2 : 1);
             }
             if (this.gbPOPBankPriority.Visible)
             {
                 string text2 = "";
                 int    num;
                 int    num2;
                 if (deviceModelConfig.bankNum == 0)
                 {
                     num  = 1;
                     num2 = deviceModelConfig.portNum;
                 }
                 else
                 {
                     num  = deviceModelConfig.bankOutlets[0].fromPort;
                     num2 = deviceModelConfig.bankOutlets[0].toPort;
                 }
                 for (int i = 0; i < this.dgvBank1_PList.Rows.Count; i++)
                 {
                     DataGridViewComboBoxCell dataGridViewComboBoxCell = (DataGridViewComboBoxCell)this.dgvBank1_PList.Rows[i].Cells[1];
                     string text3 = dataGridViewComboBoxCell.Value.ToString();
                     if (text3.Equals("N/A"))
                     {
                         text2 += "0,";
                     }
                     else
                     {
                         text3 = text3.Substring("Outlet ".Length);
                         text2 = text2 + ((int)System.Convert.ToInt16(text3)).ToString() + ",";
                     }
                 }
                 for (int j = 0; j < num2 - num + 1 - this.dgvBank1_PList.Rows.Count; j++)
                 {
                     text2 += "0,";
                 }
                 text2 = text2.Substring(0, text2.Length - 1);
                 if (this.dgvBank2_PList.Visible)
                 {
                     num    = deviceModelConfig.bankOutlets[1].fromPort;
                     num2   = deviceModelConfig.bankOutlets[1].toPort;
                     text2 += "#";
                     for (int k = 0; k < this.dgvBank2_PList.Rows.Count; k++)
                     {
                         DataGridViewComboBoxCell dataGridViewComboBoxCell = (DataGridViewComboBoxCell)this.dgvBank2_PList.Rows[k].Cells[1];
                         string text3 = dataGridViewComboBoxCell.Value.ToString();
                         if (text3.Equals("N/A"))
                         {
                             text2 += "0,";
                         }
                         else
                         {
                             text3 = text3.Substring("Outlet ".Length);
                             text2 = text2 + ((int)System.Convert.ToInt16(text3)).ToString() + ",";
                         }
                     }
                     for (int l = 0; l < num2 - num + 1 - this.dgvBank1_PList.Rows.Count; l++)
                     {
                         text2 += "0,";
                     }
                     text2 = text2.Substring(0, text2.Length - 1);
                 }
                 deviceByID.Bank_Priority = text2;
             }
             if (this.gbPop.Visible)
             {
                 if (!this.cbPopEnable.Checked)
                 {
                     deviceByID.POPEnableMode = 1;
                 }
                 else
                 {
                     deviceByID.POPEnableMode = 2;
                     if (this.rbPopMaxBankC.Checked)
                     {
                         deviceByID.POPThreshold = -0.1f;
                     }
                     else
                     {
                         deviceByID.POPThreshold = System.Convert.ToSingle(this.tbPopThreshold.Text);
                     }
                 }
             }
             string            mac               = deviceByID.Mac;
             DevSnmpConfig     sNMPpara          = commUtil.getSNMPpara(deviceByID);
             DevAccessAPI      devAccessAPI      = new DevAccessAPI(sNMPpara);
             DevicePOPSettings devicePOPSettings = new DevicePOPSettings();
             devicePOPSettings.PopEnableMode   = deviceByID.POPEnableMode;
             devicePOPSettings.PopThreshold    = deviceByID.POPThreshold;
             devicePOPSettings.PopModeOutlet   = deviceByID.OutletPOPMode;
             devicePOPSettings.PopModeLIFO     = deviceByID.BankPOPLIFOMode;
             devicePOPSettings.PopModePriority = deviceByID.BankPOPPriorityMode;
             devicePOPSettings.PopPriorityList = deviceByID.Bank_Priority;
             if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold && !devAccessAPI.SetDevicePOPSettings(devicePOPSettings, mac))
             {
                 EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
             }
             else
             {
                 deviceByID.Update();
                 string valuePair = ValuePairs.getValuePair("Username");
                 if (!string.IsNullOrEmpty(valuePair))
                 {
                     LogAPI.writeEventLog("0630005", new string[]
                     {
                         deviceByID.DeviceName,
                         deviceByID.Mac,
                         deviceByID.DeviceIP,
                         valuePair
                     });
                 }
                 else
                 {
                     LogAPI.writeEventLog("0630005", new string[]
                     {
                         deviceByID.DeviceName,
                         deviceByID.Mac,
                         deviceByID.DeviceIP
                     });
                 }
                 EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0]));
             }
         }
     }
     catch (System.Exception ex)
     {
         System.Console.WriteLine("PropDev Exception" + ex.Message);
         EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
     }
 }
Beispiel #24
0
 private void butBankSave_Click(object sender, System.EventArgs e)
 {
     try
     {
         string         value             = this.labDevModel.Tag.ToString();
         int            num               = System.Convert.ToInt32(value);
         DeviceInfo     deviceByID        = DeviceOperation.getDeviceByID(num);
         DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion);
         if (this.bankCheck(deviceModelConfig))
         {
             string        text          = this.tbBankNm.Text;
             string        text2         = this.labBankNo.Text;
             int           num2          = System.Convert.ToInt32(text2);
             BankInfo      bankInfo      = new BankInfo(num, num2);
             DevSnmpConfig sNMPpara      = commUtil.getSNMPpara(deviceByID);
             BankThreshold bankThreshold = new BankThreshold(num2);
             bankThreshold.BankName = text;
             if (this.gbThreshold.Visible)
             {
                 bankInfo.Min_current    = ThresholdUtil.UI2DB(this.tbOMinCurrent, bankInfo.Min_current, 0);
                 bankInfo.Max_current    = ThresholdUtil.UI2DB(this.tbOMaxCurrent, bankInfo.Max_current, 0);
                 bankInfo.Min_voltage    = ThresholdUtil.UI2DB(this.tbOMinVoltage, bankInfo.Min_voltage, 0);
                 bankInfo.Max_voltage    = ThresholdUtil.UI2DB(this.tbOMaxVoltage, bankInfo.Max_voltage, 0);
                 bankInfo.Min_power      = ThresholdUtil.UI2DB(this.tbOMinPower, bankInfo.Min_power, 0);
                 bankInfo.Max_power      = ThresholdUtil.UI2DB(this.tbOMaxPower, bankInfo.Max_power, 0);
                 bankInfo.Min_power_diss = ThresholdUtil.UI2DB(this.tbOMinPowerDiss, bankInfo.Min_power_diss, 0);
                 bankInfo.Max_power_diss = ThresholdUtil.UI2DB(this.tbOMaxPowerDiss, bankInfo.Max_power_diss, 0);
                 int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "bank");
                 bankThreshold.MinCurrentMt   = bankInfo.Min_current;
                 bankThreshold.MaxCurrentMT   = bankInfo.Max_current;
                 bankThreshold.MinVoltageMT   = bankInfo.Min_voltage;
                 bankThreshold.MaxVoltageMT   = bankInfo.Max_voltage;
                 bankThreshold.MinPowerMT     = bankInfo.Min_power;
                 bankThreshold.MaxPowerMT     = bankInfo.Max_power;
                 bankThreshold.MaxPowerDissMT = bankInfo.Max_power_diss;
                 ThresholdUtil.UI2Dev(thflg, bankThreshold);
             }
             bool flag = true;
             if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold)
             {
                 DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara);
                 flag = devAccessAPI.SetBankThreshold(bankThreshold, deviceByID.Mac);
             }
             if (flag)
             {
                 if (bankInfo != null)
                 {
                     bankInfo.BankName = text;
                     bankInfo.Update();
                     EcoGlobalVar.setDashBoardFlg(128uL, string.Concat(new object[]
                     {
                         "#UPDATE#D",
                         bankInfo.DeviceID,
                         ":B",
                         bankInfo.ID,
                         ";"
                     }), 2);
                     string valuePair = ValuePairs.getValuePair("Username");
                     if (!string.IsNullOrEmpty(valuePair))
                     {
                         LogAPI.writeEventLog("0630010", new string[]
                         {
                             bankInfo.BankName,
                             bankInfo.PortLists,
                             deviceByID.DeviceIP,
                             deviceByID.DeviceName,
                             valuePair
                         });
                     }
                     else
                     {
                         LogAPI.writeEventLog("0630010", new string[]
                         {
                             bankInfo.BankName,
                             bankInfo.PortLists,
                             deviceByID.DeviceIP,
                             deviceByID.DeviceName
                         });
                     }
                 }
                 EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0]));
             }
             else
             {
                 EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
             }
         }
     }
     catch (System.Exception ex)
     {
         System.Console.WriteLine("PropBank Exception" + ex.Message);
         EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
     }
 }
Beispiel #25
0
        public void pageInit(int devID, bool onlinest)
        {
            this.butSave.Enabled = onlinest;
            DeviceInfo deviceByID = DeviceOperation.getDeviceByID(devID);

            this.labDevNm.Text    = deviceByID.DeviceName;
            this.labDevModel.Text = deviceByID.ModelNm;
            this.labDevModel.Tag  = devID.ToString();
            string text = deviceByID.ModelNm;

            if (DevAccessCfg.GetInstance().isAutodectDev(deviceByID.ModelNm, deviceByID.FWVersion))
            {
                text = text + " (F/W: " + deviceByID.FWVersion + ")";
            }
            this.toolTip1.SetToolTip(this.labDevModel, text);
            this.labDevIp.Text = deviceByID.DeviceIP;
            this.labDevIp.Tag  = deviceByID.FWVersion;
            this.labDevNm.Text = deviceByID.DeviceName;
            RackInfo rackByID = RackInfo.getRackByID(deviceByID.RackID);

            this.labDevRackNm.Text = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
            DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion);

            if (deviceModelConfig.popReading != 2)
            {
                this.gbPop.Hide();
                this.gbPop2.Hide();
                this.gbPOPBankPriority.Hide();
                return;
            }
            if (deviceModelConfig.popNewRule == Constant.YES)
            {
                this.gbPop.Hide();
                this.gbPop2.Show();
                if (deviceModelConfig.perportreading == Constant.NO)
                {
                    this.pop2_cbOutlet.Hide();
                    this.pop2_cbBankLIFO.Hide();
                }
                else
                {
                    this.pop2_cbOutlet.Show();
                    this.pop2_cbBankLIFO.Show();
                }
                if (deviceByID.OutletPOPMode == 1)
                {
                    this.pop2_cbOutlet.Checked = false;
                }
                else
                {
                    this.pop2_cbOutlet.Checked = true;
                }
                if (deviceByID.BankPOPLIFOMode == 1)
                {
                    this.pop2_cbBankLIFO.Checked = false;
                }
                else
                {
                    this.pop2_cbBankLIFO.Checked = true;
                }
                if (deviceByID.BankPOPPriorityMode == 1)
                {
                    this.pop2_cbBankPriority.Checked = false;
                }
                else
                {
                    this.pop2_cbBankPriority.Checked = true;
                }
                if (deviceModelConfig.popPrioritySupport == Constant.NO)
                {
                    this.gbPOPBankPriority.Hide();
                    return;
                }
                this.gbPOPBankPriority.Show();
                string[] array = deviceByID.Bank_Priority.Split(new char[]
                {
                    '#'
                });
                string[] array2 = array[0].Split(new char[]
                {
                    ','
                });
                string[] array3 = null;
                if (array.Length >= 2)
                {
                    array3 = array[1].Split(new char[]
                    {
                        ','
                    });
                }
                this.dgvBank1_PList.Rows.Clear();
                DataGridViewComboBoxColumn dataGridViewComboBoxColumn = (DataGridViewComboBoxColumn)this.dgvBank1_PList.Columns[1];
                this.m_Bank1_Priority_ComboStrings = new System.Collections.Generic.List <string>();
                dataGridViewComboBoxColumn.Items.Clear();
                dataGridViewComboBoxColumn.Items.Add("N/A");
                this.m_Bank1_Priority_ComboStrings.Add("N/A");
                int num;
                int num2;
                if (deviceModelConfig.bankNum == 0)
                {
                    num  = 1;
                    num2 = deviceModelConfig.portNum;
                }
                else
                {
                    num  = deviceModelConfig.bankOutlets[0].fromPort;
                    num2 = deviceModelConfig.bankOutlets[0].toPort;
                }
                for (int i = num; i <= num2; i++)
                {
                    if (deviceModelConfig.isOutletSwitchable(i - 1))
                    {
                        dataGridViewComboBoxColumn.Items.Add("Outlet " + i.ToString());
                        this.m_Bank1_Priority_ComboStrings.Add("Outlet " + i.ToString());
                    }
                }
                int num3 = 0;
                for (int j = num; j <= num2; j++)
                {
                    if (deviceModelConfig.isOutletSwitchable(j - 1))
                    {
                        if (array2[num3].Equals("0"))
                        {
                            this.dgvBank1_PList.Rows.Add(new object[]
                            {
                                "Priority" + (num3 + 1).ToString(),
                                "N/A"
                            });
                        }
                        else
                        {
                            string text2 = "Outlet " + System.Convert.ToInt16(array2[num3]).ToString();
                            if (this.m_Bank1_Priority_ComboStrings.Contains(text2))
                            {
                                this.dgvBank1_PList.Rows.Add(new object[]
                                {
                                    "Priority" + (num3 + 1).ToString(),
                                    text2
                                });
                            }
                            else
                            {
                                this.dgvBank1_PList.Rows.Add(new object[]
                                {
                                    "Priority" + (num3 + 1).ToString(),
                                    "N/A"
                                });
                            }
                        }
                        num3++;
                    }
                }
                if (deviceModelConfig.bankNum >= 2)
                {
                    this.lbbank2.Visible        = true;
                    this.dgvBank2_PList.Visible = true;
                    this.dgvBank2_PList.Rows.Clear();
                    dataGridViewComboBoxColumn         = (DataGridViewComboBoxColumn)this.dgvBank2_PList.Columns[1];
                    this.m_Bank2_Priority_ComboStrings = new System.Collections.Generic.List <string>();
                    dataGridViewComboBoxColumn.Items.Clear();
                    dataGridViewComboBoxColumn.Items.Add("N/A");
                    this.m_Bank2_Priority_ComboStrings.Add("N/A");
                    for (int k = deviceModelConfig.bankOutlets[1].fromPort; k <= deviceModelConfig.bankOutlets[1].toPort; k++)
                    {
                        if (deviceModelConfig.isOutletSwitchable(k - 1))
                        {
                            dataGridViewComboBoxColumn.Items.Add("Outlet " + k.ToString());
                            this.m_Bank2_Priority_ComboStrings.Add("Outlet " + k.ToString());
                        }
                    }
                    num3 = 0;
                    for (int l = deviceModelConfig.bankOutlets[1].fromPort; l <= deviceModelConfig.bankOutlets[1].toPort; l++)
                    {
                        if (deviceModelConfig.isOutletSwitchable(l - 1))
                        {
                            if (array3[num3].Equals("0"))
                            {
                                this.dgvBank2_PList.Rows.Add(new object[]
                                {
                                    "Priority" + (num3 + 1).ToString(),
                                    "N/A"
                                });
                            }
                            else
                            {
                                string text2 = "Outlet " + System.Convert.ToInt16(array3[num3]).ToString();
                                if (this.m_Bank2_Priority_ComboStrings.Contains(text2))
                                {
                                    this.dgvBank2_PList.Rows.Add(new object[]
                                    {
                                        "Priority" + (num3 + 1).ToString(),
                                        text2
                                    });
                                }
                                else
                                {
                                    this.dgvBank2_PList.Rows.Add(new object[]
                                    {
                                        "Priority" + (num3 + 1).ToString(),
                                        "N/A"
                                    });
                                }
                            }
                            num3++;
                        }
                    }
                    return;
                }
                this.lbbank2.Visible        = false;
                this.dgvBank2_PList.Visible = false;
                return;
            }
            else
            {
                if (deviceByID.POPThreshold == -500f)
                {
                    this.gbPop.Hide();
                    this.gbPop2.Hide();
                    this.gbPOPBankPriority.Hide();
                    return;
                }
                this.gbPop.Show();
                this.gbPop2.Hide();
                this.gbPOPBankPriority.Hide();
                this.rbPopMaxBankC.Text = this.PopMaxBank_txt + " " + deviceModelConfig.popDefault.ToString("F1") + "A";
                if (deviceByID.POPEnableMode == 1)
                {
                    this.cbPopEnable.Checked   = false;
                    this.rbPopMaxBankC.Checked = true;
                    this.tbPopThreshold.Text   = "";
                    this.cbPopEnable_CheckedChanged(this.cbPopEnable, null);
                    return;
                }
                if (deviceByID.POPThreshold < 0f)
                {
                    this.cbPopEnable.Checked   = true;
                    this.rbPopMaxBankC.Checked = true;
                    this.tbPopThreshold.Text   = "";
                    return;
                }
                this.cbPopEnable.Checked = true;
                this.rbPopUsrdef.Checked = true;
                this.tbPopThreshold.Text = deviceByID.POPThreshold.ToString("F1");
                return;
            }
        }
Beispiel #26
0
        private void FillData_Bank(TreeNode denode, DataSet ds, string devid, DevModelConfig devcfg)
        {
            if (devcfg.perbankReading == 1)
            {
                return;
            }
            DataTable dataTable = ds.Tables[3].Clone();

            DataRow[] array = ds.Tables[3].Select(string.Concat(new string[]
            {
                "device_id= ",
                devid,
                " and bank_state='",
                BankStatus.ON.ToString(),
                "'"
            }));
            for (int i = 0; i < array.Length; i++)
            {
                dataTable.ImportRow(array[i]);
            }
            int uIthEdidflg = devcfgUtil.UIThresholdEditFlg(devcfg, "bank");

            for (int j = 0; j < dataTable.Rows.Count; j++)
            {
                bool     flag     = true;
                double   maxV     = ecoConvert.f2d(dataTable.Rows[j]["max_power"]);
                double   minV     = ecoConvert.f2d(dataTable.Rows[j]["min_power"]);
                double   maxV2    = ecoConvert.f2d(dataTable.Rows[j]["max_current"]);
                double   minV2    = ecoConvert.f2d(dataTable.Rows[j]["min_current"]);
                double   maxV3    = ecoConvert.f2d(dataTable.Rows[j]["max_voltage"]);
                double   minV3    = ecoConvert.f2d(dataTable.Rows[j]["min_voltage"]);
                double   maxV4    = ecoConvert.f2d(dataTable.Rows[j]["max_power_diss"]);
                double   minV4    = ecoConvert.f2d(dataTable.Rows[j]["min_power_diss"]);
                TreeNode treeNode = new TreeNode();
                treeNode.Name        = System.Convert.ToString(dataTable.Rows[j]["bank_number"]);
                treeNode.ToolTipText = System.Convert.ToString(dataTable.Rows[j]["bank_nm"]);
                if (System.Convert.ToString(dataTable.Rows[j]["bank_nm"]) != System.Convert.ToString(-1000))
                {
                    treeNode.Text = System.Convert.ToString(dataTable.Rows[j]["bank_nm"]);
                }
                else
                {
                    treeNode.Text = "";
                }
                treeNode.Text               = treeNode.Name + ":" + treeNode.Text;
                treeNode.ToolTipText        = treeNode.Text;
                treeNode.ImageIndex         = 30;
                treeNode.SelectedImageIndex = 30;
                TreeNode treeNode2 = this.genTreeNode(uIthEdidflg, 4, EcoLanguage.getMsg(LangRes.Title_PowerDiss, new string[0]), ecoConvert.f2d(dataTable.Rows[j]["power_consumption"]), minV4, maxV4, "F4", "kWh", 13, 15, 14, 12, ref flag);
                TreeNode treeNode3 = this.genTreeNode(uIthEdidflg, 3, EcoLanguage.getMsg(LangRes.Title_Power, new string[0]), ecoConvert.f2d(dataTable.Rows[j]["power_value"]), minV, maxV, "F4", "W", 13, 15, 14, 12, ref flag);
                TreeNode treeNode4 = this.genTreeNode(uIthEdidflg, 2, EcoLanguage.getMsg(LangRes.Title_Voltage, new string[0]), ecoConvert.f2d(dataTable.Rows[j]["voltage_value"]), minV3, maxV3, "F2", "V", 25, 27, 26, 24, ref flag);
                TreeNode treeNode5 = this.genTreeNode(uIthEdidflg, 1, EcoLanguage.getMsg(LangRes.Title_Current, new string[0]), ecoConvert.f2d(dataTable.Rows[j]["current_value"]), minV2, maxV2, "F2", "A", 3, 5, 4, 2, ref flag);
                if (!flag)
                {
                    if (treeNode2 != null)
                    {
                        treeNode.Nodes.Add(treeNode2);
                    }
                    if (treeNode3 != null)
                    {
                        treeNode.Nodes.Add(treeNode3);
                    }
                    if (treeNode4 != null)
                    {
                        treeNode.Nodes.Add(treeNode4);
                    }
                    if (treeNode5 != null)
                    {
                        treeNode.Nodes.Add(treeNode5);
                    }
                    denode.Nodes.Add(treeNode);
                    denode.Expand();
                    treeNode.Expand();
                }
            }
        }
Beispiel #27
0
        private void FillData_Outlet(TreeNode denode, DataSet ds, string devid, DevModelConfig devcfg)
        {
            if (devcfg.perportreading == 1)
            {
                return;
            }
            DataTable dataTable = ds.Tables[2].Clone();

            DataRow[] array = ds.Tables[2].Select("device_id= " + devid);
            for (int i = 0; i < array.Length; i++)
            {
                dataTable.ImportRow(array[i]);
            }
            int uIthEdidflg = devcfgUtil.UIThresholdEditFlg(devcfg, "port");

            System.Collections.Generic.List <long> list = this.m_UACDevPort[(long)System.Convert.ToInt32(devid)];
            for (int j = 0; j < dataTable.Rows.Count; j++)
            {
                int num = System.Convert.ToInt32(dataTable.Rows[j]["port_id"]);
                if (list == null || list.Count == 0 || list.Contains((long)num))
                {
                    bool     flag     = true;
                    double   maxV     = ecoConvert.f2d(dataTable.Rows[j]["max_power"]);
                    double   minV     = ecoConvert.f2d(dataTable.Rows[j]["min_power"]);
                    double   maxV2    = ecoConvert.f2d(dataTable.Rows[j]["max_current"]);
                    double   minV2    = ecoConvert.f2d(dataTable.Rows[j]["min_current"]);
                    double   maxV3    = ecoConvert.f2d(dataTable.Rows[j]["max_voltage"]);
                    double   minV3    = ecoConvert.f2d(dataTable.Rows[j]["min_voltage"]);
                    double   maxV4    = ecoConvert.f2d(dataTable.Rows[j]["max_power_diss"]);
                    double   minV4    = ecoConvert.f2d(dataTable.Rows[j]["min_power_diss"]);
                    TreeNode treeNode = new TreeNode();
                    treeNode.Name = System.Convert.ToString(dataTable.Rows[j]["port_number"]);
                    if (System.Convert.ToString(dataTable.Rows[j]["port_nm"]) != System.Convert.ToString(-1000))
                    {
                        treeNode.Text = System.Convert.ToString(dataTable.Rows[j]["port_nm"]);
                    }
                    else
                    {
                        treeNode.Text = "";
                    }
                    treeNode.Text               = treeNode.Name + ":" + treeNode.Text;
                    treeNode.ToolTipText        = treeNode.Text;
                    treeNode.ImageIndex         = 29;
                    treeNode.SelectedImageIndex = 29;
                    string a = System.Convert.ToString(dataTable.Rows[j]["port_state"]);
                    if (!(a != OutletStatus.ON.ToString()) || !(a != OutletStatus.NA.ToString()))
                    {
                        TreeNode treeNode2 = this.genTreeNode(uIthEdidflg, 4, EcoLanguage.getMsg(LangRes.Title_PowerDiss, new string[0]), ecoConvert.f2d(dataTable.Rows[j]["power_consumption"]), minV4, maxV4, "F4", "kWh", 13, 15, 14, 12, ref flag);
                        TreeNode treeNode3 = this.genTreeNode(uIthEdidflg, 3, EcoLanguage.getMsg(LangRes.Title_Power, new string[0]), ecoConvert.f2d(dataTable.Rows[j]["power_value"]), minV, maxV, "F4", "W", 13, 15, 14, 12, ref flag);
                        TreeNode treeNode4 = this.genTreeNode(uIthEdidflg, 2, EcoLanguage.getMsg(LangRes.Title_Voltage, new string[0]), ecoConvert.f2d(dataTable.Rows[j]["voltage_value"]), minV3, maxV3, "F2", "V", 25, 27, 26, 24, ref flag);
                        TreeNode treeNode5 = this.genTreeNode(uIthEdidflg, 1, EcoLanguage.getMsg(LangRes.Title_Current, new string[0]), ecoConvert.f2d(dataTable.Rows[j]["current_value"]), minV2, maxV2, "F2", "A", 3, 5, 4, 2, ref flag);
                        if (!flag)
                        {
                            if (treeNode2 != null)
                            {
                                treeNode.Nodes.Add(treeNode2);
                            }
                            if (treeNode3 != null)
                            {
                                treeNode.Nodes.Add(treeNode3);
                            }
                            if (treeNode4 != null)
                            {
                                treeNode.Nodes.Add(treeNode4);
                            }
                            if (treeNode5 != null)
                            {
                                treeNode.Nodes.Add(treeNode5);
                            }
                            denode.Nodes.Add(treeNode);
                            denode.Expand();
                            treeNode.Expand();
                        }
                    }
                }
            }
        }
Beispiel #28
0
        private void FillData()
        {
            string[] array = this.m_devidsinRack.Split(new char[]
            {
                ','
            });
            System.Collections.Generic.Dictionary <int, ClientAPI.DeviceWithZoneRackInfo> devicRackZoneRelation = ClientAPI.GetDevicRackZoneRelation();
            this.treeView1.Nodes.Clear();
            string   text     = "";
            TreeNode treeNode = new TreeNode();

            treeNode.Name       = "Root";
            treeNode.ImageIndex = 1;
            this.treeView1.Nodes.Add(treeNode);
            this.treeView1.Indent = 15;
            DataSet dataSet = new DataSet();

            try
            {
                dataSet = this.allData;
                string[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    string text2 = array2[i];
                    int    num   = System.Convert.ToInt32(text2);
                    if (devicRackZoneRelation.ContainsKey(num))
                    {
                        ClientAPI.DeviceWithZoneRackInfo deviceWithZoneRackInfo = devicRackZoneRelation[num];
                        DataTable dataTable = dataSet.Tables[0].Clone();
                        DataRow[] array3    = dataSet.Tables[0].Select("device_id=" + text2);
                        for (int j = 0; j < array3.Length; j++)
                        {
                            dataTable.ImportRow(array3[j]);
                        }
                        if (dataTable.Rows.Count > 0 && this.m_UACDevPort.ContainsKey((long)num))
                        {
                            TreeNode treeNode2 = new TreeNode();
                            treeNode2.Name = "Device";
                            if (System.Convert.ToString(dataTable.Rows[0]["device_nm"]) != System.Convert.ToString(-1000))
                            {
                                if (System.Convert.ToString(dataTable.Rows[0]["device_nm"]) != "")
                                {
                                    treeNode2.Text = System.Convert.ToString(dataTable.Rows[0]["device_nm"]);
                                }
                                else
                                {
                                    treeNode2.Text = System.Convert.ToString(dataTable.Rows[0]["device_ip"]);
                                }
                            }
                            else
                            {
                                treeNode2.Text = "";
                            }
                            text = deviceWithZoneRackInfo.rack_nm;
                            if (System.Convert.ToString(dataTable.Rows[0]["device_state"]) != "1")
                            {
                                treeNode2.ImageIndex         = 6;
                                treeNode2.SelectedImageIndex = 6;
                                treeNode.Nodes.Add(treeNode2);
                            }
                            else
                            {
                                treeNode2.ImageIndex         = 7;
                                treeNode2.SelectedImageIndex = 7;
                                string         device_model      = deviceWithZoneRackInfo.device_model;
                                string         fw_version        = deviceWithZoneRackInfo.fw_version;
                                DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(device_model, fw_version);
                                bool           flag = true;
                                if (this.m_UACDevPort.ContainsKey((long)num) && (this.m_UACDevPort[(long)num] == null || this.m_UACDevPort[(long)num].Count == 0))
                                {
                                    double   maxV        = ecoConvert.f2d(dataTable.Rows[0]["max_power"]);
                                    double   minV        = ecoConvert.f2d(dataTable.Rows[0]["min_power"]);
                                    double   maxV2       = ecoConvert.f2d(dataTable.Rows[0]["max_current"]);
                                    double   minV2       = ecoConvert.f2d(dataTable.Rows[0]["min_current"]);
                                    double   maxV3       = ecoConvert.f2d(dataTable.Rows[0]["max_voltage"]);
                                    double   minV3       = ecoConvert.f2d(dataTable.Rows[0]["min_voltage"]);
                                    double   maxV4       = ecoConvert.f2d(dataTable.Rows[0]["max_power_diss"]);
                                    double   minV4       = ecoConvert.f2d(dataTable.Rows[0]["min_power_diss"]);
                                    int      uIthEdidflg = devcfgUtil.UIThresholdEditFlg(deviceModelConfig, "dev");
                                    TreeNode treeNode3   = this.genTreeNode(uIthEdidflg, 4, EcoLanguage.getMsg(LangRes.Title_PowerDiss, new string[0]), ecoConvert.f2d(dataTable.Rows[0]["power_consumption"]), minV4, maxV4, "F4", "kWh", 13, 15, 14, 12, ref flag);
                                    if (treeNode3 != null)
                                    {
                                        treeNode2.Nodes.Add(treeNode3);
                                    }
                                    TreeNode treeNode4 = this.genTreeNode(uIthEdidflg, 3, EcoLanguage.getMsg(LangRes.Title_Power, new string[0]), ecoConvert.f2d(dataTable.Rows[0]["power_value"]), minV, maxV, "F4", "W", 13, 15, 14, 12, ref flag);
                                    if (treeNode4 != null)
                                    {
                                        treeNode2.Nodes.Add(treeNode4);
                                    }
                                    TreeNode treeNode5 = this.genTreeNode(uIthEdidflg, 2, EcoLanguage.getMsg(LangRes.Title_Voltage, new string[0]), ecoConvert.f2d(dataTable.Rows[0]["voltage_value"]), minV3, maxV3, "F2", "V", 25, 27, 26, 24, ref flag);
                                    if (treeNode5 != null)
                                    {
                                        treeNode2.Nodes.Add(treeNode5);
                                    }
                                    TreeNode treeNode6 = this.genTreeNode(uIthEdidflg, 1, EcoLanguage.getMsg(LangRes.Title_Current, new string[0]), ecoConvert.f2d(dataTable.Rows[0]["current_value"]), minV2, maxV2, "F2", "A", 3, 5, 4, 2, ref flag);
                                    if (treeNode6 != null)
                                    {
                                        treeNode2.Nodes.Add(treeNode6);
                                    }
                                    if (deviceModelConfig.leakCurrent == Constant.YES)
                                    {
                                        int num2 = (int)dataTable.Rows[0]["leakcurrent_status"];
                                        if (num2 == Constant.YES)
                                        {
                                            TreeNode treeNode7 = new TreeNode();
                                            treeNode7.Name               = "Neutral leakage current";
                                            treeNode7.ToolTipText        = treeNode7.Name;
                                            treeNode7.ImageIndex         = 35;
                                            treeNode7.SelectedImageIndex = 35;
                                            treeNode7.Text               = "Neutral leakage current";
                                            treeNode2.Nodes.Add(treeNode7);
                                            flag = false;
                                        }
                                    }
                                }
                                if (!flag)
                                {
                                    treeNode2.Expand();
                                }
                                if (this.m_UACDevPort.ContainsKey((long)num))
                                {
                                    this.FillData_Outlet(treeNode2, dataSet, text2, deviceModelConfig);
                                }
                                if (this.m_UACDevPort.ContainsKey((long)num) && (this.m_UACDevPort[(long)num] == null || this.m_UACDevPort[(long)num].Count == 0))
                                {
                                    this.FillData_Bank(treeNode2, dataSet, text2, deviceModelConfig);
                                }
                                if (this.m_UACDevPort.ContainsKey((long)num) && (this.m_UACDevPort[(long)num] == null || this.m_UACDevPort[(long)num].Count == 0))
                                {
                                    this.FillData_Line(treeNode2, dataSet, text2, deviceModelConfig);
                                }
                                treeNode.Nodes.Add(treeNode2);
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
            treeNode.Text = text;
            treeNode.Expand();
        }
Beispiel #29
0
        public void pageInit(int devID, int bankID, bool onlinest)
        {
            this.butBankAssign.Enabled = onlinest;
            this.butBankSave.Enabled   = onlinest;
            DeviceInfo deviceByID = DeviceOperation.getDeviceByID(devID);

            this.labDevIp.Text    = deviceByID.DeviceIP;
            this.labDevIp.Tag     = deviceByID.FWVersion;
            this.labDevModel.Text = deviceByID.ModelNm;
            this.labDevModel.Tag  = devID.ToString();
            this.labDevNm.Text    = deviceByID.DeviceName;
            string text = deviceByID.ModelNm;

            if (DevAccessCfg.GetInstance().isAutodectDev(deviceByID.ModelNm, deviceByID.FWVersion))
            {
                text = text + " (F/W: " + deviceByID.FWVersion + ")";
            }
            this.toolTip1.SetToolTip(this.labDevModel, text);
            RackInfo rackByID = RackInfo.getRackByID(deviceByID.RackID);

            this.labDevRackNm.Text = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
            DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion);

            this.butBank1.Visible = false;
            this.butBank2.Visible = false;
            this.butBank3.Visible = false;
            this.butBank4.Visible = false;
            this.butBank5.Visible = false;
            this.butBank6.Visible = false;
            this.butBank7.Visible = false;
            this.butBank8.Visible = false;
            System.Collections.Generic.List <BankInfo> bankInfo = deviceByID.GetBankInfo();
            foreach (BankInfo current in bankInfo)
            {
                string portLists = current.PortLists;
                switch (System.Convert.ToInt32(portLists))
                {
                case 1:
                    this.butBank1.Visible = true;
                    this.butBank1.Tag     = current.ID.ToString();
                    break;

                case 2:
                    this.butBank2.Visible = true;
                    this.butBank2.Tag     = current.ID.ToString();
                    break;

                case 3:
                    this.butBank3.Visible = true;
                    this.butBank3.Tag     = current.ID.ToString();
                    break;

                case 4:
                    this.butBank4.Visible = true;
                    this.butBank4.Tag     = current.ID.ToString();
                    break;

                case 5:
                    this.butBank5.Visible = true;
                    this.butBank5.Tag     = current.ID.ToString();
                    break;

                case 6:
                    this.butBank6.Visible = true;
                    this.butBank6.Tag     = current.ID.ToString();
                    break;

                case 7:
                    this.butBank7.Visible = true;
                    this.butBank7.Tag     = current.ID.ToString();
                    break;

                case 8:
                    this.butBank8.Visible = true;
                    this.butBank8.Tag     = current.ID.ToString();
                    break;
                }
            }
            this.bankConfigPageControlInit(deviceModelConfig);
            if (bankID == 0)
            {
                this.setBankConfigData(deviceByID, System.Convert.ToInt32(this.butBank1.Tag));
                return;
            }
            this.setBankConfigData(deviceByID, bankID);
        }
Beispiel #30
0
        private void butBankAssign_Click(object sender, System.EventArgs e)
        {
            bool   flag   = false;
            DBConn dBConn = null;
            string text   = this.labDevModel.Tag.ToString();

            try
            {
                int            num               = System.Convert.ToInt32(text);
                DeviceInfo     deviceByID        = DeviceOperation.getDeviceByID(num);
                DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion);
                if (this.bankCheck(deviceModelConfig))
                {
                    DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.Dev_ApplyBank, new string[0]), MessageBoxButtons.OKCancel);
                    if (dialogResult != DialogResult.Cancel)
                    {
                        string        text2         = this.tbBankNm.Text;
                        string        text3         = this.labBankNo.Text;
                        int           num2          = System.Convert.ToInt32(text3);
                        BankInfo      bankInfo      = new BankInfo(num, num2);
                        DevSnmpConfig sNMPpara      = commUtil.getSNMPpara(deviceByID);
                        BankThreshold bankThreshold = new BankThreshold(1);
                        if (this.gbThreshold.Visible)
                        {
                            bankInfo.Min_current    = ThresholdUtil.UI2DB(this.tbOMinCurrent, bankInfo.Min_current, 0);
                            bankInfo.Max_current    = ThresholdUtil.UI2DB(this.tbOMaxCurrent, bankInfo.Max_current, 0);
                            bankInfo.Min_voltage    = ThresholdUtil.UI2DB(this.tbOMinVoltage, bankInfo.Min_voltage, 0);
                            bankInfo.Max_voltage    = ThresholdUtil.UI2DB(this.tbOMaxVoltage, bankInfo.Max_voltage, 0);
                            bankInfo.Min_power      = ThresholdUtil.UI2DB(this.tbOMinPower, bankInfo.Min_power, 0);
                            bankInfo.Max_power      = ThresholdUtil.UI2DB(this.tbOMaxPower, bankInfo.Max_power, 0);
                            bankInfo.Min_power_diss = ThresholdUtil.UI2DB(this.tbOMinPowerDiss, bankInfo.Min_power_diss, 0);
                            bankInfo.Max_power_diss = ThresholdUtil.UI2DB(this.tbOMaxPowerDiss, bankInfo.Max_power_diss, 0);
                            int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "bank");
                            bankThreshold.MinCurrentMt   = bankInfo.Min_current;
                            bankThreshold.MaxCurrentMT   = bankInfo.Max_current;
                            bankThreshold.MinVoltageMT   = bankInfo.Min_voltage;
                            bankThreshold.MaxVoltageMT   = bankInfo.Max_voltage;
                            bankThreshold.MinPowerMT     = bankInfo.Min_power;
                            bankThreshold.MaxPowerMT     = bankInfo.Max_power;
                            bankThreshold.MaxPowerDissMT = bankInfo.Max_power_diss;
                            ThresholdUtil.UI2Dev(thflg, bankThreshold);
                        }
                        DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara);
                        string       myMac        = deviceByID.Mac;
                        System.Collections.Generic.List <BankInfo> bankInfo2 = deviceByID.GetBankInfo();
                        dBConn = DBConnPool.getConnection();
                        foreach (BankInfo current in bankInfo2)
                        {
                            BankThreshold bankThreshold2 = new BankThreshold(System.Convert.ToInt32(current.PortLists));
                            if (num2 == System.Convert.ToInt32(current.PortLists))
                            {
                                current.BankName = text2;
                            }
                            bankThreshold2.BankName = current.BankName;
                            if (this.gbThreshold.Visible)
                            {
                                bankThreshold2.MaxCurrentMT   = bankThreshold.MaxCurrentMT;
                                bankThreshold2.MinCurrentMt   = bankThreshold.MinCurrentMt;
                                bankThreshold2.MaxPowerMT     = bankThreshold.MaxPowerMT;
                                bankThreshold2.MinPowerMT     = bankThreshold.MinPowerMT;
                                bankThreshold2.MaxVoltageMT   = bankThreshold.MaxVoltageMT;
                                bankThreshold2.MinVoltageMT   = bankThreshold.MinVoltageMT;
                                bankThreshold2.MaxPowerDissMT = bankThreshold.MaxPowerDissMT;
                            }
                            bool flag2 = true;
                            if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold)
                            {
                                flag2 = devAccessAPI.SetBankThreshold(bankThreshold2, myMac);
                            }
                            if (!flag2)
                            {
                                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
                                return;
                            }
                            if (this.gbThreshold.Visible)
                            {
                                current.CopyThreshold(bankInfo);
                            }
                            current.UpdateBankThreshold(dBConn);
                            flag  = true;
                            myMac = "";
                        }
                        if (dBConn != null)
                        {
                            dBConn.close();
                        }
                        string valuePair = ValuePairs.getValuePair("Username");
                        if (!string.IsNullOrEmpty(valuePair))
                        {
                            LogAPI.writeEventLog("0630011", new string[]
                            {
                                deviceByID.ModelNm,
                                deviceByID.DeviceIP,
                                deviceByID.DeviceName,
                                valuePair
                            });
                        }
                        else
                        {
                            LogAPI.writeEventLog("0630011", new string[]
                            {
                                deviceByID.ModelNm,
                                deviceByID.DeviceIP,
                                deviceByID.DeviceName
                            });
                        }
                        EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0]));
                    }
                }
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine("butBankAssign_Click Exception" + ex.Message);
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
            }
            finally
            {
                if (dBConn != null)
                {
                    dBConn.close();
                }
                DeviceOperation.RefreshDBCache(false);
                if (flag)
                {
                    EcoGlobalVar.setDashBoardFlg(128uL, "#UPDATE#D" + text + ":B*;", 2);
                }
            }
        }