예제 #1
0
 private static System.Collections.Generic.Dictionary <int, BankValueEntry> GetBankValue(System.Collections.Generic.Dictionary <string, string> result)
 {
     System.Collections.Generic.Dictionary <int, BankValueEntry> dictionary = new System.Collections.Generic.Dictionary <int, BankValueEntry>();
     System.Collections.Generic.IEnumerator <string>             enumerator = result.Keys.GetEnumerator();
     while (enumerator.MoveNext())
     {
         string current = enumerator.Current;
         string value   = result[current];
         if ("\0".Equals(value))
         {
             value = System.Convert.ToString(-1000);
         }
         else
         {
             if (string.IsNullOrEmpty(value))
             {
                 value = System.Convert.ToString(-500);
             }
         }
         int num = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1));
         if (!dictionary.ContainsKey(num))
         {
             BankValueEntry value2 = new BankValueEntry(num);
             dictionary.Add(num, value2);
         }
         BankValueEntry   bankValueEntry   = dictionary[num];
         ApcBankStatusMib apcBankStatusMib = new ApcBankStatusMib(num);
         if (current.StartsWith(apcBankStatusMib.CurrentStatus))
         {
             bankValueEntry.Current = System.Convert.ToString((float)System.Convert.ToInt32(value) / 10f);
         }
     }
     return(dictionary);
 }
예제 #2
0
        private static System.Collections.Generic.Dictionary <int, BankValueEntry> GetBankValue(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, BankValueEntry> dictionary = new System.Collections.Generic.Dictionary <int, BankValueEntry>();
            System.Collections.Generic.IEnumerator <string>             enumerator = result.Keys.GetEnumerator();
            int num = 0;

            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if ("\0".Equals(text))
                {
                    text = System.Convert.ToString(-1000);
                }
                else
                {
                    if (string.IsNullOrEmpty(text))
                    {
                        text = System.Convert.ToString(-500);
                    }
                }
                int num2 = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1));
                if (!dictionary.ContainsKey(num2))
                {
                    BankValueEntry value = new BankValueEntry(num2);
                    dictionary.Add(num2, value);
                }
                if (num != num2)
                {
                    new BankValueMib(num2);
                    num = num2;
                }
                BankValueEntry          bankValueEntry         = dictionary[num2];
                EatonGroupCurrentMib_M2 eatonGroupCurrentMib_M = new EatonGroupCurrentMib_M2(num2);
                EatonGroupVoltageMib_M2 eatonGroupVoltageMib_M = new EatonGroupVoltageMib_M2(num2);
                EatonGroupPowerMib_M2   eatonGroupPowerMib_M   = new EatonGroupPowerMib_M2(num2);
                if (current.StartsWith(eatonGroupCurrentMib_M.CurrentValue))
                {
                    bankValueEntry.Current = System.Convert.ToString((float)System.Convert.ToInt32(text) / 1000f);
                }
                else
                {
                    if (current.StartsWith(eatonGroupVoltageMib_M.VoltageValue))
                    {
                        bankValueEntry.Voltage = System.Convert.ToString((float)System.Convert.ToInt32(text) / 1000f);
                    }
                    else
                    {
                        if (current.StartsWith(eatonGroupPowerMib_M.PowerValue))
                        {
                            bankValueEntry.Power = text;
                        }
                    }
                }
            }
            return(dictionary);
        }
예제 #3
0
 private void setBankTable(System.DateTime dateTime, System.Collections.Generic.Dictionary <int, BankValueEntry> dictionary, int deviceId, int bankNumbers, string mac, System.Collections.Generic.IDictionary <string, System.Collections.Generic.IDictionary <int, BankMapping> > bankIdMapper)
 {
     try
     {
         if (dictionary == null || dictionary.Count < 1)
         {
             dictionary = new System.Collections.Generic.Dictionary <int, BankValueEntry>();
             for (int i = 1; i <= bankNumbers; i++)
             {
                 dictionary.Add(i, new BankValueEntry(i));
             }
         }
         System.Collections.Generic.IEnumerator <int> enumerator = dictionary.Keys.GetEnumerator();
         while (enumerator.MoveNext())
         {
             int current = enumerator.Current;
             if (bankIdMapper.ContainsKey(mac) && bankIdMapper[mac].ContainsKey(current))
             {
                 BankValueEntry bankValueEntry = dictionary[current];
                 BankAutoValue  bankAutoValue  = new BankAutoValue();
                 bankAutoValue.BankState = bankValueEntry.BankStatus.ToString();
                 BankMapping bankMapping = bankIdMapper[mac][current];
                 bankAutoValue.BankId           = bankMapping.BankId;
                 bankAutoValue.Current          = this.ParseDeviceValue(bankValueEntry.Current);
                 bankAutoValue.Voltage          = this.ParseDeviceValue(bankValueEntry.Voltage);
                 bankAutoValue.Power            = this.ParseDeviceValue(bankValueEntry.Power);
                 bankAutoValue.PowerDissipation = this.ParseDeviceValue(bankValueEntry.PowerDissipation);
                 bankAutoValue.InsertTime       = this.parseSecondTime(dateTime);
                 this.presentValue.BankTable.Rows.Add(new object[]
                 {
                     deviceId,
                     bankAutoValue.BankId,
                     bankMapping.BankNumber,
                     bankMapping.BankName,
                     bankAutoValue.Voltage,
                     bankAutoValue.Current,
                     bankAutoValue.Power,
                     bankAutoValue.PowerDissipation,
                     bankAutoValue.BankState,
                     bankAutoValue.InsertTime
                 });
             }
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
        public static ValueMessage GetValueMessageEatonPDU_M2(DevModelConfig modelCfg, System.Collections.Generic.Dictionary <string, string> result)
        {
            ValueMessage valueMessage = new ValueMessage();

            System.Collections.Generic.Dictionary <string, string> dictionary  = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.Dictionary <string, string> dictionary2 = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.Dictionary <string, string> dictionary3 = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.Dictionary <string, string> dictionary4 = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.IEnumerator <string>        enumerator  = result.Keys.GetEnumerator();
            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if (current.StartsWith(EatonInputCurrentMib_M2.Entry) || current.StartsWith(EatonInputVoltageMib_M2.Entry) || current.StartsWith(EatonInputPowerMib_M2.Entry))
                {
                    dictionary.Add(current, text);
                }
                else
                {
                    if (current.StartsWith(EatonSensorTemperatureMib_M2.Entry) || current.StartsWith(EatonSensorHumidityMib_M2.Entry))
                    {
                        dictionary2.Add(current, text);
                    }
                    else
                    {
                        if (current.StartsWith(EatonOutletCurrentMib_M2.Entry) || current.StartsWith(EatonOutletVoltageMib_M2.Entry) || current.StartsWith(EatonOutletPowerMib_M2.Entry))
                        {
                            dictionary3.Add(current, text);
                        }
                        else
                        {
                            if (current.StartsWith(EatonGroupCurrentMib_M2.Entry) || current.StartsWith(EatonGroupVoltageMib_M2.Entry) || current.StartsWith(EatonGroupPowerMib_M2.Entry))
                            {
                                dictionary4.Add(current, text);
                            }
                            else
                            {
                                if (current.StartsWith(EatonPDUBaseMib_M2.Mac))
                                {
                                    valueMessage.DeviceReplyMac = text.Replace(" ", ":").Replace("-", ":");
                                }
                            }
                        }
                    }
                }
            }
            if (dictionary != null && dictionary.Count > 0)
            {
                valueMessage.DeviceValue = EatonMibParser.GetDeviceValue(dictionary);
            }
            if (dictionary3 != null && dictionary3.Count > 0)
            {
                valueMessage.OutletValue = EatonMibParser.GetOutletValue(dictionary3);
            }
            if (dictionary2 != null && dictionary2.Count > 0)
            {
                valueMessage.SensorValue = EatonMibParser.GetSensorValue(dictionary2);
            }
            if (dictionary4 != null && dictionary4.Count > 0)
            {
                valueMessage.BankValue = EatonMibParser.GetBankValue(dictionary4);
            }
            if (modelCfg.doorReading == Constant.DoorSensorNo)
            {
                valueMessage.DeviceValue.DoorSensorStatus = -500;
            }
            if (modelCfg.commonThresholdFlag == Constant.EatonPDU_M2)
            {
                valueMessage.DeviceValue.PowerDissipation = "N/A";
                if (valueMessage.BankValue != null && valueMessage.BankValue.Count > 0)
                {
                    foreach (System.Collections.Generic.KeyValuePair <int, BankValueEntry> current2 in valueMessage.BankValue)
                    {
                        BankValueEntry value = current2.Value;
                        value.PowerDissipation = "N/A";
                        value.Voltage          = valueMessage.DeviceValue.Voltage;
                    }
                }
                if (valueMessage.OutletValue != null && valueMessage.OutletValue.Count > 0)
                {
                    foreach (System.Collections.Generic.KeyValuePair <int, OutletValueEntry> current3 in valueMessage.OutletValue)
                    {
                        OutletValueEntry value2 = current3.Value;
                        value2.PowerDissipation = "N/A";
                    }
                }
            }
            return(valueMessage);
        }