Hardware/ATI/ATIGroup.cs
changeset 1 361e324a0ed4
child 3 1a0928afac6b
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Hardware/ATI/ATIGroup.cs	Tue Jan 26 22:37:48 2010 +0000
     1.3 @@ -0,0 +1,111 @@
     1.4 +/*
     1.5 +  
     1.6 +  Version: MPL 1.1/GPL 2.0/LGPL 2.1
     1.7 +
     1.8 +  The contents of this file are subject to the Mozilla Public License Version
     1.9 +  1.1 (the "License"); you may not use this file except in compliance with
    1.10 +  the License. You may obtain a copy of the License at
    1.11 + 
    1.12 +  http://www.mozilla.org/MPL/
    1.13 +
    1.14 +  Software distributed under the License is distributed on an "AS IS" basis,
    1.15 +  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    1.16 +  for the specific language governing rights and limitations under the License.
    1.17 +
    1.18 +  The Original Code is the Open Hardware Monitor code.
    1.19 +
    1.20 +  The Initial Developer of the Original Code is 
    1.21 +  Michael Möller <m.moeller@gmx.ch>.
    1.22 +  Portions created by the Initial Developer are Copyright (C) 2009-2010
    1.23 +  the Initial Developer. All Rights Reserved.
    1.24 +
    1.25 +  Contributor(s):
    1.26 +
    1.27 +  Alternatively, the contents of this file may be used under the terms of
    1.28 +  either the GNU General Public License Version 2 or later (the "GPL"), or
    1.29 +  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    1.30 +  in which case the provisions of the GPL or the LGPL are applicable instead
    1.31 +  of those above. If you wish to allow use of your version of this file only
    1.32 +  under the terms of either the GPL or the LGPL, and not to allow others to
    1.33 +  use your version of this file under the terms of the MPL, indicate your
    1.34 +  decision by deleting the provisions above and replace them with the notice
    1.35 +  and other provisions required by the GPL or the LGPL. If you do not delete
    1.36 +  the provisions above, a recipient may use your version of this file under
    1.37 +  the terms of any one of the MPL, the GPL or the LGPL.
    1.38 + 
    1.39 +*/
    1.40 +
    1.41 +using System;
    1.42 +using System.Collections.Generic;
    1.43 +using System.Text;
    1.44 +
    1.45 +namespace OpenHardwareMonitor.Hardware.ATI {
    1.46 +  public class ATIGroup : IGroup {
    1.47 +
    1.48 +    private List<ATIGPU> hardware = new List<ATIGPU>();
    1.49 +    private StringBuilder report = new StringBuilder();
    1.50 +
    1.51 +    public ATIGroup() {
    1.52 +      try {
    1.53 +        if (ADL.ADL_Main_Control_Create(1) == ADL.ADL_SUCCESS) {
    1.54 +          int numberOfAdapters = 0;
    1.55 +          ADL.ADL_Adapter_NumberOfAdapters_Get(ref numberOfAdapters);
    1.56 +
    1.57 +          report.AppendLine("AMD Display Library");
    1.58 +          report.AppendLine();
    1.59 +          report.Append("Numer of adapters: "); 
    1.60 +          report.AppendLine(numberOfAdapters.ToString());
    1.61 +          report.AppendLine();
    1.62 +
    1.63 +          if (numberOfAdapters > 0) {
    1.64 +            ADLAdapterInfo[] adapterInfo = new ADLAdapterInfo[numberOfAdapters];
    1.65 +            if (ADL.ADL_Adapter_AdapterInfo_Get(adapterInfo) == ADL.ADL_SUCCESS)
    1.66 +              for (int i = 0; i < numberOfAdapters; i++) {
    1.67 +                int isActive;
    1.68 +                ADL.ADL_Adapter_Active_Get(adapterInfo[i].AdapterIndex,
    1.69 +                  out isActive);
    1.70 +
    1.71 +                report.Append("AdapterIndex: "); 
    1.72 +                report.AppendLine(i.ToString());
    1.73 +                report.Append("isActive: "); 
    1.74 +                report.AppendLine(isActive.ToString());
    1.75 +                report.Append("AdapterName: "); 
    1.76 +                report.AppendLine(adapterInfo[i].AdapterName);     
    1.77 +                report.Append("UDID: ");
    1.78 +                report.AppendLine(adapterInfo[i].UDID);
    1.79 +                report.AppendLine();
    1.80 +
    1.81 +                if (isActive == 1) {
    1.82 +                  int adapterID;
    1.83 +                  ADL.ADL_Adapter_ID_Get(adapterInfo[i].AdapterIndex,
    1.84 +                    out adapterID);
    1.85 +
    1.86 +                  if (adapterID > 0 && adapterInfo[i].UDID != "") {
    1.87 +                    hardware.Add(new ATIGPU(
    1.88 +                      adapterInfo[i].AdapterName,
    1.89 +                      adapterInfo[i].AdapterIndex));
    1.90 +                  }
    1.91 +                }
    1.92 +              }
    1.93 +          }
    1.94 +        }
    1.95 +      } catch (DllNotFoundException) { } catch (EntryPointNotFoundException) { }
    1.96 +    }
    1.97 +
    1.98 +    public IHardware[] Hardware {
    1.99 +      get {
   1.100 +        return hardware.ToArray();
   1.101 +      }
   1.102 +    }
   1.103 +
   1.104 +    public string GetReport() {
   1.105 +      return report.ToString();
   1.106 +    }
   1.107 +
   1.108 +    public void Close() {
   1.109 +      try {
   1.110 +        ADL.ADL_Main_Control_Destroy();
   1.111 +      } catch (Exception) { }
   1.112 +    }
   1.113 +  }
   1.114 +}