Refactored some of the hardware monitoring code and fixed a few code inspection warnings.

This commit is contained in:
Michael Möller 2010-09-21 20:32:36 +00:00
parent dfb06376d6
commit bcde768e25
44 changed files with 437 additions and 472 deletions

View File

@ -35,18 +35,14 @@
*/ */
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
namespace OpenHardwareMonitor.Collections { namespace OpenHardwareMonitor.Collections {
public class ListSet<T> : IEnumerable<T> { public class ListSet<T> : IEnumerable<T> {
private List<T> list = new List<T>(); private readonly List<T> list = new List<T>();
public ListSet() { }
public bool Add(T item) { public bool Add(T item) {
if (list.Contains(item)) if (list.Contains(item))

View File

@ -35,7 +35,6 @@
*/ */
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -43,7 +42,7 @@ namespace OpenHardwareMonitor.Collections {
public class ReadOnlyArray<T> : IReadOnlyArray<T> { public class ReadOnlyArray<T> : IReadOnlyArray<T> {
private T[] array; private readonly T[] array;
public ReadOnlyArray(T[] array) { public ReadOnlyArray(T[] array) {
this.array = array; this.array = array;

View File

@ -187,7 +187,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
} }
private static void CreateDelegates(string name) { private static void CreateDelegates(string name) {
int p = (int)System.Environment.OSVersion.Platform; int p = (int)Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) if ((p == 4) || (p == 128))
dllName = name + ".so"; dllName = name + ".so";
else else
@ -234,7 +234,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
enumConnectedAdapters); enumConnectedAdapters);
} }
} catch { } catch {
return ADL.ADL_ERR; return ADL_ERR;
} }
} }

View File

@ -41,17 +41,17 @@ using System.Globalization;
namespace OpenHardwareMonitor.Hardware.ATI { namespace OpenHardwareMonitor.Hardware.ATI {
internal sealed class ATIGPU : Hardware { internal sealed class ATIGPU : Hardware {
private string name; private readonly string name;
private int adapterIndex; private readonly int adapterIndex;
private int busNumber; private readonly int busNumber;
private int deviceNumber; private readonly int deviceNumber;
private Sensor temperature; private readonly Sensor temperature;
private Sensor fan; private readonly Sensor fan;
private Sensor coreClock; private readonly Sensor coreClock;
private Sensor memoryClock; private readonly Sensor memoryClock;
private Sensor coreVoltage; private readonly Sensor coreVoltage;
private Sensor coreLoad; private readonly Sensor coreLoad;
private Sensor fanControl; private readonly Sensor fanControl;
public ATIGPU(string name, int adapterIndex, int busNumber, public ATIGPU(string name, int adapterIndex, int busNumber,
int deviceNumber, ISettings settings) int deviceNumber, ISettings settings)

View File

@ -43,8 +43,8 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.ATI { namespace OpenHardwareMonitor.Hardware.ATI {
internal class ATIGroup : IGroup { internal class ATIGroup : IGroup {
private List<ATIGPU> hardware = new List<ATIGPU>(); private readonly List<ATIGPU> hardware = new List<ATIGPU>();
private StringBuilder report = new StringBuilder(); private readonly StringBuilder report = new StringBuilder();
public ATIGroup(ISettings settings) { public ATIGroup(ISettings settings) {
try { try {
@ -53,10 +53,8 @@ namespace OpenHardwareMonitor.Hardware.ATI {
report.AppendLine("AMD Display Library"); report.AppendLine("AMD Display Library");
report.AppendLine(); report.AppendLine();
report.Append("Status: "); report.Append("Status: ");
if (status == ADL.ADL_OK) report.AppendLine(status == ADL.ADL_OK ? "OK" :
report.AppendLine("OK"); status.ToString(CultureInfo.InvariantCulture));
else
report.AppendLine(status.ToString(CultureInfo.InvariantCulture));
report.AppendLine(); report.AppendLine();
if (status == ADL.ADL_OK) { if (status == ADL.ADL_OK) {

View File

@ -41,10 +41,10 @@ using System.Threading;
namespace OpenHardwareMonitor.Hardware.CPU { namespace OpenHardwareMonitor.Hardware.CPU {
internal sealed class AMD0FCPU : GenericCPU { internal sealed class AMD0FCPU : GenericCPU {
private uint pciAddress; private readonly uint pciAddress;
private Sensor[] coreTemperatures; private readonly Sensor[] coreTemperatures;
private Sensor[] coreClocks; private readonly Sensor[] coreClocks;
private Sensor busClock; private readonly Sensor busClock;
private const ushort PCI_AMD_VENDOR_ID = 0x1022; private const ushort PCI_AMD_VENDOR_ID = 0x1022;
private const ushort PCI_AMD_0FH_MISCELLANEOUS_DEVICE_ID = 0x1103; private const ushort PCI_AMD_0FH_MISCELLANEOUS_DEVICE_ID = 0x1103;
@ -71,8 +71,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
for (int i = 0; i < coreCount; i++) { for (int i = 0; i < coreCount; i++) {
coreTemperatures[i] = coreTemperatures[i] =
new Sensor("Core #" + (i + 1), i, SensorType.Temperature, new Sensor("Core #" + (i + 1), i, SensorType.Temperature,
this, new ParameterDescription[] { this, new [] { new ParameterDescription("Offset [°C]",
new ParameterDescription("Offset [°C]",
"Temperature offset of the thermal sensor.\n" + "Temperature offset of the thermal sensor.\n" +
"Temperature = Value + Offset.", offset) "Temperature = Value + Offset.", offset)
}, settings); }, settings);
@ -97,9 +96,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
} }
protected override uint[] GetMSRs() { protected override uint[] GetMSRs() {
return new uint[] { return new [] { FIDVID_STATUS };
FIDVID_STATUS
};
} }
public override void Update() { public override void Update() {

View File

@ -39,9 +39,9 @@ namespace OpenHardwareMonitor.Hardware.CPU {
internal sealed class AMD10CPU : GenericCPU { internal sealed class AMD10CPU : GenericCPU {
private uint pciAddress; private readonly uint pciAddress;
private Sensor coreTemperature; private readonly Sensor coreTemperature;
private const ushort PCI_AMD_VENDOR_ID = 0x1022; private const ushort PCI_AMD_VENDOR_ID = 0x1022;
private const ushort PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID = 0x1203; private const ushort PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID = 0x1203;
@ -54,7 +54,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
// AMD family 10h processors support only one temperature sensor // AMD family 10h processors support only one temperature sensor
coreTemperature = new Sensor( coreTemperature = new Sensor(
"Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0, "Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0,
SensorType.Temperature, this, new ParameterDescription[] { SensorType.Temperature, this, new [] {
new ParameterDescription("Offset [°C]", "Temperature offset.", 0) new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
}, settings); }, settings);

View File

@ -43,9 +43,9 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.CPU { namespace OpenHardwareMonitor.Hardware.CPU {
internal class CPUGroup : IGroup { internal class CPUGroup : IGroup {
private List<IHardware> hardware = new List<IHardware>(); private readonly List<IHardware> hardware = new List<IHardware>();
private CPUID[][][] threads; private readonly CPUID[][][] threads;
private static CPUID[][] GetProcessorThreads() { private static CPUID[][] GetProcessorThreads() {
@ -77,7 +77,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
return processorThreads; return processorThreads;
} }
private static CPUID[][] GroupThreadsByCore(CPUID[] threads) { private static CPUID[][] GroupThreadsByCore(IEnumerable<CPUID> threads) {
SortedDictionary<uint, List<CPUID>> cores = SortedDictionary<uint, List<CPUID>> cores =
new SortedDictionary<uint, List<CPUID>>(); new SortedDictionary<uint, List<CPUID>>();
@ -102,7 +102,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
public CPUGroup(ISettings settings) { public CPUGroup(ISettings settings) {
// No implementation for cpuid on Unix systems // No implementation for cpuid on Unix systems
int p = (int)System.Environment.OSVersion.Platform; int p = (int)Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) if ((p == 4) || (p == 128))
return; return;

View File

@ -48,31 +48,31 @@ namespace OpenHardwareMonitor.Hardware.CPU {
internal class CPUID { internal class CPUID {
private int thread; private readonly int thread;
private Vendor vendor = Vendor.Unknown; private readonly Vendor vendor = Vendor.Unknown;
private string cpuBrandString = ""; private readonly string cpuBrandString = "";
private string name = ""; private readonly string name = "";
private uint[,] cpuidData = new uint[0, 0]; private readonly uint[,] cpuidData = new uint[0, 0];
private uint[,] cpuidExtData = new uint[0, 0]; private readonly uint[,] cpuidExtData = new uint[0, 0];
private uint family; private readonly uint family;
private uint model; private readonly uint model;
private uint stepping; private readonly uint stepping;
private uint apicId; private readonly uint apicId;
private uint threadMaskWith; private readonly uint threadMaskWith;
private uint coreMaskWith; private readonly uint coreMaskWith;
private uint processorId; private readonly uint processorId;
private uint coreId; private readonly uint coreId;
private uint threadId; private readonly uint threadId;
public static uint CPUID_0 = 0; public const uint CPUID_0 = 0;
public static uint CPUID_EXT = 0x80000000; public const uint CPUID_EXT = 0x80000000;
private static void AppendRegister(StringBuilder b, uint value) { private static void AppendRegister(StringBuilder b, uint value) {
b.Append((char)((value) & 0xff)); b.Append((char)((value) & 0xff));
@ -217,8 +217,8 @@ namespace OpenHardwareMonitor.Hardware.CPU {
break; break;
} }
processorId = (uint)(apicId >> (int)(coreMaskWith + threadMaskWith)); processorId = (apicId >> (int)(coreMaskWith + threadMaskWith));
coreId = (uint)((apicId >> (int)(threadMaskWith)) coreId = ((apicId >> (int)(threadMaskWith))
- (processorId << (int)(coreMaskWith))); - (processorId << (int)(coreMaskWith)));
threadId = apicId threadId = apicId
- (processorId << (int)(coreMaskWith + threadMaskWith)) - (processorId << (int)(coreMaskWith + threadMaskWith))

View File

@ -42,7 +42,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
internal class CPULoad { internal class CPULoad {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
private struct SystemProcessorPerformanceInformation { protected struct SystemProcessorPerformanceInformation {
public long IdleTime; public long IdleTime;
public long KernelTime; public long KernelTime;
public long UserTime; public long UserTime;
@ -51,7 +51,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
public ulong Reserved2; public ulong Reserved2;
} }
private enum SystemInformationClass : int { protected enum SystemInformationClass {
SystemBasicInformation = 0, SystemBasicInformation = 0,
SystemCpuInformation = 1, SystemCpuInformation = 1,
SystemPerformanceInformation = 2, SystemPerformanceInformation = 2,
@ -60,15 +60,15 @@ namespace OpenHardwareMonitor.Hardware.CPU {
SystemProcessorPerformanceInformation = 8 SystemProcessorPerformanceInformation = 8
} }
private CPUID[][] cpuid; private readonly CPUID[][] cpuid;
private long systemTime; private long systemTime;
private long[] idleTimes; private long[] idleTimes;
private float totalLoad; private float totalLoad;
private float[] coreLoads; private readonly float[] coreLoads;
private bool available = false; private readonly bool available;
private static long[] GetIdleTimes() { private static long[] GetIdleTimes() {
SystemProcessorPerformanceInformation[] informations = new SystemProcessorPerformanceInformation[] informations = new
@ -159,7 +159,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
this.idleTimes = newIdleTimes; this.idleTimes = newIdleTimes;
} }
private static class NativeMethods { protected static class NativeMethods {
[DllImport("ntdll.dll")] [DllImport("ntdll.dll")]
public static extern int NtQuerySystemInformation( public static extern int NtQuerySystemInformation(

View File

@ -43,7 +43,7 @@ using System.Text;
using System.Threading; using System.Threading;
namespace OpenHardwareMonitor.Hardware.CPU { namespace OpenHardwareMonitor.Hardware.CPU {
internal class GenericCPU : Hardware, IHardware { internal class GenericCPU : Hardware {
protected readonly CPUID[][] cpuid; protected readonly CPUID[][] cpuid;
@ -57,13 +57,13 @@ namespace OpenHardwareMonitor.Hardware.CPU {
protected readonly bool hasTSC; protected readonly bool hasTSC;
protected readonly bool invariantTSC; protected readonly bool invariantTSC;
private readonly double estimatedMaxClock;
private ulong lastTimeStampCount; private ulong lastTimeStampCount;
private long lastTime; private long lastTime;
private double maxClock; private double maxClock;
private double estimatedMaxClock;
private Vendor vendor; private readonly Vendor vendor;
private readonly CPULoad cpuLoad; private readonly CPULoad cpuLoad;
private readonly Sensor totalLoad; private readonly Sensor totalLoad;
@ -129,7 +129,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
lastTime = 0; lastTime = 0;
} }
private double EstimateMaxClock() { private static double EstimateMaxClock() {
// preload the function // preload the function
EstimateMaxClock(0); EstimateMaxClock(0);
EstimateMaxClock(0); EstimateMaxClock(0);
@ -184,7 +184,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
StringBuilder r = new StringBuilder(); StringBuilder r = new StringBuilder();
switch (vendor) { switch (vendor) {
case Vendor.AMD: r.AppendLine("Intel CPU"); break; case Vendor.AMD: r.AppendLine("AMD CPU"); break;
case Vendor.Intel: r.AppendLine("Intel CPU"); break; case Vendor.Intel: r.AppendLine("Intel CPU"); break;
default: r.AppendLine("Generic CPU"); break; default: r.AppendLine("Generic CPU"); break;
} }

View File

@ -41,11 +41,11 @@ using System.Collections.Generic;
namespace OpenHardwareMonitor.Hardware.CPU { namespace OpenHardwareMonitor.Hardware.CPU {
internal sealed class IntelCPU : GenericCPU { internal sealed class IntelCPU : GenericCPU {
private Sensor[] coreTemperatures; private readonly Sensor[] coreTemperatures;
private Sensor[] coreClocks; private readonly Sensor[] coreClocks;
private Sensor busClock; private readonly Sensor busClock;
private uint maxNehalemMultiplier = 0; private readonly uint maxNehalemMultiplier;
private const uint IA32_THERM_STATUS_MSR = 0x019C; private const uint IA32_THERM_STATUS_MSR = 0x019C;
private const uint IA32_TEMPERATURE_TARGET = 0x01A2; private const uint IA32_TEMPERATURE_TARGET = 0x01A2;
@ -127,7 +127,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
coreTemperatures = new Sensor[coreCount]; coreTemperatures = new Sensor[coreCount];
for (int i = 0; i < coreTemperatures.Length; i++) { for (int i = 0; i < coreTemperatures.Length; i++) {
coreTemperatures[i] = new Sensor(CoreString(i), i, coreTemperatures[i] = new Sensor(CoreString(i), i,
SensorType.Temperature, this, new ParameterDescription[] { SensorType.Temperature, this, new [] {
new ParameterDescription( new ParameterDescription(
"TjMax [°C]", "TjMax temperature of the core.\n" + "TjMax [°C]", "TjMax temperature of the core.\n" +
"Temperature = TjMax - TSlope * Value.", tjMax[i]), "Temperature = TjMax - TSlope * Value.", tjMax[i]),
@ -153,7 +153,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
} }
protected override uint[] GetMSRs() { protected override uint[] GetMSRs() {
return new uint[] { return new [] {
MSR_PLATFORM_INFO, MSR_PLATFORM_INFO,
IA32_PERF_STATUS , IA32_PERF_STATUS ,
IA32_THERM_STATUS_MSR, IA32_THERM_STATUS_MSR,

View File

@ -45,22 +45,18 @@ namespace OpenHardwareMonitor.Hardware {
public class Computer : IComputer { public class Computer : IComputer {
private List<IGroup> groups = new List<IGroup>(); private readonly List<IGroup> groups = new List<IGroup>();
private readonly ISettings settings;
private bool open = false; private bool open;
private bool hddEnabled = false; private bool hddEnabled;
private ISettings settings;
public Computer() { public Computer() {
this.settings = new Settings(); this.settings = new Settings();
} }
public Computer(ISettings settings) { public Computer(ISettings settings) {
if (settings != null) this.settings = settings ?? new Settings();
this.settings = settings;
else {
this.settings = new Settings();
}
} }
private void Add(IGroup group) { private void Add(IGroup group) {
@ -141,7 +137,7 @@ namespace OpenHardwareMonitor.Hardware {
writer.WriteLine(); writer.WriteLine();
} }
private int CompareSensor(ISensor a, ISensor b) { private static int CompareSensor(ISensor a, ISensor b) {
int c = a.SensorType.CompareTo(b.SensorType); int c = a.SensorType.CompareTo(b.SensorType);
if (c == 0) if (c == 0)
return a.Index.CompareTo(b.Index); return a.Index.CompareTo(b.Index);
@ -149,13 +145,14 @@ namespace OpenHardwareMonitor.Hardware {
return c; return c;
} }
private void ReportHardwareSensorTree(IHardware hardware, TextWriter w, private static void ReportHardwareSensorTree(
string space) { IHardware hardware, TextWriter w, string space)
{
w.WriteLine("{0}|", space); w.WriteLine("{0}|", space);
w.WriteLine("{0}+-+ {1} ({2})", w.WriteLine("{0}+-+ {1} ({2})",
space, hardware.Name, hardware.Identifier); space, hardware.Name, hardware.Identifier);
ISensor[] sensors = hardware.Sensors; ISensor[] sensors = hardware.Sensors;
Array.Sort<ISensor>(sensors, CompareSensor); Array.Sort(sensors, CompareSensor);
foreach (ISensor sensor in sensors) { foreach (ISensor sensor in sensors) {
w.WriteLine("{0}| +- {1}[{2}] : {3} : {4}", w.WriteLine("{0}| +- {1}[{2}] : {3} : {4}",
space, sensor.SensorType, sensor.Index, space, sensor.SensorType, sensor.Index,
@ -166,13 +163,14 @@ namespace OpenHardwareMonitor.Hardware {
ReportHardwareSensorTree(subHardware, w, "| "); ReportHardwareSensorTree(subHardware, w, "| ");
} }
private void ReportHardwareParameterTree(IHardware hardware, TextWriter w, private static void ReportHardwareParameterTree(
string space) { IHardware hardware, TextWriter w, string space)
{
w.WriteLine("{0}|", space); w.WriteLine("{0}|", space);
w.WriteLine("{0}+-+ {1} ({2})", w.WriteLine("{0}+-+ {1} ({2})",
space, hardware.Name, hardware.Identifier); space, hardware.Name, hardware.Identifier);
ISensor[] sensors = hardware.Sensors; ISensor[] sensors = hardware.Sensors;
Array.Sort<ISensor>(sensors, CompareSensor); Array.Sort(sensors, CompareSensor);
foreach (ISensor sensor in sensors) { foreach (ISensor sensor in sensors) {
if (sensor.Parameters.Length > 0) { if (sensor.Parameters.Length > 0) {
w.WriteLine("{0}| +- {1}[{2}] : {3}", w.WriteLine("{0}| +- {1}[{2}] : {3}",
@ -189,7 +187,7 @@ namespace OpenHardwareMonitor.Hardware {
ReportHardwareParameterTree(subHardware, w, "| "); ReportHardwareParameterTree(subHardware, w, "| ");
} }
private void ReportHardware(IHardware hardware, TextWriter w) { private static void ReportHardware(IHardware hardware, TextWriter w) {
string hardwareReport = hardware.GetReport(); string hardwareReport = hardware.GetReport();
if (!string.IsNullOrEmpty(hardwareReport)) { if (!string.IsNullOrEmpty(hardwareReport)) {
NewSection(w); NewSection(w);

View File

@ -36,7 +36,6 @@
*/ */
using System; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
namespace OpenHardwareMonitor.Hardware.HDD { namespace OpenHardwareMonitor.Hardware.HDD {
@ -44,11 +43,11 @@ namespace OpenHardwareMonitor.Hardware.HDD {
private const int UPDATE_DIVIDER = 30; // update only every 30s private const int UPDATE_DIVIDER = 30; // update only every 30s
private string name; private readonly string name;
private IntPtr handle; private readonly IntPtr handle;
private int drive; private readonly int drive;
private int attribute; private readonly int attribute;
private Sensor temperature; private readonly Sensor temperature;
private int count; private int count;

View File

@ -43,11 +43,11 @@ namespace OpenHardwareMonitor.Hardware.HDD {
private const int MAX_DRIVES = 32; private const int MAX_DRIVES = 32;
private List<HDD> hardware = new List<HDD>(); private readonly List<HDD> hardware = new List<HDD>();
public HDDGroup(ISettings settings) { public HDDGroup(ISettings settings) {
int p = (int)System.Environment.OSVersion.Platform; int p = (int)Environment.OSVersion.Platform;
if ((p != 4) && (p != 128)) { if ((p != 4) && (p != 128)) {
for (int drive = 0; drive < MAX_DRIVES; drive++) { for (int drive = 0; drive < MAX_DRIVES; drive++) {
IntPtr handle = SMART.OpenPhysicalDrive(drive); IntPtr handle = SMART.OpenPhysicalDrive(drive);

View File

@ -36,7 +36,6 @@
*/ */
using System; using System;
using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace OpenHardwareMonitor.Hardware.HDD { namespace OpenHardwareMonitor.Hardware.HDD {
@ -90,7 +89,7 @@ namespace OpenHardwareMonitor.Hardware.HDD {
}; };
[Flags] [Flags]
private enum AccessMode : uint { protected enum AccessMode : uint {
Read = 0x80000000, Read = 0x80000000,
Write = 0x40000000, Write = 0x40000000,
Execute = 0x20000000, Execute = 0x20000000,
@ -98,14 +97,14 @@ namespace OpenHardwareMonitor.Hardware.HDD {
} }
[Flags] [Flags]
private enum ShareMode : uint { protected enum ShareMode : uint {
None = 0, None = 0,
Read = 1, Read = 1,
Write = 2, Write = 2,
Delete = 4 Delete = 4
} }
private enum CreationMode : uint { protected enum CreationMode : uint {
New = 1, New = 1,
CreateAlways = 2, CreateAlways = 2,
OpenExisting = 3, OpenExisting = 3,
@ -114,7 +113,7 @@ namespace OpenHardwareMonitor.Hardware.HDD {
} }
[Flags] [Flags]
private enum FileAttribute : uint { protected enum FileAttribute : uint {
Readonly = 0x00000001, Readonly = 0x00000001,
Hidden = 0x00000002, Hidden = 0x00000002,
System = 0x00000004, System = 0x00000004,
@ -131,14 +130,14 @@ namespace OpenHardwareMonitor.Hardware.HDD {
Encrypted = 0x00004000, Encrypted = 0x00004000,
} }
private enum DriveCommand : uint { protected enum DriveCommand : uint {
GetVersion = 0x00074080, GetVersion = 0x00074080,
SendDriveCommand = 0x0007c084, SendDriveCommand = 0x0007c084,
ReceiveDriveData = 0x0007c088 ReceiveDriveData = 0x0007c088
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
private struct CommandBlockRegisters { protected struct CommandBlockRegisters {
public byte Features; public byte Features;
public byte SectorCount; public byte SectorCount;
public byte LBALow; public byte LBALow;
@ -150,8 +149,8 @@ namespace OpenHardwareMonitor.Hardware.HDD {
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
private struct DriveCommandParameter { protected struct DriveCommandParameter {
private uint BufferSize; public uint BufferSize;
public CommandBlockRegisters Registers; public CommandBlockRegisters Registers;
public byte DriveNumber; public byte DriveNumber;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
@ -159,7 +158,7 @@ namespace OpenHardwareMonitor.Hardware.HDD {
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
private struct DriverStatus { protected struct DriverStatus {
public byte DriverError; public byte DriverError;
public byte IDEError; public byte IDEError;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
@ -167,13 +166,13 @@ namespace OpenHardwareMonitor.Hardware.HDD {
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
private struct DriveCommandResult { protected struct DriveCommandResult {
public uint BufferSize; public uint BufferSize;
public DriverStatus DriverStatus; public DriverStatus DriverStatus;
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
private struct DriveSmartReadResult { protected struct DriveSmartReadResult {
public uint BufferSize; public uint BufferSize;
public DriverStatus DriverStatus; public DriverStatus DriverStatus;
public byte Version; public byte Version;
@ -183,7 +182,7 @@ namespace OpenHardwareMonitor.Hardware.HDD {
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
private struct Identify { protected struct Identify {
public ushort GeneralConfiguration; public ushort GeneralConfiguration;
public ushort NumberOfCylinders; public ushort NumberOfCylinders;
public ushort Reserved; public ushort Reserved;
@ -213,7 +212,7 @@ namespace OpenHardwareMonitor.Hardware.HDD {
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
private struct DriveIdentifyResult { protected struct DriveIdentifyResult {
public uint BufferSize; public uint BufferSize;
public DriverStatus DriverStatus; public DriverStatus DriverStatus;
public Identify Identify; public Identify Identify;
@ -312,7 +311,7 @@ namespace OpenHardwareMonitor.Hardware.HDD {
return NativeMethods.CloseHandle(handle); return NativeMethods.CloseHandle(handle);
} }
private static class NativeMethods { protected static class NativeMethods {
private const string KERNEL = "kernel32.dll"; private const string KERNEL = "kernel32.dll";
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi, [DllImport(KERNEL, CallingConvention = CallingConvention.Winapi,

View File

@ -41,7 +41,7 @@ using OpenHardwareMonitor.Collections;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {
internal abstract class Hardware : IHardware { internal abstract class Hardware : IHardware {
private ListSet<ISensor> active = new ListSet<ISensor>(); private readonly ListSet<ISensor> active = new ListSet<ISensor>();
public IHardware[] SubHardware { public IHardware[] SubHardware {
get { return new IHardware[0]; } get { return new IHardware[0]; }

View File

@ -46,22 +46,22 @@ using System.Threading;
namespace OpenHardwareMonitor.Hardware.Heatmaster { namespace OpenHardwareMonitor.Hardware.Heatmaster {
internal class Heatmaster : Hardware, IDisposable { internal class Heatmaster : Hardware, IDisposable {
private string portName; private readonly string portName;
private SerialPort serialPort; private SerialPort serialPort;
private int hardwareRevision; private readonly int hardwareRevision;
private int firmwareRevision; private readonly int firmwareRevision;
private int firmwareCRC; private readonly int firmwareCRC;
private Sensor[] fans; private readonly Sensor[] fans;
private Sensor[] controls; private readonly Sensor[] controls;
private Sensor[] temperatures; private readonly Sensor[] temperatures;
private Sensor[] flows; private readonly Sensor[] flows;
private Sensor[] relays; private readonly Sensor[] relays;
private bool available = false; private readonly bool available;
private StringBuilder buffer = new StringBuilder(); private readonly StringBuilder buffer = new StringBuilder();
private string ReadLine(int timeout) { private string ReadLine(int timeout) {
int i = 0; int i = 0;
@ -94,7 +94,7 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
return null; return null;
} }
private string ReadString(int device, char field) { protected string ReadString(int device, char field) {
string s = ReadField(device, field); string s = ReadField(device, field);
if (s != null && s[0] == '"' && s[s.Length - 1] == '"') if (s != null && s[0] == '"' && s[s.Length - 1] == '"')
return s.Substring(1, s.Length - 2); return s.Substring(1, s.Length - 2);
@ -102,7 +102,7 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
return null; return null;
} }
private int ReadInteger(int device, char field) { protected int ReadInteger(int device, char field) {
string s = ReadField(device, field); string s = ReadField(device, field);
int i; int i;
if (int.TryParse(s, out i)) if (int.TryParse(s, out i))
@ -125,12 +125,12 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
return false; return false;
} }
private bool WriteInteger(int device, char field, int value) { protected bool WriteInteger(int device, char field, int value) {
return WriteField(device, field, return WriteField(device, field,
value.ToString(CultureInfo.InvariantCulture)); value.ToString(CultureInfo.InvariantCulture));
} }
private bool WriteString(int device, char field, string value) { protected bool WriteString(int device, char field, string value) {
return WriteField(device, field, '"' + value + '"'); return WriteField(device, field, '"' + value + '"');
} }
@ -166,14 +166,6 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
ActivateSensor(controls[i]); ActivateSensor(controls[i]);
} }
for (int i = 0; i < fanCount; i++) {
int device = 33 + i;
string name = ReadString(device, 'C');
fans[i].Value = ReadInteger(device, 'R');
ActivateSensor(fans[i]);
}
temperatures = new Sensor[temperatureCount]; temperatures = new Sensor[temperatureCount];
for (int i = 0; i < temperatureCount; i++) { for (int i = 0; i < temperatureCount; i++) {
int device = 49 + i; int device = 49 + i;
@ -220,7 +212,7 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
public override Identifier Identifier { public override Identifier Identifier {
get { get {
return new Identifier("heatmaster", return new Identifier("heatmaster",
serialPort.PortName.TrimStart(new char[]{'/'}).ToLowerInvariant()); serialPort.PortName.TrimStart(new [] {'/'}).ToLowerInvariant());
} }
} }

View File

@ -47,8 +47,8 @@ using Microsoft.Win32;
namespace OpenHardwareMonitor.Hardware.Heatmaster { namespace OpenHardwareMonitor.Hardware.Heatmaster {
internal class HeatmasterGroup : IGroup { internal class HeatmasterGroup : IGroup {
private List<Heatmaster> hardware = new List<Heatmaster>(); private readonly List<Heatmaster> hardware = new List<Heatmaster>();
private StringBuilder report = new StringBuilder(); private readonly StringBuilder report = new StringBuilder();
private static string ReadLine(SerialPort port, int timeout) { private static string ReadLine(SerialPort port, int timeout) {
int i = 0; int i = 0;
@ -82,7 +82,7 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
if (subKey != null) { if (subKey != null) {
string name = subKey.GetValue("PortName") as string; string name = subKey.GetValue("PortName") as string;
if (name != null && !result.Contains(name)) if (name != null && !result.Contains(name))
result.Add((string)name); result.Add(name);
} }
} }
} }
@ -94,7 +94,7 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
public HeatmasterGroup(ISettings settings) { public HeatmasterGroup(ISettings settings) {
// No implementation for Heatmaster on Unix systems // No implementation for Heatmaster on Unix systems
int p = (int)System.Environment.OSVersion.Platform; int p = (int)Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) if ((p == 4) || (p == 128))
return; return;

View File

@ -41,7 +41,7 @@ using System.Collections.Generic;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {
internal class HexStringArray { internal class HexStringArray {
private byte[] array; private readonly byte[] array;
public HexStringArray(string input) { public HexStringArray(string input) {
List<byte> list = new List<byte>(); List<byte> list = new List<byte>();

View File

@ -52,8 +52,8 @@ namespace OpenHardwareMonitor.Hardware {
} }
public struct SensorValue { public struct SensorValue {
private float value; private readonly float value;
private DateTime time; private readonly DateTime time;
public SensorValue(float value, DateTime time) { public SensorValue(float value, DateTime time) {
this.value = value; this.value = value;

View File

@ -36,17 +36,18 @@
*/ */
using System; using System;
using System.Collections.Generic;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {
public class Identifier : IComparable<Identifier> { public class Identifier : IComparable<Identifier> {
private string identifier; private readonly string identifier;
private static char SEPARATOR = '/'; private const char Separator = '/';
private static void CheckIdentifiers(string[] identifiers) { private static void CheckIdentifiers(IEnumerable<string> identifiers) {
foreach (string s in identifiers) foreach (string s in identifiers)
if (s.Contains(" ") || s.Contains(SEPARATOR.ToString())) if (s.Contains(" ") || s.Contains(Separator.ToString()))
throw new ArgumentException("Invalid identifier"); throw new ArgumentException("Invalid identifier");
} }
@ -55,7 +56,7 @@ namespace OpenHardwareMonitor.Hardware {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
for (int i = 0; i < identifiers.Length; i++) { for (int i = 0; i < identifiers.Length; i++) {
s.Append(SEPARATOR); s.Append(Separator);
s.Append(identifiers[i]); s.Append(identifiers[i]);
} }
this.identifier = s.ToString(); this.identifier = s.ToString();
@ -67,7 +68,7 @@ namespace OpenHardwareMonitor.Hardware {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
s.Append(identifier.ToString()); s.Append(identifier.ToString());
for (int i = 0; i < extensions.Length; i++) { for (int i = 0; i < extensions.Length; i++) {
s.Append(SEPARATOR); s.Append(Separator);
s.Append(extensions[i]); s.Append(extensions[i]);
} }
this.identifier = s.ToString(); this.identifier = s.ToString();
@ -77,7 +78,7 @@ namespace OpenHardwareMonitor.Hardware {
return identifier; return identifier;
} }
public override bool Equals(System.Object obj) { public override bool Equals(Object obj) {
if (obj == null) if (obj == null)
return false; return false;

View File

@ -35,20 +35,18 @@
*/ */
using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware.LPC { namespace OpenHardwareMonitor.Hardware.LPC {
internal class F718XX : ISuperIO { internal class F718XX : ISuperIO {
private ushort address; private readonly ushort address;
private Chip chip; private readonly Chip chip;
private float?[] voltages; private readonly float?[] voltages;
private float?[] temperatures; private readonly float?[] temperatures;
private float?[] fans; private readonly float?[] fans;
// Hardware Monitor // Hardware Monitor
private const byte ADDRESS_REGISTER_OFFSET = 0x05; private const byte ADDRESS_REGISTER_OFFSET = 0x05;
@ -58,7 +56,8 @@ namespace OpenHardwareMonitor.Hardware.LPC {
private const byte VOLTAGE_BASE_REG = 0x20; private const byte VOLTAGE_BASE_REG = 0x20;
private const byte TEMPERATURE_CONFIG_REG = 0x69; private const byte TEMPERATURE_CONFIG_REG = 0x69;
private const byte TEMPERATURE_BASE_REG = 0x70; private const byte TEMPERATURE_BASE_REG = 0x70;
private byte[] FAN_TACHOMETER_REG = new byte[] { 0xA0, 0xB0, 0xC0, 0xD0 }; private readonly byte[] FAN_TACHOMETER_REG =
new byte[] { 0xA0, 0xB0, 0xC0, 0xD0 };
private byte ReadByte(byte register) { private byte ReadByte(byte register) {
WinRing0.WriteIoPortByte( WinRing0.WriteIoPortByte(
@ -126,7 +125,7 @@ namespace OpenHardwareMonitor.Hardware.LPC {
for (int i = 0; i < temperatures.Length; i++) { for (int i = 0; i < temperatures.Length; i++) {
switch (chip) { switch (chip) {
case Chip.F71858: { case Chip.F71858: {
int tableMode = 0x3 & ReadByte((byte)(TEMPERATURE_CONFIG_REG)); int tableMode = 0x3 & ReadByte(TEMPERATURE_CONFIG_REG);
int high = int high =
ReadByte((byte)(TEMPERATURE_BASE_REG + 2 * i)); ReadByte((byte)(TEMPERATURE_BASE_REG + 2 * i));
int low = int low =

View File

@ -41,16 +41,16 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.LPC { namespace OpenHardwareMonitor.Hardware.LPC {
internal class IT87XX : ISuperIO { internal class IT87XX : ISuperIO {
private ushort address; private readonly ushort address;
private Chip chip; private readonly Chip chip;
private byte version; private readonly byte version;
private readonly ushort addressReg; private readonly ushort addressReg;
private readonly ushort dataReg; private readonly ushort dataReg;
private float?[] voltages = new float?[0]; private readonly float?[] voltages = new float?[0];
private float?[] temperatures = new float?[0]; private readonly float?[] temperatures = new float?[0];
private float?[] fans = new float?[0]; private readonly float?[] fans = new float?[0];
private readonly float voltageGain; private readonly float voltageGain;
@ -66,9 +66,9 @@ namespace OpenHardwareMonitor.Hardware.LPC {
private const byte TEMPERATURE_BASE_REG = 0x29; private const byte TEMPERATURE_BASE_REG = 0x29;
private const byte VENDOR_ID_REGISTER = 0x58; private const byte VENDOR_ID_REGISTER = 0x58;
private const byte FAN_TACHOMETER_16_BIT_ENABLE_REGISTER = 0x0c; private const byte FAN_TACHOMETER_16_BIT_ENABLE_REGISTER = 0x0c;
private byte[] FAN_TACHOMETER_REG = private readonly byte[] FAN_TACHOMETER_REG =
new byte[] { 0x0d, 0x0e, 0x0f, 0x80, 0x82 }; new byte[] { 0x0d, 0x0e, 0x0f, 0x80, 0x82 };
private byte[] FAN_TACHOMETER_EXT_REG = private readonly byte[] FAN_TACHOMETER_EXT_REG =
new byte[] { 0x18, 0x19, 0x1a, 0x81, 0x83 }; new byte[] { 0x18, 0x19, 0x1a, 0x81, 0x83 };
private const byte VOLTAGE_BASE_REG = 0x20; private const byte VOLTAGE_BASE_REG = 0x20;
@ -143,10 +143,8 @@ namespace OpenHardwareMonitor.Hardware.LPC {
r.Append(" "); r.Append(" ");
bool valid; bool valid;
byte value = ReadByte((byte)((i << 4) | j), out valid); byte value = ReadByte((byte)((i << 4) | j), out valid);
if (valid) r.Append(
r.Append(value.ToString("X2", CultureInfo.InvariantCulture)); valid ? value.ToString("X2", CultureInfo.InvariantCulture) : "??");
else
r.Append("??");
} }
r.AppendLine(); r.AppendLine();
} }

View File

@ -43,7 +43,7 @@ namespace OpenHardwareMonitor.Hardware.LPC {
internal class LMSensors { internal class LMSensors {
private List<LMChip> lmChips = new List<LMChip>(); private readonly List<LMChip> lmChips = new List<LMChip>();
public LMSensors() { public LMSensors() {
string[] devicePaths = Directory.GetDirectories("/sys/class/hwmon/"); string[] devicePaths = Directory.GetDirectories("/sys/class/hwmon/");
@ -102,15 +102,15 @@ namespace OpenHardwareMonitor.Hardware.LPC {
private class LMChip : ISuperIO { private class LMChip : ISuperIO {
private string path; private string path;
private Chip chip; private readonly Chip chip;
private float?[] voltages; private readonly float?[] voltages;
private float?[] temperatures; private readonly float?[] temperatures;
private float?[] fans; private readonly float?[] fans;
private StreamReader[] voltageReaders; private readonly StreamReader[] voltageReaders;
private StreamReader[] temperatureReaders; private readonly StreamReader[] temperatureReaders;
private StreamReader[] fanReaders; private readonly StreamReader[] fanReaders;
public Chip Chip { get { return chip; } } public Chip Chip { get { return chip; } }
public float?[] Voltages { get { return voltages; } } public float?[] Voltages { get { return voltages; } }

View File

@ -44,12 +44,12 @@ using System.Threading;
namespace OpenHardwareMonitor.Hardware.LPC { namespace OpenHardwareMonitor.Hardware.LPC {
internal class LPCIO { internal class LPCIO {
private List<ISuperIO> superIOs = new List<ISuperIO>(); private readonly List<ISuperIO> superIOs = new List<ISuperIO>();
private StringBuilder report = new StringBuilder(); private readonly StringBuilder report = new StringBuilder();
// I/O Ports // I/O Ports
private ushort[] REGISTER_PORTS = new ushort[] { 0x2E, 0x4E }; private readonly ushort[] REGISTER_PORTS = new ushort[] { 0x2E, 0x4E };
private ushort[] VALUE_PORTS = new ushort[] { 0x2F, 0x4F }; private readonly ushort[] VALUE_PORTS = new ushort[] { 0x2F, 0x4F };
private ushort registerPort; private ushort registerPort;
private ushort valuePort; private ushort valuePort;
@ -110,11 +110,10 @@ namespace OpenHardwareMonitor.Hardware.LPC {
private bool DetectWinbondFintek() { private bool DetectWinbondFintek() {
WinbondFintekEnter(); WinbondFintekEnter();
byte logicalDeviceNumber; byte logicalDeviceNumber = 0;
byte id = ReadByte(CHIP_ID_REGISTER); byte id = ReadByte(CHIP_ID_REGISTER);
byte revision = ReadByte(CHIP_REVISION_REGISTER); byte revision = ReadByte(CHIP_REVISION_REGISTER);
Chip chip = Chip.Unknown; Chip chip = Chip.Unknown;
logicalDeviceNumber = 0;
switch (id) { switch (id) {
case 0x05: case 0x05:
switch (revision) { switch (revision) {
@ -441,8 +440,7 @@ namespace OpenHardwareMonitor.Hardware.LPC {
public string GetReport() { public string GetReport() {
if (report.Length > 0) { if (report.Length > 0) {
return "LPCIO" + Environment.NewLine + Environment.NewLine + return "LPCIO" + Environment.NewLine + Environment.NewLine + report;
report.ToString();
} else } else
return null; return null;
} }

View File

@ -42,19 +42,19 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.LPC { namespace OpenHardwareMonitor.Hardware.LPC {
internal class W836XX : ISuperIO { internal class W836XX : ISuperIO {
private ushort address; private readonly ushort address;
private byte revision; private readonly byte revision;
private Chip chip; private readonly Chip chip;
private float?[] voltages = new float?[0]; private readonly float?[] voltages = new float?[0];
private float?[] temperatures = new float?[0]; private readonly float?[] temperatures = new float?[0];
private float?[] fans = new float?[0]; private readonly float?[] fans = new float?[0];
private bool[] peciTemperature = new bool[0]; private readonly bool[] peciTemperature = new bool[0];
private byte[] voltageRegister = new byte[0]; private readonly byte[] voltageRegister = new byte[0];
private byte[] voltageBank = new byte[0]; private readonly byte[] voltageBank = new byte[0];
private float voltageGain = 0.008f; private readonly float voltageGain = 0.008f;
// Consts // Consts
private const ushort WINBOND_VENDOR_ID = 0x5CA3; private const ushort WINBOND_VENDOR_ID = 0x5CA3;
@ -70,15 +70,18 @@ namespace OpenHardwareMonitor.Hardware.LPC {
private const byte VENDOR_ID_REGISTER = 0x4F; private const byte VENDOR_ID_REGISTER = 0x4F;
private const byte TEMPERATURE_SOURCE_SELECT_REG = 0x49; private const byte TEMPERATURE_SOURCE_SELECT_REG = 0x49;
private byte[] TEMPERATURE_REG = new byte[] { 0x50, 0x50, 0x27 }; private readonly byte[] TEMPERATURE_REG = new byte[] { 0x50, 0x50, 0x27 };
private byte[] TEMPERATURE_BANK = new byte[] { 1, 2, 0 }; private readonly byte[] TEMPERATURE_BANK = new byte[] { 1, 2, 0 };
private byte[] FAN_TACHO_REG = new byte[] { 0x28, 0x29, 0x2A, 0x3F, 0x53 }; private readonly byte[] FAN_TACHO_REG =
private byte[] FAN_TACHO_BANK = new byte[] { 0, 0, 0, 0, 5 }; new byte[] { 0x28, 0x29, 0x2A, 0x3F, 0x53 };
private byte[] FAN_BIT_REG = new byte[] { 0x47, 0x4B, 0x4C, 0x59, 0x5D }; private readonly byte[] FAN_TACHO_BANK =
private byte[] FAN_DIV_BIT0 = new byte[] { 36, 38, 30, 8, 10 }; new byte[] { 0, 0, 0, 0, 5 };
private byte[] FAN_DIV_BIT1 = new byte[] { 37, 39, 31, 9, 11 }; private readonly byte[] FAN_BIT_REG =
private byte[] FAN_DIV_BIT2 = new byte[] { 5, 6, 7, 23, 15 }; new byte[] { 0x47, 0x4B, 0x4C, 0x59, 0x5D };
private readonly byte[] FAN_DIV_BIT0 = new byte[] { 36, 38, 30, 8, 10 };
private readonly byte[] FAN_DIV_BIT1 = new byte[] { 37, 39, 31, 9, 11 };
private readonly byte[] FAN_DIV_BIT2 = new byte[] { 5, 6, 7, 23, 15 };
private byte ReadByte(byte bank, byte register) { private byte ReadByte(byte bank, byte register) {
WinRing0.WriteIoPortByte( WinRing0.WriteIoPortByte(

View File

@ -41,12 +41,12 @@ using OpenHardwareMonitor.Hardware.LPC;
namespace OpenHardwareMonitor.Hardware.Mainboard { namespace OpenHardwareMonitor.Hardware.Mainboard {
internal class Mainboard : IHardware { internal class Mainboard : IHardware {
private SMBIOS smbios; private readonly SMBIOS smbios;
private string name; private readonly string name;
private LPCIO lpcio; private readonly LPCIO lpcio;
private LMSensors lmSensors; private readonly LMSensors lmSensors;
private IHardware[] superIOHardware; private readonly IHardware[] superIOHardware;
public Mainboard(ISettings settings) { public Mainboard(ISettings settings) {
this.smbios = new SMBIOS(); this.smbios = new SMBIOS();
@ -66,7 +66,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
} }
ISuperIO[] superIO; ISuperIO[] superIO;
int p = (int)System.Environment.OSVersion.Platform; int p = (int)Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) { if ((p == 4) || (p == 128)) {
this.lmSensors = new LMSensors(); this.lmSensors = new LMSensors();
superIO = lmSensors.SuperIO; superIO = lmSensors.SuperIO;

View File

@ -38,7 +38,7 @@
namespace OpenHardwareMonitor.Hardware.Mainboard { namespace OpenHardwareMonitor.Hardware.Mainboard {
internal class MainboardGroup : IGroup { internal class MainboardGroup : IGroup {
private Mainboard[] mainboards; private readonly Mainboard[] mainboards;
public MainboardGroup(ISettings settings) { public MainboardGroup(ISettings settings) {
mainboards = new Mainboard[1]; mainboards = new Mainboard[1];

View File

@ -45,11 +45,11 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
internal class SMBIOS { internal class SMBIOS {
private byte[] raw; private readonly byte[] raw;
private Structure[] table; private readonly Structure[] table;
private BIOSInformation biosInformation = null; private readonly BIOSInformation biosInformation;
private BaseBoardInformation baseBoardInformation = null; private readonly BaseBoardInformation baseBoardInformation;
private static string ReadSysFS(string path) { private static string ReadSysFS(string path) {
try { try {
@ -65,7 +65,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
} }
public SMBIOS() { public SMBIOS() {
int p = (int)System.Environment.OSVersion.Platform; int p = (int)Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) { if ((p == 4) || (p == 128)) {
this.raw = null; this.raw = null;
this.table = null; this.table = null;
@ -193,11 +193,11 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
} }
public class Structure { public class Structure {
private byte type; private readonly byte type;
private ushort handle; private readonly ushort handle;
private byte[] data; private readonly byte[] data;
private string[] strings; private readonly string[] strings;
protected string GetString(int offset) { protected string GetString(int offset) {
if (offset < data.Length && data[offset] > 0 && if (offset < data.Length && data[offset] > 0 &&
@ -222,8 +222,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
public class BIOSInformation : Structure { public class BIOSInformation : Structure {
private string vendor; private readonly string vendor;
private string version; private readonly string version;
public BIOSInformation(string vendor, string version) public BIOSInformation(string vendor, string version)
: base (0x00, 0, null, null) : base (0x00, 0, null, null)
@ -247,108 +247,104 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
public class BaseBoardInformation : Structure { public class BaseBoardInformation : Structure {
private string manufacturerName; private readonly string manufacturerName;
private string productName; private readonly string productName;
private string version; private readonly string version;
private string serialNumber; private readonly string serialNumber;
private Manufacturer manufacturer; private readonly Manufacturer manufacturer;
private Model model; private readonly Model model;
private void SetManufacturerName(string name) {
this.manufacturerName = name;
private static Manufacturer GetManufacturer(string name) {
switch (name) { switch (name) {
case "ASRock": case "ASRock":
manufacturer = Manufacturer.ASRock; break; return Manufacturer.ASRock;
case "ASUSTeK Computer INC.": case "ASUSTeK Computer INC.":
manufacturer = Manufacturer.ASUS; break; return Manufacturer.ASUS;
case "Dell Inc.": case "Dell Inc.":
manufacturer = Manufacturer.Dell; break; return Manufacturer.Dell;
case "DFI": case "DFI":
case "DFI Inc.": case "DFI Inc.":
manufacturer = Manufacturer.DFI; break; return Manufacturer.DFI;
case "ECS": case "ECS":
manufacturer = Manufacturer.ECS; break; return Manufacturer.ECS;
case "EPoX COMPUTER CO., LTD": case "EPoX COMPUTER CO., LTD":
manufacturer = Manufacturer.EPoX; break; return Manufacturer.EPoX;
case "EVGA": case "EVGA":
manufacturer = Manufacturer.EVGA; break; return Manufacturer.EVGA;
case "First International Computer, Inc.": case "First International Computer, Inc.":
manufacturer = Manufacturer.FIC; break; return Manufacturer.FIC;
case "Gigabyte Technology Co., Ltd.": case "Gigabyte Technology Co., Ltd.":
manufacturer = Manufacturer.Gigabyte; break; return Manufacturer.Gigabyte;
case "Hewlett-Packard": case "Hewlett-Packard":
manufacturer = Manufacturer.HP; break; return Manufacturer.HP;
case "IBM": case "IBM":
manufacturer = Manufacturer.IBM; break; return Manufacturer.IBM;
case "MICRO-STAR INTERNATIONAL CO., LTD": case "MICRO-STAR INTERNATIONAL CO., LTD":
case "MICRO-STAR INTERNATIONAL CO.,LTD": case "MICRO-STAR INTERNATIONAL CO.,LTD":
manufacturer = Manufacturer.MSI; break; return Manufacturer.MSI;
case "XFX": case "XFX":
manufacturer = Manufacturer.XFX; break; return Manufacturer.XFX;
case "To be filled by O.E.M.": case "To be filled by O.E.M.":
manufacturer = Manufacturer.Unknown; break; return Manufacturer.Unknown;
default: default:
manufacturer = Manufacturer.Unknown; break; return Manufacturer.Unknown;
} }
} }
private void SetProductName(string name) { private static Model GetModel(string name) {
this.productName = name;
switch (name) { switch (name) {
case "880GMH/USB3": case "880GMH/USB3":
model = Model._880GMH_USB3; break; return Model._880GMH_USB3;
case "Crosshair III Formula": case "Crosshair III Formula":
model = Model.Crosshair_III_Formula; break; return Model.Crosshair_III_Formula;
case "M2N-SLI DELUXE": case "M2N-SLI DELUXE":
model = Model.M2N_SLI_DELUXE; break; return Model.M2N_SLI_DELUXE;
case "M4A79XTD EVO": case "M4A79XTD EVO":
model = Model.M4A79XTD_EVO; break; return Model.M4A79XTD_EVO;
case "P5W DH Deluxe": case "P5W DH Deluxe":
model = Model.P5W_DH_Deluxe; break; return Model.P5W_DH_Deluxe;
case "P6X58D-E": case "P6X58D-E":
model = Model.P6X58D_E; break; return Model.P6X58D_E;
case "Rampage Extreme": case "Rampage Extreme":
model = Model.Rampage_Extreme; break; return Model.Rampage_Extreme;
case "Rampage II GENE": case "Rampage II GENE":
model = Model.Rampage_II_GENE; break; return Model.Rampage_II_GENE;
case "LP BI P45-T2RS Elite": case "LP BI P45-T2RS Elite":
model = Model.LP_BI_P45_T2RS_Elite; break; return Model.LP_BI_P45_T2RS_Elite;
case "LP DK P55-T3eH9": case "LP DK P55-T3eH9":
model = Model.LP_DK_P55_T3eH9; break; return Model.LP_DK_P55_T3eH9;
case "A890GXM-A": case "A890GXM-A":
model = Model.A890GXM_A; break; return Model.A890GXM_A;
case "X58 SLI Classified": case "X58 SLI Classified":
model = Model.X58_SLI_Classified; break; return Model.X58_SLI_Classified;
case "965P-S3": case "965P-S3":
model = Model._965P_S3; break; return Model._965P_S3;
case "EP45-DS3R": case "EP45-DS3R":
model = Model.EP45_DS3R; break; return Model.EP45_DS3R;
case "EP45-UD3R": case "EP45-UD3R":
model = Model.EP45_UD3R; break; return Model.EP45_UD3R;
case "EX58-EXTREME": case "EX58-EXTREME":
model = Model.EX58_EXTREME; break; return Model.EX58_EXTREME;
case "GA-MA770T-UD3": case "GA-MA770T-UD3":
model = Model.GA_MA770T_UD3; break; return Model.GA_MA770T_UD3;
case "GA-MA785GMT-UD2H": case "GA-MA785GMT-UD2H":
model = Model.GA_MA785GMT_UD2H; break; return Model.GA_MA785GMT_UD2H;
case "P35-DS3": case "P35-DS3":
model = Model.P35_DS3; break; return Model.P35_DS3;
case "P35-DS3L": case "P35-DS3L":
model = Model.P35_DS3L; break; return Model.P35_DS3L;
case "P55-UD4": case "P55-UD4":
model = Model.P55_UD4; break; return Model.P55_UD4;
case "P55M-UD4": case "P55M-UD4":
model = Model.P55M_UD4; break; return Model.P55M_UD4;
case "X38-DS5": case "X38-DS5":
model = Model.X38_DS5; break; return Model.X38_DS5;
case "X58A-UD3R": case "X58A-UD3R":
model = Model.X58A_UD3R; break; return Model.X58A_UD3R;
case "To be filled by O.E.M.": case "To be filled by O.E.M.":
model = Model.Unknown; break; return Model.Unknown;
default: default:
model = Model.Unknown; break; return Model.Unknown;
} }
} }
@ -356,8 +352,10 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
string version, string serialNumber) string version, string serialNumber)
: base(0x02, 0, null, null) : base(0x02, 0, null, null)
{ {
SetManufacturerName(manufacturerName); this.manufacturerName = manufacturerName;
SetProductName(productName); this.manufacturer = GetManufacturer(manufacturerName);
this.productName = productName;
this.model = GetModel(productName);
this.version = version; this.version = version;
this.serialNumber = serialNumber; this.serialNumber = serialNumber;
} }
@ -366,8 +364,10 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
string[] strings) string[] strings)
: base(type, handle, data, strings) { : base(type, handle, data, strings) {
SetManufacturerName(GetString(0x04).Trim()); this.manufacturerName = GetString(0x04).Trim();
SetProductName(GetString(0x05).Trim()); this.manufacturer = GetManufacturer(this.manufacturerName);
this.productName = GetString(0x05).Trim();
this.model = GetModel(this.productName);
this.version = GetString(0x06).Trim(); this.version = GetString(0x06).Trim();
this.serialNumber = GetString(0x07).Trim(); this.serialNumber = GetString(0x07).Trim();
} }

View File

@ -42,13 +42,13 @@ using OpenHardwareMonitor.Hardware.LPC;
namespace OpenHardwareMonitor.Hardware.Mainboard { namespace OpenHardwareMonitor.Hardware.Mainboard {
internal class SuperIOHardware : Hardware { internal class SuperIOHardware : Hardware {
private Mainboard mainboard; private readonly Mainboard mainboard;
private ISuperIO superIO; private readonly ISuperIO superIO;
private string name; private readonly string name;
private List<Sensor> voltages = new List<Sensor>(); private readonly List<Sensor> voltages = new List<Sensor>();
private List<Sensor> temperatures = new List<Sensor>(); private readonly List<Sensor> temperatures = new List<Sensor>();
private List<Sensor> fans = new List<Sensor>(); private readonly List<Sensor> fans = new List<Sensor>();
public SuperIOHardware(Mainboard mainboard, ISuperIO superIO, public SuperIOHardware(Mainboard mainboard, ISuperIO superIO,
@ -80,9 +80,9 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
case Model.M2N_SLI_DELUXE: case Model.M2N_SLI_DELUXE:
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("+3.3V", 1)); v.Add(new Voltage("+3.3V", 1));
v.Add(new Voltage("+5V", 3, 6.8f, 10, 0)); v.Add(new Voltage("+5V", 3, 6.8f, 10));
v.Add(new Voltage("+12V", 4, 30, 10, 0)); v.Add(new Voltage("+12V", 4, 30, 10));
v.Add(new Voltage("+5VSB", 7, 6.8f, 10, 0)); v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
v.Add(new Voltage("VBat", 8)); v.Add(new Voltage("VBat", 8));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("Motherboard", 1)); t.Add(new Temperature("Motherboard", 1));
@ -91,7 +91,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
f.Add(new Fan("Power Fan", 2)); f.Add(new Fan("Power Fan", 2));
break; break;
case Model.M4A79XTD_EVO: // IT8720F case Model.M4A79XTD_EVO: // IT8720F
v.Add(new Voltage("+5V", 3, 6.8f, 10, 0)); v.Add(new Voltage("+5V", 3, 6.8f, 10));
v.Add(new Voltage("VBat", 8)); v.Add(new Voltage("VBat", 8));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("Motherboard", 1)); t.Add(new Temperature("Motherboard", 1));
@ -122,11 +122,11 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("FSB VTT", 1)); v.Add(new Voltage("FSB VTT", 1));
v.Add(new Voltage("+3.3V", 2)); v.Add(new Voltage("+3.3V", 2));
v.Add(new Voltage("+5V", 3, 6.8f, 10, 0)); v.Add(new Voltage("+5V", 3, 6.8f, 10));
v.Add(new Voltage("+12V", 4, 30, 10, 0)); v.Add(new Voltage("+12V", 4, 30, 10));
v.Add(new Voltage("NB Core", 5)); v.Add(new Voltage("NB Core", 5));
v.Add(new Voltage("VDIMM", 6)); v.Add(new Voltage("VDIMM", 6));
v.Add(new Voltage("+5VSB", 7, 6.8f, 10, 0)); v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
v.Add(new Voltage("VBat", 8)); v.Add(new Voltage("VBat", 8));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("System", 1)); t.Add(new Temperature("System", 1));
@ -139,11 +139,11 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("VTT", 1)); v.Add(new Voltage("VTT", 1));
v.Add(new Voltage("+3.3V", 2)); v.Add(new Voltage("+3.3V", 2));
v.Add(new Voltage("+5V", 3, 6.8f, 10, 0)); v.Add(new Voltage("+5V", 3, 6.8f, 10));
v.Add(new Voltage("+12V", 4, 30, 10, 0)); v.Add(new Voltage("+12V", 4, 30, 10));
v.Add(new Voltage("CPU PLL", 5)); v.Add(new Voltage("CPU PLL", 5));
v.Add(new Voltage("DRAM", 6)); v.Add(new Voltage("DRAM", 6));
v.Add(new Voltage("+5VSB", 7, 6.8f, 10, 0)); v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
v.Add(new Voltage("VBat", 8)); v.Add(new Voltage("VBat", 8));
t.Add(new Temperature("Chipset", 0)); t.Add(new Temperature("Chipset", 0));
t.Add(new Temperature("CPU PWM", 1)); t.Add(new Temperature("CPU PWM", 1));
@ -176,8 +176,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("DRAM", 1)); v.Add(new Voltage("DRAM", 1));
v.Add(new Voltage("+3.3V", 2)); v.Add(new Voltage("+3.3V", 2));
v.Add(new Voltage("+5V", 3, 6.8f, 10, 0)); v.Add(new Voltage("+5V", 3, 6.8f, 10));
v.Add(new Voltage("+12V", 7, 27, 9.1f, 0)); v.Add(new Voltage("+12V", 7, 27, 9.1f));
v.Add(new Voltage("VBat", 8)); v.Add(new Voltage("VBat", 8));
t.Add(new Temperature("System", 0)); t.Add(new Temperature("System", 0));
t.Add(new Temperature("CPU", 1)); t.Add(new Temperature("CPU", 1));
@ -190,8 +190,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("DRAM", 1)); v.Add(new Voltage("DRAM", 1));
v.Add(new Voltage("+3.3V", 2)); v.Add(new Voltage("+3.3V", 2));
v.Add(new Voltage("+5V", 3, 6.8f, 10, 0)); v.Add(new Voltage("+5V", 3, 6.8f, 10));
v.Add(new Voltage("+12V", 7, 27, 9.1f, 0)); v.Add(new Voltage("+12V", 7, 27, 9.1f));
v.Add(new Voltage("VBat", 8)); v.Add(new Voltage("VBat", 8));
t.Add(new Temperature("System", 0)); t.Add(new Temperature("System", 0));
t.Add(new Temperature("CPU", 1)); t.Add(new Temperature("CPU", 1));
@ -203,7 +203,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
case Model.EX58_EXTREME: // IT8720F case Model.EX58_EXTREME: // IT8720F
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("DRAM", 1)); v.Add(new Voltage("DRAM", 1));
v.Add(new Voltage("+5V", 3, 6.8f, 10, 0)); v.Add(new Voltage("+5V", 3, 6.8f, 10));
v.Add(new Voltage("VBat", 8)); v.Add(new Voltage("VBat", 8));
t.Add(new Temperature("System", 0)); t.Add(new Temperature("System", 0));
t.Add(new Temperature("CPU", 1)); t.Add(new Temperature("CPU", 1));
@ -218,8 +218,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("DRAM", 1)); v.Add(new Voltage("DRAM", 1));
v.Add(new Voltage("+3.3V", 2)); v.Add(new Voltage("+3.3V", 2));
v.Add(new Voltage("+5V", 3, 6.8f, 10, 0)); v.Add(new Voltage("+5V", 3, 6.8f, 10));
v.Add(new Voltage("+12V", 7, 27, 9.1f, 0)); v.Add(new Voltage("+12V", 7, 27, 9.1f));
v.Add(new Voltage("VBat", 8)); v.Add(new Voltage("VBat", 8));
t.Add(new Temperature("System", 0)); t.Add(new Temperature("System", 0));
t.Add(new Temperature("CPU", 1)); t.Add(new Temperature("CPU", 1));
@ -233,8 +233,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("DRAM", 1)); v.Add(new Voltage("DRAM", 1));
v.Add(new Voltage("+3.3V", 2)); v.Add(new Voltage("+3.3V", 2));
v.Add(new Voltage("+5V", 3, 6.8f, 10, 0)); v.Add(new Voltage("+5V", 3, 6.8f, 10));
v.Add(new Voltage("+12V", 5, 27, 9.1f, 0)); v.Add(new Voltage("+12V", 5, 27, 9.1f));
v.Add(new Voltage("VBat", 8)); v.Add(new Voltage("VBat", 8));
t.Add(new Temperature("System", 0)); t.Add(new Temperature("System", 0));
t.Add(new Temperature("CPU", 2)); t.Add(new Temperature("CPU", 2));
@ -247,8 +247,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("DRAM", 1)); v.Add(new Voltage("DRAM", 1));
v.Add(new Voltage("+3.3V", 2)); v.Add(new Voltage("+3.3V", 2));
v.Add(new Voltage("+5V", 3, 6.8f, 10, 0)); v.Add(new Voltage("+5V", 3, 6.8f, 10));
v.Add(new Voltage("+12V", 4, 27, 9.1f, 0)); v.Add(new Voltage("+12V", 4, 27, 9.1f));
v.Add(new Voltage("VBat", 8)); v.Add(new Voltage("VBat", 8));
t.Add(new Temperature("System", 0)); t.Add(new Temperature("System", 0));
t.Add(new Temperature("CPU", 1)); t.Add(new Temperature("CPU", 1));
@ -261,8 +261,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("DRAM", 1)); v.Add(new Voltage("DRAM", 1));
v.Add(new Voltage("+3.3V", 2)); v.Add(new Voltage("+3.3V", 2));
v.Add(new Voltage("+5V", 3, 6.8f, 10, 0)); v.Add(new Voltage("+5V", 3, 6.8f, 10));
v.Add(new Voltage("+12V", 4, 27, 9.1f, 0)); v.Add(new Voltage("+12V", 4, 27, 9.1f));
v.Add(new Voltage("VBat", 8)); v.Add(new Voltage("VBat", 8));
t.Add(new Temperature("System", 0)); t.Add(new Temperature("System", 0));
t.Add(new Temperature("CPU", 1)); t.Add(new Temperature("CPU", 1));
@ -274,8 +274,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("DRAM", 1)); v.Add(new Voltage("DRAM", 1));
v.Add(new Voltage("+3.3V", 2)); v.Add(new Voltage("+3.3V", 2));
v.Add(new Voltage("+5V", 3, 6.8f, 10, 0)); v.Add(new Voltage("+5V", 3, 6.8f, 10));
v.Add(new Voltage("+12V", 5, 27, 9.1f, 0)); v.Add(new Voltage("+12V", 5, 27, 9.1f));
v.Add(new Voltage("VBat", 8)); v.Add(new Voltage("VBat", 8));
t.Add(new Temperature("System", 0)); t.Add(new Temperature("System", 0));
t.Add(new Temperature("CPU", 1)); t.Add(new Temperature("CPU", 1));
@ -329,10 +329,10 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("VDIMM", 1)); v.Add(new Voltage("VDIMM", 1));
v.Add(new Voltage("NB Voltage", 2)); v.Add(new Voltage("NB Voltage", 2));
v.Add(new Voltage("Analog +3.3V", 3, 10, 10, 0)); v.Add(new Voltage("Analog +3.3V", 3, 10, 10));
// v.Add(new Voltage("VDIMM", 6, true)); // v.Add(new Voltage("VDIMM", 6, true));
v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0)); v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
v.Add(new Voltage("VBat", 8, 10, 10, 0)); v.Add(new Voltage("VBat", 8, 10, 10));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("System", 1)); t.Add(new Temperature("System", 1));
t.Add(new Temperature("Northbridge", 2)); t.Add(new Temperature("Northbridge", 2));
@ -349,7 +349,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #6", 5, true));
v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("Voltage #7", 6, true));
v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true)); v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
v.Add(new Voltage("VBat", 8, 10, 10, 0)); v.Add(new Voltage("VBat", 8, 10, 10));
for (int i = 0; i < superIO.Temperatures.Length; i++) for (int i = 0; i < superIO.Temperatures.Length; i++)
t.Add(new Temperature("Temperature #" + (i + 1), i)); t.Add(new Temperature("Temperature #" + (i + 1), i));
for (int i = 0; i < superIO.Fans.Length; i++) for (int i = 0; i < superIO.Fans.Length; i++)
@ -366,7 +366,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #6", 5, true));
v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("Voltage #7", 6, true));
v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true)); v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
v.Add(new Voltage("VBat", 8, 10, 10, 0)); v.Add(new Voltage("VBat", 8, 10, 10));
for (int i = 0; i < superIO.Temperatures.Length; i++) for (int i = 0; i < superIO.Temperatures.Length; i++)
t.Add(new Temperature("Temperature #" + (i + 1), i)); t.Add(new Temperature("Temperature #" + (i + 1), i));
for (int i = 0; i < superIO.Fans.Length; i++) for (int i = 0; i < superIO.Fans.Length; i++)
@ -376,9 +376,9 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
break; break;
case Chip.F71858: case Chip.F71858:
v.Add(new Voltage("VCC3V", 0, 150, 150, 0)); v.Add(new Voltage("VCC3V", 0, 150, 150));
v.Add(new Voltage("VSB3V", 1, 150, 150, 0)); v.Add(new Voltage("VSB3V", 1, 150, 150));
v.Add(new Voltage("Battery", 2, 150, 150, 0)); v.Add(new Voltage("Battery", 2, 150, 150));
for (int i = 0; i < superIO.Temperatures.Length; i++) for (int i = 0; i < superIO.Temperatures.Length; i++)
t.Add(new Temperature("Temperature #" + (i + 1), i)); t.Add(new Temperature("Temperature #" + (i + 1), i));
for (int i = 0; i < superIO.Fans.Length; i++) for (int i = 0; i < superIO.Fans.Length; i++)
@ -393,15 +393,15 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
case Manufacturer.EVGA: case Manufacturer.EVGA:
switch (model) { switch (model) {
case Model.X58_SLI_Classified: // F71882 case Model.X58_SLI_Classified: // F71882
v.Add(new Voltage("VCC3V", 0, 150, 150, 0)); v.Add(new Voltage("VCC3V", 0, 150, 150));
v.Add(new Voltage("CPU VCore", 1, 47, 100, 0)); v.Add(new Voltage("CPU VCore", 1, 47, 100));
v.Add(new Voltage("DIMM", 2, 47, 100, 0)); v.Add(new Voltage("DIMM", 2, 47, 100));
v.Add(new Voltage("CPU VTT", 3, 24, 100, 0)); v.Add(new Voltage("CPU VTT", 3, 24, 100));
v.Add(new Voltage("IOH Vcore", 4, 24, 100, 0)); v.Add(new Voltage("IOH Vcore", 4, 24, 100));
v.Add(new Voltage("+5V", 5, 51, 12, 0)); v.Add(new Voltage("+5V", 5, 51, 12));
v.Add(new Voltage("+12V", 6, 56, 6.8f, 0)); v.Add(new Voltage("+12V", 6, 56, 6.8f));
v.Add(new Voltage("3VSB", 7, 150, 150, 0)); v.Add(new Voltage("3VSB", 7, 150, 150));
v.Add(new Voltage("VBat", 8, 150, 150, 0)); v.Add(new Voltage("VBat", 8, 150, 150));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("VREG", 1)); t.Add(new Temperature("VREG", 1));
t.Add(new Temperature("System", 2)); t.Add(new Temperature("System", 2));
@ -410,15 +410,15 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
f.Add(new Fan("Chassis Fan", 2)); f.Add(new Fan("Chassis Fan", 2));
break; break;
default: default:
v.Add(new Voltage("VCC3V", 0, 150, 150, 0)); v.Add(new Voltage("VCC3V", 0, 150, 150));
v.Add(new Voltage("CPU VCore", 1)); v.Add(new Voltage("CPU VCore", 1));
v.Add(new Voltage("Voltage #3", 2, true)); v.Add(new Voltage("Voltage #3", 2, true));
v.Add(new Voltage("Voltage #4", 3, true)); v.Add(new Voltage("Voltage #4", 3, true));
v.Add(new Voltage("Voltage #5", 4, true)); v.Add(new Voltage("Voltage #5", 4, true));
v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #6", 5, true));
v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("Voltage #7", 6, true));
v.Add(new Voltage("VSB3V", 7, 150, 150, 0)); v.Add(new Voltage("VSB3V", 7, 150, 150));
v.Add(new Voltage("VBat", 8, 150, 150, 0)); v.Add(new Voltage("VBat", 8, 150, 150));
for (int i = 0; i < superIO.Temperatures.Length; i++) for (int i = 0; i < superIO.Temperatures.Length; i++)
t.Add(new Temperature("Temperature #" + (i + 1), i)); t.Add(new Temperature("Temperature #" + (i + 1), i));
for (int i = 0; i < superIO.Fans.Length; i++) for (int i = 0; i < superIO.Fans.Length; i++)
@ -427,15 +427,15 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
} }
break; break;
default: default:
v.Add(new Voltage("VCC3V", 0, 150, 150, 0)); v.Add(new Voltage("VCC3V", 0, 150, 150));
v.Add(new Voltage("CPU VCore", 1)); v.Add(new Voltage("CPU VCore", 1));
v.Add(new Voltage("Voltage #3", 2, true)); v.Add(new Voltage("Voltage #3", 2, true));
v.Add(new Voltage("Voltage #4", 3, true)); v.Add(new Voltage("Voltage #4", 3, true));
v.Add(new Voltage("Voltage #5", 4, true)); v.Add(new Voltage("Voltage #5", 4, true));
v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #6", 5, true));
v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("Voltage #7", 6, true));
v.Add(new Voltage("VSB3V", 7, 150, 150, 0)); v.Add(new Voltage("VSB3V", 7, 150, 150));
v.Add(new Voltage("VBat", 8, 150, 150, 0)); v.Add(new Voltage("VBat", 8, 150, 150));
for (int i = 0; i < superIO.Temperatures.Length; i++) for (int i = 0; i < superIO.Temperatures.Length; i++)
t.Add(new Temperature("Temperature #" + (i + 1), i)); t.Add(new Temperature("Temperature #" + (i + 1), i));
for (int i = 0; i < superIO.Fans.Length; i++) for (int i = 0; i < superIO.Fans.Length; i++)
@ -447,13 +447,13 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
case Chip.W83627EHF: case Chip.W83627EHF:
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("Voltage #2", 1, true)); v.Add(new Voltage("Voltage #2", 1, true));
v.Add(new Voltage("AVCC", 2, 34, 34, 0)); v.Add(new Voltage("AVCC", 2, 34, 34));
v.Add(new Voltage("3VCC", 3, 34, 34, 0)); v.Add(new Voltage("3VCC", 3, 34, 34));
v.Add(new Voltage("Voltage #5", 4, true)); v.Add(new Voltage("Voltage #5", 4, true));
v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #6", 5, true));
v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("Voltage #7", 6, true));
v.Add(new Voltage("3VSB", 7, 34, 34, 0)); v.Add(new Voltage("3VSB", 7, 34, 34));
v.Add(new Voltage("VBAT", 8, 34, 34, 0)); v.Add(new Voltage("VBAT", 8, 34, 34));
v.Add(new Voltage("Voltage #10", 9, true)); v.Add(new Voltage("Voltage #10", 9, true));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("Auxiliary", 1)); t.Add(new Temperature("Auxiliary", 1));
@ -473,11 +473,11 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
switch (model) { switch (model) {
case Model._880GMH_USB3: // W83627DHG-P case Model._880GMH_USB3: // W83627DHG-P
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("+3.3V", 3, 34, 34, 0)); v.Add(new Voltage("+3.3V", 3, 34, 34));
v.Add(new Voltage("+5V", 5, 15, 7.5f, 0)); v.Add(new Voltage("+5V", 5, 15, 7.5f));
v.Add(new Voltage("+12V", 6, 56, 10, 0)); v.Add(new Voltage("+12V", 6, 56, 10));
v.Add(new Voltage("Standby +3.3V", 7, 34, 34, 0)); v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
v.Add(new Voltage("VBAT", 8, 34, 34, 0)); v.Add(new Voltage("VBAT", 8, 34, 34));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("Motherboard", 2)); t.Add(new Temperature("Motherboard", 2));
f.Add(new Fan("Chassis Fan", 0)); f.Add(new Fan("Chassis Fan", 0));
@ -487,13 +487,13 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
default: default:
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("Voltage #2", 1, true)); v.Add(new Voltage("Voltage #2", 1, true));
v.Add(new Voltage("AVCC", 2, 34, 34, 0)); v.Add(new Voltage("AVCC", 2, 34, 34));
v.Add(new Voltage("3VCC", 3, 34, 34, 0)); v.Add(new Voltage("3VCC", 3, 34, 34));
v.Add(new Voltage("Voltage #5", 4, true)); v.Add(new Voltage("Voltage #5", 4, true));
v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #6", 5, true));
v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("Voltage #7", 6, true));
v.Add(new Voltage("3VSB", 7, 34, 34, 0)); v.Add(new Voltage("3VSB", 7, 34, 34));
v.Add(new Voltage("VBAT", 8, 34, 34, 0)); v.Add(new Voltage("VBAT", 8, 34, 34));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("Auxiliary", 1)); t.Add(new Temperature("Auxiliary", 1));
t.Add(new Temperature("System", 2)); t.Add(new Temperature("System", 2));
@ -510,12 +510,12 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
case Model.P6X58D_E: // W83667HG case Model.P6X58D_E: // W83667HG
case Model.Rampage_II_GENE: // W83667HG case Model.Rampage_II_GENE: // W83667HG
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("+12V", 1, 11.5f, 1.91f, 0)); v.Add(new Voltage("+12V", 1, 11.5f, 1.91f));
v.Add(new Voltage("Analog +3.3V", 2, 34, 34, 0)); v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
v.Add(new Voltage("+3.3V", 3, 34, 34, 0)); v.Add(new Voltage("+3.3V", 3, 34, 34));
v.Add(new Voltage("+5V", 4, 15, 7.5f, 0)); v.Add(new Voltage("+5V", 4, 15, 7.5f));
v.Add(new Voltage("Standby +3.3V", 7, 34, 34, 0)); v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
v.Add(new Voltage("VBAT", 8, 34, 34, 0)); v.Add(new Voltage("VBAT", 8, 34, 34));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("Motherboard", 2)); t.Add(new Temperature("Motherboard", 2));
f.Add(new Fan("Chassis Fan #1", 0)); f.Add(new Fan("Chassis Fan #1", 0));
@ -526,12 +526,12 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
break; break;
case Model.Rampage_Extreme: // W83667HG case Model.Rampage_Extreme: // W83667HG
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("+12V", 1, 12, 2, 0)); v.Add(new Voltage("+12V", 1, 12, 2));
v.Add(new Voltage("Analog +3.3V", 2, 34, 34, 0)); v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
v.Add(new Voltage("+3.3V", 3, 34, 34, 0)); v.Add(new Voltage("+3.3V", 3, 34, 34));
v.Add(new Voltage("+5V", 4, 15, 7.5f, 0)); v.Add(new Voltage("+5V", 4, 15, 7.5f));
v.Add(new Voltage("Standby +3.3V", 7, 34, 34, 0)); v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
v.Add(new Voltage("VBAT", 8, 34, 34, 0)); v.Add(new Voltage("VBAT", 8, 34, 34));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("Motherboard", 2)); t.Add(new Temperature("Motherboard", 2));
f.Add(new Fan("Chassis Fan #1", 0)); f.Add(new Fan("Chassis Fan #1", 0));
@ -543,13 +543,13 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
default: default:
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("Voltage #2", 1, true)); v.Add(new Voltage("Voltage #2", 1, true));
v.Add(new Voltage("AVCC", 2, 34, 34, 0)); v.Add(new Voltage("AVCC", 2, 34, 34));
v.Add(new Voltage("3VCC", 3, 34, 34, 0)); v.Add(new Voltage("3VCC", 3, 34, 34));
v.Add(new Voltage("Voltage #5", 4, true)); v.Add(new Voltage("Voltage #5", 4, true));
v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #6", 5, true));
v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("Voltage #7", 6, true));
v.Add(new Voltage("3VSB", 7, 34, 34, 0)); v.Add(new Voltage("3VSB", 7, 34, 34));
v.Add(new Voltage("VBAT", 8, 34, 34, 0)); v.Add(new Voltage("VBAT", 8, 34, 34));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("Auxiliary", 1)); t.Add(new Temperature("Auxiliary", 1));
t.Add(new Temperature("System", 2)); t.Add(new Temperature("System", 2));
@ -564,13 +564,13 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
default: default:
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("Voltage #2", 1, true)); v.Add(new Voltage("Voltage #2", 1, true));
v.Add(new Voltage("AVCC", 2, 34, 34, 0)); v.Add(new Voltage("AVCC", 2, 34, 34));
v.Add(new Voltage("3VCC", 3, 34, 34, 0)); v.Add(new Voltage("3VCC", 3, 34, 34));
v.Add(new Voltage("Voltage #5", 4, true)); v.Add(new Voltage("Voltage #5", 4, true));
v.Add(new Voltage("Voltage #6", 5, true)); v.Add(new Voltage("Voltage #6", 5, true));
v.Add(new Voltage("Voltage #7", 6, true)); v.Add(new Voltage("Voltage #7", 6, true));
v.Add(new Voltage("3VSB", 7, 34, 34, 0)); v.Add(new Voltage("3VSB", 7, 34, 34));
v.Add(new Voltage("VBAT", 8, 34, 34, 0)); v.Add(new Voltage("VBAT", 8, 34, 34));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("Auxiliary", 1)); t.Add(new Temperature("Auxiliary", 1));
t.Add(new Temperature("System", 2)); t.Add(new Temperature("System", 2));
@ -588,9 +588,9 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
v.Add(new Voltage("CPU VCore", 0)); v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("Voltage #2", 1, true)); v.Add(new Voltage("Voltage #2", 1, true));
v.Add(new Voltage("Voltage #3", 2, true)); v.Add(new Voltage("Voltage #3", 2, true));
v.Add(new Voltage("AVCC", 3, 34, 51, 0)); v.Add(new Voltage("AVCC", 3, 34, 51));
v.Add(new Voltage("Voltage #5", 4, true)); v.Add(new Voltage("Voltage #5", 4, true));
v.Add(new Voltage("5VSB", 5, 34, 51, 0)); v.Add(new Voltage("5VSB", 5, 34, 51));
v.Add(new Voltage("VBAT", 6)); v.Add(new Voltage("VBAT", 6));
t.Add(new Temperature("CPU", 0)); t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("Auxiliary", 1)); t.Add(new Temperature("Auxiliary", 1));
@ -609,12 +609,11 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
break; break;
} }
string formula = "Voltage = value + (value - Vf) * Ri / Rf."; const string formula = "Voltage = value + (value - Vf) * Ri / Rf.";
foreach (Voltage voltage in v) foreach (Voltage voltage in v)
if (voltage.Index < superIO.Voltages.Length) { if (voltage.Index < superIO.Voltages.Length) {
Sensor sensor = new Sensor(voltage.Name, voltage.Index, Sensor sensor = new Sensor(voltage.Name, voltage.Index,
voltage.Hidden, SensorType.Voltage, this, voltage.Hidden, SensorType.Voltage, this, new [] {
new ParameterDescription[] {
new ParameterDescription("Ri [kΩ]", "Input resistance.\n" + new ParameterDescription("Ri [kΩ]", "Input resistance.\n" +
formula, voltage.Ri), formula, voltage.Ri),
new ParameterDescription("Rf [kΩ]", "Reference resistance.\n" + new ParameterDescription("Rf [kΩ]", "Reference resistance.\n" +
@ -628,7 +627,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
foreach (Temperature temperature in t) foreach (Temperature temperature in t)
if (temperature.Index < superIO.Temperatures.Length) { if (temperature.Index < superIO.Temperatures.Length) {
Sensor sensor = new Sensor(temperature.Name, temperature.Index, Sensor sensor = new Sensor(temperature.Name, temperature.Index,
SensorType.Temperature, this, new ParameterDescription[] { SensorType.Temperature, this, new [] {
new ParameterDescription("Offset [°C]", "Temperature offset.", 0) new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
}, settings); }, settings);
temperatures.Add(sensor); temperatures.Add(sensor);
@ -703,17 +702,12 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
public readonly float Vf; public readonly float Vf;
public readonly bool Hidden; public readonly bool Hidden;
public Voltage(string name, int index) :
this(name, index, 0, 1, 0, false) { }
public Voltage(string name, int index, bool hidden) : public Voltage(string name, int index, bool hidden) :
this(name, index, 0, 1, 0, hidden) { } this(name, index, 0, 1, 0, hidden) { }
public Voltage(string name, int index, float ri, float rf, float vf) : public Voltage(string name, int index,
this(name, index, ri, rf, vf, false) { } float ri = 0, float rf = 1, float vf = 0, bool hidden = false)
{
public Voltage(string name, int index, float ri, float rf, float vf,
bool hidden) {
this.Name = name; this.Name = name;
this.Index = index; this.Index = index;
this.Ri = ri; this.Ri = ri;

View File

@ -141,12 +141,12 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct NvDisplayHandle { internal struct NvDisplayHandle {
private IntPtr ptr; private readonly IntPtr ptr;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct NvPhysicalGpuHandle { internal struct NvPhysicalGpuHandle {
private IntPtr ptr; private readonly IntPtr ptr;
} }
[StructLayout(LayoutKind.Sequential, Pack = 8)] [StructLayout(LayoutKind.Sequential, Pack = 8)]
@ -281,11 +281,12 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
public delegate NvStatus NvAPI_GetInterfaceVersionStringDelegate( public delegate NvStatus NvAPI_GetInterfaceVersionStringDelegate(
StringBuilder version); StringBuilder version);
private static bool available = false; private static readonly bool available;
private static nvapi_QueryInterfaceDelegate nvapi_QueryInterface; private static readonly nvapi_QueryInterfaceDelegate nvapi_QueryInterface;
private static NvAPI_InitializeDelegate NvAPI_Initialize; private static readonly NvAPI_InitializeDelegate NvAPI_Initialize;
private static NvAPI_GPU_GetFullNameDelegate _NvAPI_GPU_GetFullName; private static readonly NvAPI_GPU_GetFullNameDelegate
private static NvAPI_GetInterfaceVersionStringDelegate _NvAPI_GPU_GetFullName;
private static readonly NvAPI_GetInterfaceVersionStringDelegate
_NvAPI_GetInterfaceVersionString; _NvAPI_GetInterfaceVersionString;
public static readonly NvAPI_GPU_GetThermalSettingsDelegate public static readonly NvAPI_GPU_GetThermalSettingsDelegate

View File

@ -40,19 +40,19 @@ using System.Globalization;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware.Nvidia { namespace OpenHardwareMonitor.Hardware.Nvidia {
internal class NvidiaGPU : Hardware, IHardware { internal class NvidiaGPU : Hardware {
private string name; private readonly string name;
private int adapterIndex; private readonly int adapterIndex;
private NvPhysicalGpuHandle handle; private readonly NvPhysicalGpuHandle handle;
private NvDisplayHandle? displayHandle; private readonly NvDisplayHandle? displayHandle;
private Sensor[] temperatures; private readonly Sensor[] temperatures;
private Sensor fan = null; private readonly Sensor fan;
private Sensor[] clocks; private readonly Sensor[] clocks;
private Sensor[] loads; private readonly Sensor[] loads;
private Sensor control; private readonly Sensor control;
private Sensor memoryLoad; private readonly Sensor memoryLoad;
public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle, public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle,
NvDisplayHandle? displayHandle, ISettings settings) NvDisplayHandle? displayHandle, ISettings settings)

View File

@ -43,8 +43,8 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
internal class NvidiaGroup : IGroup { internal class NvidiaGroup : IGroup {
private List<IHardware> hardware = new List<IHardware>(); private readonly List<IHardware> hardware = new List<IHardware>();
private StringBuilder report = new StringBuilder(); private readonly StringBuilder report = new StringBuilder();
public NvidiaGroup(ISettings settings) { public NvidiaGroup(ISettings settings) {
if (!NVAPI.IsAvailable) if (!NVAPI.IsAvailable)
@ -69,7 +69,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
} else { } else {
NvStatus status = NVAPI.NvAPI_EnumPhysicalGPUs(handles, out count); NvStatus status = NVAPI.NvAPI_EnumPhysicalGPUs(handles, out count);
if (status != NvStatus.OK) { if (status != NvStatus.OK) {
report.AppendLine("Status: " + status.ToString()); report.AppendLine("Status: " + status);
report.AppendLine(); report.AppendLine();
return; return;
} }
@ -108,10 +108,8 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
NvDisplayHandle displayHandle; NvDisplayHandle displayHandle;
if (displayHandles.TryGetValue(handles[i], out displayHandle)) displayHandles.TryGetValue(handles[i], out displayHandle);
hardware.Add(new NvidiaGPU(i, handles[i], displayHandle, settings)); hardware.Add(new NvidiaGPU(i, handles[i], displayHandle, settings));
else
hardware.Add(new NvidiaGPU(i, handles[i], null, settings));
} }
report.AppendLine(); report.AppendLine();

View File

@ -43,19 +43,17 @@ using System.Runtime.InteropServices;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {
internal sealed class PInvokeDelegateFactory { internal static class PInvokeDelegateFactory {
private static ModuleBuilder moduleBuilder = private static readonly ModuleBuilder moduleBuilder =
AppDomain.CurrentDomain.DefineDynamicAssembly( AppDomain.CurrentDomain.DefineDynamicAssembly(
new AssemblyName("PInvokeDelegateFactoryInternalAssembly"), new AssemblyName("PInvokeDelegateFactoryInternalAssembly"),
AssemblyBuilderAccess.Run).DefineDynamicModule( AssemblyBuilderAccess.Run).DefineDynamicModule(
"PInvokeDelegateFactoryInternalModule"); "PInvokeDelegateFactoryInternalModule");
private static IDictionary<DllImportAttribute, Type> wrapperTypes = private static readonly IDictionary<DllImportAttribute, Type> wrapperTypes =
new Dictionary<DllImportAttribute, Type>(); new Dictionary<DllImportAttribute, Type>();
private PInvokeDelegateFactory() { }
public static void CreateDelegate<T>(DllImportAttribute dllImportAttribute, public static void CreateDelegate<T>(DllImportAttribute dllImportAttribute,
out T newDelegate) where T : class out T newDelegate) where T : class
{ {

View File

@ -41,9 +41,9 @@ using System.Globalization;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {
internal struct ParameterDescription { internal struct ParameterDescription {
private string name; private readonly string name;
private string description; private readonly string description;
private float defaultValue; private readonly float defaultValue;
public ParameterDescription(string name, string description, public ParameterDescription(string name, string description,
float defaultValue) { float defaultValue) {
@ -60,11 +60,11 @@ namespace OpenHardwareMonitor.Hardware {
} }
internal class Parameter : IParameter { internal class Parameter : IParameter {
private ISensor sensor; private readonly ISensor sensor;
private ParameterDescription description; private ParameterDescription description;
private float value; private float value;
private bool isDefault; private bool isDefault;
private ISettings settings; private readonly ISettings settings;
public Parameter(ParameterDescription description, ISensor sensor, public Parameter(ParameterDescription description, ISensor sensor,
ISettings settings) ISettings settings)

View File

@ -44,22 +44,22 @@ namespace OpenHardwareMonitor.Hardware {
internal class Sensor : ISensor { internal class Sensor : ISensor {
private string defaultName; private readonly string defaultName;
private string name; private string name;
private int index; private readonly int index;
private bool defaultHidden; private readonly bool defaultHidden;
private SensorType sensorType; private readonly SensorType sensorType;
private IHardware hardware; private readonly IHardware hardware;
private ReadOnlyArray<IParameter> parameters; private readonly ReadOnlyArray<IParameter> parameters;
private float? currentValue; private float? currentValue;
private float? minValue; private float? minValue;
private float? maxValue; private float? maxValue;
private Queue<SensorValue> values = private readonly Queue<SensorValue> values =
new Queue<SensorValue>(MAX_MINUTES * 15); new Queue<SensorValue>(MAX_MINUTES * 15);
private ISettings settings; private readonly ISettings settings;
private float sum = 0; private float sum;
private int count = 0; private int count;
private const int MAX_MINUTES = 120; private const int MAX_MINUTES = 120;

View File

@ -41,7 +41,7 @@ using System.Collections.Generic;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {
public class SensorVisitor : IVisitor { public class SensorVisitor : IVisitor {
private SensorEventHandler handler; private readonly SensorEventHandler handler;
public SensorVisitor(SensorEventHandler handler) { public SensorVisitor(SensorEventHandler handler) {
if (handler == null) if (handler == null)

View File

@ -87,7 +87,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct FT_HANDLE { internal struct FT_HANDLE {
private uint handle; private readonly uint handle;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
@ -198,7 +198,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
} }
private static string GetDllName() { private static string GetDllName() {
int p = (int)System.Environment.OSVersion.Platform; int p = (int)Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) if ((p == 4) || (p == 128))
return "libftd2xx.so"; return "libftd2xx.so";
else else

View File

@ -43,21 +43,22 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.TBalancer { namespace OpenHardwareMonitor.Hardware.TBalancer {
internal class TBalancer : IHardware { internal class TBalancer : IHardware {
private ISettings settings; private readonly ISettings settings;
private int portIndex; private readonly int portIndex;
private readonly byte protocolVersion;
private readonly Sensor[] digitalTemperatures = new Sensor[8];
private readonly Sensor[] analogTemperatures = new Sensor[4];
private readonly Sensor[] sensorhubTemperatures = new Sensor[6];
private readonly Sensor[] sensorhubFlows = new Sensor[2];
private readonly Sensor[] fans = new Sensor[4];
private readonly Sensor[] controls = new Sensor[4];
private readonly Sensor[] miniNGTemperatures = new Sensor[4];
private readonly Sensor[] miniNGFans = new Sensor[4];
private readonly Sensor[] miniNGControls = new Sensor[4];
private readonly List<ISensor> active = new List<ISensor>();
private readonly List<ISensor> deactivating = new List<ISensor>();
private FT_HANDLE handle; private FT_HANDLE handle;
private byte protocolVersion;
private Sensor[] digitalTemperatures = new Sensor[8];
private Sensor[] analogTemperatures = new Sensor[4];
private Sensor[] sensorhubTemperatures = new Sensor[6];
private Sensor[] sensorhubFlows = new Sensor[2];
private Sensor[] fans = new Sensor[4];
private Sensor[] controls = new Sensor[4];
private Sensor[] miniNGTemperatures = new Sensor[4];
private Sensor[] miniNGFans = new Sensor[4];
private Sensor[] miniNGControls = new Sensor[4];
private List<ISensor> active = new List<ISensor>();
private List<ISensor> deactivating = new List<ISensor>();
private int[] primaryData = new int[0]; private int[] primaryData = new int[0];
private int[] alternativeData = new int[0]; private int[] alternativeData = new int[0];
@ -65,7 +66,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
public const byte ENDFLAG = 254; public const byte ENDFLAG = 254;
private delegate void MethodDelegate(); private delegate void MethodDelegate();
private MethodDelegate alternativeRequest; private readonly MethodDelegate alternativeRequest;
public TBalancer(int portIndex, byte protocolVersion, ISettings settings) { public TBalancer(int portIndex, byte protocolVersion, ISettings settings) {
this.settings = settings; this.settings = settings;
@ -73,7 +74,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
this.portIndex = portIndex; this.portIndex = portIndex;
this.protocolVersion = protocolVersion; this.protocolVersion = protocolVersion;
ParameterDescription[] parameter = new ParameterDescription[] { ParameterDescription[] parameter = new [] {
new ParameterDescription("Offset [°C]", "Temperature offset.", 0) new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
}; };
int offset = 0; int offset = 0;
@ -100,7 +101,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
for (int i = 0; i < sensorhubFlows.Length; i++) for (int i = 0; i < sensorhubFlows.Length; i++)
sensorhubFlows[i] = new Sensor("Flowmeter " + (i + 1), sensorhubFlows[i] = new Sensor("Flowmeter " + (i + 1),
i, SensorType.Flow, this, new ParameterDescription[] { i, SensorType.Flow, this, new [] {
new ParameterDescription("Impulse Rate", new ParameterDescription("Impulse Rate",
"The impulse rate of the flowmeter in pulses/L", 509) "The impulse rate of the flowmeter in pulses/L", 509)
}, settings); }, settings);
@ -237,8 +238,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
if (fans[i] == null) if (fans[i] == null)
fans[i] = new Sensor("Fan Channel " + i, i, SensorType.Fan, fans[i] = new Sensor("Fan Channel " + i, i, SensorType.Fan,
this, new ParameterDescription[] { this, new [] { new ParameterDescription("MaxRPM",
new ParameterDescription("MaxRPM",
"Maximum revolutions per minute (RPM) of the fan.", maxRPM) "Maximum revolutions per minute (RPM) of the fan.", maxRPM)
}, settings); }, settings);

View File

@ -44,8 +44,8 @@ using System.Threading;
namespace OpenHardwareMonitor.Hardware.TBalancer { namespace OpenHardwareMonitor.Hardware.TBalancer {
internal class TBalancerGroup : IGroup { internal class TBalancerGroup : IGroup {
private List<TBalancer> hardware = new List<TBalancer>(); private readonly List<TBalancer> hardware = new List<TBalancer>();
private StringBuilder report = new StringBuilder(); private readonly StringBuilder report = new StringBuilder();
public TBalancerGroup(ISettings settings) { public TBalancerGroup(ISettings settings) {
@ -73,8 +73,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
} }
FT_HANDLE handle; FT_HANDLE handle;
FT_STATUS status; FT_STATUS status = FTD2XX.FT_Open(i, out handle);
status = FTD2XX.FT_Open(i, out handle);
if (status != FT_STATUS.FT_OK) { if (status != FT_STATUS.FT_OK) {
report.AppendLine("Open Status: " + status); report.AppendLine("Open Status: " + status);
continue; continue;

View File

@ -55,11 +55,11 @@ namespace OpenHardwareMonitor.Hardware {
OLS_DLL_UNKNOWN_ERROR = 9 OLS_DLL_UNKNOWN_ERROR = 9
} }
private static bool available = false; private static bool available;
private static Mutex isaBusMutex; private static Mutex isaBusMutex;
private static string GetDllName() { private static string GetDllName() {
int p = (int)System.Environment.OSVersion.Platform; int p = (int)Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) { if ((p == 4) || (p == 128)) {
if (IntPtr.Size == 4) { if (IntPtr.Size == 4) {
return "libring0.so"; return "libring0.so";
@ -97,9 +97,9 @@ namespace OpenHardwareMonitor.Hardware {
UIntPtr threadAffinityMask); UIntPtr threadAffinityMask);
public delegate bool RdtscDelegate(out uint eax, out uint edx); public delegate bool RdtscDelegate(out uint eax, out uint edx);
private static InitializeOlsDelegate InitializeOls = private static readonly InitializeOlsDelegate InitializeOls =
CreateDelegate<InitializeOlsDelegate>("InitializeOls"); CreateDelegate<InitializeOlsDelegate>("InitializeOls");
private static DeinitializeOlsDelegate DeinitializeOls = private static readonly DeinitializeOlsDelegate DeinitializeOls =
CreateDelegate<DeinitializeOlsDelegate>("DeinitializeOls"); CreateDelegate<DeinitializeOlsDelegate>("DeinitializeOls");
public static readonly IsCpuidDelegate IsCpuid = public static readonly IsCpuidDelegate IsCpuid =

View File

@ -37,7 +37,6 @@
using System; using System;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Open Hardware Monitor Library")] [assembly: AssemblyTitle("Open Hardware Monitor Library")]

View File

@ -35,7 +35,6 @@
*/ */
using System;
using System.Reflection; using System.Reflection;
[assembly: AssemblyVersion("0.1.37.14")] [assembly: AssemblyVersion("0.1.37.14")]