private static System.Collections.Generic.Dictionary <int, OutletValueEntry> GetOutletValue(System.Collections.Generic.Dictionary <string, string> result) { System.Collections.Generic.Dictionary <int, OutletValueEntry> dictionary = new System.Collections.Generic.Dictionary <int, OutletValueEntry>(); 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)) { OutletValueEntry value = new OutletValueEntry(num2); dictionary.Add(num2, value); } if (num != num2) { new OutletValueMib(num2); num = num2; } OutletValueEntry outletValueEntry = dictionary[num2]; EatonOutletCurrentMib_M2 eatonOutletCurrentMib_M = new EatonOutletCurrentMib_M2(num2); EatonOutletVoltageMib_M2 eatonOutletVoltageMib_M = new EatonOutletVoltageMib_M2(num2); EatonOutletPowerMib_M2 eatonOutletPowerMib_M = new EatonOutletPowerMib_M2(num2); if (current.StartsWith(eatonOutletCurrentMib_M.CurrentValue)) { outletValueEntry.Current = System.Convert.ToString((float)System.Convert.ToInt32(text) / 1000f); } else { if (current.StartsWith(eatonOutletVoltageMib_M.VoltageValue)) { outletValueEntry.Voltage = System.Convert.ToString((float)System.Convert.ToInt32(text) / 1000f); } else { if (current.StartsWith(eatonOutletPowerMib_M.PowerValue)) { outletValueEntry.Power = text; } } } } return(dictionary); }
private void setOutletTable(System.DateTime dateTime, System.Collections.Generic.Dictionary <int, OutletValueEntry> dictionary, int deviceId, int portNumbers, string mac, System.Collections.Generic.IDictionary <string, System.Collections.Generic.IDictionary <int, OutletMapping> > outletIdMapper) { try { if (dictionary == null || dictionary.Count < 1) { dictionary = new System.Collections.Generic.Dictionary <int, OutletValueEntry>(); for (int i = 1; i <= portNumbers; i++) { dictionary.Add(i, new OutletValueEntry(i)); } } System.Collections.Generic.IEnumerator <int> enumerator = dictionary.Keys.GetEnumerator(); while (enumerator.MoveNext()) { int current = enumerator.Current; if (outletIdMapper.ContainsKey(mac) && outletIdMapper[mac].ContainsKey(current)) { OutletValueEntry outletValueEntry = dictionary[current]; OutletAutoValue outletAutoValue = new OutletAutoValue(); outletAutoValue.PortState = outletValueEntry.OutletStatus.ToString(); OutletMapping outletMapping = outletIdMapper[mac][current]; outletAutoValue.PortId = outletMapping.OutletId; outletAutoValue.Current = this.ParseDeviceValue(outletValueEntry.Current); outletAutoValue.Voltage = this.ParseDeviceValue(outletValueEntry.Voltage); outletAutoValue.Power = this.ParseDeviceValue(outletValueEntry.Power); outletAutoValue.PowerDissipation = this.ParseDeviceValue(outletValueEntry.PowerDissipation); outletAutoValue.InsertTime = this.parseSecondTime(dateTime); this.presentValue.OutletTable.Rows.Add(new object[] { deviceId, outletAutoValue.PortId, outletMapping.OutletNumber, outletMapping.OutletName, outletAutoValue.Voltage, outletAutoValue.Current, outletAutoValue.Power, outletAutoValue.PowerDissipation, outletAutoValue.PortState, outletAutoValue.InsertTime }); } } } catch (System.Exception ex) { throw ex; } }
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); }