コード例 #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 DeviceValueEntry GetDeviceValue(System.Collections.Generic.Dictionary <string, string> result)
        {
            DeviceValueEntry deviceValueEntry = new DeviceValueEntry();

            System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator();
            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 num = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1));
                if (num == 1)
                {
                    ApcDeviceStatusMib apcDeviceStatusMib = new ApcDeviceStatusMib(num);
                    ApcPhaseStatusMib  apcPhaseStatusMib  = new ApcPhaseStatusMib(num);
                    System.Convert.ToInt32(text);
                    if (current.StartsWith(apcDeviceStatusMib.PowerStatus))
                    {
                        deviceValueEntry.Power = System.Convert.ToString((float)System.Convert.ToInt32(text) / 100f * 1000f);
                    }
                    else
                    {
                        if (current.StartsWith(apcDeviceStatusMib.PowerDsptStatus))
                        {
                            deviceValueEntry.PowerDissipation = System.Convert.ToString((float)System.Convert.ToInt32(text) / 10f);
                        }
                        else
                        {
                            if (current.StartsWith(apcPhaseStatusMib.CurrentStatus))
                            {
                                deviceValueEntry.Current = System.Convert.ToString((float)System.Convert.ToInt32(text) / 10f);
                            }
                            else
                            {
                                if (current.StartsWith(apcPhaseStatusMib.VoltageStatus))
                                {
                                    deviceValueEntry.Voltage = text;
                                }
                            }
                        }
                    }
                }
            }
            return(deviceValueEntry);
        }