示例#1
0
        public static LeafVarBinding SetOutletThresholdVariablesEatonPDU_M2(OutletThreshold threshold, DevModelConfig modelcfg)
        {
            LeafVarBinding           leafVarBinding          = new LeafVarBinding();
            int                      outletNumber            = threshold.OutletNumber;
            EatonOutletEntryMib_M2   eatonOutletEntryMib_M   = new EatonOutletEntryMib_M2(outletNumber);
            EatonOutletVoltageMib_M2 eatonOutletVoltageMib_M = new EatonOutletVoltageMib_M2(outletNumber);
            EatonOutletCurrentMib_M2 eatonOutletCurrentMib_M = new EatonOutletCurrentMib_M2(outletNumber);

            if (!string.IsNullOrEmpty(threshold.OutletName))
            {
                leafVarBinding.Add(eatonOutletEntryMib_M.OutletName, threshold.OutletName);
            }
            else
            {
                leafVarBinding.Add(eatonOutletEntryMib_M.OutletName, "/empty");
            }
            if (threshold.MaxCurrentMT != -500f)
            {
                leafVarBinding.Add(eatonOutletCurrentMib_M.MaxCurrentMT, System.Convert.ToInt32(threshold.MaxCurrentMT * 1000f));
            }
            if (threshold.MaxVoltageMT != -500f)
            {
                leafVarBinding.Add(eatonOutletVoltageMib_M.MaxVoltageMT, System.Convert.ToInt32(threshold.MaxVoltageMT * 1000f));
            }
            if (threshold.MinVoltageMT != -500f)
            {
                leafVarBinding.Add(eatonOutletVoltageMib_M.MinVoltageMt, System.Convert.ToInt32(threshold.MinVoltageMT * 1000f));
            }
            if (threshold.MaxCurrentMT != -500f)
            {
                leafVarBinding.Add(eatonOutletCurrentMib_M.CurrentUpperCritical, System.Convert.ToInt32(threshold.MaxCurrentMT * 1000f));
            }
            if (threshold.MaxVoltageMT != -500f)
            {
                leafVarBinding.Add(eatonOutletVoltageMib_M.VoltageUpperCritical, System.Convert.ToInt32(threshold.MaxVoltageMT * 1000f));
            }
            return(leafVarBinding);
        }
示例#2
0
        private static System.Collections.Generic.Dictionary <int, OutletThreshold> GetOutletThreshold(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, OutletThreshold> dictionary = new System.Collections.Generic.Dictionary <int, OutletThreshold>();
            System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator();
            EatonOutletEntryMib_M2   eatonOutletEntryMib_M             = null;
            EatonOutletCurrentMib_M2 eatonOutletCurrentMib_M           = null;
            EatonOutletVoltageMib_M2 eatonOutletVoltageMib_M           = null;
            EatonOutletControlMib_M2 eatonOutletControlMib_M           = null;
            int num = 0;

            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if ("\0".Equals(text))
                {
                    text = System.Convert.ToString(-1000000);
                }
                else
                {
                    if (text == null || string.IsNullOrEmpty(text))
                    {
                        text = System.Convert.ToString(-500000);
                    }
                }
                int num2 = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1));
                if (!dictionary.ContainsKey(num2))
                {
                    OutletThreshold value = new OutletThreshold(num2);
                    dictionary.Add(num2, value);
                }
                if (num != num2)
                {
                    eatonOutletEntryMib_M   = new EatonOutletEntryMib_M2(num2);
                    eatonOutletCurrentMib_M = new EatonOutletCurrentMib_M2(num2);
                    eatonOutletVoltageMib_M = new EatonOutletVoltageMib_M2(num2);
                    num = num2;
                }
                OutletThreshold outletThreshold = dictionary[num2];
                if (current.StartsWith(eatonOutletCurrentMib_M.MaxCurrentMT))
                {
                    outletThreshold.MaxCurrentMT = (float)System.Convert.ToInt32(text) / 1000f;
                }
                else
                {
                    if (current.StartsWith(eatonOutletVoltageMib_M.MaxVoltageMT))
                    {
                        outletThreshold.MaxVoltageMT = (float)System.Convert.ToInt32(text) / 1000f;
                    }
                    else
                    {
                        if (current.StartsWith(eatonOutletCurrentMib_M.MinCurrentMt))
                        {
                            outletThreshold.MinCurrentMt = (float)System.Convert.ToInt32(text) / 1000f;
                        }
                        else
                        {
                            if (current.StartsWith(eatonOutletVoltageMib_M.MinVoltageMt))
                            {
                                outletThreshold.MinVoltageMT = (float)System.Convert.ToInt32(text) / 1000f;
                            }
                            else
                            {
                                if (current.StartsWith(eatonOutletEntryMib_M.OutletName))
                                {
                                    outletThreshold.OutletName = (text.Equals(System.Convert.ToString(-1000000)) ? string.Empty : text);
                                }
                                else
                                {
                                    if (!current.StartsWith(eatonOutletControlMib_M.ControlSequenceDelay))
                                    {
                                        return(new System.Collections.Generic.Dictionary <int, OutletThreshold>());
                                    }
                                    outletThreshold.OffDelayTime = System.Convert.ToInt32(text);
                                    outletThreshold.OnDelayTime  = System.Convert.ToInt32(text);
                                }
                            }
                        }
                    }
                }
                if (outletThreshold.MinCurrentMt == -500f)
                {
                    outletThreshold.MinCurrentMt = -300f;
                }
                if (outletThreshold.MinPowerMT == -500f)
                {
                    outletThreshold.MinPowerMT = -300f;
                }
            }
            return(dictionary);
        }
示例#3
0
 public bool SetOutletThreshold(OutletThreshold outletThreshold, string myMac)
 {
     return(this.se.CheckDeviceMac(myMac) >= 0 && this.se.SetOutletThreshold(outletThreshold));
 }