Refactored some of the hardware monitoring code and fixed a few code inspection warnings.
This commit is contained in:
@@ -141,12 +141,12 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NvDisplayHandle {
|
||||
private IntPtr ptr;
|
||||
private readonly IntPtr ptr;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct NvPhysicalGpuHandle {
|
||||
private IntPtr ptr;
|
||||
private readonly IntPtr ptr;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
@@ -281,11 +281,12 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
public delegate NvStatus NvAPI_GetInterfaceVersionStringDelegate(
|
||||
StringBuilder version);
|
||||
|
||||
private static bool available = false;
|
||||
private static nvapi_QueryInterfaceDelegate nvapi_QueryInterface;
|
||||
private static NvAPI_InitializeDelegate NvAPI_Initialize;
|
||||
private static NvAPI_GPU_GetFullNameDelegate _NvAPI_GPU_GetFullName;
|
||||
private static NvAPI_GetInterfaceVersionStringDelegate
|
||||
private static readonly bool available;
|
||||
private static readonly nvapi_QueryInterfaceDelegate nvapi_QueryInterface;
|
||||
private static readonly NvAPI_InitializeDelegate NvAPI_Initialize;
|
||||
private static readonly NvAPI_GPU_GetFullNameDelegate
|
||||
_NvAPI_GPU_GetFullName;
|
||||
private static readonly NvAPI_GetInterfaceVersionStringDelegate
|
||||
_NvAPI_GetInterfaceVersionString;
|
||||
|
||||
public static readonly NvAPI_GPU_GetThermalSettingsDelegate
|
||||
|
||||
@@ -40,19 +40,19 @@ using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
internal class NvidiaGPU : Hardware, IHardware {
|
||||
internal class NvidiaGPU : Hardware {
|
||||
|
||||
private string name;
|
||||
private int adapterIndex;
|
||||
private NvPhysicalGpuHandle handle;
|
||||
private NvDisplayHandle? displayHandle;
|
||||
private readonly string name;
|
||||
private readonly int adapterIndex;
|
||||
private readonly NvPhysicalGpuHandle handle;
|
||||
private readonly NvDisplayHandle? displayHandle;
|
||||
|
||||
private Sensor[] temperatures;
|
||||
private Sensor fan = null;
|
||||
private Sensor[] clocks;
|
||||
private Sensor[] loads;
|
||||
private Sensor control;
|
||||
private Sensor memoryLoad;
|
||||
private readonly Sensor[] temperatures;
|
||||
private readonly Sensor fan;
|
||||
private readonly Sensor[] clocks;
|
||||
private readonly Sensor[] loads;
|
||||
private readonly Sensor control;
|
||||
private readonly Sensor memoryLoad;
|
||||
|
||||
public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle,
|
||||
NvDisplayHandle? displayHandle, ISettings settings)
|
||||
|
||||
@@ -43,8 +43,8 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
|
||||
internal class NvidiaGroup : IGroup {
|
||||
|
||||
private List<IHardware> hardware = new List<IHardware>();
|
||||
private StringBuilder report = new StringBuilder();
|
||||
private readonly List<IHardware> hardware = new List<IHardware>();
|
||||
private readonly StringBuilder report = new StringBuilder();
|
||||
|
||||
public NvidiaGroup(ISettings settings) {
|
||||
if (!NVAPI.IsAvailable)
|
||||
@@ -69,7 +69,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
} else {
|
||||
NvStatus status = NVAPI.NvAPI_EnumPhysicalGPUs(handles, out count);
|
||||
if (status != NvStatus.OK) {
|
||||
report.AppendLine("Status: " + status.ToString());
|
||||
report.AppendLine("Status: " + status);
|
||||
report.AppendLine();
|
||||
return;
|
||||
}
|
||||
@@ -104,14 +104,12 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
}
|
||||
|
||||
report.Append("Number of GPUs: ");
|
||||
report.AppendLine(count.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
report.AppendLine(count.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
NvDisplayHandle displayHandle;
|
||||
if (displayHandles.TryGetValue(handles[i], out displayHandle))
|
||||
hardware.Add(new NvidiaGPU(i, handles[i], displayHandle, settings));
|
||||
else
|
||||
hardware.Add(new NvidiaGPU(i, handles[i], null, settings));
|
||||
displayHandles.TryGetValue(handles[i], out displayHandle);
|
||||
hardware.Add(new NvidiaGPU(i, handles[i], displayHandle, settings));
|
||||
}
|
||||
|
||||
report.AppendLine();
|
||||
|
||||
Reference in New Issue
Block a user