/// <summary>
        /// Gets the Overdrive6 power.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="sensor">The sensor.</param>
        private void GetOD6Power(AtiAdlxx.ADLODNCurrentPowerType type, Sensor sensor)
        {
            int powerOf8 = 0;

            if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, type, ref powerOf8) == AtiAdlxx.ADLStatus.ADL_OK)
            {
                sensor.Value = powerOf8 >> 8;
                ActivateSensor(sensor);
            }
            else
            {
                sensor.Value = null;
            }
        }
        public override string GetReport()
        {
            var r = new StringBuilder();

            r.AppendLine("AMD GPU");
            r.AppendLine();

            r.Append("AdapterIndex: ");
            r.AppendLine(_adapterIndex.ToString(CultureInfo.InvariantCulture));
            r.AppendLine();

            r.AppendLine("Overdrive Caps");
            r.AppendLine();

            try
            {
                int supported             = 0;
                int enabled               = 0;
                int version               = 0;
                AtiAdlxx.ADLStatus status = AtiAdlxx.ADL_Overdrive_Caps(_adapterIndex, ref supported, ref enabled, ref version);

                r.Append(" Status: ");
                r.AppendLine(status.ToString());
                r.Append(" Supported: ");
                r.AppendLine(supported.ToString(CultureInfo.InvariantCulture));
                r.Append(" Enabled: ");
                r.AppendLine(enabled.ToString(CultureInfo.InvariantCulture));
                r.Append(" Version: ");
                r.AppendLine(version.ToString(CultureInfo.InvariantCulture));
            }
            catch (Exception e)
            {
                r.AppendLine(" Status: " + e.Message);
            }

            r.AppendLine();

            r.AppendLine("Overdrive5 Parameters");
            r.AppendLine();
            try
            {
                AtiAdlxx.ADLStatus status = AtiAdlxx.ADL_Overdrive5_ODParameters_Get(_adapterIndex, out AtiAdlxx.ADLODParameters p);

                r.Append(" Status: ");
                r.AppendLine(status.ToString());
                r.AppendFormat(" NumberOfPerformanceLevels: {0}{1}", p.NumberOfPerformanceLevels, Environment.NewLine);
                r.AppendFormat(" ActivityReportingSupported: {0}{1}", p.ActivityReportingSupported, Environment.NewLine);
                r.AppendFormat(" DiscretePerformanceLevels: {0}{1}", p.DiscretePerformanceLevels, Environment.NewLine);
                r.AppendFormat(" EngineClock.Min: {0}{1}", p.EngineClock.Min, Environment.NewLine);
                r.AppendFormat(" EngineClock.Max: {0}{1}", p.EngineClock.Max, Environment.NewLine);
                r.AppendFormat(" EngineClock.Step: {0}{1}", p.EngineClock.Step, Environment.NewLine);
                r.AppendFormat(" MemoryClock.Min: {0}{1}", p.MemoryClock.Min, Environment.NewLine);
                r.AppendFormat(" MemoryClock.Max: {0}{1}", p.MemoryClock.Max, Environment.NewLine);
                r.AppendFormat(" MemoryClock.Step: {0}{1}", p.MemoryClock.Step, Environment.NewLine);
                r.AppendFormat(" Vddc.Min: {0}{1}", p.Vddc.Min, Environment.NewLine);
                r.AppendFormat(" Vddc.Max: {0}{1}", p.Vddc.Max, Environment.NewLine);
                r.AppendFormat(" Vddc.Step: {0}{1}", p.Vddc.Step, Environment.NewLine);
            }
            catch (Exception e)
            {
                r.AppendLine(" Status: " + e.Message);
            }

            r.AppendLine();

            r.AppendLine("Overdrive5 Temperature");
            r.AppendLine();
            try
            {
                var adlt = new AtiAdlxx.ADLTemperature();
                AtiAdlxx.ADLStatus status = AtiAdlxx.ADL_Overdrive5_Temperature_Get(_adapterIndex, 0, ref adlt);
                r.Append(" Status: ");
                r.AppendLine(status.ToString());
                r.AppendFormat(" Value: {0}{1}", 0.001f * adlt.Temperature, Environment.NewLine);
            }
            catch (Exception e)
            {
                r.AppendLine(" Status: " + e.Message);
            }

            r.AppendLine();

            r.AppendLine("Overdrive5 FanSpeed");
            r.AppendLine();
            try
            {
                var adlf = new AtiAdlxx.ADLFanSpeedValue {
                    SpeedType = AtiAdlxx.ADL_DL_FANCTRL_SPEED_TYPE_RPM
                };
                var status = AtiAdlxx.ADL_Overdrive5_FanSpeed_Get(_adapterIndex, 0, ref adlf);
                r.Append(" Status RPM: ");
                r.AppendLine(status.ToString());
                r.AppendFormat(" Value RPM: {0}{1}", adlf.FanSpeed, Environment.NewLine);

                adlf.SpeedType = AtiAdlxx.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
                status         = AtiAdlxx.ADL_Overdrive5_FanSpeed_Get(_adapterIndex, 0, ref adlf);
                r.Append(" Status Percent: ");
                r.AppendLine(status.ToString());
                r.AppendFormat(" Value Percent: {0}{1}", adlf.FanSpeed, Environment.NewLine);
            }
            catch (Exception e)
            {
                r.AppendLine(" Status: " + e.Message);
            }

            r.AppendLine();

            r.AppendLine("Overdrive5 CurrentActivity");
            r.AppendLine();
            try
            {
                var adlp = new AtiAdlxx.ADLPMActivity();
                AtiAdlxx.ADLStatus status = AtiAdlxx.ADL_Overdrive5_CurrentActivity_Get(_adapterIndex, ref adlp);

                r.Append(" Status: ");
                r.AppendLine(status.ToString());
                r.AppendFormat(" EngineClock: {0}{1}", 0.01f * adlp.EngineClock, Environment.NewLine);
                r.AppendFormat(" MemoryClock: {0}{1}", 0.01f * adlp.MemoryClock, Environment.NewLine);
                r.AppendFormat(" Vddc: {0}{1}", 0.001f * adlp.Vddc, Environment.NewLine);
                r.AppendFormat(" ActivityPercent: {0}{1}", adlp.ActivityPercent, Environment.NewLine);
                r.AppendFormat(" CurrentPerformanceLevel: {0}{1}", adlp.CurrentPerformanceLevel, Environment.NewLine);
                r.AppendFormat(" CurrentBusSpeed: {0}{1}", adlp.CurrentBusSpeed, Environment.NewLine);
                r.AppendFormat(" CurrentBusLanes: {0}{1}", adlp.CurrentBusLanes, Environment.NewLine);
                r.AppendFormat(" MaximumBusLanes: {0}{1}", adlp.MaximumBusLanes, Environment.NewLine);
            }
            catch (Exception e)
            {
                r.AppendLine(" Status: " + e.Message);
            }

            r.AppendLine();

            if (_context != IntPtr.Zero)
            {
                r.AppendLine("Overdrive6 CurrentPower");
                r.AppendLine();
                try
                {
                    int power = 0;
                    for (int i = 0; i < 4; i++)
                    {
                        string             pt     = ((AtiAdlxx.ADLODNCurrentPowerType)i).ToString();
                        AtiAdlxx.ADLStatus status = AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, (AtiAdlxx.ADLODNCurrentPowerType)i, ref power);

                        r.AppendFormat(" Power[{0}].Status: {1}{2}", pt, status.ToString(), Environment.NewLine);
                        r.AppendFormat(" Power[{0}].Value: {1}{2}", pt, power * (1.0f / 0xFF), Environment.NewLine);
                    }
                }
                catch (EntryPointNotFoundException)
                {
                    r.AppendLine(" Status: Entry point not found");
                }
                catch (Exception e)
                {
                    r.AppendLine(" Status: " + e.Message);
                }

                r.AppendLine();
            }

            if (_context != IntPtr.Zero)
            {
                r.AppendLine("OverdriveN Temperature");
                r.AppendLine();
                try
                {
                    for (int i = 1; i < 8; i++)
                    {
                        int                temperature = 0;
                        string             tt          = ((AtiAdlxx.ADLODNTemperatureType)i).ToString();
                        AtiAdlxx.ADLStatus status      = AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, (AtiAdlxx.ADLODNTemperatureType)i, ref temperature);

                        r.AppendFormat(" Temperature[{0}].Status: {1}{2}", tt, status.ToString(), Environment.NewLine);
                        r.AppendFormat(" Temperature[{0}].Value: {1}{2}", tt, 0.001f * temperature, Environment.NewLine);
                    }
                }
                catch (EntryPointNotFoundException)
                {
                    r.AppendLine(" Status: Entry point not found");
                }
                catch (Exception e)
                {
                    r.AppendLine(" Status: " + e.Message);
                }

                r.AppendLine();
            }

            if (_context != IntPtr.Zero)
            {
                r.AppendLine("OverdriveN Performance Status");
                r.AppendLine();
                try
                {
                    var status = AtiAdlxx.ADL2_OverdriveN_PerformanceStatus_Get(_context, _adapterIndex, out var ps);

                    r.Append(" Status: ");
                    r.AppendLine(status.ToString());
                    r.AppendFormat(" CoreClock: {0}{1}", ps.CoreClock, Environment.NewLine);
                    r.AppendFormat(" MemoryClock: {0}{1}", ps.MemoryClock, Environment.NewLine);
                    r.AppendFormat(" DCEFClock: {0}{1}", ps.DCEFClock, Environment.NewLine);
                    r.AppendFormat(" GFXClock: {0}{1}", ps.GFXClock, Environment.NewLine);
                    r.AppendFormat(" UVDClock: {0}{1}", ps.UVDClock, Environment.NewLine);
                    r.AppendFormat(" VCEClock: {0}{1}", ps.VCEClock, Environment.NewLine);
                    r.AppendFormat(" GPUActivityPercent: {0}{1}", ps.GPUActivityPercent, Environment.NewLine);
                    r.AppendFormat(" CurrentCorePerformanceLevel: {0}{1}", ps.CurrentCorePerformanceLevel, Environment.NewLine);
                    r.AppendFormat(" CurrentMemoryPerformanceLevel: {0}{1}", ps.CurrentMemoryPerformanceLevel, Environment.NewLine);
                    r.AppendFormat(" CurrentDCEFPerformanceLevel: {0}{1}", ps.CurrentDCEFPerformanceLevel, Environment.NewLine);
                    r.AppendFormat(" CurrentGFXPerformanceLevel: {0}{1}", ps.CurrentGFXPerformanceLevel, Environment.NewLine);
                    r.AppendFormat(" UVDPerformanceLevel: {0}{1}", ps.UVDPerformanceLevel, Environment.NewLine);
                    r.AppendFormat(" VCEPerformanceLevel: {0}{1}", ps.VCEPerformanceLevel, Environment.NewLine);
                    r.AppendFormat(" CurrentBusSpeed: {0}{1}", ps.CurrentBusSpeed, Environment.NewLine);
                    r.AppendFormat(" CurrentBusLanes: {0}{1}", ps.CurrentBusLanes, Environment.NewLine);
                    r.AppendFormat(" MaximumBusLanes: {0}{1}", ps.MaximumBusLanes, Environment.NewLine);
                    r.AppendFormat(" VDDC: {0}{1}", ps.VDDC, Environment.NewLine);
                    r.AppendFormat(" VDDCI: {0}{1}", ps.VDDCI, Environment.NewLine);
                }
                catch (EntryPointNotFoundException)
                {
                    r.AppendLine(" Status: Entry point not found");
                }
                catch (Exception e)
                {
                    r.AppendLine(" Status: " + e.Message);
                }

                r.AppendLine();
            }

            if (_context != IntPtr.Zero)
            {
                r.AppendLine("Performance Metrics");
                r.AppendLine();
                try
                {
                    var data = new AtiAdlxx.ADLPMLogDataOutput();
                    AtiAdlxx.ADLStatus status = AtiAdlxx.ADL2_New_QueryPMLogData_Get(_context, _adapterIndex, ref data);

                    r.Append(" Status: ");
                    r.AppendLine(status.ToString());

                    for (int i = 0; i < data.sensors.Length; i++)
                    {
                        string st = ((AtiAdlxx.ADLSensorType)i).ToString();

                        r.AppendFormat(" Sensor[{0}].Supported: {1}{2}", st, data.sensors[i].supported, Environment.NewLine);
                        r.AppendFormat(" Sensor[{0}].Value: {1}{2}", st, data.sensors[i].value, Environment.NewLine);
                    }
                }
                catch (EntryPointNotFoundException)
                {
                    r.AppendLine(" Status: Entry point not found");
                }
                catch (Exception e)
                {
                    r.AppendLine(" Status: " + e.Message);
                }

                r.AppendLine();
            }

            return(r.ToString());
        }
        public override void Update()
        {
            if (_currentOverdriveApiLevel < 8)
            {
                if (_currentOverdriveApiLevel >= 6)
                {
                    int powerOf8 = 0;
                    if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_TOTAL_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
                    {
                        _powerTotal.Value = powerOf8 >> 8;
                        ActivateSensor(_powerTotal);
                    }
                    else
                    {
                        _powerTotal.Value = null;
                    }

                    if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_PPT_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
                    {
                        _powerPpt.Value = powerOf8 >> 8;
                        ActivateSensor(_powerPpt);
                    }
                    else
                    {
                        _powerPpt.Value = null;
                    }

                    if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_SOCKET_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
                    {
                        _powerSocket.Value = powerOf8 >> 8;
                        ActivateSensor(_powerSocket);
                    }
                    else
                    {
                        _powerSocket.Value = null;
                    }

                    if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_CHIP_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
                    {
                        _powerCore.Value = powerOf8 >> 8;
                        ActivateSensor(_powerCore);
                    }
                    else
                    {
                        _powerCore.Value = null;
                    }
                }

                if (_currentOverdriveApiLevel >= 7)
                {
                    // If a sensor isn't available, some cards report 54000 degrees C. 110C is expected for Navi, so 100 more than that should be enough to use as a maximum.
                    const int maxTemperature = 210;

                    int temp = 0;

                    if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.EDGE, ref temp) == AtiAdlxx.ADL_OK && temp < maxTemperature)
                    {
                        _temperatureCore.Value = 0.001f * temp;
                        ActivateSensor(_temperatureCore);
                    }
                    else
                    {
                        _temperatureCore.Value = null;
                    }

                    if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.MEM, ref temp) == AtiAdlxx.ADL_OK && temp < maxTemperature)
                    {
                        _temperatureMemory.Value = temp;
                        ActivateSensor(_temperatureMemory);
                    }
                    else
                    {
                        _temperatureMemory.Value = null;
                    }

                    if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.VRVDDC, ref temp) == AtiAdlxx.ADL_OK && temp < maxTemperature)
                    {
                        _temperatureVddc.Value = temp;
                        ActivateSensor(_temperatureVddc);
                    }
                    else
                    {
                        _temperatureVddc.Value = null;
                    }

                    if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.VRMVDD, ref temp) == AtiAdlxx.ADL_OK && temp < maxTemperature)
                    {
                        _temperatureMvdd.Value = temp;
                        ActivateSensor(_temperatureMvdd);
                    }
                    else
                    {
                        _temperatureMvdd.Value = null;
                    }

                    _temperatureLiquid.Value = null;
                    if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.LIQUID, ref temp) == AtiAdlxx.ADL_OK && temp > 0 && temp < maxTemperature)
                    {
                        _temperatureLiquid.Value = temp;
                        ActivateSensor(_temperatureLiquid);
                    }

                    _temperaturePlx.Value = null;
                    if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.PLX, ref temp) == AtiAdlxx.ADL_OK && temp > 0 && temp < maxTemperature)
                    {
                        _temperaturePlx.Value = temp;
                        ActivateSensor(_temperaturePlx);
                    }

                    if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.HOTSPOT, ref temp) == AtiAdlxx.ADL_OK && temp < maxTemperature)
                    {
                        _temperatureHotSpot.Value = temp;
                        ActivateSensor(_temperatureHotSpot);
                    }
                    else
                    {
                        _temperatureHotSpot.Value = null;
                    }
                }
                else
                {
                    AtiAdlxx.ADLTemperature temperature = new AtiAdlxx.ADLTemperature();
                    if (AtiAdlxx.ADL_Overdrive5_Temperature_Get(_adapterIndex, 0, ref temperature) == AtiAdlxx.ADL_OK)
                    {
                        _temperatureCore.Value = 0.001f * temperature.Temperature;
                        ActivateSensor(_temperatureCore);
                    }
                    else
                    {
                        _temperatureCore.Value = null;
                    }
                }

                AtiAdlxx.ADLFanSpeedValue fanSpeedValue = new AtiAdlxx.ADLFanSpeedValue {
                    SpeedType = AtiAdlxx.ADL_DL_FANCTRL_SPEED_TYPE_RPM
                };
                if (AtiAdlxx.ADL_Overdrive5_FanSpeed_Get(_adapterIndex, 0, ref fanSpeedValue) == AtiAdlxx.ADL_OK)
                {
                    _fan.Value = fanSpeedValue.FanSpeed;
                    ActivateSensor(_fan);
                }
                else
                {
                    _fan.Value = null;
                }

                fanSpeedValue = new AtiAdlxx.ADLFanSpeedValue {
                    SpeedType = AtiAdlxx.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT
                };
                if (AtiAdlxx.ADL_Overdrive5_FanSpeed_Get(_adapterIndex, 0, ref fanSpeedValue) == AtiAdlxx.ADL_OK)
                {
                    _controlSensor.Value = fanSpeedValue.FanSpeed;
                    ActivateSensor(_controlSensor);
                }
                else
                {
                    _controlSensor.Value = null;
                }

                AtiAdlxx.ADLPMActivity adlpmActivity = new AtiAdlxx.ADLPMActivity();
                if (AtiAdlxx.ADL_Overdrive5_CurrentActivity_Get(_adapterIndex, ref adlpmActivity) == AtiAdlxx.ADL_OK)
                {
                    if (adlpmActivity.EngineClock > 0)
                    {
                        _coreClock.Value = 0.01f * adlpmActivity.EngineClock;
                        ActivateSensor(_coreClock);
                    }
                    else
                    {
                        _coreClock.Value = null;
                    }

                    if (adlpmActivity.MemoryClock > 0)
                    {
                        _memoryClock.Value = 0.01f * adlpmActivity.MemoryClock;
                        ActivateSensor(_memoryClock);
                    }
                    else
                    {
                        _memoryClock.Value = null;
                    }

                    if (adlpmActivity.Vddc > 0)
                    {
                        _coreVoltage.Value = 0.001f * adlpmActivity.Vddc;
                        ActivateSensor(_coreVoltage);
                    }
                    else
                    {
                        _coreVoltage.Value = null;
                    }

                    _coreLoad.Value = Math.Min(adlpmActivity.ActivityPercent, 100);
                    ActivateSensor(_coreLoad);
                }
                else
                {
                    _coreClock.Value   = null;
                    _memoryClock.Value = null;
                    _coreVoltage.Value = null;
                    _coreLoad.Value    = null;
                }
            }
            else
            {
                AtiAdlxx.ADLPMLogDataOutput logDataOutput = new AtiAdlxx.ADLPMLogDataOutput();
                if (AtiAdlxx.ADL2_New_QueryPMLogData_Get(_context, _adapterIndex, ref logDataOutput) == AtiAdlxx.ADL_OK)
                {
                    _temperatureCore.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_EDGE].value;
                    ActivateSensor(_temperatureCore);

                    _temperatureHotSpot.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_HOTSPOT].value;
                    ActivateSensor(_temperatureHotSpot);

                    _temperatureVddc.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_VRVDDC].value;
                    ActivateSensor(_temperatureVddc);

                    _temperatureMemory.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_MEM].value;
                    ActivateSensor(_temperatureMemory);

                    _temperatureMvdd.Value = null;
                    if (logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_VRMVDD].value > 0)
                    {
                        _temperatureMvdd.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_VRMVDD].value;
                        ActivateSensor(_temperatureMvdd);
                    }

                    _temperatureLiquid.Value = null;
                    if (logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_LIQUID].value > 0)
                    {
                        _temperatureLiquid.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_LIQUID].value;
                        ActivateSensor(_temperatureLiquid);
                    }

                    _temperaturePlx.Value = null;
                    if (logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_PLX].value > 0)
                    {
                        _temperaturePlx.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_TEMPERATURE_PLX].value;
                        ActivateSensor(_temperaturePlx);
                    }

                    _coreClock.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_CLK_GFXCLK].value;
                    ActivateSensor(_coreClock);

                    _socClock.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_CLK_SOCCLK].value;
                    ActivateSensor(_socClock);

                    _memoryClock.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_CLK_MEMCLK].value;
                    ActivateSensor(_memoryClock);


                    if (logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_FAN_RPM].value != UInt16.MaxValue)
                    {
                        _fan.Value           = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_FAN_RPM].value;
                        _controlSensor.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_FAN_PERCENTAGE].value;
                    }
                    else
                    {
                        _fan.Value           = null;
                        _controlSensor.Value = null;
                    }
                    ActivateSensor(_fan);
                    ActivateSensor(_controlSensor);

                    _coreVoltage.Value = 0.001f * logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_SOC_VOLTAGE].value;
                    ActivateSensor(_coreVoltage);

                    _memoryVoltage.Value = 0.001f * logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_MEM_VOLTAGE].value;
                    ActivateSensor(_memoryVoltage);

                    _coreLoad.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_INFO_ACTIVITY_GFX].value;
                    ActivateSensor(_coreLoad);

                    _powerCore.Value = null;
                    if (logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_SOC_POWER].value > 0)
                    {
                        _powerCore.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_SOC_POWER].value;
                        ActivateSensor(_powerCore);
                    }

                    _powerSocket.Value = logDataOutput.sensors[(int)AtiAdlxx.ADLSensorType.PMLOG_ASIC_POWER].value;
                    ActivateSensor(_powerSocket);
                }
            }
        }
Exemple #4
0
        public override void Update()
        {
            if (_currentOverdriveApiLevel >= 6)
            {
                int powerOf8 = 0;
                if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_TOTAL_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
                {
                    _powerTotal.Value = powerOf8 >> 8;
                    ActivateSensor(_powerTotal);
                }
                else
                {
                    _powerTotal.Value = null;
                }

                if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_PPT_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
                {
                    _powerPpt.Value = powerOf8 >> 8;
                    ActivateSensor(_powerPpt);
                }
                else
                {
                    _powerPpt.Value = null;
                }

                if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_SOCKET_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
                {
                    _powerSocket.Value = powerOf8 >> 8;
                    ActivateSensor(_powerSocket);
                }
                else
                {
                    _powerSocket.Value = null;
                }

                if (AtiAdlxx.ADL2_Overdrive6_CurrentPower_Get(_context, _adapterIndex, AtiAdlxx.ADLODNCurrentPowerType.ODN_GPU_CHIP_POWER, ref powerOf8) == AtiAdlxx.ADL_OK)
                {
                    _powerCore.Value = powerOf8 >> 8;
                    ActivateSensor(_powerCore);
                }
                else
                {
                    _powerCore.Value = null;
                }
            }

            if (_currentOverdriveApiLevel >= 7)
            {
                int temp = 0;

                if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.EDGE, ref temp) == AtiAdlxx.ADL_OK)
                {
                    _temperatureCore.Value = 0.001f * temp;
                    ActivateSensor(_temperatureCore);
                }
                else
                {
                    _temperatureCore.Value = null;
                }

                if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.MEM, ref temp) == AtiAdlxx.ADL_OK)
                {
                    _temperatureHbm.Value = temp;
                    ActivateSensor(_temperatureHbm);
                }
                else
                {
                    _temperatureHbm.Value = null;
                }

                if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.VRVDDC, ref temp) == AtiAdlxx.ADL_OK)
                {
                    _temperatureVddc.Value = temp;
                    ActivateSensor(_temperatureVddc);
                }
                else
                {
                    _temperatureVddc.Value = null;
                }

                if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.VRMVDD, ref temp) == AtiAdlxx.ADL_OK)
                {
                    _temperatureMvdd.Value = temp;
                    ActivateSensor(_temperatureMvdd);
                }
                else
                {
                    _temperatureMvdd.Value = null;
                }

                _temperatureLiquid.Value = null;
                if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.LIQUID, ref temp) == AtiAdlxx.ADL_OK)
                {
                    if (temp > 0)
                    {
                        _temperatureLiquid.Value = temp;
                        ActivateSensor(_temperatureLiquid);
                    }
                }

                _temperaturePlx.Value = null;
                if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.PLX, ref temp) == AtiAdlxx.ADL_OK)
                {
                    if (temp > 0)
                    {
                        _temperaturePlx.Value = temp;
                        ActivateSensor(_temperaturePlx);
                    }
                }

                if (AtiAdlxx.ADL2_OverdriveN_Temperature_Get(_context, _adapterIndex, AtiAdlxx.ADLODNTemperatureType.HOTSPOT, ref temp) == AtiAdlxx.ADL_OK)
                {
                    _temperatureHotSpot.Value = temp;
                    ActivateSensor(_temperatureHotSpot);
                }
                else
                {
                    _temperatureHotSpot.Value = null;
                }
            }
            else
            {
                AtiAdlxx.ADLTemperature temperature = new AtiAdlxx.ADLTemperature();
                if (AtiAdlxx.ADL_Overdrive5_Temperature_Get(_adapterIndex, 0, ref temperature) == AtiAdlxx.ADL_OK)
                {
                    _temperatureCore.Value = 0.001f * temperature.Temperature;
                    ActivateSensor(_temperatureCore);
                }
                else
                {
                    _temperatureCore.Value = null;
                }
            }

            AtiAdlxx.ADLFanSpeedValue fanSpeedValue = new AtiAdlxx.ADLFanSpeedValue {
                SpeedType = AtiAdlxx.ADL_DL_FANCTRL_SPEED_TYPE_RPM
            };
            if (AtiAdlxx.ADL_Overdrive5_FanSpeed_Get(_adapterIndex, 0, ref fanSpeedValue) == AtiAdlxx.ADL_OK)
            {
                _fan.Value = fanSpeedValue.FanSpeed;
                ActivateSensor(_fan);
            }
            else
            {
                _fan.Value = null;
            }

            fanSpeedValue = new AtiAdlxx.ADLFanSpeedValue {
                SpeedType = AtiAdlxx.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT
            };
            if (AtiAdlxx.ADL_Overdrive5_FanSpeed_Get(_adapterIndex, 0, ref fanSpeedValue) == AtiAdlxx.ADL_OK)
            {
                _controlSensor.Value = fanSpeedValue.FanSpeed;
                ActivateSensor(_controlSensor);
            }
            else
            {
                _controlSensor.Value = null;
            }

            AtiAdlxx.ADLPMActivity adlpmActivity = new AtiAdlxx.ADLPMActivity();
            if (AtiAdlxx.ADL_Overdrive5_CurrentActivity_Get(_adapterIndex, ref adlpmActivity) == AtiAdlxx.ADL_OK)
            {
                if (adlpmActivity.EngineClock > 0)
                {
                    _coreClock.Value = 0.01f * adlpmActivity.EngineClock;
                    ActivateSensor(_coreClock);
                }
                else
                {
                    _coreClock.Value = null;
                }

                if (adlpmActivity.MemoryClock > 0)
                {
                    _memoryClock.Value = 0.01f * adlpmActivity.MemoryClock;
                    ActivateSensor(_memoryClock);
                }
                else
                {
                    _memoryClock.Value = null;
                }

                if (adlpmActivity.Vddc > 0)
                {
                    _coreVoltage.Value = 0.001f * adlpmActivity.Vddc;
                    ActivateSensor(_coreVoltage);
                }
                else
                {
                    _coreVoltage.Value = null;
                }

                _coreLoad.Value = Math.Min(adlpmActivity.ActivityPercent, 100);
                ActivateSensor(_coreLoad);
            }
            else
            {
                _coreClock.Value   = null;
                _memoryClock.Value = null;
                _coreVoltage.Value = null;
                _coreLoad.Value    = null;
            }
        }