Exemplo n.º 1
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;
        }
Exemplo n.º 2
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) : "");
        }
Exemplo n.º 3
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);
                }
            }
        }
Exemplo n.º 4
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]));
     }
 }
Exemplo n.º 5
0
 private void butAssign_Click(object sender, System.EventArgs e)
 {
     try
     {
         if (this.devConfigCheck())
         {
             DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.Dev_ApplyAll, new string[0]), MessageBoxButtons.OKCancel);
             if (dialogResult != DialogResult.Cancel)
             {
                 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);
                 System.Collections.Generic.List <DeviceInfo> allDeviceByModel = DeviceOperation.GetAllDeviceByModel(text);
                 string fWVersion = deviceByID.FWVersion;
                 System.Collections.Generic.List <DeviceInfo> list = new System.Collections.Generic.List <DeviceInfo>();
                 foreach (DeviceInfo current in allDeviceByModel)
                 {
                     if (current.DeviceID != deviceByID.DeviceID)
                     {
                         if (!DevAccessCfg.GetInstance().isAutodectDev(current.ModelNm, current.FWVersion))
                         {
                             list.Add(current);
                         }
                         else
                         {
                             if (current.FWVersion.Equals(fWVersion))
                             {
                                 list.Add(current);
                             }
                         }
                     }
                 }
                 if (this.tbRefVoltage.Visible)
                 {
                     deviceByID.ReferenceVoltage = System.Convert.ToSingle(this.tbRefVoltage.Text);
                 }
                 deviceByID.Min_current = ThresholdUtil.UI2DB(this.tbMinCurrent, deviceByID.Min_current, 0);
                 deviceByID.Max_current = ThresholdUtil.UI2DB(this.tbMaxCurrent, deviceByID.Max_current, 0);
                 deviceByID.Min_voltage = ThresholdUtil.UI2DB(this.tbMinVoltage, deviceByID.Min_voltage, 0);
                 deviceByID.Max_voltage = ThresholdUtil.UI2DB(this.tbMaxVoltage, deviceByID.Max_voltage, 0);
                 deviceByID.Min_power   = ThresholdUtil.UI2DB(this.tbMinPower, deviceByID.Min_power, 0);
                 if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Min_power != -300f)
                 {
                     deviceByID.Min_power *= 1000f;
                 }
                 deviceByID.Max_power = ThresholdUtil.UI2DB(this.tbMaxPower, deviceByID.Max_power, 0);
                 if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Max_power != -300f)
                 {
                     deviceByID.Max_power *= 1000f;
                 }
                 deviceByID.Min_power_diss = ThresholdUtil.UI2DB(this.tbMinPowerDiss, deviceByID.Min_power_diss, 0);
                 deviceByID.Max_power_diss = ThresholdUtil.UI2DB(this.tbMaxPowerDiss, deviceByID.Max_power_diss, 0);
                 if (deviceModelConfig.doorReading == 2)
                 {
                     deviceByID.DoorSensor = 0;
                     if (this.rbPhoto_1.Checked)
                     {
                         deviceByID.DoorSensor = 1;
                     }
                     else
                     {
                         if (this.rbInductive_2.Checked)
                         {
                             deviceByID.DoorSensor = 2;
                         }
                         else
                         {
                             if (this.rbReed_3.Checked)
                             {
                                 deviceByID.DoorSensor = 3;
                             }
                         }
                     }
                 }
                 DeviceInfo      item            = new DeviceInfo(-1, "", "", "", "", "", "", "", 0, 0, "", 161, 1, "", deviceByID.Max_voltage, deviceByID.Min_voltage, deviceByID.Max_power_diss, deviceByID.Min_power_diss, deviceByID.Max_power, deviceByID.Min_power, deviceByID.Max_current, deviceByID.Min_current, -1L, "", -500, -500f, deviceByID.DoorSensor, 0f, -500, -500, -500, "", -500f);
                 int             thflg           = devcfgUtil.ThresholdFlg(deviceModelConfig, "dev");
                 DeviceThreshold deviceThreshold = new DeviceThreshold();
                 deviceThreshold.MinCurrentMT   = deviceByID.Min_current;
                 deviceThreshold.MaxCurrentMT   = deviceByID.Max_current;
                 deviceThreshold.MinVoltageMT   = deviceByID.Min_voltage;
                 deviceThreshold.MaxVoltageMT   = deviceByID.Max_voltage;
                 deviceThreshold.MinPowerMT     = deviceByID.Min_power;
                 deviceThreshold.MaxPowerMT     = deviceByID.Max_power;
                 deviceThreshold.MaxPowerDissMT = deviceByID.Max_power_diss;
                 ThresholdUtil.UI2Dev(thflg, deviceThreshold);
                 deviceThreshold.PopEnableMode   = -500;
                 deviceThreshold.PopThreshold    = -500f;
                 deviceThreshold.PopModeOutlet   = -500;
                 deviceThreshold.PopModeLIFO     = -500;
                 deviceThreshold.PopModePriority = -500;
                 deviceThreshold.DoorSensorType  = -500;
                 System.Collections.Generic.List <DevSnmpConfig> list2 = new System.Collections.Generic.List <DevSnmpConfig>();
                 foreach (DeviceInfo current2 in list)
                 {
                     if (ClientAPI.IsDeviceOnline(current2.DeviceID))
                     {
                         DevSnmpConfig sNMPpara = commUtil.getSNMPpara(current2);
                         list2.Add(sNMPpara);
                     }
                 }
                 bool   flag  = false;
                 string text2 = "";
                 if (list.Count > 0)
                 {
                     System.Collections.Generic.List <object> list3 = new System.Collections.Generic.List <object>();
                     list3.Add(deviceThreshold);
                     list3.Add(item);
                     list3.Add(list2);
                     list3.Add(list);
                     Program.IdleTimer_Pause(1);
                     System.Collections.Generic.List <object> list4;
                     if (list2.Count > 50)
                     {
                         progressPopup progressPopup = new progressPopup("Information", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_setDevThreshold, new string[0]), null, new progressPopup.ProcessInThread(this.SetDeviceThresholdProc), list3, 0);
                         progressPopup.ShowDialog();
                         list4 = (progressPopup.Return_V as System.Collections.Generic.List <object>);
                     }
                     else
                     {
                         list4 = (this.SetDeviceThresholdProc(list3) as System.Collections.Generic.List <object>);
                     }
                     flag  = (bool)list4[0];
                     text2 = (string)list4[1];
                 }
                 if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold)
                 {
                     DevSnmpConfig sNMPpara2    = commUtil.getSNMPpara(deviceByID);
                     DevAccessAPI  devAccessAPI = new DevAccessAPI(sNMPpara2);
                     deviceThreshold.DevReferenceVoltage = deviceByID.ReferenceVoltage;
                     deviceThreshold.DoorSensorType      = deviceByID.DoorSensor;
                     if (devAccessAPI.SetDeviceThreshold(deviceThreshold, deviceByID.Mac))
                     {
                         flag = true;
                     }
                     else
                     {
                         text2 = "HAVE EXCEPTION!";
                     }
                 }
                 Program.IdleTimer_Run(1);
                 if (flag)
                 {
                     EcoGlobalVar.setDashBoardFlg(2uL, "", 2);
                     string valuePair = ValuePairs.getValuePair("Username");
                     if (!string.IsNullOrEmpty(valuePair))
                     {
                         LogAPI.writeEventLog("0630001", new string[]
                         {
                             text,
                             valuePair
                         });
                     }
                     else
                     {
                         LogAPI.writeEventLog("0630001", new string[]
                         {
                             text
                         });
                     }
                 }
                 if (text2.Length > 0)
                 {
                     if (text2.Equals("HAVE EXCEPTION!"))
                     {
                         EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
                     }
                     else
                     {
                         EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail_1, new string[]
                         {
                             text2
                         }));
                     }
                 }
                 else
                 {
                     EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0]));
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         System.Console.WriteLine("Devive Porperties -- butAssign_Click Error:" + ex.Message);
         EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
     }
 }
Exemplo n.º 6
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.tbRefVoltage.Visible)
             {
                 deviceByID.ReferenceVoltage = System.Convert.ToSingle(this.tbRefVoltage.Text);
             }
             deviceByID.Min_current = ThresholdUtil.UI2DB(this.tbMinCurrent, deviceByID.Min_current, 0);
             deviceByID.Max_current = ThresholdUtil.UI2DB(this.tbMaxCurrent, deviceByID.Max_current, 0);
             deviceByID.Min_voltage = ThresholdUtil.UI2DB(this.tbMinVoltage, deviceByID.Min_voltage, 0);
             deviceByID.Max_voltage = ThresholdUtil.UI2DB(this.tbMaxVoltage, deviceByID.Max_voltage, 0);
             deviceByID.Min_power   = ThresholdUtil.UI2DB(this.tbMinPower, deviceByID.Min_power, 0);
             if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Min_power != -300f)
             {
                 deviceByID.Min_power *= 1000f;
             }
             deviceByID.Max_power = ThresholdUtil.UI2DB(this.tbMaxPower, deviceByID.Max_power, 0);
             if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Max_power != -300f)
             {
                 deviceByID.Max_power *= 1000f;
             }
             deviceByID.Min_power_diss = ThresholdUtil.UI2DB(this.tbMinPowerDiss, deviceByID.Min_power_diss, 0);
             deviceByID.Max_power_diss = ThresholdUtil.UI2DB(this.tbMaxPowerDiss, deviceByID.Max_power_diss, 0);
             if (deviceModelConfig.doorReading == 2)
             {
                 deviceByID.DoorSensor = 0;
                 if (this.rbPhoto_1.Checked)
                 {
                     deviceByID.DoorSensor = 1;
                 }
                 else
                 {
                     if (this.rbInductive_2.Checked)
                     {
                         deviceByID.DoorSensor = 2;
                     }
                     else
                     {
                         if (this.rbReed_3.Checked)
                         {
                             deviceByID.DoorSensor = 3;
                         }
                     }
                 }
             }
             string          mac             = deviceByID.Mac;
             DevSnmpConfig   sNMPpara        = commUtil.getSNMPpara(deviceByID);
             DevAccessAPI    devAccessAPI    = new DevAccessAPI(sNMPpara);
             DeviceThreshold deviceThreshold = new DeviceThreshold();
             int             thflg           = devcfgUtil.ThresholdFlg(deviceModelConfig, "dev");
             deviceThreshold.MinCurrentMT   = deviceByID.Min_current;
             deviceThreshold.MaxCurrentMT   = deviceByID.Max_current;
             deviceThreshold.MinVoltageMT   = deviceByID.Min_voltage;
             deviceThreshold.MaxVoltageMT   = deviceByID.Max_voltage;
             deviceThreshold.MinPowerMT     = deviceByID.Min_power;
             deviceThreshold.MaxPowerMT     = deviceByID.Max_power;
             deviceThreshold.MaxPowerDissMT = deviceByID.Max_power_diss;
             ThresholdUtil.UI2Dev(thflg, deviceThreshold);
             deviceThreshold.DevReferenceVoltage = deviceByID.ReferenceVoltage;
             deviceThreshold.PopEnableMode       = -500;
             deviceThreshold.PopThreshold        = -500f;
             deviceThreshold.PopModeOutlet       = -500;
             deviceThreshold.PopModeLIFO         = -500;
             deviceThreshold.PopModePriority     = -500;
             deviceThreshold.DoorSensorType      = deviceByID.DoorSensor;
             if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold && !devAccessAPI.SetDeviceThreshold(deviceThreshold, 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("0630000", new string[]
                     {
                         deviceByID.DeviceName,
                         deviceByID.Mac,
                         deviceByID.DeviceIP,
                         valuePair
                     });
                 }
                 else
                 {
                     LogAPI.writeEventLog("0630000", new string[]
                     {
                         deviceByID.DeviceName,
                         deviceByID.Mac,
                         deviceByID.DeviceIP
                     });
                 }
                 EcoGlobalVar.setDashBoardFlg(128uL, "#UPDATE#D" + deviceByID.DeviceID + ":;", 2);
                 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]));
     }
 }
Exemplo n.º 7
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 (deviceByID.ModelNm.Equals("EC1000"))
            {
                this.lbRefVoltage.Visible     = true;
                this.tbRefVoltage.Visible     = true;
                this.lbRefVoltageUnit.Visible = true;
                if (DevAccessCfg.GetInstance().isAutodectDev(deviceByID.ModelNm, deviceByID.FWVersion))
                {
                    this.tbRefVoltage.Enabled = true;
                    if (deviceByID.ReferenceVoltage == -500f || deviceByID.ReferenceVoltage == -300f)
                    {
                        this.tbRefVoltage.Text = "";
                    }
                    else
                    {
                        this.tbRefVoltage.Text = System.Convert.ToString(deviceByID.ReferenceVoltage);
                    }
                }
                else
                {
                    this.tbRefVoltage.Enabled = false;
                    this.tbRefVoltage.Text    = System.Convert.ToString(Sys_Para.GetEnergyValue());
                }
            }
            else
            {
                this.lbRefVoltage.Visible     = false;
                this.tbRefVoltage.Visible     = false;
                this.lbRefVoltageUnit.Visible = false;
            }
            int num = devcfgUtil.UIThresholdEditFlg(deviceModelConfig, "dev");

            ThresholdUtil.SetUIEdit(this.tbMinVoltage, (num & 4) == 0, deviceByID.Min_voltage, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbMaxVoltage, (num & 8) == 0, deviceByID.Max_voltage, 0, "F1");
            this.labMaxVoltageBound.Text = ((!this.tbMinVoltage.ReadOnly || !this.tbMaxVoltage.ReadOnly) ? devcfgUtil.RangeVoltage(deviceModelConfig, "dev", 0) : "");
            if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU)
            {
                ThresholdUtil.SetUIEdit(this.tbMinCurrent, (num & 1) == 0, deviceByID.Min_current, 0, "F0");
                ThresholdUtil.SetUIEdit(this.tbMaxCurrent, (num & 2) == 0, deviceByID.Max_current, 0, "F0");
                this.labMaxCurrentBound.Text = ((!this.tbMinCurrent.ReadOnly || !this.tbMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "dev", 0, "F0") : "");
                this.lbunitPower.Text        = "kW";
                ThresholdUtil.SetUIEdit(this.tbMinPower, (num & 16) == 0, deviceByID.Min_power / 1000f, 0, "F1");
                ThresholdUtil.SetUIEdit(this.tbMaxPower, (num & 32) == 0, deviceByID.Max_power / 1000f, 0, "F1");
                this.labMaxPowerBound.Text = ((!this.tbMinPower.ReadOnly || !this.tbMaxPower.ReadOnly) ? devcfgUtil.RangePower(deviceModelConfig, "dev", 0, 1000.0) : "");
            }
            else
            {
                ThresholdUtil.SetUIEdit(this.tbMinCurrent, (num & 1) == 0, deviceByID.Min_current, 0, "F1");
                ThresholdUtil.SetUIEdit(this.tbMaxCurrent, (num & 2) == 0, deviceByID.Max_current, 0, "F1");
                this.labMaxCurrentBound.Text = ((!this.tbMinCurrent.ReadOnly || !this.tbMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "dev", 0, "F1") : "");
                this.lbunitPower.Text        = "W";
                ThresholdUtil.SetUIEdit(this.tbMinPower, (num & 16) == 0, deviceByID.Min_power, 0, "F1");
                ThresholdUtil.SetUIEdit(this.tbMaxPower, (num & 32) == 0, deviceByID.Max_power, 0, "F1");
                this.labMaxPowerBound.Text = ((!this.tbMinPower.ReadOnly || !this.tbMaxPower.ReadOnly) ? devcfgUtil.RangePower(deviceModelConfig, "dev", 0, 1.0) : "");
            }
            ThresholdUtil.SetUIEdit(this.tbMinPowerDiss, (num & 64) == 0, deviceByID.Min_power_diss, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbMaxPowerDiss, (num & 128) == 0, deviceByID.Max_power_diss, 0, "F1");
            this.labMaxPowerDisBound.Text = ((!this.tbMinPowerDiss.ReadOnly || !this.tbMaxPowerDiss.ReadOnly) ? devcfgUtil.RangePowerDiss(deviceModelConfig, "dev", 0) : "");
            if (deviceModelConfig.doorReading != 2)
            {
                this.gbDoorSS.Hide();
                return;
            }
            this.gbDoorSS.Show();
            switch (deviceByID.DoorSensor)
            {
            case 0:
                this.rbNoInstall_0.Checked = true;
                return;

            case 1:
                this.rbPhoto_1.Checked = true;
                return;

            case 2:
                this.rbInductive_2.Checked = true;
                return;

            case 3:
                this.rbReed_3.Checked = true;
                return;

            default:
                return;
            }
        }