# HG changeset patch # User moel.mich # Date 1286034372 0 # Node ID a38b51ef489c76833e4028fd56176ade8abaded6 # Parent 59278dadc5c057a1af20efd0cbfcfb7dde6b9a00 Reverted the SMART temperature attribute search strategy to the one used previously. Fixed a few minor details in the HDDGroup class. diff -r 59278dadc5c0 -r a38b51ef489c Hardware/HDD/HDDGroup.cs --- a/Hardware/HDD/HDDGroup.cs Sat Oct 02 14:39:25 2010 +0000 +++ b/Hardware/HDD/HDDGroup.cs Sat Oct 02 15:46:12 2010 +0000 @@ -37,6 +37,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Text; namespace OpenHardwareMonitor.Hardware.HDD { @@ -46,8 +47,6 @@ private readonly List hardware = new List(); - private readonly Dictionary ignoredDrives = new Dictionary(); - public HDDGroup(ISettings settings) { int p = (int)Environment.OSVersion.Platform; if (p == 4 || p == 128) return; @@ -70,26 +69,39 @@ } SMART.DriveAttribute[] attributes = SMART.ReadSmart(handle, drive); + if (attributes == null) { + SMART.CloseHandle(handle); + continue; + } - if (attributes != null) { - int attribute = -1; + int attribute = -1; - int i = 0; - foreach (SMART.DriveAttribute attr in attributes) { - if (attr.ID == SMART.AttributeID.Temperature - || attr.ID == SMART.AttributeID.DriveTemperature - || attr.ID == SMART.AttributeID.AirflowTemperature) { + // search for the Temperature attribute + for (int i = 0; i < attributes.Length; i++) + if (attributes[i].ID == SMART.AttributeID.Temperature) { + attribute = i; + break; + } + + // if no temperature attribute is found, search for DriveTemperature + if (attribute == -1) + for (int i = 0; i < attributes.Length; i++) + if (attributes[i].ID == SMART.AttributeID.DriveTemperature) { attribute = i; break; } - i++; - } - if (attribute >= 0) - { - hardware.Add(new HDD(name, handle, drive, attribute, settings)); - continue; - } + // if no temperature attribute is found, search for AirflowTemperature + if (attribute == -1) + for (int i = 0; i < attributes.Length; i++) + if (attributes[i].ID == SMART.AttributeID.AirflowTemperature) { + attribute = i; + break; + } + + if (attribute >= 0) { + hardware.Add(new HDD(name, handle, drive, attribute, settings)); + continue; } SMART.CloseHandle(handle); @@ -133,25 +145,24 @@ if (attributes != null) { r.AppendLine("Drive name: " + name); r.AppendLine(); - r.AppendFormat(" {0}{1}{2}{3}{4}{5}", - ("ID").PadRight(6), - ("RawValue").PadRight(20), - ("WorstValue").PadRight(12), - ("AttrValue").PadRight(12), - ("Name"), - Environment.NewLine); + r.AppendFormat(CultureInfo.InvariantCulture, " {0}{1}{2}{3}{4}{5}", + ("ID").PadRight(6), + ("RawValue").PadRight(20), + ("WorstValue").PadRight(12), + ("AttrValue").PadRight(12), + ("Name"), + Environment.NewLine); - foreach (SMART.DriveAttribute attr in attributes) { - if (attr.ID == 0) continue; - string raw = BitConverter.ToString(attr.RawValue); - r.AppendFormat(" {0}{1}{2}{3}{4}{5}", - attr.ID.ToString("d").PadRight(6), - raw.Replace("-", " ").PadRight(20), - attr.WorstValue.ToString().PadRight(12), - attr.AttrValue.ToString().PadRight(12), - attr.ID, - Environment.NewLine) - ; + foreach (SMART.DriveAttribute a in attributes) { + if (a.ID == 0) continue; + string raw = BitConverter.ToString(a.RawValue); + r.AppendFormat(CultureInfo.InvariantCulture, " {0}{1}{2}{3}{4}{5}", + a.ID.ToString("d").PadRight(6), + raw.Replace("-", " ").PadRight(20), + a.WorstValue.ToString(CultureInfo.InvariantCulture).PadRight(12), + a.AttrValue.ToString(CultureInfo.InvariantCulture).PadRight(12), + a.ID, + Environment.NewLine); } r.AppendLine(); } diff -r 59278dadc5c0 -r a38b51ef489c Properties/AssemblyVersion.cs --- a/Properties/AssemblyVersion.cs Sat Oct 02 14:39:25 2010 +0000 +++ b/Properties/AssemblyVersion.cs Sat Oct 02 15:46:12 2010 +0000 @@ -37,5 +37,5 @@ using System.Reflection; -[assembly: AssemblyVersion("0.1.37.24")] -[assembly: AssemblyInformationalVersion("0.1.37.24 Alpha")] \ No newline at end of file +[assembly: AssemblyVersion("0.2.0.0")] +[assembly: AssemblyInformationalVersion("0.2.0 Beta")] \ No newline at end of file