コード例 #1
0
        public static System.Collections.Generic.List <LeafVarBinding> GetValuesRequestApcPDU(DevModelConfig modelcfg, DevRealConfig realcfg, int sensorNum)
        {
            int num     = 1;
            int bankNum = modelcfg.bankNum;

            System.Collections.Generic.List <LeafVarBinding> list = new System.Collections.Generic.List <LeafVarBinding>();
            LeafVarBinding leafVarBinding = new LeafVarBinding();

            leafVarBinding.Add(ApcPDUBaseMib.Mac);
            for (int i = 1; i <= num; i++)
            {
                ApcDeviceStatusMib apcDeviceStatusMib = new ApcDeviceStatusMib(i);
                leafVarBinding.Add(apcDeviceStatusMib.PowerStatus);
                leafVarBinding.Add(apcDeviceStatusMib.PowerDsptStatus);
                ApcPhaseStatusMib apcPhaseStatusMib = new ApcPhaseStatusMib(i);
                leafVarBinding.Add(apcPhaseStatusMib.CurrentStatus);
                leafVarBinding.Add(apcPhaseStatusMib.VoltageStatus);
            }
            for (int j = 1; j <= bankNum; j++)
            {
                ApcBankStatusMib apcBankStatusMib = new ApcBankStatusMib(j);
                leafVarBinding.Add(apcBankStatusMib.CurrentStatus);
            }
            for (int k = 1; k <= sensorNum; k++)
            {
                ApcSensorStatusMib apcSensorStatusMib = new ApcSensorStatusMib(k);
                leafVarBinding.Add(apcSensorStatusMib.Temperature);
                leafVarBinding.Add(apcSensorStatusMib.Humidity);
            }
            list.Add(leafVarBinding);
            return(list);
        }
コード例 #2
0
        private static System.Collections.Generic.Dictionary <int, SensorValueEntry> GetSensorValue(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, SensorValueEntry> dictionary = new System.Collections.Generic.Dictionary <int, SensorValueEntry>();
            System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator();
            ApcSensorStatusMib apcSensorStatusMib = null;
            int num = 0;

            while (enumerator.MoveNext())
            {
                string text  = enumerator.Current;
                string text2 = result[text];
                if ("\0".Equals(text2) || "n/a".Equals(text2) || "N/A".Equals(text2) || "-1".Equals(text2))
                {
                    text2 = System.Convert.ToString(-1000);
                }
                else
                {
                    if (string.IsNullOrEmpty(text2) || text2.Equals("Null"))
                    {
                        text2 = System.Convert.ToString(-500);
                    }
                }
                if (text.LastIndexOf(".0") > 0)
                {
                    text = text.Substring(0, text.LastIndexOf(".0"));
                }
                int num2 = System.Convert.ToInt32(text.Substring(text.LastIndexOf(".") + 1));
                if (!dictionary.ContainsKey(num2))
                {
                    SensorValueEntry value = new SensorValueEntry(num2);
                    dictionary.Add(num2, value);
                }
                if (num != num2)
                {
                    apcSensorStatusMib = new ApcSensorStatusMib(num2);
                    num = num2;
                }
                SensorValueEntry sensorValueEntry = dictionary[num2];
                if (text.StartsWith(apcSensorStatusMib.Humidity))
                {
                    sensorValueEntry.Humidity = text2;
                }
                else
                {
                    if (text.StartsWith(apcSensorStatusMib.Temperature))
                    {
                        if (text2.Equals(System.Convert.ToString(-1000)) || text2.Equals(System.Convert.ToString(-500)))
                        {
                            sensorValueEntry.Temperature = text2;
                        }
                        else
                        {
                            sensorValueEntry.Temperature = ((float)System.Convert.ToInt32(text2) / 10f).ToString();
                        }
                    }
                }
            }
            return(dictionary);
        }