Beispiel #1
0
        public static ValueMessage GetValueMessageApcPDU(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.IEnumerator <string>        enumerator  = result.Keys.GetEnumerator();
            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if (current.StartsWith(ApcDeviceStatusMib.Entry) || current.StartsWith(ApcPhaseStatusMib.Entry))
                {
                    dictionary.Add(current, text);
                }
                else
                {
                    if (current.StartsWith(ApcBankStatusMib.Entry))
                    {
                        dictionary2.Add(current, text);
                    }
                    else
                    {
                        if (current.StartsWith(ApcPDUBaseMib.Mac))
                        {
                            valueMessage.DeviceReplyMac = text.Replace(" ", ":").Replace("-", ":");
                        }
                        else
                        {
                            if (current.StartsWith(ApcSensorStatusMib.Entry))
                            {
                                dictionary3.Add(current, text);
                            }
                        }
                    }
                }
            }
            if (dictionary != null && dictionary.Count > 0)
            {
                valueMessage.DeviceValue = ApcMibParser.GetDeviceValue(dictionary);
            }
            if (dictionary2 != null && dictionary2.Count > 0)
            {
                valueMessage.BankValue = ApcMibParser.GetBankValue(dictionary2);
            }
            if (dictionary3 != null && dictionary3.Count > 0)
            {
                valueMessage.SensorValue = ApcMibParser.GetSensorValue(dictionary3);
            }
            else
            {
                valueMessage.SensorValue = ApcMibParser.GetSensorValue_Empty(dictionary3);
            }
            return(valueMessage);
        }
Beispiel #2
0
        public static ThresholdMessage GetThresholdMessageApcPDU(DevModelConfig modelcfg, System.Collections.Generic.Dictionary <string, string> result)
        {
            ThresholdMessage thresholdMessage = new ThresholdMessage();

            System.Collections.Generic.IEnumerator <string>        enumerator  = result.Keys.GetEnumerator();
            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>();
            new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.Dictionary <string, string> dictionary3 = new System.Collections.Generic.Dictionary <string, string>();
            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if (current.StartsWith(ApcPDUBaseMib.Mac))
                {
                    thresholdMessage.DeviceReplyMac = text.Replace(" ", ":").Replace("-", ":");
                }
                else
                {
                    if (current.StartsWith(ApcPDUBaseMib.FWversion))
                    {
                        text = text.Replace("v", "");
                        text = text.Replace("V", "");
                        thresholdMessage.DeviceFWVer = text;
                    }
                    else
                    {
                        if (current.StartsWith(ApcPDUBaseMib.DeviceName))
                        {
                            if ("\0".Equals(text) || string.IsNullOrEmpty(text))
                            {
                                text = string.Empty;
                            }
                            thresholdMessage.DeviceName = text;
                        }
                        else
                        {
                            if (current.StartsWith(ApcDeviceConfigMib.Entry) || current.StartsWith(ApcPhaseConfigMib.Entry))
                            {
                                dictionary.Add(current, text);
                            }
                            else
                            {
                                if (current.StartsWith(ApcBankConfigMib.Entry))
                                {
                                    dictionary3.Add(current, text);
                                }
                                else
                                {
                                    if (current.StartsWith(ApcSensorConfigMib.Entry))
                                    {
                                        dictionary2.Add(current, text);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (dictionary != null && dictionary.Count > 0)
            {
                thresholdMessage.DeviceThreshold = ApcMibParser.GetDeviceThreshold(dictionary);
            }
            if (dictionary3 != null && dictionary3.Count > 0)
            {
                thresholdMessage.BankThreshold = ApcMibParser.GetBankThreshold(dictionary3);
            }
            if (dictionary2 != null && dictionary2.Count > 0)
            {
                thresholdMessage.SensorThreshold = ApcMibParser.GetSensorThreshold(dictionary2);
            }
            else
            {
                thresholdMessage.SensorThreshold = ApcMibParser.GetSensorThreshold_Empty(dictionary2);
            }
            return(thresholdMessage);
        }