Hardware/ATI/ATIGPU.cs
author moel.mich
Tue, 26 Jan 2010 22:37:48 +0000
changeset 1 361e324a0ed4
child 3 1a0928afac6b
permissions -rw-r--r--
Initial commit.
     1 /*
     2   
     3   Version: MPL 1.1/GPL 2.0/LGPL 2.1
     4 
     5   The contents of this file are subject to the Mozilla Public License Version
     6   1.1 (the "License"); you may not use this file except in compliance with
     7   the License. You may obtain a copy of the License at
     8  
     9   http://www.mozilla.org/MPL/
    10 
    11   Software distributed under the License is distributed on an "AS IS" basis,
    12   WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    13   for the specific language governing rights and limitations under the License.
    14 
    15   The Original Code is the Open Hardware Monitor code.
    16 
    17   The Initial Developer of the Original Code is 
    18   Michael Möller <m.moeller@gmx.ch>.
    19   Portions created by the Initial Developer are Copyright (C) 2009-2010
    20   the Initial Developer. All Rights Reserved.
    21 
    22   Contributor(s):
    23 
    24   Alternatively, the contents of this file may be used under the terms of
    25   either the GNU General Public License Version 2 or later (the "GPL"), or
    26   the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    27   in which case the provisions of the GPL or the LGPL are applicable instead
    28   of those above. If you wish to allow use of your version of this file only
    29   under the terms of either the GPL or the LGPL, and not to allow others to
    30   use your version of this file under the terms of the MPL, indicate your
    31   decision by deleting the provisions above and replace them with the notice
    32   and other provisions required by the GPL or the LGPL. If you do not delete
    33   the provisions above, a recipient may use your version of this file under
    34   the terms of any one of the MPL, the GPL or the LGPL.
    35  
    36 */
    37 
    38 using System;
    39 using System.Collections.Generic;
    40 using System.Drawing;
    41 using System.Reflection;
    42 
    43 namespace OpenHardwareMonitor.Hardware.ATI {
    44   public class ATIGPU : IHardware {
    45 
    46     private string name;
    47     private Image icon;
    48     private int adapterIndex;
    49     private Sensor temperature;
    50     private Sensor fan;
    51     private Sensor coreClock;
    52     private Sensor memoryClock;
    53     private Sensor coreVoltage;
    54 
    55     public ATIGPU(string name, int adapterIndex) {
    56       this.name = name;
    57       this.icon = Utilities.EmbeddedResources.GetImage("ati.png");
    58       this.adapterIndex = adapterIndex;
    59 
    60       ADLFanSpeedInfo speedInfo = new ADLFanSpeedInfo();
    61       ADL.ADL_Overdrive5_FanSpeedInfo_Get(adapterIndex, 0, ref speedInfo);
    62 
    63       this.temperature = 
    64         new Sensor("GPU Core", 0, SensorType.Temperature, this);
    65       this.fan = new Sensor("GPU", 0, speedInfo.MaxRPM, SensorType.Fan, this);
    66       this.coreClock = new Sensor("GPU Core", 0, SensorType.Clock, this);
    67       this.memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this);
    68       this.coreVoltage = new Sensor("GPU Core", 0, SensorType.Voltage, this);
    69       Update();                   
    70     }
    71 
    72     public string Name {
    73       get { return name; }
    74     }
    75 
    76     public string Identifier {
    77       get { return "/atigpu/" + adapterIndex; }
    78     }
    79 
    80     public Image Icon {
    81       get { return icon; }
    82     }
    83 
    84     public ISensor[] Sensors {
    85       get {
    86         return new ISensor[] { coreVoltage, coreClock, memoryClock, temperature, 
    87           fan };
    88       }
    89     }
    90 
    91     public string GetReport() {
    92       return null;
    93     }
    94 
    95     public void Update() {
    96       ADLTemperature adlt = new ADLTemperature();
    97       ADL.ADL_Overdrive5_Temperature_Get(adapterIndex, 0, ref adlt);
    98       temperature.Value = 0.001f * adlt.Temperature;
    99 
   100       ADLFanSpeedValue adlf = new ADLFanSpeedValue();
   101       adlf.SpeedType = ADL.ADL_DL_FANCTRL_SPEED_TYPE_RPM;
   102       ADL.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0, ref adlf);
   103       fan.Value = adlf.FanSpeed;
   104 
   105       ADLPMActivity adlp = new ADLPMActivity();
   106       ADL.ADL_Overdrive5_CurrentActivity_Get(adapterIndex, ref adlp);
   107       coreClock.Value = 0.01f * adlp.EngineClock;
   108       memoryClock.Value = 0.01f * adlp.MemoryClock;
   109       coreVoltage.Value = 0.001f * adlp.Vddc;
   110     }
   111 
   112     #pragma warning disable 67
   113     public event SensorEventHandler SensorAdded;
   114     public event SensorEventHandler SensorRemoved;
   115     #pragma warning restore 67
   116   }
   117 }