예제 #1
0
        public virtual List <PowerReading> GetPowerReading()
        {
            // Return item
            List <PowerReading> returnlist = new List <PowerReading>();

            // Get Power Readings Array (DCMI spec)
            // Reading mode: 0x01 = standard, 0x02 = advanced
            PowerReadingSupport powerreadings = this.PowerReadingSupport(0x01, 0x00);

            // create a new instance of the power reading class
            PowerReading pwr = new PowerReading(powerreadings.CompletionCode);

            if (powerreadings.CompletionCode == 0)
            {
                // system does support power readings
                pwr.SetParamaters(powerreadings.Readings);
            }

            // add pwr to the return list
            returnlist.Add(pwr);

            // return the list
            return(returnlist);
        }
예제 #2
0
        /// <summary>
        /// DCMI Get Power Reading Command
        /// </summary>
        public virtual List <PowerReading> GetAdvancedPowerReading()
        {
            // Return item
            List <PowerReading> returnlist = new List <PowerReading>();

            // Index Offset of 0 into ResponseData
            int index = 0;

            // Get DCMI Capabilities to check if power management is supported, if so
            // check if advanced power stats are supported.
            GetDcmiCapabilitiesResponse response = (GetDcmiCapabilitiesResponse)this.IpmiSendReceive(
                new GetDcmiCapabilitiesRequest(0x01), typeof(GetDcmiCapabilitiesResponse));

            byte[] powerSupport = new byte[2] {
                0x00, 0x00
            };

            if (response.CompletionCode == 0)
            {
                // power management support byte array.  response.ResponseData[1] = platform capabilities.
                // [7-1]  Reserved, Power Management.
                byte[] tempArray = IpmiSharedFunc.ByteSplit(response.ResponseData[1], new int[2] {
                    1, 0
                });
                Buffer.BlockCopy(tempArray, 0, powerSupport, 0, 2);
            }

            if (powerSupport[1] == 0x01)
            {
                // Check DCMI paramater revision 0x02 = DCMI errata for advanced
                // power management.  If the paramater version is 2, it should
                // support advanced power management.
                if (response.ParameterRevision == 0x02)
                {
                    // Get DCMI Capabilities for advanced power averages
                    response = (GetDcmiCapabilitiesResponse)this.IpmiSendReceive(
                        new GetDcmiCapabilitiesRequest(0x05), typeof(GetDcmiCapabilitiesResponse));

                    if (response.CompletionCode == 0)
                    {
                        // GetDcmiCapabilitiesResponse Response Data
                        byte[] capabilities = response.ResponseData;

                        // The number of supported rolling average time periods
                        int averages = (int)capabilities[0];

                        if (averages > 0)
                        {
                            // Loop through the available averages
                            for (int i = 0; i < averages; i++)
                            {
                                // Increment the Index Offset
                                index++;

                                //[7:6]: Time duration units 
                                //[5-0]: Time duration (Maximum of 63 units)
                                byte[] timeperiod = IpmiSharedFunc.ByteSplit(capabilities[index], new int[2] {
                                    6, 0
                                });

                                // Get Power Readings Array (DCMI spec)
                                // Reading mode: 0x01 = standard, 0x02 = advanced
                                PowerReadingSupport powerreadings = PowerReadingSupport(0x02, capabilities[index]);

                                // create a new instance of the power reading class
                                PowerReading pwr = new PowerReading(powerreadings.CompletionCode);

                                if (pwr.CompletionCode == 0)
                                {
                                    pwr.SetParamaters(powerreadings.Readings);

                                    // Units of time (number of units)
                                    pwr.TimeNumber = Convert.ToInt32(timeperiod[1]);

                                    // time sample (hours, minutes etc)
                                    pwr.TimeUnit = Convert.ToInt16(timeperiod[0]);
                                }
                                // add pwr to the return list
                                returnlist.Add(pwr);
                            }
                        }
                        else // get standard power statistics
                        {
                            return(GetPowerReading());
                        }
                    }
                    else
                    {
                        // create a new instance of the power reading class
                        PowerReading pwr = new PowerReading(response.CompletionCode);
                        // add ERROR pwr to the return list
                        returnlist.Add(pwr);
                    }
                }
                else // standard power statistics
                {
                    return(GetPowerReading());
                }
            }
            else
            {
                // power management is unsupported
                // create a new instance of the power reading class
                PowerReading pwr = new PowerReading(response.CompletionCode);

                // system does not support power readings
                pwr.PowerSupport = false;

                // add pwr to the return list
                returnlist.Add(pwr);
            }

            return(returnlist);
        }