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.Generic;
using System.Text;
namespace OpenHardwareMonitor.Collections {
public class ListSet<T> : IEnumerable<T> {
private List<T> list = new List<T>();
public ListSet() { }
private readonly List<T> list = new List<T>();
public bool Add(T item) {
if (list.Contains(item))

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,9 +39,9 @@ namespace OpenHardwareMonitor.Hardware.CPU {
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_10H_MISCELLANEOUS_DEVICE_ID = 0x1203;
@ -54,7 +54,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
// AMD family 10h processors support only one temperature sensor
coreTemperature = new Sensor(
"Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0,
SensorType.Temperature, this, new ParameterDescription[] {
SensorType.Temperature, this, new [] {
new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
}, settings);

View File

@ -43,9 +43,9 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.CPU {
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() {
@ -77,7 +77,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
return processorThreads;
}
private static CPUID[][] GroupThreadsByCore(CPUID[] threads) {
private static CPUID[][] GroupThreadsByCore(IEnumerable<CPUID> threads) {
SortedDictionary<uint, List<CPUID>> cores =
new SortedDictionary<uint, List<CPUID>>();
@ -102,7 +102,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
public CPUGroup(ISettings settings) {
// 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))
return;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -43,11 +43,11 @@ namespace OpenHardwareMonitor.Hardware.HDD {
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) {
int p = (int)System.Environment.OSVersion.Platform;
int p = (int)Environment.OSVersion.Platform;
if ((p != 4) && (p != 128)) {
for (int drive = 0; drive < MAX_DRIVES; drive++) {
IntPtr handle = SMART.OpenPhysicalDrive(drive);

View File

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

View File

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

View File

@ -46,22 +46,22 @@ using System.Threading;
namespace OpenHardwareMonitor.Hardware.Heatmaster {
internal class Heatmaster : Hardware, IDisposable {
private string portName;
private readonly string portName;
private SerialPort serialPort;
private int hardwareRevision;
private int firmwareRevision;
private int firmwareCRC;
private readonly int hardwareRevision;
private readonly int firmwareRevision;
private readonly int firmwareCRC;
private Sensor[] fans;
private Sensor[] controls;
private Sensor[] temperatures;
private Sensor[] flows;
private Sensor[] relays;
private readonly Sensor[] fans;
private readonly Sensor[] controls;
private readonly Sensor[] temperatures;
private readonly Sensor[] flows;
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) {
int i = 0;
@ -94,7 +94,7 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
return null;
}
private string ReadString(int device, char field) {
protected string ReadString(int device, char field) {
string s = ReadField(device, field);
if (s != null && s[0] == '"' && s[s.Length - 1] == '"')
return s.Substring(1, s.Length - 2);
@ -102,7 +102,7 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
return null;
}
private int ReadInteger(int device, char field) {
protected int ReadInteger(int device, char field) {
string s = ReadField(device, field);
int i;
if (int.TryParse(s, out i))
@ -125,12 +125,12 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
return false;
}
private bool WriteInteger(int device, char field, int value) {
protected bool WriteInteger(int device, char field, int value) {
return WriteField(device, field,
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 + '"');
}
@ -164,15 +164,7 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
new Sensor(name, device, SensorType.Control, this, settings);
controls[i].Value = (100 / 255.0f) * ReadInteger(device, 'P');
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];
for (int i = 0; i < temperatureCount; i++) {
@ -220,7 +212,7 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
public override Identifier Identifier {
get {
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 {
internal class HeatmasterGroup : IGroup {
private List<Heatmaster> hardware = new List<Heatmaster>();
private StringBuilder report = new StringBuilder();
private readonly List<Heatmaster> hardware = new List<Heatmaster>();
private readonly StringBuilder report = new StringBuilder();
private static string ReadLine(SerialPort port, int timeout) {
int i = 0;
@ -82,7 +82,7 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
if (subKey != null) {
string name = subKey.GetValue("PortName") as string;
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) {
// 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))
return;

View File

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

View File

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

View File

@ -36,17 +36,18 @@
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenHardwareMonitor.Hardware {
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)
if (s.Contains(" ") || s.Contains(SEPARATOR.ToString()))
if (s.Contains(" ") || s.Contains(Separator.ToString()))
throw new ArgumentException("Invalid identifier");
}
@ -55,7 +56,7 @@ namespace OpenHardwareMonitor.Hardware {
StringBuilder s = new StringBuilder();
for (int i = 0; i < identifiers.Length; i++) {
s.Append(SEPARATOR);
s.Append(Separator);
s.Append(identifiers[i]);
}
this.identifier = s.ToString();
@ -67,7 +68,7 @@ namespace OpenHardwareMonitor.Hardware {
StringBuilder s = new StringBuilder();
s.Append(identifier.ToString());
for (int i = 0; i < extensions.Length; i++) {
s.Append(SEPARATOR);
s.Append(Separator);
s.Append(extensions[i]);
}
this.identifier = s.ToString();
@ -77,7 +78,7 @@ namespace OpenHardwareMonitor.Hardware {
return identifier;
}
public override bool Equals(System.Object obj) {
public override bool Equals(Object obj) {
if (obj == null)
return false;

View File

@ -35,20 +35,18 @@
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
namespace OpenHardwareMonitor.Hardware.LPC {
internal class F718XX : ISuperIO {
private ushort address;
private Chip chip;
private readonly ushort address;
private readonly Chip chip;
private float?[] voltages;
private float?[] temperatures;
private float?[] fans;
private readonly float?[] voltages;
private readonly float?[] temperatures;
private readonly float?[] fans;
// Hardware Monitor
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 TEMPERATURE_CONFIG_REG = 0x69;
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) {
WinRing0.WriteIoPortByte(
@ -126,7 +125,7 @@ namespace OpenHardwareMonitor.Hardware.LPC {
for (int i = 0; i < temperatures.Length; i++) {
switch (chip) {
case Chip.F71858: {
int tableMode = 0x3 & ReadByte((byte)(TEMPERATURE_CONFIG_REG));
int tableMode = 0x3 & ReadByte(TEMPERATURE_CONFIG_REG);
int high =
ReadByte((byte)(TEMPERATURE_BASE_REG + 2 * i));
int low =

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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