Refactored some of the hardware monitoring code and fixed a few code inspection warnings.
1.1 --- a/Collections/ListSet.cs Tue Sep 21 10:33:28 2010 +0000
1.2 +++ b/Collections/ListSet.cs Tue Sep 21 20:32:36 2010 +0000
1.3 @@ -35,18 +35,14 @@
1.4
1.5 */
1.6
1.7 -using System;
1.8 using System.Collections;
1.9 using System.Collections.Generic;
1.10 -using System.Text;
1.11
1.12 namespace OpenHardwareMonitor.Collections {
1.13
1.14 public class ListSet<T> : IEnumerable<T> {
1.15
1.16 - private List<T> list = new List<T>();
1.17 -
1.18 - public ListSet() { }
1.19 + private readonly List<T> list = new List<T>();
1.20
1.21 public bool Add(T item) {
1.22 if (list.Contains(item))
2.1 --- a/Collections/ReadOnlyArray.cs Tue Sep 21 10:33:28 2010 +0000
2.2 +++ b/Collections/ReadOnlyArray.cs Tue Sep 21 20:32:36 2010 +0000
2.3 @@ -35,7 +35,6 @@
2.4
2.5 */
2.6
2.7 -using System;
2.8 using System.Collections;
2.9 using System.Collections.Generic;
2.10
2.11 @@ -43,7 +42,7 @@
2.12
2.13 public class ReadOnlyArray<T> : IReadOnlyArray<T> {
2.14
2.15 - private T[] array;
2.16 + private readonly T[] array;
2.17
2.18 public ReadOnlyArray(T[] array) {
2.19 this.array = array;
3.1 --- a/Hardware/ATI/ADL.cs Tue Sep 21 10:33:28 2010 +0000
3.2 +++ b/Hardware/ATI/ADL.cs Tue Sep 21 20:32:36 2010 +0000
3.3 @@ -187,7 +187,7 @@
3.4 }
3.5
3.6 private static void CreateDelegates(string name) {
3.7 - int p = (int)System.Environment.OSVersion.Platform;
3.8 + int p = (int)Environment.OSVersion.Platform;
3.9 if ((p == 4) || (p == 128))
3.10 dllName = name + ".so";
3.11 else
3.12 @@ -234,7 +234,7 @@
3.13 enumConnectedAdapters);
3.14 }
3.15 } catch {
3.16 - return ADL.ADL_ERR;
3.17 + return ADL_ERR;
3.18 }
3.19 }
3.20
4.1 --- a/Hardware/ATI/ATIGPU.cs Tue Sep 21 10:33:28 2010 +0000
4.2 +++ b/Hardware/ATI/ATIGPU.cs Tue Sep 21 20:32:36 2010 +0000
4.3 @@ -41,17 +41,17 @@
4.4 namespace OpenHardwareMonitor.Hardware.ATI {
4.5 internal sealed class ATIGPU : Hardware {
4.6
4.7 - private string name;
4.8 - private int adapterIndex;
4.9 - private int busNumber;
4.10 - private int deviceNumber;
4.11 - private Sensor temperature;
4.12 - private Sensor fan;
4.13 - private Sensor coreClock;
4.14 - private Sensor memoryClock;
4.15 - private Sensor coreVoltage;
4.16 - private Sensor coreLoad;
4.17 - private Sensor fanControl;
4.18 + private readonly string name;
4.19 + private readonly int adapterIndex;
4.20 + private readonly int busNumber;
4.21 + private readonly int deviceNumber;
4.22 + private readonly Sensor temperature;
4.23 + private readonly Sensor fan;
4.24 + private readonly Sensor coreClock;
4.25 + private readonly Sensor memoryClock;
4.26 + private readonly Sensor coreVoltage;
4.27 + private readonly Sensor coreLoad;
4.28 + private readonly Sensor fanControl;
4.29
4.30 public ATIGPU(string name, int adapterIndex, int busNumber,
4.31 int deviceNumber, ISettings settings)
5.1 --- a/Hardware/ATI/ATIGroup.cs Tue Sep 21 10:33:28 2010 +0000
5.2 +++ b/Hardware/ATI/ATIGroup.cs Tue Sep 21 20:32:36 2010 +0000
5.3 @@ -43,8 +43,8 @@
5.4 namespace OpenHardwareMonitor.Hardware.ATI {
5.5 internal class ATIGroup : IGroup {
5.6
5.7 - private List<ATIGPU> hardware = new List<ATIGPU>();
5.8 - private StringBuilder report = new StringBuilder();
5.9 + private readonly List<ATIGPU> hardware = new List<ATIGPU>();
5.10 + private readonly StringBuilder report = new StringBuilder();
5.11
5.12 public ATIGroup(ISettings settings) {
5.13 try {
5.14 @@ -53,10 +53,8 @@
5.15 report.AppendLine("AMD Display Library");
5.16 report.AppendLine();
5.17 report.Append("Status: ");
5.18 - if (status == ADL.ADL_OK)
5.19 - report.AppendLine("OK");
5.20 - else
5.21 - report.AppendLine(status.ToString(CultureInfo.InvariantCulture));
5.22 + report.AppendLine(status == ADL.ADL_OK ? "OK" :
5.23 + status.ToString(CultureInfo.InvariantCulture));
5.24 report.AppendLine();
5.25
5.26 if (status == ADL.ADL_OK) {
6.1 --- a/Hardware/CPU/AMD0FCPU.cs Tue Sep 21 10:33:28 2010 +0000
6.2 +++ b/Hardware/CPU/AMD0FCPU.cs Tue Sep 21 20:32:36 2010 +0000
6.3 @@ -41,10 +41,10 @@
6.4 namespace OpenHardwareMonitor.Hardware.CPU {
6.5 internal sealed class AMD0FCPU : GenericCPU {
6.6
6.7 - private uint pciAddress;
6.8 - private Sensor[] coreTemperatures;
6.9 - private Sensor[] coreClocks;
6.10 - private Sensor busClock;
6.11 + private readonly uint pciAddress;
6.12 + private readonly Sensor[] coreTemperatures;
6.13 + private readonly Sensor[] coreClocks;
6.14 + private readonly Sensor busClock;
6.15
6.16 private const ushort PCI_AMD_VENDOR_ID = 0x1022;
6.17 private const ushort PCI_AMD_0FH_MISCELLANEOUS_DEVICE_ID = 0x1103;
6.18 @@ -71,8 +71,7 @@
6.19 for (int i = 0; i < coreCount; i++) {
6.20 coreTemperatures[i] =
6.21 new Sensor("Core #" + (i + 1), i, SensorType.Temperature,
6.22 - this, new ParameterDescription[] {
6.23 - new ParameterDescription("Offset [°C]",
6.24 + this, new [] { new ParameterDescription("Offset [°C]",
6.25 "Temperature offset of the thermal sensor.\n" +
6.26 "Temperature = Value + Offset.", offset)
6.27 }, settings);
6.28 @@ -97,9 +96,7 @@
6.29 }
6.30
6.31 protected override uint[] GetMSRs() {
6.32 - return new uint[] {
6.33 - FIDVID_STATUS
6.34 - };
6.35 + return new [] { FIDVID_STATUS };
6.36 }
6.37
6.38 public override void Update() {
7.1 --- a/Hardware/CPU/AMD10CPU.cs Tue Sep 21 10:33:28 2010 +0000
7.2 +++ b/Hardware/CPU/AMD10CPU.cs Tue Sep 21 20:32:36 2010 +0000
7.3 @@ -39,9 +39,9 @@
7.4
7.5 internal sealed class AMD10CPU : GenericCPU {
7.6
7.7 - private uint pciAddress;
7.8 + private readonly uint pciAddress;
7.9
7.10 - private Sensor coreTemperature;
7.11 + private readonly Sensor coreTemperature;
7.12
7.13 private const ushort PCI_AMD_VENDOR_ID = 0x1022;
7.14 private const ushort PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID = 0x1203;
7.15 @@ -54,7 +54,7 @@
7.16 // AMD family 10h processors support only one temperature sensor
7.17 coreTemperature = new Sensor(
7.18 "Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0,
7.19 - SensorType.Temperature, this, new ParameterDescription[] {
7.20 + SensorType.Temperature, this, new [] {
7.21 new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
7.22 }, settings);
7.23
8.1 --- a/Hardware/CPU/CPUGroup.cs Tue Sep 21 10:33:28 2010 +0000
8.2 +++ b/Hardware/CPU/CPUGroup.cs Tue Sep 21 20:32:36 2010 +0000
8.3 @@ -43,9 +43,9 @@
8.4 namespace OpenHardwareMonitor.Hardware.CPU {
8.5
8.6 internal class CPUGroup : IGroup {
8.7 - private List<IHardware> hardware = new List<IHardware>();
8.8 + private readonly List<IHardware> hardware = new List<IHardware>();
8.9
8.10 - private CPUID[][][] threads;
8.11 + private readonly CPUID[][][] threads;
8.12
8.13 private static CPUID[][] GetProcessorThreads() {
8.14
8.15 @@ -77,7 +77,7 @@
8.16 return processorThreads;
8.17 }
8.18
8.19 - private static CPUID[][] GroupThreadsByCore(CPUID[] threads) {
8.20 + private static CPUID[][] GroupThreadsByCore(IEnumerable<CPUID> threads) {
8.21
8.22 SortedDictionary<uint, List<CPUID>> cores =
8.23 new SortedDictionary<uint, List<CPUID>>();
8.24 @@ -102,7 +102,7 @@
8.25
8.26 public CPUGroup(ISettings settings) {
8.27 // No implementation for cpuid on Unix systems
8.28 - int p = (int)System.Environment.OSVersion.Platform;
8.29 + int p = (int)Environment.OSVersion.Platform;
8.30 if ((p == 4) || (p == 128))
8.31 return;
8.32
9.1 --- a/Hardware/CPU/CPUID.cs Tue Sep 21 10:33:28 2010 +0000
9.2 +++ b/Hardware/CPU/CPUID.cs Tue Sep 21 20:32:36 2010 +0000
9.3 @@ -48,31 +48,31 @@
9.4
9.5 internal class CPUID {
9.6
9.7 - private int thread;
9.8 + private readonly int thread;
9.9
9.10 - private Vendor vendor = Vendor.Unknown;
9.11 + private readonly Vendor vendor = Vendor.Unknown;
9.12
9.13 - private string cpuBrandString = "";
9.14 - private string name = "";
9.15 + private readonly string cpuBrandString = "";
9.16 + private readonly string name = "";
9.17
9.18 - private uint[,] cpuidData = new uint[0, 0];
9.19 - private uint[,] cpuidExtData = new uint[0, 0];
9.20 + private readonly uint[,] cpuidData = new uint[0, 0];
9.21 + private readonly uint[,] cpuidExtData = new uint[0, 0];
9.22
9.23 - private uint family;
9.24 - private uint model;
9.25 - private uint stepping;
9.26 + private readonly uint family;
9.27 + private readonly uint model;
9.28 + private readonly uint stepping;
9.29
9.30 - private uint apicId;
9.31 + private readonly uint apicId;
9.32
9.33 - private uint threadMaskWith;
9.34 - private uint coreMaskWith;
9.35 + private readonly uint threadMaskWith;
9.36 + private readonly uint coreMaskWith;
9.37
9.38 - private uint processorId;
9.39 - private uint coreId;
9.40 - private uint threadId;
9.41 + private readonly uint processorId;
9.42 + private readonly uint coreId;
9.43 + private readonly uint threadId;
9.44
9.45 - public static uint CPUID_0 = 0;
9.46 - public static uint CPUID_EXT = 0x80000000;
9.47 + public const uint CPUID_0 = 0;
9.48 + public const uint CPUID_EXT = 0x80000000;
9.49
9.50 private static void AppendRegister(StringBuilder b, uint value) {
9.51 b.Append((char)((value) & 0xff));
9.52 @@ -217,8 +217,8 @@
9.53 break;
9.54 }
9.55
9.56 - processorId = (uint)(apicId >> (int)(coreMaskWith + threadMaskWith));
9.57 - coreId = (uint)((apicId >> (int)(threadMaskWith))
9.58 + processorId = (apicId >> (int)(coreMaskWith + threadMaskWith));
9.59 + coreId = ((apicId >> (int)(threadMaskWith))
9.60 - (processorId << (int)(coreMaskWith)));
9.61 threadId = apicId
9.62 - (processorId << (int)(coreMaskWith + threadMaskWith))
10.1 --- a/Hardware/CPU/CPULoad.cs Tue Sep 21 10:33:28 2010 +0000
10.2 +++ b/Hardware/CPU/CPULoad.cs Tue Sep 21 20:32:36 2010 +0000
10.3 @@ -42,7 +42,7 @@
10.4 internal class CPULoad {
10.5
10.6 [StructLayout(LayoutKind.Sequential)]
10.7 - private struct SystemProcessorPerformanceInformation {
10.8 + protected struct SystemProcessorPerformanceInformation {
10.9 public long IdleTime;
10.10 public long KernelTime;
10.11 public long UserTime;
10.12 @@ -51,7 +51,7 @@
10.13 public ulong Reserved2;
10.14 }
10.15
10.16 - private enum SystemInformationClass : int {
10.17 + protected enum SystemInformationClass {
10.18 SystemBasicInformation = 0,
10.19 SystemCpuInformation = 1,
10.20 SystemPerformanceInformation = 2,
10.21 @@ -60,15 +60,15 @@
10.22 SystemProcessorPerformanceInformation = 8
10.23 }
10.24
10.25 - private CPUID[][] cpuid;
10.26 + private readonly CPUID[][] cpuid;
10.27
10.28 private long systemTime;
10.29 private long[] idleTimes;
10.30
10.31 private float totalLoad;
10.32 - private float[] coreLoads;
10.33 + private readonly float[] coreLoads;
10.34
10.35 - private bool available = false;
10.36 + private readonly bool available;
10.37
10.38 private static long[] GetIdleTimes() {
10.39 SystemProcessorPerformanceInformation[] informations = new
10.40 @@ -159,7 +159,7 @@
10.41 this.idleTimes = newIdleTimes;
10.42 }
10.43
10.44 - private static class NativeMethods {
10.45 + protected static class NativeMethods {
10.46
10.47 [DllImport("ntdll.dll")]
10.48 public static extern int NtQuerySystemInformation(
11.1 --- a/Hardware/CPU/GenericCPU.cs Tue Sep 21 10:33:28 2010 +0000
11.2 +++ b/Hardware/CPU/GenericCPU.cs Tue Sep 21 20:32:36 2010 +0000
11.3 @@ -43,7 +43,7 @@
11.4 using System.Threading;
11.5
11.6 namespace OpenHardwareMonitor.Hardware.CPU {
11.7 - internal class GenericCPU : Hardware, IHardware {
11.8 + internal class GenericCPU : Hardware {
11.9
11.10 protected readonly CPUID[][] cpuid;
11.11
11.12 @@ -57,13 +57,13 @@
11.13
11.14 protected readonly bool hasTSC;
11.15 protected readonly bool invariantTSC;
11.16 + private readonly double estimatedMaxClock;
11.17
11.18 private ulong lastTimeStampCount;
11.19 private long lastTime;
11.20 - private double maxClock;
11.21 - private double estimatedMaxClock;
11.22 + private double maxClock;
11.23
11.24 - private Vendor vendor;
11.25 + private readonly Vendor vendor;
11.26
11.27 private readonly CPULoad cpuLoad;
11.28 private readonly Sensor totalLoad;
11.29 @@ -129,7 +129,7 @@
11.30 lastTime = 0;
11.31 }
11.32
11.33 - private double EstimateMaxClock() {
11.34 + private static double EstimateMaxClock() {
11.35 // preload the function
11.36 EstimateMaxClock(0);
11.37 EstimateMaxClock(0);
11.38 @@ -184,7 +184,7 @@
11.39 StringBuilder r = new StringBuilder();
11.40
11.41 switch (vendor) {
11.42 - case Vendor.AMD: r.AppendLine("Intel CPU"); break;
11.43 + case Vendor.AMD: r.AppendLine("AMD CPU"); break;
11.44 case Vendor.Intel: r.AppendLine("Intel CPU"); break;
11.45 default: r.AppendLine("Generic CPU"); break;
11.46 }
12.1 --- a/Hardware/CPU/IntelCPU.cs Tue Sep 21 10:33:28 2010 +0000
12.2 +++ b/Hardware/CPU/IntelCPU.cs Tue Sep 21 20:32:36 2010 +0000
12.3 @@ -41,11 +41,11 @@
12.4 namespace OpenHardwareMonitor.Hardware.CPU {
12.5 internal sealed class IntelCPU : GenericCPU {
12.6
12.7 - private Sensor[] coreTemperatures;
12.8 - private Sensor[] coreClocks;
12.9 - private Sensor busClock;
12.10 + private readonly Sensor[] coreTemperatures;
12.11 + private readonly Sensor[] coreClocks;
12.12 + private readonly Sensor busClock;
12.13
12.14 - private uint maxNehalemMultiplier = 0;
12.15 + private readonly uint maxNehalemMultiplier;
12.16
12.17 private const uint IA32_THERM_STATUS_MSR = 0x019C;
12.18 private const uint IA32_TEMPERATURE_TARGET = 0x01A2;
12.19 @@ -127,7 +127,7 @@
12.20 coreTemperatures = new Sensor[coreCount];
12.21 for (int i = 0; i < coreTemperatures.Length; i++) {
12.22 coreTemperatures[i] = new Sensor(CoreString(i), i,
12.23 - SensorType.Temperature, this, new ParameterDescription[] {
12.24 + SensorType.Temperature, this, new [] {
12.25 new ParameterDescription(
12.26 "TjMax [°C]", "TjMax temperature of the core.\n" +
12.27 "Temperature = TjMax - TSlope * Value.", tjMax[i]),
12.28 @@ -153,7 +153,7 @@
12.29 }
12.30
12.31 protected override uint[] GetMSRs() {
12.32 - return new uint[] {
12.33 + return new [] {
12.34 MSR_PLATFORM_INFO,
12.35 IA32_PERF_STATUS ,
12.36 IA32_THERM_STATUS_MSR,
13.1 --- a/Hardware/Computer.cs Tue Sep 21 10:33:28 2010 +0000
13.2 +++ b/Hardware/Computer.cs Tue Sep 21 20:32:36 2010 +0000
13.3 @@ -45,22 +45,18 @@
13.4
13.5 public class Computer : IComputer {
13.6
13.7 - private List<IGroup> groups = new List<IGroup>();
13.8 + private readonly List<IGroup> groups = new List<IGroup>();
13.9 + private readonly ISettings settings;
13.10
13.11 - private bool open = false;
13.12 - private bool hddEnabled = false;
13.13 - private ISettings settings;
13.14 + private bool open;
13.15 + private bool hddEnabled;
13.16
13.17 public Computer() {
13.18 this.settings = new Settings();
13.19 }
13.20
13.21 public Computer(ISettings settings) {
13.22 - if (settings != null)
13.23 - this.settings = settings;
13.24 - else {
13.25 - this.settings = new Settings();
13.26 - }
13.27 + this.settings = settings ?? new Settings();
13.28 }
13.29
13.30 private void Add(IGroup group) {
13.31 @@ -141,7 +137,7 @@
13.32 writer.WriteLine();
13.33 }
13.34
13.35 - private int CompareSensor(ISensor a, ISensor b) {
13.36 + private static int CompareSensor(ISensor a, ISensor b) {
13.37 int c = a.SensorType.CompareTo(b.SensorType);
13.38 if (c == 0)
13.39 return a.Index.CompareTo(b.Index);
13.40 @@ -149,13 +145,14 @@
13.41 return c;
13.42 }
13.43
13.44 - private void ReportHardwareSensorTree(IHardware hardware, TextWriter w,
13.45 - string space) {
13.46 + private static void ReportHardwareSensorTree(
13.47 + IHardware hardware, TextWriter w, string space)
13.48 + {
13.49 w.WriteLine("{0}|", space);
13.50 w.WriteLine("{0}+-+ {1} ({2})",
13.51 space, hardware.Name, hardware.Identifier);
13.52 ISensor[] sensors = hardware.Sensors;
13.53 - Array.Sort<ISensor>(sensors, CompareSensor);
13.54 + Array.Sort(sensors, CompareSensor);
13.55 foreach (ISensor sensor in sensors) {
13.56 w.WriteLine("{0}| +- {1}[{2}] : {3} : {4}",
13.57 space, sensor.SensorType, sensor.Index,
13.58 @@ -166,13 +163,14 @@
13.59 ReportHardwareSensorTree(subHardware, w, "| ");
13.60 }
13.61
13.62 - private void ReportHardwareParameterTree(IHardware hardware, TextWriter w,
13.63 - string space) {
13.64 + private static void ReportHardwareParameterTree(
13.65 + IHardware hardware, TextWriter w, string space)
13.66 + {
13.67 w.WriteLine("{0}|", space);
13.68 w.WriteLine("{0}+-+ {1} ({2})",
13.69 space, hardware.Name, hardware.Identifier);
13.70 ISensor[] sensors = hardware.Sensors;
13.71 - Array.Sort<ISensor>(sensors, CompareSensor);
13.72 + Array.Sort(sensors, CompareSensor);
13.73 foreach (ISensor sensor in sensors) {
13.74 if (sensor.Parameters.Length > 0) {
13.75 w.WriteLine("{0}| +- {1}[{2}] : {3}",
13.76 @@ -189,7 +187,7 @@
13.77 ReportHardwareParameterTree(subHardware, w, "| ");
13.78 }
13.79
13.80 - private void ReportHardware(IHardware hardware, TextWriter w) {
13.81 + private static void ReportHardware(IHardware hardware, TextWriter w) {
13.82 string hardwareReport = hardware.GetReport();
13.83 if (!string.IsNullOrEmpty(hardwareReport)) {
13.84 NewSection(w);
14.1 --- a/Hardware/HDD/HDD.cs Tue Sep 21 10:33:28 2010 +0000
14.2 +++ b/Hardware/HDD/HDD.cs Tue Sep 21 20:32:36 2010 +0000
14.3 @@ -36,7 +36,6 @@
14.4 */
14.5
14.6 using System;
14.7 -using System.Collections.Generic;
14.8 using System.Globalization;
14.9
14.10 namespace OpenHardwareMonitor.Hardware.HDD {
14.11 @@ -44,11 +43,11 @@
14.12
14.13 private const int UPDATE_DIVIDER = 30; // update only every 30s
14.14
14.15 - private string name;
14.16 - private IntPtr handle;
14.17 - private int drive;
14.18 - private int attribute;
14.19 - private Sensor temperature;
14.20 + private readonly string name;
14.21 + private readonly IntPtr handle;
14.22 + private readonly int drive;
14.23 + private readonly int attribute;
14.24 + private readonly Sensor temperature;
14.25 private int count;
14.26
14.27
15.1 --- a/Hardware/HDD/HDDGroup.cs Tue Sep 21 10:33:28 2010 +0000
15.2 +++ b/Hardware/HDD/HDDGroup.cs Tue Sep 21 20:32:36 2010 +0000
15.3 @@ -43,11 +43,11 @@
15.4
15.5 private const int MAX_DRIVES = 32;
15.6
15.7 - private List<HDD> hardware = new List<HDD>();
15.8 + private readonly List<HDD> hardware = new List<HDD>();
15.9
15.10 public HDDGroup(ISettings settings) {
15.11
15.12 - int p = (int)System.Environment.OSVersion.Platform;
15.13 + int p = (int)Environment.OSVersion.Platform;
15.14 if ((p != 4) && (p != 128)) {
15.15 for (int drive = 0; drive < MAX_DRIVES; drive++) {
15.16 IntPtr handle = SMART.OpenPhysicalDrive(drive);
16.1 --- a/Hardware/HDD/SMART.cs Tue Sep 21 10:33:28 2010 +0000
16.2 +++ b/Hardware/HDD/SMART.cs Tue Sep 21 20:32:36 2010 +0000
16.3 @@ -36,7 +36,6 @@
16.4 */
16.5
16.6 using System;
16.7 -using System.Collections.Generic;
16.8 using System.Runtime.InteropServices;
16.9
16.10 namespace OpenHardwareMonitor.Hardware.HDD {
16.11 @@ -90,7 +89,7 @@
16.12 };
16.13
16.14 [Flags]
16.15 - private enum AccessMode : uint {
16.16 + protected enum AccessMode : uint {
16.17 Read = 0x80000000,
16.18 Write = 0x40000000,
16.19 Execute = 0x20000000,
16.20 @@ -98,14 +97,14 @@
16.21 }
16.22
16.23 [Flags]
16.24 - private enum ShareMode : uint {
16.25 + protected enum ShareMode : uint {
16.26 None = 0,
16.27 Read = 1,
16.28 Write = 2,
16.29 Delete = 4
16.30 }
16.31
16.32 - private enum CreationMode : uint {
16.33 + protected enum CreationMode : uint {
16.34 New = 1,
16.35 CreateAlways = 2,
16.36 OpenExisting = 3,
16.37 @@ -114,7 +113,7 @@
16.38 }
16.39
16.40 [Flags]
16.41 - private enum FileAttribute : uint {
16.42 + protected enum FileAttribute : uint {
16.43 Readonly = 0x00000001,
16.44 Hidden = 0x00000002,
16.45 System = 0x00000004,
16.46 @@ -131,14 +130,14 @@
16.47 Encrypted = 0x00004000,
16.48 }
16.49
16.50 - private enum DriveCommand : uint {
16.51 + protected enum DriveCommand : uint {
16.52 GetVersion = 0x00074080,
16.53 SendDriveCommand = 0x0007c084,
16.54 ReceiveDriveData = 0x0007c088
16.55 }
16.56
16.57 [StructLayout(LayoutKind.Sequential, Pack = 1)]
16.58 - private struct CommandBlockRegisters {
16.59 + protected struct CommandBlockRegisters {
16.60 public byte Features;
16.61 public byte SectorCount;
16.62 public byte LBALow;
16.63 @@ -150,8 +149,8 @@
16.64 }
16.65
16.66 [StructLayout(LayoutKind.Sequential, Pack = 1)]
16.67 - private struct DriveCommandParameter {
16.68 - private uint BufferSize;
16.69 + protected struct DriveCommandParameter {
16.70 + public uint BufferSize;
16.71 public CommandBlockRegisters Registers;
16.72 public byte DriveNumber;
16.73 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
16.74 @@ -159,7 +158,7 @@
16.75 }
16.76
16.77 [StructLayout(LayoutKind.Sequential, Pack = 1)]
16.78 - private struct DriverStatus {
16.79 + protected struct DriverStatus {
16.80 public byte DriverError;
16.81 public byte IDEError;
16.82 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)]
16.83 @@ -167,13 +166,13 @@
16.84 }
16.85
16.86 [StructLayout(LayoutKind.Sequential, Pack = 1)]
16.87 - private struct DriveCommandResult {
16.88 + protected struct DriveCommandResult {
16.89 public uint BufferSize;
16.90 public DriverStatus DriverStatus;
16.91 }
16.92
16.93 [StructLayout(LayoutKind.Sequential, Pack = 1)]
16.94 - private struct DriveSmartReadResult {
16.95 + protected struct DriveSmartReadResult {
16.96 public uint BufferSize;
16.97 public DriverStatus DriverStatus;
16.98 public byte Version;
16.99 @@ -183,7 +182,7 @@
16.100 }
16.101
16.102 [StructLayout(LayoutKind.Sequential, Pack = 1)]
16.103 - private struct Identify {
16.104 + protected struct Identify {
16.105 public ushort GeneralConfiguration;
16.106 public ushort NumberOfCylinders;
16.107 public ushort Reserved;
16.108 @@ -213,7 +212,7 @@
16.109 }
16.110
16.111 [StructLayout(LayoutKind.Sequential, Pack = 1)]
16.112 - private struct DriveIdentifyResult {
16.113 + protected struct DriveIdentifyResult {
16.114 public uint BufferSize;
16.115 public DriverStatus DriverStatus;
16.116 public Identify Identify;
16.117 @@ -312,7 +311,7 @@
16.118 return NativeMethods.CloseHandle(handle);
16.119 }
16.120
16.121 - private static class NativeMethods {
16.122 + protected static class NativeMethods {
16.123 private const string KERNEL = "kernel32.dll";
16.124
16.125 [DllImport(KERNEL, CallingConvention = CallingConvention.Winapi,
17.1 --- a/Hardware/Hardware.cs Tue Sep 21 10:33:28 2010 +0000
17.2 +++ b/Hardware/Hardware.cs Tue Sep 21 20:32:36 2010 +0000
17.3 @@ -41,7 +41,7 @@
17.4 namespace OpenHardwareMonitor.Hardware {
17.5 internal abstract class Hardware : IHardware {
17.6
17.7 - private ListSet<ISensor> active = new ListSet<ISensor>();
17.8 + private readonly ListSet<ISensor> active = new ListSet<ISensor>();
17.9
17.10 public IHardware[] SubHardware {
17.11 get { return new IHardware[0]; }
18.1 --- a/Hardware/Heatmaster/Heatmaster.cs Tue Sep 21 10:33:28 2010 +0000
18.2 +++ b/Hardware/Heatmaster/Heatmaster.cs Tue Sep 21 20:32:36 2010 +0000
18.3 @@ -46,22 +46,22 @@
18.4 namespace OpenHardwareMonitor.Hardware.Heatmaster {
18.5 internal class Heatmaster : Hardware, IDisposable {
18.6
18.7 - private string portName;
18.8 + private readonly string portName;
18.9 private SerialPort serialPort;
18.10
18.11 - private int hardwareRevision;
18.12 - private int firmwareRevision;
18.13 - private int firmwareCRC;
18.14 + private readonly int hardwareRevision;
18.15 + private readonly int firmwareRevision;
18.16 + private readonly int firmwareCRC;
18.17
18.18 - private Sensor[] fans;
18.19 - private Sensor[] controls;
18.20 - private Sensor[] temperatures;
18.21 - private Sensor[] flows;
18.22 - private Sensor[] relays;
18.23 + private readonly Sensor[] fans;
18.24 + private readonly Sensor[] controls;
18.25 + private readonly Sensor[] temperatures;
18.26 + private readonly Sensor[] flows;
18.27 + private readonly Sensor[] relays;
18.28
18.29 - private bool available = false;
18.30 + private readonly bool available;
18.31
18.32 - private StringBuilder buffer = new StringBuilder();
18.33 + private readonly StringBuilder buffer = new StringBuilder();
18.34
18.35 private string ReadLine(int timeout) {
18.36 int i = 0;
18.37 @@ -94,7 +94,7 @@
18.38 return null;
18.39 }
18.40
18.41 - private string ReadString(int device, char field) {
18.42 + protected string ReadString(int device, char field) {
18.43 string s = ReadField(device, field);
18.44 if (s != null && s[0] == '"' && s[s.Length - 1] == '"')
18.45 return s.Substring(1, s.Length - 2);
18.46 @@ -102,7 +102,7 @@
18.47 return null;
18.48 }
18.49
18.50 - private int ReadInteger(int device, char field) {
18.51 + protected int ReadInteger(int device, char field) {
18.52 string s = ReadField(device, field);
18.53 int i;
18.54 if (int.TryParse(s, out i))
18.55 @@ -125,12 +125,12 @@
18.56 return false;
18.57 }
18.58
18.59 - private bool WriteInteger(int device, char field, int value) {
18.60 + protected bool WriteInteger(int device, char field, int value) {
18.61 return WriteField(device, field,
18.62 value.ToString(CultureInfo.InvariantCulture));
18.63 }
18.64
18.65 - private bool WriteString(int device, char field, string value) {
18.66 + protected bool WriteString(int device, char field, string value) {
18.67 return WriteField(device, field, '"' + value + '"');
18.68 }
18.69
18.70 @@ -164,15 +164,7 @@
18.71 new Sensor(name, device, SensorType.Control, this, settings);
18.72 controls[i].Value = (100 / 255.0f) * ReadInteger(device, 'P');
18.73 ActivateSensor(controls[i]);
18.74 - }
18.75 -
18.76 - for (int i = 0; i < fanCount; i++) {
18.77 - int device = 33 + i;
18.78 - string name = ReadString(device, 'C');
18.79 -
18.80 - fans[i].Value = ReadInteger(device, 'R');
18.81 - ActivateSensor(fans[i]);
18.82 - }
18.83 + }
18.84
18.85 temperatures = new Sensor[temperatureCount];
18.86 for (int i = 0; i < temperatureCount; i++) {
18.87 @@ -220,7 +212,7 @@
18.88 public override Identifier Identifier {
18.89 get {
18.90 return new Identifier("heatmaster",
18.91 - serialPort.PortName.TrimStart(new char[]{'/'}).ToLowerInvariant());
18.92 + serialPort.PortName.TrimStart(new [] {'/'}).ToLowerInvariant());
18.93 }
18.94 }
18.95
19.1 --- a/Hardware/Heatmaster/HeatmasterGroup.cs Tue Sep 21 10:33:28 2010 +0000
19.2 +++ b/Hardware/Heatmaster/HeatmasterGroup.cs Tue Sep 21 20:32:36 2010 +0000
19.3 @@ -47,8 +47,8 @@
19.4 namespace OpenHardwareMonitor.Hardware.Heatmaster {
19.5 internal class HeatmasterGroup : IGroup {
19.6
19.7 - private List<Heatmaster> hardware = new List<Heatmaster>();
19.8 - private StringBuilder report = new StringBuilder();
19.9 + private readonly List<Heatmaster> hardware = new List<Heatmaster>();
19.10 + private readonly StringBuilder report = new StringBuilder();
19.11
19.12 private static string ReadLine(SerialPort port, int timeout) {
19.13 int i = 0;
19.14 @@ -82,7 +82,7 @@
19.15 if (subKey != null) {
19.16 string name = subKey.GetValue("PortName") as string;
19.17 if (name != null && !result.Contains(name))
19.18 - result.Add((string)name);
19.19 + result.Add(name);
19.20 }
19.21 }
19.22 }
19.23 @@ -94,7 +94,7 @@
19.24 public HeatmasterGroup(ISettings settings) {
19.25
19.26 // No implementation for Heatmaster on Unix systems
19.27 - int p = (int)System.Environment.OSVersion.Platform;
19.28 + int p = (int)Environment.OSVersion.Platform;
19.29 if ((p == 4) || (p == 128))
19.30 return;
19.31
20.1 --- a/Hardware/HexStringArray.cs Tue Sep 21 10:33:28 2010 +0000
20.2 +++ b/Hardware/HexStringArray.cs Tue Sep 21 20:32:36 2010 +0000
20.3 @@ -41,7 +41,7 @@
20.4 namespace OpenHardwareMonitor.Hardware {
20.5 internal class HexStringArray {
20.6
20.7 - private byte[] array;
20.8 + private readonly byte[] array;
20.9
20.10 public HexStringArray(string input) {
20.11 List<byte> list = new List<byte>();
21.1 --- a/Hardware/ISensor.cs Tue Sep 21 10:33:28 2010 +0000
21.2 +++ b/Hardware/ISensor.cs Tue Sep 21 20:32:36 2010 +0000
21.3 @@ -52,8 +52,8 @@
21.4 }
21.5
21.6 public struct SensorValue {
21.7 - private float value;
21.8 - private DateTime time;
21.9 + private readonly float value;
21.10 + private readonly DateTime time;
21.11
21.12 public SensorValue(float value, DateTime time) {
21.13 this.value = value;
22.1 --- a/Hardware/Identifier.cs Tue Sep 21 10:33:28 2010 +0000
22.2 +++ b/Hardware/Identifier.cs Tue Sep 21 20:32:36 2010 +0000
22.3 @@ -36,17 +36,18 @@
22.4 */
22.5
22.6 using System;
22.7 +using System.Collections.Generic;
22.8 using System.Text;
22.9
22.10 namespace OpenHardwareMonitor.Hardware {
22.11 public class Identifier : IComparable<Identifier> {
22.12 - private string identifier;
22.13 + private readonly string identifier;
22.14
22.15 - private static char SEPARATOR = '/';
22.16 + private const char Separator = '/';
22.17
22.18 - private static void CheckIdentifiers(string[] identifiers) {
22.19 + private static void CheckIdentifiers(IEnumerable<string> identifiers) {
22.20 foreach (string s in identifiers)
22.21 - if (s.Contains(" ") || s.Contains(SEPARATOR.ToString()))
22.22 + if (s.Contains(" ") || s.Contains(Separator.ToString()))
22.23 throw new ArgumentException("Invalid identifier");
22.24 }
22.25
22.26 @@ -55,7 +56,7 @@
22.27
22.28 StringBuilder s = new StringBuilder();
22.29 for (int i = 0; i < identifiers.Length; i++) {
22.30 - s.Append(SEPARATOR);
22.31 + s.Append(Separator);
22.32 s.Append(identifiers[i]);
22.33 }
22.34 this.identifier = s.ToString();
22.35 @@ -67,7 +68,7 @@
22.36 StringBuilder s = new StringBuilder();
22.37 s.Append(identifier.ToString());
22.38 for (int i = 0; i < extensions.Length; i++) {
22.39 - s.Append(SEPARATOR);
22.40 + s.Append(Separator);
22.41 s.Append(extensions[i]);
22.42 }
22.43 this.identifier = s.ToString();
22.44 @@ -77,7 +78,7 @@
22.45 return identifier;
22.46 }
22.47
22.48 - public override bool Equals(System.Object obj) {
22.49 + public override bool Equals(Object obj) {
22.50 if (obj == null)
22.51 return false;
22.52
23.1 --- a/Hardware/LPC/F718XX.cs Tue Sep 21 10:33:28 2010 +0000
23.2 +++ b/Hardware/LPC/F718XX.cs Tue Sep 21 20:32:36 2010 +0000
23.3 @@ -35,20 +35,18 @@
23.4
23.5 */
23.6
23.7 -using System;
23.8 -using System.Collections.Generic;
23.9 using System.Globalization;
23.10 using System.Text;
23.11
23.12 namespace OpenHardwareMonitor.Hardware.LPC {
23.13 internal class F718XX : ISuperIO {
23.14
23.15 - private ushort address;
23.16 - private Chip chip;
23.17 + private readonly ushort address;
23.18 + private readonly Chip chip;
23.19
23.20 - private float?[] voltages;
23.21 - private float?[] temperatures;
23.22 - private float?[] fans;
23.23 + private readonly float?[] voltages;
23.24 + private readonly float?[] temperatures;
23.25 + private readonly float?[] fans;
23.26
23.27 // Hardware Monitor
23.28 private const byte ADDRESS_REGISTER_OFFSET = 0x05;
23.29 @@ -58,7 +56,8 @@
23.30 private const byte VOLTAGE_BASE_REG = 0x20;
23.31 private const byte TEMPERATURE_CONFIG_REG = 0x69;
23.32 private const byte TEMPERATURE_BASE_REG = 0x70;
23.33 - private byte[] FAN_TACHOMETER_REG = new byte[] { 0xA0, 0xB0, 0xC0, 0xD0 };
23.34 + private readonly byte[] FAN_TACHOMETER_REG =
23.35 + new byte[] { 0xA0, 0xB0, 0xC0, 0xD0 };
23.36
23.37 private byte ReadByte(byte register) {
23.38 WinRing0.WriteIoPortByte(
23.39 @@ -126,7 +125,7 @@
23.40 for (int i = 0; i < temperatures.Length; i++) {
23.41 switch (chip) {
23.42 case Chip.F71858: {
23.43 - int tableMode = 0x3 & ReadByte((byte)(TEMPERATURE_CONFIG_REG));
23.44 + int tableMode = 0x3 & ReadByte(TEMPERATURE_CONFIG_REG);
23.45 int high =
23.46 ReadByte((byte)(TEMPERATURE_BASE_REG + 2 * i));
23.47 int low =
24.1 --- a/Hardware/LPC/IT87XX.cs Tue Sep 21 10:33:28 2010 +0000
24.2 +++ b/Hardware/LPC/IT87XX.cs Tue Sep 21 20:32:36 2010 +0000
24.3 @@ -41,16 +41,16 @@
24.4 namespace OpenHardwareMonitor.Hardware.LPC {
24.5 internal class IT87XX : ISuperIO {
24.6
24.7 - private ushort address;
24.8 - private Chip chip;
24.9 - private byte version;
24.10 + private readonly ushort address;
24.11 + private readonly Chip chip;
24.12 + private readonly byte version;
24.13
24.14 private readonly ushort addressReg;
24.15 private readonly ushort dataReg;
24.16
24.17 - private float?[] voltages = new float?[0];
24.18 - private float?[] temperatures = new float?[0];
24.19 - private float?[] fans = new float?[0];
24.20 + private readonly float?[] voltages = new float?[0];
24.21 + private readonly float?[] temperatures = new float?[0];
24.22 + private readonly float?[] fans = new float?[0];
24.23
24.24 private readonly float voltageGain;
24.25
24.26 @@ -66,9 +66,9 @@
24.27 private const byte TEMPERATURE_BASE_REG = 0x29;
24.28 private const byte VENDOR_ID_REGISTER = 0x58;
24.29 private const byte FAN_TACHOMETER_16_BIT_ENABLE_REGISTER = 0x0c;
24.30 - private byte[] FAN_TACHOMETER_REG =
24.31 + private readonly byte[] FAN_TACHOMETER_REG =
24.32 new byte[] { 0x0d, 0x0e, 0x0f, 0x80, 0x82 };
24.33 - private byte[] FAN_TACHOMETER_EXT_REG =
24.34 + private readonly byte[] FAN_TACHOMETER_EXT_REG =
24.35 new byte[] { 0x18, 0x19, 0x1a, 0x81, 0x83 };
24.36 private const byte VOLTAGE_BASE_REG = 0x20;
24.37
24.38 @@ -143,10 +143,8 @@
24.39 r.Append(" ");
24.40 bool valid;
24.41 byte value = ReadByte((byte)((i << 4) | j), out valid);
24.42 - if (valid)
24.43 - r.Append(value.ToString("X2", CultureInfo.InvariantCulture));
24.44 - else
24.45 - r.Append("??");
24.46 + r.Append(
24.47 + valid ? value.ToString("X2", CultureInfo.InvariantCulture) : "??");
24.48 }
24.49 r.AppendLine();
24.50 }
25.1 --- a/Hardware/LPC/LMSensors.cs Tue Sep 21 10:33:28 2010 +0000
25.2 +++ b/Hardware/LPC/LMSensors.cs Tue Sep 21 20:32:36 2010 +0000
25.3 @@ -43,7 +43,7 @@
25.4
25.5 internal class LMSensors {
25.6
25.7 - private List<LMChip> lmChips = new List<LMChip>();
25.8 + private readonly List<LMChip> lmChips = new List<LMChip>();
25.9
25.10 public LMSensors() {
25.11 string[] devicePaths = Directory.GetDirectories("/sys/class/hwmon/");
25.12 @@ -102,15 +102,15 @@
25.13 private class LMChip : ISuperIO {
25.14
25.15 private string path;
25.16 - private Chip chip;
25.17 + private readonly Chip chip;
25.18
25.19 - private float?[] voltages;
25.20 - private float?[] temperatures;
25.21 - private float?[] fans;
25.22 + private readonly float?[] voltages;
25.23 + private readonly float?[] temperatures;
25.24 + private readonly float?[] fans;
25.25
25.26 - private StreamReader[] voltageReaders;
25.27 - private StreamReader[] temperatureReaders;
25.28 - private StreamReader[] fanReaders;
25.29 + private readonly StreamReader[] voltageReaders;
25.30 + private readonly StreamReader[] temperatureReaders;
25.31 + private readonly StreamReader[] fanReaders;
25.32
25.33 public Chip Chip { get { return chip; } }
25.34 public float?[] Voltages { get { return voltages; } }
26.1 --- a/Hardware/LPC/LPCIO.cs Tue Sep 21 10:33:28 2010 +0000
26.2 +++ b/Hardware/LPC/LPCIO.cs Tue Sep 21 20:32:36 2010 +0000
26.3 @@ -44,12 +44,12 @@
26.4 namespace OpenHardwareMonitor.Hardware.LPC {
26.5 internal class LPCIO {
26.6
26.7 - private List<ISuperIO> superIOs = new List<ISuperIO>();
26.8 - private StringBuilder report = new StringBuilder();
26.9 + private readonly List<ISuperIO> superIOs = new List<ISuperIO>();
26.10 + private readonly StringBuilder report = new StringBuilder();
26.11
26.12 // I/O Ports
26.13 - private ushort[] REGISTER_PORTS = new ushort[] { 0x2E, 0x4E };
26.14 - private ushort[] VALUE_PORTS = new ushort[] { 0x2F, 0x4F };
26.15 + private readonly ushort[] REGISTER_PORTS = new ushort[] { 0x2E, 0x4E };
26.16 + private readonly ushort[] VALUE_PORTS = new ushort[] { 0x2F, 0x4F };
26.17
26.18 private ushort registerPort;
26.19 private ushort valuePort;
26.20 @@ -110,11 +110,10 @@
26.21 private bool DetectWinbondFintek() {
26.22 WinbondFintekEnter();
26.23
26.24 - byte logicalDeviceNumber;
26.25 + byte logicalDeviceNumber = 0;
26.26 byte id = ReadByte(CHIP_ID_REGISTER);
26.27 byte revision = ReadByte(CHIP_REVISION_REGISTER);
26.28 Chip chip = Chip.Unknown;
26.29 - logicalDeviceNumber = 0;
26.30 switch (id) {
26.31 case 0x05:
26.32 switch (revision) {
26.33 @@ -441,8 +440,7 @@
26.34
26.35 public string GetReport() {
26.36 if (report.Length > 0) {
26.37 - return "LPCIO" + Environment.NewLine + Environment.NewLine +
26.38 - report.ToString();
26.39 + return "LPCIO" + Environment.NewLine + Environment.NewLine + report;
26.40 } else
26.41 return null;
26.42 }
27.1 --- a/Hardware/LPC/W836XX.cs Tue Sep 21 10:33:28 2010 +0000
27.2 +++ b/Hardware/LPC/W836XX.cs Tue Sep 21 20:32:36 2010 +0000
27.3 @@ -42,19 +42,19 @@
27.4 namespace OpenHardwareMonitor.Hardware.LPC {
27.5 internal class W836XX : ISuperIO {
27.6
27.7 - private ushort address;
27.8 - private byte revision;
27.9 + private readonly ushort address;
27.10 + private readonly byte revision;
27.11
27.12 - private Chip chip;
27.13 + private readonly Chip chip;
27.14
27.15 - private float?[] voltages = new float?[0];
27.16 - private float?[] temperatures = new float?[0];
27.17 - private float?[] fans = new float?[0];
27.18 + private readonly float?[] voltages = new float?[0];
27.19 + private readonly float?[] temperatures = new float?[0];
27.20 + private readonly float?[] fans = new float?[0];
27.21
27.22 - private bool[] peciTemperature = new bool[0];
27.23 - private byte[] voltageRegister = new byte[0];
27.24 - private byte[] voltageBank = new byte[0];
27.25 - private float voltageGain = 0.008f;
27.26 + private readonly bool[] peciTemperature = new bool[0];
27.27 + private readonly byte[] voltageRegister = new byte[0];
27.28 + private readonly byte[] voltageBank = new byte[0];
27.29 + private readonly float voltageGain = 0.008f;
27.30
27.31 // Consts
27.32 private const ushort WINBOND_VENDOR_ID = 0x5CA3;
27.33 @@ -70,15 +70,18 @@
27.34 private const byte VENDOR_ID_REGISTER = 0x4F;
27.35 private const byte TEMPERATURE_SOURCE_SELECT_REG = 0x49;
27.36
27.37 - private byte[] TEMPERATURE_REG = new byte[] { 0x50, 0x50, 0x27 };
27.38 - private byte[] TEMPERATURE_BANK = new byte[] { 1, 2, 0 };
27.39 + private readonly byte[] TEMPERATURE_REG = new byte[] { 0x50, 0x50, 0x27 };
27.40 + private readonly byte[] TEMPERATURE_BANK = new byte[] { 1, 2, 0 };
27.41
27.42 - private byte[] FAN_TACHO_REG = new byte[] { 0x28, 0x29, 0x2A, 0x3F, 0x53 };
27.43 - private byte[] FAN_TACHO_BANK = new byte[] { 0, 0, 0, 0, 5 };
27.44 - private byte[] FAN_BIT_REG = new byte[] { 0x47, 0x4B, 0x4C, 0x59, 0x5D };
27.45 - private byte[] FAN_DIV_BIT0 = new byte[] { 36, 38, 30, 8, 10 };
27.46 - private byte[] FAN_DIV_BIT1 = new byte[] { 37, 39, 31, 9, 11 };
27.47 - private byte[] FAN_DIV_BIT2 = new byte[] { 5, 6, 7, 23, 15 };
27.48 + private readonly byte[] FAN_TACHO_REG =
27.49 + new byte[] { 0x28, 0x29, 0x2A, 0x3F, 0x53 };
27.50 + private readonly byte[] FAN_TACHO_BANK =
27.51 + new byte[] { 0, 0, 0, 0, 5 };
27.52 + private readonly byte[] FAN_BIT_REG =
27.53 + new byte[] { 0x47, 0x4B, 0x4C, 0x59, 0x5D };
27.54 + private readonly byte[] FAN_DIV_BIT0 = new byte[] { 36, 38, 30, 8, 10 };
27.55 + private readonly byte[] FAN_DIV_BIT1 = new byte[] { 37, 39, 31, 9, 11 };
27.56 + private readonly byte[] FAN_DIV_BIT2 = new byte[] { 5, 6, 7, 23, 15 };
27.57
27.58 private byte ReadByte(byte bank, byte register) {
27.59 WinRing0.WriteIoPortByte(
28.1 --- a/Hardware/Mainboard/Mainboard.cs Tue Sep 21 10:33:28 2010 +0000
28.2 +++ b/Hardware/Mainboard/Mainboard.cs Tue Sep 21 20:32:36 2010 +0000
28.3 @@ -41,12 +41,12 @@
28.4
28.5 namespace OpenHardwareMonitor.Hardware.Mainboard {
28.6 internal class Mainboard : IHardware {
28.7 - private SMBIOS smbios;
28.8 - private string name;
28.9 + private readonly SMBIOS smbios;
28.10 + private readonly string name;
28.11
28.12 - private LPCIO lpcio;
28.13 - private LMSensors lmSensors;
28.14 - private IHardware[] superIOHardware;
28.15 + private readonly LPCIO lpcio;
28.16 + private readonly LMSensors lmSensors;
28.17 + private readonly IHardware[] superIOHardware;
28.18
28.19 public Mainboard(ISettings settings) {
28.20 this.smbios = new SMBIOS();
28.21 @@ -66,7 +66,7 @@
28.22 }
28.23
28.24 ISuperIO[] superIO;
28.25 - int p = (int)System.Environment.OSVersion.Platform;
28.26 + int p = (int)Environment.OSVersion.Platform;
28.27 if ((p == 4) || (p == 128)) {
28.28 this.lmSensors = new LMSensors();
28.29 superIO = lmSensors.SuperIO;
29.1 --- a/Hardware/Mainboard/MainboardGroup.cs Tue Sep 21 10:33:28 2010 +0000
29.2 +++ b/Hardware/Mainboard/MainboardGroup.cs Tue Sep 21 20:32:36 2010 +0000
29.3 @@ -38,7 +38,7 @@
29.4 namespace OpenHardwareMonitor.Hardware.Mainboard {
29.5 internal class MainboardGroup : IGroup {
29.6
29.7 - private Mainboard[] mainboards;
29.8 + private readonly Mainboard[] mainboards;
29.9
29.10 public MainboardGroup(ISettings settings) {
29.11 mainboards = new Mainboard[1];
30.1 --- a/Hardware/Mainboard/SMBIOS.cs Tue Sep 21 10:33:28 2010 +0000
30.2 +++ b/Hardware/Mainboard/SMBIOS.cs Tue Sep 21 20:32:36 2010 +0000
30.3 @@ -45,11 +45,11 @@
30.4
30.5 internal class SMBIOS {
30.6
30.7 - private byte[] raw;
30.8 - private Structure[] table;
30.9 + private readonly byte[] raw;
30.10 + private readonly Structure[] table;
30.11
30.12 - private BIOSInformation biosInformation = null;
30.13 - private BaseBoardInformation baseBoardInformation = null;
30.14 + private readonly BIOSInformation biosInformation;
30.15 + private readonly BaseBoardInformation baseBoardInformation;
30.16
30.17 private static string ReadSysFS(string path) {
30.18 try {
30.19 @@ -65,7 +65,7 @@
30.20 }
30.21
30.22 public SMBIOS() {
30.23 - int p = (int)System.Environment.OSVersion.Platform;
30.24 + int p = (int)Environment.OSVersion.Platform;
30.25 if ((p == 4) || (p == 128)) {
30.26 this.raw = null;
30.27 this.table = null;
30.28 @@ -193,11 +193,11 @@
30.29 }
30.30
30.31 public class Structure {
30.32 - private byte type;
30.33 - private ushort handle;
30.34 + private readonly byte type;
30.35 + private readonly ushort handle;
30.36
30.37 - private byte[] data;
30.38 - private string[] strings;
30.39 + private readonly byte[] data;
30.40 + private readonly string[] strings;
30.41
30.42 protected string GetString(int offset) {
30.43 if (offset < data.Length && data[offset] > 0 &&
30.44 @@ -222,8 +222,8 @@
30.45
30.46 public class BIOSInformation : Structure {
30.47
30.48 - private string vendor;
30.49 - private string version;
30.50 + private readonly string vendor;
30.51 + private readonly string version;
30.52
30.53 public BIOSInformation(string vendor, string version)
30.54 : base (0x00, 0, null, null)
30.55 @@ -247,117 +247,115 @@
30.56
30.57 public class BaseBoardInformation : Structure {
30.58
30.59 - private string manufacturerName;
30.60 - private string productName;
30.61 - private string version;
30.62 - private string serialNumber;
30.63 - private Manufacturer manufacturer;
30.64 - private Model model;
30.65 + private readonly string manufacturerName;
30.66 + private readonly string productName;
30.67 + private readonly string version;
30.68 + private readonly string serialNumber;
30.69 + private readonly Manufacturer manufacturer;
30.70 + private readonly Model model;
30.71
30.72 - private void SetManufacturerName(string name) {
30.73 - this.manufacturerName = name;
30.74 -
30.75 + private static Manufacturer GetManufacturer(string name) {
30.76 switch (name) {
30.77 case "ASRock":
30.78 - manufacturer = Manufacturer.ASRock; break;
30.79 + return Manufacturer.ASRock;
30.80 case "ASUSTeK Computer INC.":
30.81 - manufacturer = Manufacturer.ASUS; break;
30.82 + return Manufacturer.ASUS;
30.83 case "Dell Inc.":
30.84 - manufacturer = Manufacturer.Dell; break;
30.85 + return Manufacturer.Dell;
30.86 case "DFI":
30.87 case "DFI Inc.":
30.88 - manufacturer = Manufacturer.DFI; break;
30.89 + return Manufacturer.DFI;
30.90 case "ECS":
30.91 - manufacturer = Manufacturer.ECS; break;
30.92 + return Manufacturer.ECS;
30.93 case "EPoX COMPUTER CO., LTD":
30.94 - manufacturer = Manufacturer.EPoX; break;
30.95 + return Manufacturer.EPoX;
30.96 case "EVGA":
30.97 - manufacturer = Manufacturer.EVGA; break;
30.98 + return Manufacturer.EVGA;
30.99 case "First International Computer, Inc.":
30.100 - manufacturer = Manufacturer.FIC; break;
30.101 + return Manufacturer.FIC;
30.102 case "Gigabyte Technology Co., Ltd.":
30.103 - manufacturer = Manufacturer.Gigabyte; break;
30.104 + return Manufacturer.Gigabyte;
30.105 case "Hewlett-Packard":
30.106 - manufacturer = Manufacturer.HP; break;
30.107 + return Manufacturer.HP;
30.108 case "IBM":
30.109 - manufacturer = Manufacturer.IBM; break;
30.110 + return Manufacturer.IBM;
30.111 case "MICRO-STAR INTERNATIONAL CO., LTD":
30.112 case "MICRO-STAR INTERNATIONAL CO.,LTD":
30.113 - manufacturer = Manufacturer.MSI; break;
30.114 + return Manufacturer.MSI;
30.115 case "XFX":
30.116 - manufacturer = Manufacturer.XFX; break;
30.117 + return Manufacturer.XFX;
30.118 case "To be filled by O.E.M.":
30.119 - manufacturer = Manufacturer.Unknown; break;
30.120 + return Manufacturer.Unknown;
30.121 default:
30.122 - manufacturer = Manufacturer.Unknown; break;
30.123 + return Manufacturer.Unknown;
30.124 }
30.125 }
30.126 -
30.127 - private void SetProductName(string name) {
30.128 - this.productName = name;
30.129 -
30.130 +
30.131 + private static Model GetModel(string name) {
30.132 switch (name) {
30.133 case "880GMH/USB3":
30.134 - model = Model._880GMH_USB3; break;
30.135 + return Model._880GMH_USB3;
30.136 case "Crosshair III Formula":
30.137 - model = Model.Crosshair_III_Formula; break;
30.138 + return Model.Crosshair_III_Formula;
30.139 case "M2N-SLI DELUXE":
30.140 - model = Model.M2N_SLI_DELUXE; break;
30.141 + return Model.M2N_SLI_DELUXE;
30.142 case "M4A79XTD EVO":
30.143 - model = Model.M4A79XTD_EVO; break;
30.144 + return Model.M4A79XTD_EVO;
30.145 case "P5W DH Deluxe":
30.146 - model = Model.P5W_DH_Deluxe; break;
30.147 + return Model.P5W_DH_Deluxe;
30.148 case "P6X58D-E":
30.149 - model = Model.P6X58D_E; break;
30.150 + return Model.P6X58D_E;
30.151 case "Rampage Extreme":
30.152 - model = Model.Rampage_Extreme; break;
30.153 + return Model.Rampage_Extreme;
30.154 case "Rampage II GENE":
30.155 - model = Model.Rampage_II_GENE; break;
30.156 + return Model.Rampage_II_GENE;
30.157 case "LP BI P45-T2RS Elite":
30.158 - model = Model.LP_BI_P45_T2RS_Elite; break;
30.159 + return Model.LP_BI_P45_T2RS_Elite;
30.160 case "LP DK P55-T3eH9":
30.161 - model = Model.LP_DK_P55_T3eH9; break;
30.162 + return Model.LP_DK_P55_T3eH9;
30.163 case "A890GXM-A":
30.164 - model = Model.A890GXM_A; break;
30.165 + return Model.A890GXM_A;
30.166 case "X58 SLI Classified":
30.167 - model = Model.X58_SLI_Classified; break;
30.168 + return Model.X58_SLI_Classified;
30.169 case "965P-S3":
30.170 - model = Model._965P_S3; break;
30.171 + return Model._965P_S3;
30.172 case "EP45-DS3R":
30.173 - model = Model.EP45_DS3R; break;
30.174 + return Model.EP45_DS3R;
30.175 case "EP45-UD3R":
30.176 - model = Model.EP45_UD3R; break;
30.177 + return Model.EP45_UD3R;
30.178 case "EX58-EXTREME":
30.179 - model = Model.EX58_EXTREME; break;
30.180 + return Model.EX58_EXTREME;
30.181 case "GA-MA770T-UD3":
30.182 - model = Model.GA_MA770T_UD3; break;
30.183 + return Model.GA_MA770T_UD3;
30.184 case "GA-MA785GMT-UD2H":
30.185 - model = Model.GA_MA785GMT_UD2H; break;
30.186 + return Model.GA_MA785GMT_UD2H;
30.187 case "P35-DS3":
30.188 - model = Model.P35_DS3; break;
30.189 + return Model.P35_DS3;
30.190 case "P35-DS3L":
30.191 - model = Model.P35_DS3L; break;
30.192 + return Model.P35_DS3L;
30.193 case "P55-UD4":
30.194 - model = Model.P55_UD4; break;
30.195 + return Model.P55_UD4;
30.196 case "P55M-UD4":
30.197 - model = Model.P55M_UD4; break;
30.198 + return Model.P55M_UD4;
30.199 case "X38-DS5":
30.200 - model = Model.X38_DS5; break;
30.201 + return Model.X38_DS5;
30.202 case "X58A-UD3R":
30.203 - model = Model.X58A_UD3R; break;
30.204 + return Model.X58A_UD3R;
30.205 case "To be filled by O.E.M.":
30.206 - model = Model.Unknown; break;
30.207 + return Model.Unknown;
30.208 default:
30.209 - model = Model.Unknown; break;
30.210 + return Model.Unknown;
30.211 }
30.212 }
30.213
30.214 public BaseBoardInformation(string manufacturerName, string productName,
30.215 string version, string serialNumber)
30.216 : base(0x02, 0, null, null)
30.217 - {
30.218 - SetManufacturerName(manufacturerName);
30.219 - SetProductName(productName);
30.220 + {
30.221 + this.manufacturerName = manufacturerName;
30.222 + this.manufacturer = GetManufacturer(manufacturerName);
30.223 + this.productName = productName;
30.224 + this.model = GetModel(productName);
30.225 this.version = version;
30.226 this.serialNumber = serialNumber;
30.227 }
30.228 @@ -366,8 +364,10 @@
30.229 string[] strings)
30.230 : base(type, handle, data, strings) {
30.231
30.232 - SetManufacturerName(GetString(0x04).Trim());
30.233 - SetProductName(GetString(0x05).Trim());
30.234 + this.manufacturerName = GetString(0x04).Trim();
30.235 + this.manufacturer = GetManufacturer(this.manufacturerName);
30.236 + this.productName = GetString(0x05).Trim();
30.237 + this.model = GetModel(this.productName);
30.238 this.version = GetString(0x06).Trim();
30.239 this.serialNumber = GetString(0x07).Trim();
30.240 }
31.1 --- a/Hardware/Mainboard/SuperIOHardware.cs Tue Sep 21 10:33:28 2010 +0000
31.2 +++ b/Hardware/Mainboard/SuperIOHardware.cs Tue Sep 21 20:32:36 2010 +0000
31.3 @@ -42,13 +42,13 @@
31.4 namespace OpenHardwareMonitor.Hardware.Mainboard {
31.5 internal class SuperIOHardware : Hardware {
31.6
31.7 - private Mainboard mainboard;
31.8 - private ISuperIO superIO;
31.9 - private string name;
31.10 + private readonly Mainboard mainboard;
31.11 + private readonly ISuperIO superIO;
31.12 + private readonly string name;
31.13
31.14 - private List<Sensor> voltages = new List<Sensor>();
31.15 - private List<Sensor> temperatures = new List<Sensor>();
31.16 - private List<Sensor> fans = new List<Sensor>();
31.17 + private readonly List<Sensor> voltages = new List<Sensor>();
31.18 + private readonly List<Sensor> temperatures = new List<Sensor>();
31.19 + private readonly List<Sensor> fans = new List<Sensor>();
31.20
31.21
31.22 public SuperIOHardware(Mainboard mainboard, ISuperIO superIO,
31.23 @@ -80,9 +80,9 @@
31.24 case Model.M2N_SLI_DELUXE:
31.25 v.Add(new Voltage("CPU VCore", 0));
31.26 v.Add(new Voltage("+3.3V", 1));
31.27 - v.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
31.28 - v.Add(new Voltage("+12V", 4, 30, 10, 0));
31.29 - v.Add(new Voltage("+5VSB", 7, 6.8f, 10, 0));
31.30 + v.Add(new Voltage("+5V", 3, 6.8f, 10));
31.31 + v.Add(new Voltage("+12V", 4, 30, 10));
31.32 + v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
31.33 v.Add(new Voltage("VBat", 8));
31.34 t.Add(new Temperature("CPU", 0));
31.35 t.Add(new Temperature("Motherboard", 1));
31.36 @@ -91,7 +91,7 @@
31.37 f.Add(new Fan("Power Fan", 2));
31.38 break;
31.39 case Model.M4A79XTD_EVO: // IT8720F
31.40 - v.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
31.41 + v.Add(new Voltage("+5V", 3, 6.8f, 10));
31.42 v.Add(new Voltage("VBat", 8));
31.43 t.Add(new Temperature("CPU", 0));
31.44 t.Add(new Temperature("Motherboard", 1));
31.45 @@ -122,11 +122,11 @@
31.46 v.Add(new Voltage("CPU VCore", 0));
31.47 v.Add(new Voltage("FSB VTT", 1));
31.48 v.Add(new Voltage("+3.3V", 2));
31.49 - v.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
31.50 - v.Add(new Voltage("+12V", 4, 30, 10, 0));
31.51 + v.Add(new Voltage("+5V", 3, 6.8f, 10));
31.52 + v.Add(new Voltage("+12V", 4, 30, 10));
31.53 v.Add(new Voltage("NB Core", 5));
31.54 v.Add(new Voltage("VDIMM", 6));
31.55 - v.Add(new Voltage("+5VSB", 7, 6.8f, 10, 0));
31.56 + v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
31.57 v.Add(new Voltage("VBat", 8));
31.58 t.Add(new Temperature("CPU", 0));
31.59 t.Add(new Temperature("System", 1));
31.60 @@ -139,11 +139,11 @@
31.61 v.Add(new Voltage("CPU VCore", 0));
31.62 v.Add(new Voltage("VTT", 1));
31.63 v.Add(new Voltage("+3.3V", 2));
31.64 - v.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
31.65 - v.Add(new Voltage("+12V", 4, 30, 10, 0));
31.66 + v.Add(new Voltage("+5V", 3, 6.8f, 10));
31.67 + v.Add(new Voltage("+12V", 4, 30, 10));
31.68 v.Add(new Voltage("CPU PLL", 5));
31.69 v.Add(new Voltage("DRAM", 6));
31.70 - v.Add(new Voltage("+5VSB", 7, 6.8f, 10, 0));
31.71 + v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
31.72 v.Add(new Voltage("VBat", 8));
31.73 t.Add(new Temperature("Chipset", 0));
31.74 t.Add(new Temperature("CPU PWM", 1));
31.75 @@ -176,8 +176,8 @@
31.76 v.Add(new Voltage("CPU VCore", 0));
31.77 v.Add(new Voltage("DRAM", 1));
31.78 v.Add(new Voltage("+3.3V", 2));
31.79 - v.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
31.80 - v.Add(new Voltage("+12V", 7, 27, 9.1f, 0));
31.81 + v.Add(new Voltage("+5V", 3, 6.8f, 10));
31.82 + v.Add(new Voltage("+12V", 7, 27, 9.1f));
31.83 v.Add(new Voltage("VBat", 8));
31.84 t.Add(new Temperature("System", 0));
31.85 t.Add(new Temperature("CPU", 1));
31.86 @@ -190,8 +190,8 @@
31.87 v.Add(new Voltage("CPU VCore", 0));
31.88 v.Add(new Voltage("DRAM", 1));
31.89 v.Add(new Voltage("+3.3V", 2));
31.90 - v.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
31.91 - v.Add(new Voltage("+12V", 7, 27, 9.1f, 0));
31.92 + v.Add(new Voltage("+5V", 3, 6.8f, 10));
31.93 + v.Add(new Voltage("+12V", 7, 27, 9.1f));
31.94 v.Add(new Voltage("VBat", 8));
31.95 t.Add(new Temperature("System", 0));
31.96 t.Add(new Temperature("CPU", 1));
31.97 @@ -203,7 +203,7 @@
31.98 case Model.EX58_EXTREME: // IT8720F
31.99 v.Add(new Voltage("CPU VCore", 0));
31.100 v.Add(new Voltage("DRAM", 1));
31.101 - v.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
31.102 + v.Add(new Voltage("+5V", 3, 6.8f, 10));
31.103 v.Add(new Voltage("VBat", 8));
31.104 t.Add(new Temperature("System", 0));
31.105 t.Add(new Temperature("CPU", 1));
31.106 @@ -218,8 +218,8 @@
31.107 v.Add(new Voltage("CPU VCore", 0));
31.108 v.Add(new Voltage("DRAM", 1));
31.109 v.Add(new Voltage("+3.3V", 2));
31.110 - v.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
31.111 - v.Add(new Voltage("+12V", 7, 27, 9.1f, 0));
31.112 + v.Add(new Voltage("+5V", 3, 6.8f, 10));
31.113 + v.Add(new Voltage("+12V", 7, 27, 9.1f));
31.114 v.Add(new Voltage("VBat", 8));
31.115 t.Add(new Temperature("System", 0));
31.116 t.Add(new Temperature("CPU", 1));
31.117 @@ -233,8 +233,8 @@
31.118 v.Add(new Voltage("CPU VCore", 0));
31.119 v.Add(new Voltage("DRAM", 1));
31.120 v.Add(new Voltage("+3.3V", 2));
31.121 - v.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
31.122 - v.Add(new Voltage("+12V", 5, 27, 9.1f, 0));
31.123 + v.Add(new Voltage("+5V", 3, 6.8f, 10));
31.124 + v.Add(new Voltage("+12V", 5, 27, 9.1f));
31.125 v.Add(new Voltage("VBat", 8));
31.126 t.Add(new Temperature("System", 0));
31.127 t.Add(new Temperature("CPU", 2));
31.128 @@ -247,8 +247,8 @@
31.129 v.Add(new Voltage("CPU VCore", 0));
31.130 v.Add(new Voltage("DRAM", 1));
31.131 v.Add(new Voltage("+3.3V", 2));
31.132 - v.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
31.133 - v.Add(new Voltage("+12V", 4, 27, 9.1f, 0));
31.134 + v.Add(new Voltage("+5V", 3, 6.8f, 10));
31.135 + v.Add(new Voltage("+12V", 4, 27, 9.1f));
31.136 v.Add(new Voltage("VBat", 8));
31.137 t.Add(new Temperature("System", 0));
31.138 t.Add(new Temperature("CPU", 1));
31.139 @@ -261,8 +261,8 @@
31.140 v.Add(new Voltage("CPU VCore", 0));
31.141 v.Add(new Voltage("DRAM", 1));
31.142 v.Add(new Voltage("+3.3V", 2));
31.143 - v.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
31.144 - v.Add(new Voltage("+12V", 4, 27, 9.1f, 0));
31.145 + v.Add(new Voltage("+5V", 3, 6.8f, 10));
31.146 + v.Add(new Voltage("+12V", 4, 27, 9.1f));
31.147 v.Add(new Voltage("VBat", 8));
31.148 t.Add(new Temperature("System", 0));
31.149 t.Add(new Temperature("CPU", 1));
31.150 @@ -274,8 +274,8 @@
31.151 v.Add(new Voltage("CPU VCore", 0));
31.152 v.Add(new Voltage("DRAM", 1));
31.153 v.Add(new Voltage("+3.3V", 2));
31.154 - v.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
31.155 - v.Add(new Voltage("+12V", 5, 27, 9.1f, 0));
31.156 + v.Add(new Voltage("+5V", 3, 6.8f, 10));
31.157 + v.Add(new Voltage("+12V", 5, 27, 9.1f));
31.158 v.Add(new Voltage("VBat", 8));
31.159 t.Add(new Temperature("System", 0));
31.160 t.Add(new Temperature("CPU", 1));
31.161 @@ -329,10 +329,10 @@
31.162 v.Add(new Voltage("CPU VCore", 0));
31.163 v.Add(new Voltage("VDIMM", 1));
31.164 v.Add(new Voltage("NB Voltage", 2));
31.165 - v.Add(new Voltage("Analog +3.3V", 3, 10, 10, 0));
31.166 + v.Add(new Voltage("Analog +3.3V", 3, 10, 10));
31.167 // v.Add(new Voltage("VDIMM", 6, true));
31.168 - v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0));
31.169 - v.Add(new Voltage("VBat", 8, 10, 10, 0));
31.170 + v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
31.171 + v.Add(new Voltage("VBat", 8, 10, 10));
31.172 t.Add(new Temperature("CPU", 0));
31.173 t.Add(new Temperature("System", 1));
31.174 t.Add(new Temperature("Northbridge", 2));
31.175 @@ -349,7 +349,7 @@
31.176 v.Add(new Voltage("Voltage #6", 5, true));
31.177 v.Add(new Voltage("Voltage #7", 6, true));
31.178 v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
31.179 - v.Add(new Voltage("VBat", 8, 10, 10, 0));
31.180 + v.Add(new Voltage("VBat", 8, 10, 10));
31.181 for (int i = 0; i < superIO.Temperatures.Length; i++)
31.182 t.Add(new Temperature("Temperature #" + (i + 1), i));
31.183 for (int i = 0; i < superIO.Fans.Length; i++)
31.184 @@ -366,7 +366,7 @@
31.185 v.Add(new Voltage("Voltage #6", 5, true));
31.186 v.Add(new Voltage("Voltage #7", 6, true));
31.187 v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
31.188 - v.Add(new Voltage("VBat", 8, 10, 10, 0));
31.189 + v.Add(new Voltage("VBat", 8, 10, 10));
31.190 for (int i = 0; i < superIO.Temperatures.Length; i++)
31.191 t.Add(new Temperature("Temperature #" + (i + 1), i));
31.192 for (int i = 0; i < superIO.Fans.Length; i++)
31.193 @@ -376,9 +376,9 @@
31.194 break;
31.195
31.196 case Chip.F71858:
31.197 - v.Add(new Voltage("VCC3V", 0, 150, 150, 0));
31.198 - v.Add(new Voltage("VSB3V", 1, 150, 150, 0));
31.199 - v.Add(new Voltage("Battery", 2, 150, 150, 0));
31.200 + v.Add(new Voltage("VCC3V", 0, 150, 150));
31.201 + v.Add(new Voltage("VSB3V", 1, 150, 150));
31.202 + v.Add(new Voltage("Battery", 2, 150, 150));
31.203 for (int i = 0; i < superIO.Temperatures.Length; i++)
31.204 t.Add(new Temperature("Temperature #" + (i + 1), i));
31.205 for (int i = 0; i < superIO.Fans.Length; i++)
31.206 @@ -393,15 +393,15 @@
31.207 case Manufacturer.EVGA:
31.208 switch (model) {
31.209 case Model.X58_SLI_Classified: // F71882
31.210 - v.Add(new Voltage("VCC3V", 0, 150, 150, 0));
31.211 - v.Add(new Voltage("CPU VCore", 1, 47, 100, 0));
31.212 - v.Add(new Voltage("DIMM", 2, 47, 100, 0));
31.213 - v.Add(new Voltage("CPU VTT", 3, 24, 100, 0));
31.214 - v.Add(new Voltage("IOH Vcore", 4, 24, 100, 0));
31.215 - v.Add(new Voltage("+5V", 5, 51, 12, 0));
31.216 - v.Add(new Voltage("+12V", 6, 56, 6.8f, 0));
31.217 - v.Add(new Voltage("3VSB", 7, 150, 150, 0));
31.218 - v.Add(new Voltage("VBat", 8, 150, 150, 0));
31.219 + v.Add(new Voltage("VCC3V", 0, 150, 150));
31.220 + v.Add(new Voltage("CPU VCore", 1, 47, 100));
31.221 + v.Add(new Voltage("DIMM", 2, 47, 100));
31.222 + v.Add(new Voltage("CPU VTT", 3, 24, 100));
31.223 + v.Add(new Voltage("IOH Vcore", 4, 24, 100));
31.224 + v.Add(new Voltage("+5V", 5, 51, 12));
31.225 + v.Add(new Voltage("+12V", 6, 56, 6.8f));
31.226 + v.Add(new Voltage("3VSB", 7, 150, 150));
31.227 + v.Add(new Voltage("VBat", 8, 150, 150));
31.228 t.Add(new Temperature("CPU", 0));
31.229 t.Add(new Temperature("VREG", 1));
31.230 t.Add(new Temperature("System", 2));
31.231 @@ -410,15 +410,15 @@
31.232 f.Add(new Fan("Chassis Fan", 2));
31.233 break;
31.234 default:
31.235 - v.Add(new Voltage("VCC3V", 0, 150, 150, 0));
31.236 + v.Add(new Voltage("VCC3V", 0, 150, 150));
31.237 v.Add(new Voltage("CPU VCore", 1));
31.238 v.Add(new Voltage("Voltage #3", 2, true));
31.239 v.Add(new Voltage("Voltage #4", 3, true));
31.240 v.Add(new Voltage("Voltage #5", 4, true));
31.241 v.Add(new Voltage("Voltage #6", 5, true));
31.242 v.Add(new Voltage("Voltage #7", 6, true));
31.243 - v.Add(new Voltage("VSB3V", 7, 150, 150, 0));
31.244 - v.Add(new Voltage("VBat", 8, 150, 150, 0));
31.245 + v.Add(new Voltage("VSB3V", 7, 150, 150));
31.246 + v.Add(new Voltage("VBat", 8, 150, 150));
31.247 for (int i = 0; i < superIO.Temperatures.Length; i++)
31.248 t.Add(new Temperature("Temperature #" + (i + 1), i));
31.249 for (int i = 0; i < superIO.Fans.Length; i++)
31.250 @@ -427,15 +427,15 @@
31.251 }
31.252 break;
31.253 default:
31.254 - v.Add(new Voltage("VCC3V", 0, 150, 150, 0));
31.255 + v.Add(new Voltage("VCC3V", 0, 150, 150));
31.256 v.Add(new Voltage("CPU VCore", 1));
31.257 v.Add(new Voltage("Voltage #3", 2, true));
31.258 v.Add(new Voltage("Voltage #4", 3, true));
31.259 v.Add(new Voltage("Voltage #5", 4, true));
31.260 v.Add(new Voltage("Voltage #6", 5, true));
31.261 v.Add(new Voltage("Voltage #7", 6, true));
31.262 - v.Add(new Voltage("VSB3V", 7, 150, 150, 0));
31.263 - v.Add(new Voltage("VBat", 8, 150, 150, 0));
31.264 + v.Add(new Voltage("VSB3V", 7, 150, 150));
31.265 + v.Add(new Voltage("VBat", 8, 150, 150));
31.266 for (int i = 0; i < superIO.Temperatures.Length; i++)
31.267 t.Add(new Temperature("Temperature #" + (i + 1), i));
31.268 for (int i = 0; i < superIO.Fans.Length; i++)
31.269 @@ -447,13 +447,13 @@
31.270 case Chip.W83627EHF:
31.271 v.Add(new Voltage("CPU VCore", 0));
31.272 v.Add(new Voltage("Voltage #2", 1, true));
31.273 - v.Add(new Voltage("AVCC", 2, 34, 34, 0));
31.274 - v.Add(new Voltage("3VCC", 3, 34, 34, 0));
31.275 + v.Add(new Voltage("AVCC", 2, 34, 34));
31.276 + v.Add(new Voltage("3VCC", 3, 34, 34));
31.277 v.Add(new Voltage("Voltage #5", 4, true));
31.278 v.Add(new Voltage("Voltage #6", 5, true));
31.279 v.Add(new Voltage("Voltage #7", 6, true));
31.280 - v.Add(new Voltage("3VSB", 7, 34, 34, 0));
31.281 - v.Add(new Voltage("VBAT", 8, 34, 34, 0));
31.282 + v.Add(new Voltage("3VSB", 7, 34, 34));
31.283 + v.Add(new Voltage("VBAT", 8, 34, 34));
31.284 v.Add(new Voltage("Voltage #10", 9, true));
31.285 t.Add(new Temperature("CPU", 0));
31.286 t.Add(new Temperature("Auxiliary", 1));
31.287 @@ -473,11 +473,11 @@
31.288 switch (model) {
31.289 case Model._880GMH_USB3: // W83627DHG-P
31.290 v.Add(new Voltage("CPU VCore", 0));
31.291 - v.Add(new Voltage("+3.3V", 3, 34, 34, 0));
31.292 - v.Add(new Voltage("+5V", 5, 15, 7.5f, 0));
31.293 - v.Add(new Voltage("+12V", 6, 56, 10, 0));
31.294 - v.Add(new Voltage("Standby +3.3V", 7, 34, 34, 0));
31.295 - v.Add(new Voltage("VBAT", 8, 34, 34, 0));
31.296 + v.Add(new Voltage("+3.3V", 3, 34, 34));
31.297 + v.Add(new Voltage("+5V", 5, 15, 7.5f));
31.298 + v.Add(new Voltage("+12V", 6, 56, 10));
31.299 + v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
31.300 + v.Add(new Voltage("VBAT", 8, 34, 34));
31.301 t.Add(new Temperature("CPU", 0));
31.302 t.Add(new Temperature("Motherboard", 2));
31.303 f.Add(new Fan("Chassis Fan", 0));
31.304 @@ -487,13 +487,13 @@
31.305 default:
31.306 v.Add(new Voltage("CPU VCore", 0));
31.307 v.Add(new Voltage("Voltage #2", 1, true));
31.308 - v.Add(new Voltage("AVCC", 2, 34, 34, 0));
31.309 - v.Add(new Voltage("3VCC", 3, 34, 34, 0));
31.310 + v.Add(new Voltage("AVCC", 2, 34, 34));
31.311 + v.Add(new Voltage("3VCC", 3, 34, 34));
31.312 v.Add(new Voltage("Voltage #5", 4, true));
31.313 v.Add(new Voltage("Voltage #6", 5, true));
31.314 v.Add(new Voltage("Voltage #7", 6, true));
31.315 - v.Add(new Voltage("3VSB", 7, 34, 34, 0));
31.316 - v.Add(new Voltage("VBAT", 8, 34, 34, 0));
31.317 + v.Add(new Voltage("3VSB", 7, 34, 34));
31.318 + v.Add(new Voltage("VBAT", 8, 34, 34));
31.319 t.Add(new Temperature("CPU", 0));
31.320 t.Add(new Temperature("Auxiliary", 1));
31.321 t.Add(new Temperature("System", 2));
31.322 @@ -510,12 +510,12 @@
31.323 case Model.P6X58D_E: // W83667HG
31.324 case Model.Rampage_II_GENE: // W83667HG
31.325 v.Add(new Voltage("CPU VCore", 0));
31.326 - v.Add(new Voltage("+12V", 1, 11.5f, 1.91f, 0));
31.327 - v.Add(new Voltage("Analog +3.3V", 2, 34, 34, 0));
31.328 - v.Add(new Voltage("+3.3V", 3, 34, 34, 0));
31.329 - v.Add(new Voltage("+5V", 4, 15, 7.5f, 0));
31.330 - v.Add(new Voltage("Standby +3.3V", 7, 34, 34, 0));
31.331 - v.Add(new Voltage("VBAT", 8, 34, 34, 0));
31.332 + v.Add(new Voltage("+12V", 1, 11.5f, 1.91f));
31.333 + v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
31.334 + v.Add(new Voltage("+3.3V", 3, 34, 34));
31.335 + v.Add(new Voltage("+5V", 4, 15, 7.5f));
31.336 + v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
31.337 + v.Add(new Voltage("VBAT", 8, 34, 34));
31.338 t.Add(new Temperature("CPU", 0));
31.339 t.Add(new Temperature("Motherboard", 2));
31.340 f.Add(new Fan("Chassis Fan #1", 0));
31.341 @@ -526,12 +526,12 @@
31.342 break;
31.343 case Model.Rampage_Extreme: // W83667HG
31.344 v.Add(new Voltage("CPU VCore", 0));
31.345 - v.Add(new Voltage("+12V", 1, 12, 2, 0));
31.346 - v.Add(new Voltage("Analog +3.3V", 2, 34, 34, 0));
31.347 - v.Add(new Voltage("+3.3V", 3, 34, 34, 0));
31.348 - v.Add(new Voltage("+5V", 4, 15, 7.5f, 0));
31.349 - v.Add(new Voltage("Standby +3.3V", 7, 34, 34, 0));
31.350 - v.Add(new Voltage("VBAT", 8, 34, 34, 0));
31.351 + v.Add(new Voltage("+12V", 1, 12, 2));
31.352 + v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
31.353 + v.Add(new Voltage("+3.3V", 3, 34, 34));
31.354 + v.Add(new Voltage("+5V", 4, 15, 7.5f));
31.355 + v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
31.356 + v.Add(new Voltage("VBAT", 8, 34, 34));
31.357 t.Add(new Temperature("CPU", 0));
31.358 t.Add(new Temperature("Motherboard", 2));
31.359 f.Add(new Fan("Chassis Fan #1", 0));
31.360 @@ -543,13 +543,13 @@
31.361 default:
31.362 v.Add(new Voltage("CPU VCore", 0));
31.363 v.Add(new Voltage("Voltage #2", 1, true));
31.364 - v.Add(new Voltage("AVCC", 2, 34, 34, 0));
31.365 - v.Add(new Voltage("3VCC", 3, 34, 34, 0));
31.366 + v.Add(new Voltage("AVCC", 2, 34, 34));
31.367 + v.Add(new Voltage("3VCC", 3, 34, 34));
31.368 v.Add(new Voltage("Voltage #5", 4, true));
31.369 v.Add(new Voltage("Voltage #6", 5, true));
31.370 v.Add(new Voltage("Voltage #7", 6, true));
31.371 - v.Add(new Voltage("3VSB", 7, 34, 34, 0));
31.372 - v.Add(new Voltage("VBAT", 8, 34, 34, 0));
31.373 + v.Add(new Voltage("3VSB", 7, 34, 34));
31.374 + v.Add(new Voltage("VBAT", 8, 34, 34));
31.375 t.Add(new Temperature("CPU", 0));
31.376 t.Add(new Temperature("Auxiliary", 1));
31.377 t.Add(new Temperature("System", 2));
31.378 @@ -564,13 +564,13 @@
31.379 default:
31.380 v.Add(new Voltage("CPU VCore", 0));
31.381 v.Add(new Voltage("Voltage #2", 1, true));
31.382 - v.Add(new Voltage("AVCC", 2, 34, 34, 0));
31.383 - v.Add(new Voltage("3VCC", 3, 34, 34, 0));
31.384 + v.Add(new Voltage("AVCC", 2, 34, 34));
31.385 + v.Add(new Voltage("3VCC", 3, 34, 34));
31.386 v.Add(new Voltage("Voltage #5", 4, true));
31.387 v.Add(new Voltage("Voltage #6", 5, true));
31.388 v.Add(new Voltage("Voltage #7", 6, true));
31.389 - v.Add(new Voltage("3VSB", 7, 34, 34, 0));
31.390 - v.Add(new Voltage("VBAT", 8, 34, 34, 0));
31.391 + v.Add(new Voltage("3VSB", 7, 34, 34));
31.392 + v.Add(new Voltage("VBAT", 8, 34, 34));
31.393 t.Add(new Temperature("CPU", 0));
31.394 t.Add(new Temperature("Auxiliary", 1));
31.395 t.Add(new Temperature("System", 2));
31.396 @@ -588,9 +588,9 @@
31.397 v.Add(new Voltage("CPU VCore", 0));
31.398 v.Add(new Voltage("Voltage #2", 1, true));
31.399 v.Add(new Voltage("Voltage #3", 2, true));
31.400 - v.Add(new Voltage("AVCC", 3, 34, 51, 0));
31.401 + v.Add(new Voltage("AVCC", 3, 34, 51));
31.402 v.Add(new Voltage("Voltage #5", 4, true));
31.403 - v.Add(new Voltage("5VSB", 5, 34, 51, 0));
31.404 + v.Add(new Voltage("5VSB", 5, 34, 51));
31.405 v.Add(new Voltage("VBAT", 6));
31.406 t.Add(new Temperature("CPU", 0));
31.407 t.Add(new Temperature("Auxiliary", 1));
31.408 @@ -609,12 +609,11 @@
31.409 break;
31.410 }
31.411
31.412 - string formula = "Voltage = value + (value - Vf) * Ri / Rf.";
31.413 + const string formula = "Voltage = value + (value - Vf) * Ri / Rf.";
31.414 foreach (Voltage voltage in v)
31.415 if (voltage.Index < superIO.Voltages.Length) {
31.416 Sensor sensor = new Sensor(voltage.Name, voltage.Index,
31.417 - voltage.Hidden, SensorType.Voltage, this,
31.418 - new ParameterDescription[] {
31.419 + voltage.Hidden, SensorType.Voltage, this, new [] {
31.420 new ParameterDescription("Ri [kΩ]", "Input resistance.\n" +
31.421 formula, voltage.Ri),
31.422 new ParameterDescription("Rf [kΩ]", "Reference resistance.\n" +
31.423 @@ -628,7 +627,7 @@
31.424 foreach (Temperature temperature in t)
31.425 if (temperature.Index < superIO.Temperatures.Length) {
31.426 Sensor sensor = new Sensor(temperature.Name, temperature.Index,
31.427 - SensorType.Temperature, this, new ParameterDescription[] {
31.428 + SensorType.Temperature, this, new [] {
31.429 new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
31.430 }, settings);
31.431 temperatures.Add(sensor);
31.432 @@ -703,17 +702,12 @@
31.433 public readonly float Vf;
31.434 public readonly bool Hidden;
31.435
31.436 - public Voltage(string name, int index) :
31.437 - this(name, index, 0, 1, 0, false) { }
31.438 -
31.439 public Voltage(string name, int index, bool hidden) :
31.440 this(name, index, 0, 1, 0, hidden) { }
31.441
31.442 - public Voltage(string name, int index, float ri, float rf, float vf) :
31.443 - this(name, index, ri, rf, vf, false) { }
31.444 -
31.445 - public Voltage(string name, int index, float ri, float rf, float vf,
31.446 - bool hidden) {
31.447 + public Voltage(string name, int index,
31.448 + float ri = 0, float rf = 1, float vf = 0, bool hidden = false)
31.449 + {
31.450 this.Name = name;
31.451 this.Index = index;
31.452 this.Ri = ri;
32.1 --- a/Hardware/Nvidia/NVAPI.cs Tue Sep 21 10:33:28 2010 +0000
32.2 +++ b/Hardware/Nvidia/NVAPI.cs Tue Sep 21 20:32:36 2010 +0000
32.3 @@ -141,12 +141,12 @@
32.4
32.5 [StructLayout(LayoutKind.Sequential)]
32.6 internal struct NvDisplayHandle {
32.7 - private IntPtr ptr;
32.8 + private readonly IntPtr ptr;
32.9 }
32.10
32.11 [StructLayout(LayoutKind.Sequential)]
32.12 internal struct NvPhysicalGpuHandle {
32.13 - private IntPtr ptr;
32.14 + private readonly IntPtr ptr;
32.15 }
32.16
32.17 [StructLayout(LayoutKind.Sequential, Pack = 8)]
32.18 @@ -281,11 +281,12 @@
32.19 public delegate NvStatus NvAPI_GetInterfaceVersionStringDelegate(
32.20 StringBuilder version);
32.21
32.22 - private static bool available = false;
32.23 - private static nvapi_QueryInterfaceDelegate nvapi_QueryInterface;
32.24 - private static NvAPI_InitializeDelegate NvAPI_Initialize;
32.25 - private static NvAPI_GPU_GetFullNameDelegate _NvAPI_GPU_GetFullName;
32.26 - private static NvAPI_GetInterfaceVersionStringDelegate
32.27 + private static readonly bool available;
32.28 + private static readonly nvapi_QueryInterfaceDelegate nvapi_QueryInterface;
32.29 + private static readonly NvAPI_InitializeDelegate NvAPI_Initialize;
32.30 + private static readonly NvAPI_GPU_GetFullNameDelegate
32.31 + _NvAPI_GPU_GetFullName;
32.32 + private static readonly NvAPI_GetInterfaceVersionStringDelegate
32.33 _NvAPI_GetInterfaceVersionString;
32.34
32.35 public static readonly NvAPI_GPU_GetThermalSettingsDelegate
33.1 --- a/Hardware/Nvidia/NvidiaGPU.cs Tue Sep 21 10:33:28 2010 +0000
33.2 +++ b/Hardware/Nvidia/NvidiaGPU.cs Tue Sep 21 20:32:36 2010 +0000
33.3 @@ -40,19 +40,19 @@
33.4 using System.Text;
33.5
33.6 namespace OpenHardwareMonitor.Hardware.Nvidia {
33.7 - internal class NvidiaGPU : Hardware, IHardware {
33.8 + internal class NvidiaGPU : Hardware {
33.9
33.10 - private string name;
33.11 - private int adapterIndex;
33.12 - private NvPhysicalGpuHandle handle;
33.13 - private NvDisplayHandle? displayHandle;
33.14 + private readonly string name;
33.15 + private readonly int adapterIndex;
33.16 + private readonly NvPhysicalGpuHandle handle;
33.17 + private readonly NvDisplayHandle? displayHandle;
33.18
33.19 - private Sensor[] temperatures;
33.20 - private Sensor fan = null;
33.21 - private Sensor[] clocks;
33.22 - private Sensor[] loads;
33.23 - private Sensor control;
33.24 - private Sensor memoryLoad;
33.25 + private readonly Sensor[] temperatures;
33.26 + private readonly Sensor fan;
33.27 + private readonly Sensor[] clocks;
33.28 + private readonly Sensor[] loads;
33.29 + private readonly Sensor control;
33.30 + private readonly Sensor memoryLoad;
33.31
33.32 public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle,
33.33 NvDisplayHandle? displayHandle, ISettings settings)
34.1 --- a/Hardware/Nvidia/NvidiaGroup.cs Tue Sep 21 10:33:28 2010 +0000
34.2 +++ b/Hardware/Nvidia/NvidiaGroup.cs Tue Sep 21 20:32:36 2010 +0000
34.3 @@ -43,8 +43,8 @@
34.4
34.5 internal class NvidiaGroup : IGroup {
34.6
34.7 - private List<IHardware> hardware = new List<IHardware>();
34.8 - private StringBuilder report = new StringBuilder();
34.9 + private readonly List<IHardware> hardware = new List<IHardware>();
34.10 + private readonly StringBuilder report = new StringBuilder();
34.11
34.12 public NvidiaGroup(ISettings settings) {
34.13 if (!NVAPI.IsAvailable)
34.14 @@ -69,7 +69,7 @@
34.15 } else {
34.16 NvStatus status = NVAPI.NvAPI_EnumPhysicalGPUs(handles, out count);
34.17 if (status != NvStatus.OK) {
34.18 - report.AppendLine("Status: " + status.ToString());
34.19 + report.AppendLine("Status: " + status);
34.20 report.AppendLine();
34.21 return;
34.22 }
34.23 @@ -104,14 +104,12 @@
34.24 }
34.25
34.26 report.Append("Number of GPUs: ");
34.27 - report.AppendLine(count.ToString(CultureInfo.InvariantCulture));
34.28 -
34.29 - for (int i = 0; i < count; i++) {
34.30 + report.AppendLine(count.ToString(CultureInfo.InvariantCulture));
34.31 +
34.32 + for (int i = 0; i < count; i++) {
34.33 NvDisplayHandle displayHandle;
34.34 - if (displayHandles.TryGetValue(handles[i], out displayHandle))
34.35 - hardware.Add(new NvidiaGPU(i, handles[i], displayHandle, settings));
34.36 - else
34.37 - hardware.Add(new NvidiaGPU(i, handles[i], null, settings));
34.38 + displayHandles.TryGetValue(handles[i], out displayHandle);
34.39 + hardware.Add(new NvidiaGPU(i, handles[i], displayHandle, settings));
34.40 }
34.41
34.42 report.AppendLine();
35.1 --- a/Hardware/PInvokeDelegateFactory.cs Tue Sep 21 10:33:28 2010 +0000
35.2 +++ b/Hardware/PInvokeDelegateFactory.cs Tue Sep 21 20:32:36 2010 +0000
35.3 @@ -43,19 +43,17 @@
35.4
35.5 namespace OpenHardwareMonitor.Hardware {
35.6
35.7 - internal sealed class PInvokeDelegateFactory {
35.8 + internal static class PInvokeDelegateFactory {
35.9
35.10 - private static ModuleBuilder moduleBuilder =
35.11 + private static readonly ModuleBuilder moduleBuilder =
35.12 AppDomain.CurrentDomain.DefineDynamicAssembly(
35.13 new AssemblyName("PInvokeDelegateFactoryInternalAssembly"),
35.14 AssemblyBuilderAccess.Run).DefineDynamicModule(
35.15 "PInvokeDelegateFactoryInternalModule");
35.16
35.17 - private static IDictionary<DllImportAttribute, Type> wrapperTypes =
35.18 + private static readonly IDictionary<DllImportAttribute, Type> wrapperTypes =
35.19 new Dictionary<DllImportAttribute, Type>();
35.20
35.21 - private PInvokeDelegateFactory() { }
35.22 -
35.23 public static void CreateDelegate<T>(DllImportAttribute dllImportAttribute,
35.24 out T newDelegate) where T : class
35.25 {
36.1 --- a/Hardware/Parameter.cs Tue Sep 21 10:33:28 2010 +0000
36.2 +++ b/Hardware/Parameter.cs Tue Sep 21 20:32:36 2010 +0000
36.3 @@ -41,9 +41,9 @@
36.4 namespace OpenHardwareMonitor.Hardware {
36.5
36.6 internal struct ParameterDescription {
36.7 - private string name;
36.8 - private string description;
36.9 - private float defaultValue;
36.10 + private readonly string name;
36.11 + private readonly string description;
36.12 + private readonly float defaultValue;
36.13
36.14 public ParameterDescription(string name, string description,
36.15 float defaultValue) {
36.16 @@ -60,11 +60,11 @@
36.17 }
36.18
36.19 internal class Parameter : IParameter {
36.20 - private ISensor sensor;
36.21 + private readonly ISensor sensor;
36.22 private ParameterDescription description;
36.23 private float value;
36.24 private bool isDefault;
36.25 - private ISettings settings;
36.26 + private readonly ISettings settings;
36.27
36.28 public Parameter(ParameterDescription description, ISensor sensor,
36.29 ISettings settings)
37.1 --- a/Hardware/Sensor.cs Tue Sep 21 10:33:28 2010 +0000
37.2 +++ b/Hardware/Sensor.cs Tue Sep 21 20:32:36 2010 +0000
37.3 @@ -44,22 +44,22 @@
37.4
37.5 internal class Sensor : ISensor {
37.6
37.7 - private string defaultName;
37.8 + private readonly string defaultName;
37.9 private string name;
37.10 - private int index;
37.11 - private bool defaultHidden;
37.12 - private SensorType sensorType;
37.13 - private IHardware hardware;
37.14 - private ReadOnlyArray<IParameter> parameters;
37.15 + private readonly int index;
37.16 + private readonly bool defaultHidden;
37.17 + private readonly SensorType sensorType;
37.18 + private readonly IHardware hardware;
37.19 + private readonly ReadOnlyArray<IParameter> parameters;
37.20 private float? currentValue;
37.21 private float? minValue;
37.22 private float? maxValue;
37.23 - private Queue<SensorValue> values =
37.24 + private readonly Queue<SensorValue> values =
37.25 new Queue<SensorValue>(MAX_MINUTES * 15);
37.26 - private ISettings settings;
37.27 + private readonly ISettings settings;
37.28
37.29 - private float sum = 0;
37.30 - private int count = 0;
37.31 + private float sum;
37.32 + private int count;
37.33
37.34 private const int MAX_MINUTES = 120;
37.35
38.1 --- a/Hardware/SensorVisitor.cs Tue Sep 21 10:33:28 2010 +0000
38.2 +++ b/Hardware/SensorVisitor.cs Tue Sep 21 20:32:36 2010 +0000
38.3 @@ -41,7 +41,7 @@
38.4 namespace OpenHardwareMonitor.Hardware {
38.5
38.6 public class SensorVisitor : IVisitor {
38.7 - private SensorEventHandler handler;
38.8 + private readonly SensorEventHandler handler;
38.9
38.10 public SensorVisitor(SensorEventHandler handler) {
38.11 if (handler == null)
39.1 --- a/Hardware/TBalancer/FTD2XX.cs Tue Sep 21 10:33:28 2010 +0000
39.2 +++ b/Hardware/TBalancer/FTD2XX.cs Tue Sep 21 20:32:36 2010 +0000
39.3 @@ -87,7 +87,7 @@
39.4
39.5 [StructLayout(LayoutKind.Sequential)]
39.6 internal struct FT_HANDLE {
39.7 - private uint handle;
39.8 + private readonly uint handle;
39.9 }
39.10
39.11 [StructLayout(LayoutKind.Sequential)]
39.12 @@ -198,7 +198,7 @@
39.13 }
39.14
39.15 private static string GetDllName() {
39.16 - int p = (int)System.Environment.OSVersion.Platform;
39.17 + int p = (int)Environment.OSVersion.Platform;
39.18 if ((p == 4) || (p == 128))
39.19 return "libftd2xx.so";
39.20 else
40.1 --- a/Hardware/TBalancer/TBalancer.cs Tue Sep 21 10:33:28 2010 +0000
40.2 +++ b/Hardware/TBalancer/TBalancer.cs Tue Sep 21 20:32:36 2010 +0000
40.3 @@ -43,21 +43,22 @@
40.4 namespace OpenHardwareMonitor.Hardware.TBalancer {
40.5 internal class TBalancer : IHardware {
40.6
40.7 - private ISettings settings;
40.8 - private int portIndex;
40.9 + private readonly ISettings settings;
40.10 + private readonly int portIndex;
40.11 + private readonly byte protocolVersion;
40.12 + private readonly Sensor[] digitalTemperatures = new Sensor[8];
40.13 + private readonly Sensor[] analogTemperatures = new Sensor[4];
40.14 + private readonly Sensor[] sensorhubTemperatures = new Sensor[6];
40.15 + private readonly Sensor[] sensorhubFlows = new Sensor[2];
40.16 + private readonly Sensor[] fans = new Sensor[4];
40.17 + private readonly Sensor[] controls = new Sensor[4];
40.18 + private readonly Sensor[] miniNGTemperatures = new Sensor[4];
40.19 + private readonly Sensor[] miniNGFans = new Sensor[4];
40.20 + private readonly Sensor[] miniNGControls = new Sensor[4];
40.21 + private readonly List<ISensor> active = new List<ISensor>();
40.22 + private readonly List<ISensor> deactivating = new List<ISensor>();
40.23 +
40.24 private FT_HANDLE handle;
40.25 - private byte protocolVersion;
40.26 - private Sensor[] digitalTemperatures = new Sensor[8];
40.27 - private Sensor[] analogTemperatures = new Sensor[4];
40.28 - private Sensor[] sensorhubTemperatures = new Sensor[6];
40.29 - private Sensor[] sensorhubFlows = new Sensor[2];
40.30 - private Sensor[] fans = new Sensor[4];
40.31 - private Sensor[] controls = new Sensor[4];
40.32 - private Sensor[] miniNGTemperatures = new Sensor[4];
40.33 - private Sensor[] miniNGFans = new Sensor[4];
40.34 - private Sensor[] miniNGControls = new Sensor[4];
40.35 - private List<ISensor> active = new List<ISensor>();
40.36 - private List<ISensor> deactivating = new List<ISensor>();
40.37 private int[] primaryData = new int[0];
40.38 private int[] alternativeData = new int[0];
40.39
40.40 @@ -65,7 +66,7 @@
40.41 public const byte ENDFLAG = 254;
40.42
40.43 private delegate void MethodDelegate();
40.44 - private MethodDelegate alternativeRequest;
40.45 + private readonly MethodDelegate alternativeRequest;
40.46
40.47 public TBalancer(int portIndex, byte protocolVersion, ISettings settings) {
40.48 this.settings = settings;
40.49 @@ -73,7 +74,7 @@
40.50 this.portIndex = portIndex;
40.51 this.protocolVersion = protocolVersion;
40.52
40.53 - ParameterDescription[] parameter = new ParameterDescription[] {
40.54 + ParameterDescription[] parameter = new [] {
40.55 new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
40.56 };
40.57 int offset = 0;
40.58 @@ -100,7 +101,7 @@
40.59
40.60 for (int i = 0; i < sensorhubFlows.Length; i++)
40.61 sensorhubFlows[i] = new Sensor("Flowmeter " + (i + 1),
40.62 - i, SensorType.Flow, this, new ParameterDescription[] {
40.63 + i, SensorType.Flow, this, new [] {
40.64 new ParameterDescription("Impulse Rate",
40.65 "The impulse rate of the flowmeter in pulses/L", 509)
40.66 }, settings);
40.67 @@ -237,8 +238,7 @@
40.68
40.69 if (fans[i] == null)
40.70 fans[i] = new Sensor("Fan Channel " + i, i, SensorType.Fan,
40.71 - this, new ParameterDescription[] {
40.72 - new ParameterDescription("MaxRPM",
40.73 + this, new [] { new ParameterDescription("MaxRPM",
40.74 "Maximum revolutions per minute (RPM) of the fan.", maxRPM)
40.75 }, settings);
40.76
41.1 --- a/Hardware/TBalancer/TBalancerGroup.cs Tue Sep 21 10:33:28 2010 +0000
41.2 +++ b/Hardware/TBalancer/TBalancerGroup.cs Tue Sep 21 20:32:36 2010 +0000
41.3 @@ -44,8 +44,8 @@
41.4 namespace OpenHardwareMonitor.Hardware.TBalancer {
41.5 internal class TBalancerGroup : IGroup {
41.6
41.7 - private List<TBalancer> hardware = new List<TBalancer>();
41.8 - private StringBuilder report = new StringBuilder();
41.9 + private readonly List<TBalancer> hardware = new List<TBalancer>();
41.10 + private readonly StringBuilder report = new StringBuilder();
41.11
41.12 public TBalancerGroup(ISettings settings) {
41.13
41.14 @@ -73,8 +73,7 @@
41.15 }
41.16
41.17 FT_HANDLE handle;
41.18 - FT_STATUS status;
41.19 - status = FTD2XX.FT_Open(i, out handle);
41.20 + FT_STATUS status = FTD2XX.FT_Open(i, out handle);
41.21 if (status != FT_STATUS.FT_OK) {
41.22 report.AppendLine("Open Status: " + status);
41.23 continue;
42.1 --- a/Hardware/WinRing0.cs Tue Sep 21 10:33:28 2010 +0000
42.2 +++ b/Hardware/WinRing0.cs Tue Sep 21 20:32:36 2010 +0000
42.3 @@ -55,11 +55,11 @@
42.4 OLS_DLL_UNKNOWN_ERROR = 9
42.5 }
42.6
42.7 - private static bool available = false;
42.8 + private static bool available;
42.9 private static Mutex isaBusMutex;
42.10
42.11 private static string GetDllName() {
42.12 - int p = (int)System.Environment.OSVersion.Platform;
42.13 + int p = (int)Environment.OSVersion.Platform;
42.14 if ((p == 4) || (p == 128)) {
42.15 if (IntPtr.Size == 4) {
42.16 return "libring0.so";
42.17 @@ -97,9 +97,9 @@
42.18 UIntPtr threadAffinityMask);
42.19 public delegate bool RdtscDelegate(out uint eax, out uint edx);
42.20
42.21 - private static InitializeOlsDelegate InitializeOls =
42.22 + private static readonly InitializeOlsDelegate InitializeOls =
42.23 CreateDelegate<InitializeOlsDelegate>("InitializeOls");
42.24 - private static DeinitializeOlsDelegate DeinitializeOls =
42.25 + private static readonly DeinitializeOlsDelegate DeinitializeOls =
42.26 CreateDelegate<DeinitializeOlsDelegate>("DeinitializeOls");
42.27
42.28 public static readonly IsCpuidDelegate IsCpuid =
43.1 --- a/Properties/AssemblyLibInfo.cs Tue Sep 21 10:33:28 2010 +0000
43.2 +++ b/Properties/AssemblyLibInfo.cs Tue Sep 21 20:32:36 2010 +0000
43.3 @@ -37,7 +37,6 @@
43.4
43.5 using System;
43.6 using System.Reflection;
43.7 -using System.Runtime.CompilerServices;
43.8 using System.Runtime.InteropServices;
43.9
43.10 [assembly: AssemblyTitle("Open Hardware Monitor Library")]
44.1 --- a/Properties/AssemblyVersion.cs Tue Sep 21 10:33:28 2010 +0000
44.2 +++ b/Properties/AssemblyVersion.cs Tue Sep 21 20:32:36 2010 +0000
44.3 @@ -35,7 +35,6 @@
44.4
44.5 */
44.6
44.7 -using System;
44.8 using System.Reflection;
44.9
44.10 [assembly: AssemblyVersion("0.1.37.14")]