Added temperature offset parameters to all HDD temperature sensors. Fixed issue 271.
1.1 --- a/Hardware/HDD/AbstractHarddrive.cs Wed Jul 25 15:33:16 2012 +0000
1.2 +++ b/Hardware/HDD/AbstractHarddrive.cs Wed Jul 25 16:03:36 2012 +0000
1.3 @@ -169,7 +169,8 @@
1.4 if (!sensorTypeAndChannels.Contains(pair)) {
1.5 Sensor sensor = new Sensor(attribute.Name,
1.6 attribute.SensorChannel, attribute.DefaultHiddenSensor,
1.7 - attribute.SensorType.Value, this, null, settings);
1.8 + attribute.SensorType.Value, this, attribute.ParameterDescriptions,
1.9 + settings);
1.10
1.11 sensors.Add(attribute, sensor);
1.12 ActivateSensor(sensor);
1.13 @@ -199,7 +200,7 @@
1.14 foreach (DriveAttributeValue value in values) {
1.15 if (value.Identifier == attribute.Identifier) {
1.16 Sensor sensor = keyValuePair.Value;
1.17 - sensor.Value = attribute.ConvertValue(value);
1.18 + sensor.Value = attribute.ConvertValue(value, sensor.Parameters);
1.19 }
1.20 }
1.21 }
1.22 @@ -261,7 +262,7 @@
1.23 if (a.Identifier == value.Identifier) {
1.24 description = a.Name;
1.25 if (a.HasRawValueConversion | a.SensorType.HasValue)
1.26 - physical = a.ConvertValue(value);
1.27 + physical = a.ConvertValue(value, null);
1.28 else
1.29 physical = null;
1.30 }
1.31 @@ -295,7 +296,9 @@
1.32 return r.ToString();
1.33 }
1.34
1.35 - protected static float RawToInt(byte[] raw, byte value) {
1.36 + protected static float RawToInt(byte[] raw, byte value,
1.37 + IReadOnlyArray<IParameter> parameters)
1.38 + {
1.39 return (raw[3] << 24) | (raw[2] << 16) | (raw[1] << 8) | raw[0];
1.40 }
1.41
2.1 --- a/Hardware/HDD/HDDGeneric.cs Wed Jul 25 15:33:16 2012 +0000
2.2 +++ b/Hardware/HDD/HDDGeneric.cs Wed Jul 25 16:03:36 2012 +0000
2.3 @@ -13,6 +13,7 @@
2.4 using System;
2.5 using System.Collections.Generic;
2.6 using System.Text;
2.7 +using OpenHardwareMonitor.Collections;
2.8
2.9 namespace OpenHardwareMonitor.Hardware.HDD {
2.10
2.11 @@ -82,9 +83,19 @@
2.12 new SmartAttribute(0xFE, SmartNames.FreeFallProtection),
2.13
2.14 new SmartAttribute(0xC2, SmartNames.Temperature,
2.15 - (byte[] r, byte v) => { return r[0]; }, SensorType.Temperature, 0),
2.16 + (byte[] r, byte v, IReadOnlyArray<IParameter> p)
2.17 + => { return r[0] + (p == null ? 0 : p[0].Value); },
2.18 + SensorType.Temperature, 0, false,
2.19 + new[] { new ParameterDescription("Offset [°C]",
2.20 + "Temperature offset of the thermal sensor.\n" +
2.21 + "Temperature = Value + Offset.", 0) }),
2.22 new SmartAttribute(0xE7, SmartNames.Temperature,
2.23 - (byte[] r, byte v) => { return r[0]; }, SensorType.Temperature, 0),
2.24 + (byte[] r, byte v, IReadOnlyArray<IParameter> p)
2.25 + => { return r[0] + (p == null ? 0 : p[0].Value); },
2.26 + SensorType.Temperature, 0, false,
2.27 + new[] { new ParameterDescription("Offset [°C]",
2.28 + "Temperature offset of the thermal sensor.\n" +
2.29 + "Temperature = Value + Offset.", 0) }),
2.30 new SmartAttribute(0xBE, SmartNames.TemperatureDifferenceFrom100,
2.31 null, SensorType.Temperature, 0)
2.32 };
3.1 --- a/Hardware/HDD/SSDIntel.cs Wed Jul 25 15:33:16 2012 +0000
3.2 +++ b/Hardware/HDD/SSDIntel.cs Wed Jul 25 16:03:36 2012 +0000
3.3 @@ -10,9 +10,11 @@
3.4
3.5 */
3.6
3.7 +using System.Collections.Generic;
3.8 +using OpenHardwareMonitor.Collections;
3.9 +
3.10 namespace OpenHardwareMonitor.Hardware.HDD {
3.11 - using System.Collections.Generic;
3.12 -
3.13 +
3.14 [NamePrefix("INTEL SSD"),
3.15 RequireSmart(0xE1), RequireSmart(0xE8), RequireSmart(0xE9)]
3.16 internal class SSDIntel : AbstractHarddrive {
3.17 @@ -32,16 +34,19 @@
3.18 new SmartAttribute(0xB8, SmartNames.EndToEndError),
3.19 new SmartAttribute(0xC0, SmartNames.UnsafeShutdownCount),
3.20 new SmartAttribute(0xE1, SmartNames.HostWrites,
3.21 - (byte[] r, byte v) => { return RawToInt(r, v) / 0x20; },
3.22 + (byte[] r, byte v, IReadOnlyArray<IParameter> p)
3.23 + => { return RawToInt(r, v, p) / 0x20; },
3.24 SensorType.Data, 0),
3.25 new SmartAttribute(0xE8, SmartNames.RemainingLife,
3.26 null, SensorType.Level, 0),
3.27 new SmartAttribute(0xE9, SmartNames.MediaWearOutIndicator),
3.28 new SmartAttribute(0xF1, SmartNames.HostWrites,
3.29 - (byte[] r, byte v) => { return RawToInt(r, v) / 0x20; },
3.30 + (byte[] r, byte v, IReadOnlyArray<IParameter> p)
3.31 + => { return RawToInt(r, v, p) / 0x20; },
3.32 SensorType.Data, 0),
3.33 new SmartAttribute(0xF2, SmartNames.HostReads,
3.34 - (byte[] r, byte v) => { return RawToInt(r, v) / 0x20; },
3.35 + (byte[] r, byte v, IReadOnlyArray<IParameter> p)
3.36 + => { return RawToInt(r, v, p) / 0x20; },
3.37 SensorType.Data, 1),
3.38 };
3.39
4.1 --- a/Hardware/HDD/SSDMicron.cs Wed Jul 25 15:33:16 2012 +0000
4.2 +++ b/Hardware/HDD/SSDMicron.cs Wed Jul 25 16:03:36 2012 +0000
4.3 @@ -8,8 +8,10 @@
4.4
4.5 */
4.6
4.7 -namespace OpenHardwareMonitor.Hardware.HDD {
4.8 - using System.Collections.Generic;
4.9 +using System.Collections.Generic;
4.10 +using OpenHardwareMonitor.Collections;
4.11 +
4.12 +namespace OpenHardwareMonitor.Hardware.HDD {
4.13
4.14 [NamePrefix(""), RequireSmart(0xAA), RequireSmart(0xAB), RequireSmart(0xAC),
4.15 RequireSmart(0xAD), RequireSmart(0xAE), RequireSmart(0xCA)]
4.16 @@ -28,7 +30,8 @@
4.17 new SmartAttribute(0xAD, SmartNames.WearLevelingCount, RawToInt),
4.18 new SmartAttribute(0xAE, SmartNames.UnexpectedPowerLossCount, RawToInt),
4.19 new SmartAttribute(0xB5, SmartNames.Non4kAlignedAccess,
4.20 - (byte[] raw, byte value) => { return 6e4f * ((raw[5] << 8) | raw[4]); }),
4.21 + (byte[] raw, byte value, IReadOnlyArray<IParameter> p)
4.22 + => { return 6e4f * ((raw[5] << 8) | raw[4]); }),
4.23 new SmartAttribute(0xB7, SmartNames.SataDownshiftErrorCount, RawToInt),
4.24 new SmartAttribute(0xBB, SmartNames.ReportedUncorrectableErrors, RawToInt),
4.25 new SmartAttribute(0xBC, SmartNames.CommandTimeout, RawToInt),
4.26 @@ -38,10 +41,12 @@
4.27 new SmartAttribute(0xC6, SmartNames.OffLineUncorrectableErrorCount, RawToInt),
4.28 new SmartAttribute(0xC7, SmartNames.UltraDmaCrcErrorCount, RawToInt),
4.29 new SmartAttribute(0xCA, SmartNames.RemainingLife,
4.30 - (byte[] raw, byte value) => { return 100 - RawToInt(raw, value); },
4.31 + (byte[] raw, byte value, IReadOnlyArray<IParameter> p)
4.32 + => { return 100 - RawToInt(raw, value, p); },
4.33 SensorType.Level, 0),
4.34 new SmartAttribute(0xCE, SmartNames.WriteErrorRate,
4.35 - (byte[] raw, byte value) => { return 6e4f * ((raw[1] << 8) | raw[0]); }),
4.36 + (byte[] raw, byte value, IReadOnlyArray<IParameter> p)
4.37 + => { return 6e4f * ((raw[1] << 8) | raw[0]); }),
4.38 };
4.39
4.40 public SSDMicron(ISmart smart, string name, string firmwareRevision,
5.1 --- a/Hardware/HDD/SSDSandforce.cs Wed Jul 25 15:33:16 2012 +0000
5.2 +++ b/Hardware/HDD/SSDSandforce.cs Wed Jul 25 16:03:36 2012 +0000
5.3 @@ -9,8 +9,10 @@
5.4
5.5 */
5.6
5.7 +using System.Collections.Generic;
5.8 +using OpenHardwareMonitor.Collections;
5.9 +
5.10 namespace OpenHardwareMonitor.Hardware.HDD {
5.11 - using System.Collections.Generic;
5.12
5.13 [NamePrefix(""), RequireSmart(0xAB), RequireSmart(0xB1)]
5.14 internal class SSDSandforce : AbstractHarddrive {
5.15 @@ -28,8 +30,13 @@
5.16 new SmartAttribute(0xB5, SmartNames.AlternativeProgramFailCount, RawToInt),
5.17 new SmartAttribute(0xB6, SmartNames.AlternativeEraseFailCount, RawToInt),
5.18 new SmartAttribute(0xBB, SmartNames.UncorrectableErrorCount, RawToInt),
5.19 - new SmartAttribute(0xC2, SmartNames.Temperature, (byte[] raw, byte value)
5.20 - => { return value; }, SensorType.Temperature, 0, true),
5.21 + new SmartAttribute(0xC2, SmartNames.Temperature,
5.22 + (byte[] raw, byte value, IReadOnlyArray<IParameter> p)
5.23 + => { return value + (p == null ? 0 : p[0].Value); },
5.24 + SensorType.Temperature, 0, true,
5.25 + new[] { new ParameterDescription("Offset [°C]",
5.26 + "Temperature offset of the thermal sensor.\n" +
5.27 + "Temperature = Value + Offset.", 0) }),
5.28 new SmartAttribute(0xC3, SmartNames.UnrecoverableEcc),
5.29 new SmartAttribute(0xC4, SmartNames.ReallocationEventCount, RawToInt),
5.30 new SmartAttribute(0xE7, SmartNames.RemainingLife, null,
5.31 @@ -59,10 +66,10 @@
5.32 float? hostWritesToController = null;
5.33 foreach (DriveAttributeValue value in values) {
5.34 if (value.Identifier == 0xE9)
5.35 - controllerWritesToNAND = RawToInt(value.RawValue, value.AttrValue);
5.36 + controllerWritesToNAND = RawToInt(value.RawValue, value.AttrValue, null);
5.37
5.38 if (value.Identifier == 0xEA)
5.39 - hostWritesToController = RawToInt(value.RawValue, value.AttrValue);
5.40 + hostWritesToController = RawToInt(value.RawValue, value.AttrValue, null);
5.41 }
5.42 if (controllerWritesToNAND.HasValue && hostWritesToController.HasValue) {
5.43 if (hostWritesToController.Value > 0)
6.1 --- a/Hardware/HDD/SmartAttribute.cs Wed Jul 25 15:33:16 2012 +0000
6.2 +++ b/Hardware/HDD/SmartAttribute.cs Wed Jul 25 16:03:36 2012 +0000
6.3 @@ -11,6 +11,7 @@
6.4
6.5 using System;
6.6 using System.Collections.Generic;
6.7 +using OpenHardwareMonitor.Collections;
6.8
6.9 namespace OpenHardwareMonitor.Hardware.HDD {
6.10 internal class SmartAttribute {
6.11 @@ -49,9 +50,12 @@
6.12 /// the same sensor channel and type, then a sensor is created only for the
6.13 /// first attribute.</param>
6.14 /// <param name="defaultHiddenSensor">True to hide the sensor initially.</param>
6.15 + /// <param name="parameterDescriptions">Description for the parameters of the sensor
6.16 + /// (or null).</param>
6.17 public SmartAttribute(byte identifier, string name,
6.18 RawValueConversion rawValueConversion, SensorType? sensorType,
6.19 - int sensorChannel, bool defaultHiddenSensor = false)
6.20 + int sensorChannel, bool defaultHiddenSensor = false,
6.21 + ParameterDescription[] parameterDescriptions = null)
6.22 {
6.23 this.Identifier = identifier;
6.24 this.Name = name;
6.25 @@ -59,6 +63,7 @@
6.26 this.SensorType = sensorType;
6.27 this.SensorChannel = sensorChannel;
6.28 this.DefaultHiddenSensor = defaultHiddenSensor;
6.29 + this.ParameterDescriptions = parameterDescriptions;
6.30 }
6.31
6.32 /// <summary>
6.33 @@ -74,20 +79,25 @@
6.34
6.35 public bool DefaultHiddenSensor { get; private set; }
6.36
6.37 + public ParameterDescription[] ParameterDescriptions { get; private set; }
6.38 +
6.39 public bool HasRawValueConversion {
6.40 get {
6.41 return rawValueConversion != null;
6.42 }
6.43 }
6.44
6.45 - public float ConvertValue(DriveAttributeValue value) {
6.46 + public float ConvertValue(DriveAttributeValue value,
6.47 + IReadOnlyArray<IParameter> parameters)
6.48 + {
6.49 if (rawValueConversion == null) {
6.50 return value.AttrValue;
6.51 } else {
6.52 - return rawValueConversion(value.RawValue, value.AttrValue);
6.53 + return rawValueConversion(value.RawValue, value.AttrValue, parameters);
6.54 }
6.55 }
6.56
6.57 - public delegate float RawValueConversion(byte[] rawValue, byte value);
6.58 + public delegate float RawValueConversion(byte[] rawValue, byte value,
6.59 + IReadOnlyArray<IParameter> parameters);
6.60 }
6.61 }