Fixed Issue 651.
3 This Source Code Form is subject to the terms of the Mozilla Public
4 License, v. 2.0. If a copy of the MPL was not distributed with this
5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
12 using System.Collections.Generic;
13 using System.Globalization;
16 namespace OpenHardwareMonitor.Hardware.ATI {
17 internal class ATIGroup : IGroup {
19 private readonly List<ATIGPU> hardware = new List<ATIGPU>();
20 private readonly StringBuilder report = new StringBuilder();
22 public ATIGroup(ISettings settings) {
24 int status = ADL.ADL_Main_Control_Create(1);
26 report.AppendLine("AMD Display Library");
28 report.Append("Status: ");
29 report.AppendLine(status == ADL.ADL_OK ? "OK" :
30 status.ToString(CultureInfo.InvariantCulture));
33 if (status == ADL.ADL_OK) {
34 int numberOfAdapters = 0;
35 ADL.ADL_Adapter_NumberOfAdapters_Get(ref numberOfAdapters);
37 report.Append("Number of adapters: ");
38 report.AppendLine(numberOfAdapters.ToString(CultureInfo.InvariantCulture));
41 if (numberOfAdapters > 0) {
42 ADLAdapterInfo[] adapterInfo = new ADLAdapterInfo[numberOfAdapters];
43 if (ADL.ADL_Adapter_AdapterInfo_Get(adapterInfo) == ADL.ADL_OK)
44 for (int i = 0; i < numberOfAdapters; i++) {
46 ADL.ADL_Adapter_Active_Get(adapterInfo[i].AdapterIndex,
49 ADL.ADL_Adapter_ID_Get(adapterInfo[i].AdapterIndex,
52 report.Append("AdapterIndex: ");
53 report.AppendLine(i.ToString(CultureInfo.InvariantCulture));
54 report.Append("isActive: ");
55 report.AppendLine(isActive.ToString(CultureInfo.InvariantCulture));
56 report.Append("AdapterName: ");
57 report.AppendLine(adapterInfo[i].AdapterName);
58 report.Append("UDID: ");
59 report.AppendLine(adapterInfo[i].UDID);
60 report.Append("Present: ");
61 report.AppendLine(adapterInfo[i].Present.ToString(
62 CultureInfo.InvariantCulture));
63 report.Append("VendorID: 0x");
64 report.AppendLine(adapterInfo[i].VendorID.ToString("X",
65 CultureInfo.InvariantCulture));
66 report.Append("BusNumber: ");
67 report.AppendLine(adapterInfo[i].BusNumber.ToString(
68 CultureInfo.InvariantCulture));
69 report.Append("DeviceNumber: ");
70 report.AppendLine(adapterInfo[i].DeviceNumber.ToString(
71 CultureInfo.InvariantCulture));
72 report.Append("FunctionNumber: ");
73 report.AppendLine(adapterInfo[i].FunctionNumber.ToString(
74 CultureInfo.InvariantCulture));
75 report.Append("AdapterID: 0x");
76 report.AppendLine(adapterID.ToString("X",
77 CultureInfo.InvariantCulture));
79 if (!string.IsNullOrEmpty(adapterInfo[i].UDID) &&
80 adapterInfo[i].VendorID == ADL.ATI_VENDOR_ID)
83 foreach (ATIGPU gpu in hardware)
84 if (gpu.BusNumber == adapterInfo[i].BusNumber &&
85 gpu.DeviceNumber == adapterInfo[i].DeviceNumber) {
90 hardware.Add(new ATIGPU(
91 adapterInfo[i].AdapterName.Trim(),
92 adapterInfo[i].AdapterIndex,
93 adapterInfo[i].BusNumber,
94 adapterInfo[i].DeviceNumber, settings));
101 } catch (DllNotFoundException) { }
102 catch (EntryPointNotFoundException e) {
104 report.AppendLine(e.ToString());
109 public IHardware[] Hardware {
111 return hardware.ToArray();
115 public string GetReport() {
116 return report.ToString();
119 public void Close() {
121 foreach (ATIGPU gpu in hardware)
123 ADL.ADL_Main_Control_Destroy();
124 } catch (Exception) { }