From 7b6fc115d86c3687d6ea9665f717becf18fc50a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Sun, 13 Dec 2015 18:11:48 +0100 Subject: [PATCH] Added a SensorName property to the SmartAttribute class in order to support sensor names that are different from the attribute name. Used the SensorName property to replace the "Temperature Difference From 100" sensor with a standard "Temperature" sensor. Closed issue #717. --- Hardware/HDD/AbstractHarddrive.cs | 4 ++-- Hardware/HDD/HDDGeneric.cs | 13 +++++++++---- Hardware/HDD/SSDIndilinx.cs | 4 ++-- Hardware/HDD/SSDIntel.cs | 10 +++++----- Hardware/HDD/SSDMicron.cs | 6 +++--- Hardware/HDD/SSDSamsung.cs | 6 +++--- Hardware/HDD/SSDSandforce.cs | 14 +++++++------- Hardware/HDD/SmartAttribute.cs | 13 +++++++++---- Properties/AssemblyVersion.cs | 4 ++-- 9 files changed, 42 insertions(+), 32 deletions(-) diff --git a/Hardware/HDD/AbstractHarddrive.cs b/Hardware/HDD/AbstractHarddrive.cs index d1f10d8..ca687e8 100644 --- a/Hardware/HDD/AbstractHarddrive.cs +++ b/Hardware/HDD/AbstractHarddrive.cs @@ -4,7 +4,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - Copyright (C) 2009-2013 Michael Möller + Copyright (C) 2009-2015 Michael Möller Copyright (C) 2010 Paul Werelds Copyright (C) 2011 Roland Reinl @@ -201,7 +201,7 @@ namespace OpenHardwareMonitor.Hardware.HDD { attribute.SensorType.Value, attribute.SensorChannel); if (!sensorTypeAndChannels.Contains(pair)) { - Sensor sensor = new Sensor(attribute.Name, + Sensor sensor = new Sensor(attribute.SensorName, attribute.SensorChannel, attribute.DefaultHiddenSensor, attribute.SensorType.Value, this, attribute.ParameterDescriptions, settings); diff --git a/Hardware/HDD/HDDGeneric.cs b/Hardware/HDD/HDDGeneric.cs index b94ba5b..47d9abe 100644 --- a/Hardware/HDD/HDDGeneric.cs +++ b/Hardware/HDD/HDDGeneric.cs @@ -4,7 +4,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - Copyright (C) 2011-2012 Michael Möller + Copyright (C) 2011-2015 Michael Möller Copyright (C) 2010 Paul Werelds Copyright (C) 2011 Roland Reinl @@ -85,19 +85,24 @@ namespace OpenHardwareMonitor.Hardware.HDD { new SmartAttribute(0xC2, SmartNames.Temperature, (byte[] r, byte v, IReadOnlyArray p) => { return r[0] + (p == null ? 0 : p[0].Value); }, - SensorType.Temperature, 0, false, + SensorType.Temperature, 0, SmartNames.Temperature, false, new[] { new ParameterDescription("Offset [°C]", "Temperature offset of the thermal sensor.\n" + "Temperature = Value + Offset.", 0) }), new SmartAttribute(0xE7, SmartNames.Temperature, (byte[] r, byte v, IReadOnlyArray p) => { return r[0] + (p == null ? 0 : p[0].Value); }, - SensorType.Temperature, 0, false, + SensorType.Temperature, 0, SmartNames.Temperature, false, new[] { new ParameterDescription("Offset [°C]", "Temperature offset of the thermal sensor.\n" + "Temperature = Value + Offset.", 0) }), new SmartAttribute(0xBE, SmartNames.TemperatureDifferenceFrom100, - null, SensorType.Temperature, 0) + (byte[] r, byte v, IReadOnlyArray p) + => { return r[0] + (p == null ? 0 : p[0].Value); }, + SensorType.Temperature, 0, "Temperature", false, + new[] { new ParameterDescription("Offset [°C]", + "Temperature offset of the thermal sensor.\n" + + "Temperature = Value + Offset.", 0) }) }; public GenericHarddisk(ISmart smart, string name, string firmwareRevision, diff --git a/Hardware/HDD/SSDIndilinx.cs b/Hardware/HDD/SSDIndilinx.cs index 029d88a..1e4ff23 100644 --- a/Hardware/HDD/SSDIndilinx.cs +++ b/Hardware/HDD/SSDIndilinx.cs @@ -4,7 +4,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - Copyright (C) 2009-2012 Michael Möller + Copyright (C) 2009-2015 Michael Möller Copyright (C) 2010 Paul Werelds Copyright (C) 2011 Roland Reinl @@ -38,7 +38,7 @@ namespace OpenHardwareMonitor.Hardware.HDD { new SmartAttribute(0xCF, SmartNames.MaxErase), new SmartAttribute(0xD0, SmartNames.AverageEraseCount), new SmartAttribute(0xD1, SmartNames.RemainingLife, - null, SensorType.Level, 0), + null, SensorType.Level, 0, SmartNames.RemainingLife), new SmartAttribute(0xD2, SmartNames.UnknownUnique), new SmartAttribute(0xD3, SmartNames.SataErrorCountCrc), new SmartAttribute(0xD4, SmartNames.SataErrorCountHandshake) diff --git a/Hardware/HDD/SSDIntel.cs b/Hardware/HDD/SSDIntel.cs index 9b8ed96..8162557 100644 --- a/Hardware/HDD/SSDIntel.cs +++ b/Hardware/HDD/SSDIntel.cs @@ -4,7 +4,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - Copyright (C) 2009-2012 Michael Möller + Copyright (C) 2009-2015 Michael Möller Copyright (C) 2010 Paul Werelds Copyright (C) 2011 Roland Reinl @@ -36,18 +36,18 @@ namespace OpenHardwareMonitor.Hardware.HDD { new SmartAttribute(0xE1, SmartNames.HostWrites, (byte[] r, byte v, IReadOnlyArray p) => { return RawToInt(r, v, p) / 0x20; }, - SensorType.Data, 0), + SensorType.Data, 0, SmartNames.HostWrites), new SmartAttribute(0xE8, SmartNames.RemainingLife, - null, SensorType.Level, 0), + null, SensorType.Level, 0, SmartNames.RemainingLife), new SmartAttribute(0xE9, SmartNames.MediaWearOutIndicator), new SmartAttribute(0xF1, SmartNames.HostWrites, (byte[] r, byte v, IReadOnlyArray p) => { return RawToInt(r, v, p) / 0x20; }, - SensorType.Data, 0), + SensorType.Data, 0, SmartNames.HostWrites), new SmartAttribute(0xF2, SmartNames.HostReads, (byte[] r, byte v, IReadOnlyArray p) => { return RawToInt(r, v, p) / 0x20; }, - SensorType.Data, 1), + SensorType.Data, 1, SmartNames.HostReads), }; public SSDIntel(ISmart smart, string name, string firmwareRevision, diff --git a/Hardware/HDD/SSDMicron.cs b/Hardware/HDD/SSDMicron.cs index 92f525c..493e0fb 100644 --- a/Hardware/HDD/SSDMicron.cs +++ b/Hardware/HDD/SSDMicron.cs @@ -4,7 +4,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - Copyright (C) 2012 Michael Möller + Copyright (C) 2012-2015 Michael Möller */ @@ -43,8 +43,8 @@ namespace OpenHardwareMonitor.Hardware.HDD { new SmartAttribute(0xCA, SmartNames.RemainingLife, (byte[] raw, byte value, IReadOnlyArray p) => { return 100 - RawToInt(raw, value, p); }, - SensorType.Level, 0), - new SmartAttribute(0xCE, SmartNames.WriteErrorRate, + SensorType.Level, 0, SmartNames.RemainingLife), + new SmartAttribute(0xCE, SmartNames.WriteErrorRate, (byte[] raw, byte value, IReadOnlyArray p) => { return 6e4f * ((raw[1] << 8) | raw[0]); }), }; diff --git a/Hardware/HDD/SSDSamsung.cs b/Hardware/HDD/SSDSamsung.cs index a571d47..b19bf2f 100644 --- a/Hardware/HDD/SSDSamsung.cs +++ b/Hardware/HDD/SSDSamsung.cs @@ -4,7 +4,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - Copyright (C) 2012-2013 Michael Möller + Copyright (C) 2012-2015 Michael Möller */ @@ -30,7 +30,7 @@ namespace OpenHardwareMonitor.Hardware.HDD { // Unused Reserved Block Count (Total) new SmartAttribute(0xB4, SmartNames.RemainingLife, - null, SensorType.Level, 0), + null, SensorType.Level, 0, SmartNames.RemainingLife), new SmartAttribute(0xB5, SmartNames.ProgramFailCountTotal, RawToInt), new SmartAttribute(0xB6, SmartNames.EraseFailCountTotal, RawToInt), @@ -39,7 +39,7 @@ namespace OpenHardwareMonitor.Hardware.HDD { new SmartAttribute(0xBE, SmartNames.Temperature, (byte[] r, byte v, IReadOnlyArray p) => { return r[0] + (p == null ? 0 : p[0].Value); }, - SensorType.Temperature, 0, false, + SensorType.Temperature, 0, SmartNames.Temperature, false, new[] { new ParameterDescription("Offset [°C]", "Temperature offset of the thermal sensor.\n" + "Temperature = Value + Offset.", 0) }), diff --git a/Hardware/HDD/SSDSandforce.cs b/Hardware/HDD/SSDSandforce.cs index 4068a66..115ec5f 100644 --- a/Hardware/HDD/SSDSandforce.cs +++ b/Hardware/HDD/SSDSandforce.cs @@ -4,7 +4,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - Copyright (C) 2009-2012 Michael Möller + Copyright (C) 2009-2015 Michael Möller Copyright (C) 2010 Paul Werelds */ @@ -33,22 +33,22 @@ namespace OpenHardwareMonitor.Hardware.HDD { new SmartAttribute(0xC2, SmartNames.Temperature, (byte[] raw, byte value, IReadOnlyArray p) => { return value + (p == null ? 0 : p[0].Value); }, - SensorType.Temperature, 0, true, + SensorType.Temperature, 0, SmartNames.Temperature, true, new[] { new ParameterDescription("Offset [°C]", "Temperature offset of the thermal sensor.\n" + "Temperature = Value + Offset.", 0) }), new SmartAttribute(0xC3, SmartNames.UnrecoverableEcc), new SmartAttribute(0xC4, SmartNames.ReallocationEventCount, RawToInt), new SmartAttribute(0xE7, SmartNames.RemainingLife, null, - SensorType.Level, 0), + SensorType.Level, 0, SmartNames.RemainingLife), new SmartAttribute(0xE9, SmartNames.ControllerWritesToNAND, RawToInt, - SensorType.Data, 0), + SensorType.Data, 0, SmartNames.ControllerWritesToNAND), new SmartAttribute(0xEA, SmartNames.HostWritesToController, RawToInt, - SensorType.Data, 1), + SensorType.Data, 1, SmartNames.HostWritesToController), new SmartAttribute(0xF1, SmartNames.HostWrites, RawToInt, - SensorType.Data, 1), + SensorType.Data, 1, SmartNames.HostWrites), new SmartAttribute(0xF2, SmartNames.HostReads, RawToInt, - SensorType.Data, 2) + SensorType.Data, 2, SmartNames.HostReads) }; private Sensor writeAmplification; diff --git a/Hardware/HDD/SmartAttribute.cs b/Hardware/HDD/SmartAttribute.cs index d3f114b..4c9b8c2 100644 --- a/Hardware/HDD/SmartAttribute.cs +++ b/Hardware/HDD/SmartAttribute.cs @@ -4,7 +4,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - Copyright (C) 2011-2012 Michael Möller + Copyright (C) 2011-2015 Michael Möller Copyright (C) 2011 Roland Reinl */ @@ -24,7 +24,7 @@ namespace OpenHardwareMonitor.Hardware.HDD { /// The SMART identifier of the attribute. /// The name of the attribute. public SmartAttribute(byte identifier, string name) : - this(identifier, name, null, null, 0) { } + this(identifier, name, null, null, 0, null) { } /// /// Initializes a new instance of the class. @@ -35,7 +35,7 @@ namespace OpenHardwareMonitor.Hardware.HDD { /// array into a value (or null to use the attribute value). public SmartAttribute(byte identifier, string name, RawValueConversion rawValueConversion) : - this(identifier, name, rawValueConversion, null, 0) { } + this(identifier, name, rawValueConversion, null, 0, null) { } /// /// Initializes a new instance of the class. @@ -49,12 +49,14 @@ namespace OpenHardwareMonitor.Hardware.HDD { /// If there exists more than one attribute with /// the same sensor channel and type, then a sensor is created only for the /// first attribute. + /// The name to be used for the sensor, or null if + /// no sensor is created. /// True to hide the sensor initially. /// Description for the parameters of the sensor /// (or null). public SmartAttribute(byte identifier, string name, RawValueConversion rawValueConversion, SensorType? sensorType, - int sensorChannel, bool defaultHiddenSensor = false, + int sensorChannel, string sensorName, bool defaultHiddenSensor = false, ParameterDescription[] parameterDescriptions = null) { this.Identifier = identifier; @@ -62,6 +64,7 @@ namespace OpenHardwareMonitor.Hardware.HDD { this.rawValueConversion = rawValueConversion; this.SensorType = sensorType; this.SensorChannel = sensorChannel; + this.SensorName = sensorName; this.DefaultHiddenSensor = defaultHiddenSensor; this.ParameterDescriptions = parameterDescriptions; } @@ -77,6 +80,8 @@ namespace OpenHardwareMonitor.Hardware.HDD { public int SensorChannel { get; private set; } + public string SensorName { get; private set; } + public bool DefaultHiddenSensor { get; private set; } public ParameterDescription[] ParameterDescriptions { get; private set; } diff --git a/Properties/AssemblyVersion.cs b/Properties/AssemblyVersion.cs index d11f18a..5a1aea3 100644 --- a/Properties/AssemblyVersion.cs +++ b/Properties/AssemblyVersion.cs @@ -10,5 +10,5 @@ using System.Reflection; -[assembly: AssemblyVersion("0.7.1.2")] -[assembly: AssemblyInformationalVersion("0.7.1.2 Alpha")] \ No newline at end of file +[assembly: AssemblyVersion("0.7.1.3")] +[assembly: AssemblyInformationalVersion("0.7.1.3 Alpha")] \ No newline at end of file