From f8867d671aa285244128b207409adc625869eba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Tue, 14 Feb 2012 23:07:55 +0000 Subject: [PATCH] Added a new sensor type "Factor" for dimensionless values (and similar) that are not to be shown as percent ("Level" type). Changed the write amplification sensor to use the new "Factor" sensor type. Added the temperature SMART attribute for Sandforce SSDs as hidden sensor (as it may show fake results on some hardware). --- GUI/HardwareNode.cs | 14 +++----------- GUI/SensorGadget.cs | 5 ++++- GUI/SensorNode.cs | 3 ++- GUI/SensorNotifyIcon.cs | 13 ++++++++----- GUI/TypeNode.cs | 6 +++++- Hardware/HDD/AbstractHarddrive.cs | 4 ++-- Hardware/HDD/SSDSandforce.cs | 8 ++++---- Hardware/HDD/SmartAttribute.cs | 8 ++++++-- Hardware/ISensor.cs | 5 +++-- OpenHardwareMonitor.csproj | 3 +++ Properties/AssemblyVersion.cs | 4 ++-- Resources/factor.png | Bin 0 -> 533 bytes 12 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 Resources/factor.png diff --git a/GUI/HardwareNode.cs b/GUI/HardwareNode.cs index 7ef4098..dee5123 100644 --- a/GUI/HardwareNode.cs +++ b/GUI/HardwareNode.cs @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2011 + Portions created by the Initial Developer are Copyright (C) 2009-2012 the Initial Developer. All Rights Reserved. Contributor(s): @@ -57,16 +57,8 @@ namespace OpenHardwareMonitor.GUI { this.hardware = hardware; this.Image = HardwareTypeImage.Instance.GetImage(hardware.HardwareType); - typeNodes.Add(new TypeNode(SensorType.Voltage)); - typeNodes.Add(new TypeNode(SensorType.Clock)); - typeNodes.Add(new TypeNode(SensorType.Temperature)); - typeNodes.Add(new TypeNode(SensorType.Load)); - typeNodes.Add(new TypeNode(SensorType.Fan)); - typeNodes.Add(new TypeNode(SensorType.Flow)); - typeNodes.Add(new TypeNode(SensorType.Control)); - typeNodes.Add(new TypeNode(SensorType.Level)); - typeNodes.Add(new TypeNode(SensorType.Power)); - typeNodes.Add(new TypeNode(SensorType.Data)); + foreach (SensorType sensorType in Enum.GetValues(typeof(SensorType))) + typeNodes.Add(new TypeNode(sensorType)); foreach (ISensor sensor in hardware.Sensors) SensorAdded(sensor); diff --git a/GUI/SensorGadget.cs b/GUI/SensorGadget.cs index 889f204..192180f 100644 --- a/GUI/SensorGadget.cs +++ b/GUI/SensorGadget.cs @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2010-2011 + Portions created by the Initial Developer are Copyright (C) 2010-2012 the Initial Developer. All Rights Reserved. Contributor(s): @@ -521,6 +521,9 @@ namespace OpenHardwareMonitor.GUI { case SensorType.Data: format = "{0:F1} GB"; break; + case SensorType.Factor: + format = "{0:F3}"; + break; } if (sensor.SensorType == SensorType.Temperature && diff --git a/GUI/SensorNode.cs b/GUI/SensorNode.cs index b72ec6f..fca750a 100644 --- a/GUI/SensorNode.cs +++ b/GUI/SensorNode.cs @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2011 + Portions created by the Initial Developer are Copyright (C) 2009-2012 the Initial Developer. All Rights Reserved. Contributor(s): @@ -77,6 +77,7 @@ namespace OpenHardwareMonitor.GUI { case SensorType.Level: format = "{0:F1} %"; break; case SensorType.Power: format = "{0:F1} W"; break; case SensorType.Data: format = "{0:F1} GB"; break; + case SensorType.Factor: format = "{0:F3}"; break; } bool hidden = settings.GetValue(new Identifier(sensor.Identifier, diff --git a/GUI/SensorNotifyIcon.cs b/GUI/SensorNotifyIcon.cs index 7d8b8be..853a0cc 100644 --- a/GUI/SensorNotifyIcon.cs +++ b/GUI/SensorNotifyIcon.cs @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2011 + Portions created by the Initial Developer are Copyright (C) 2009-2012 the Initial Developer. All Rights Reserved. Contributor(s): @@ -181,17 +181,17 @@ namespace OpenHardwareMonitor.GUI { switch (sensor.SensorType) { case SensorType.Voltage: - return string.Format("{0:F11}", sensor.Value); + return string.Format("{0:F1}", sensor.Value); case SensorType.Clock: - return string.Format("{0:F11}", 1e-3f * sensor.Value); + return string.Format("{0:F1}", 1e-3f * sensor.Value); case SensorType.Load: return string.Format("{0:F0}", sensor.Value); case SensorType.Temperature: return string.Format("{0:F0}", sensor.Value); case SensorType.Fan: - return string.Format("{0:F11}", 1e-3f * sensor.Value); + return string.Format("{0:F1}", 1e-3f * sensor.Value); case SensorType.Flow: - return string.Format("{0:F11}", 1e-3f * sensor.Value); + return string.Format("{0:F1}", 1e-3f * sensor.Value); case SensorType.Control: return string.Format("{0:F0}", sensor.Value); case SensorType.Level: @@ -200,6 +200,8 @@ namespace OpenHardwareMonitor.GUI { return string.Format("{0:F0}", sensor.Value); case SensorType.Data: return string.Format("{0:F0}", sensor.Value); + case SensorType.Factor: + return string.Format("{0:F1}", sensor.Value); } return "-"; } @@ -289,6 +291,7 @@ namespace OpenHardwareMonitor.GUI { case SensorType.Level: format = "\n{0}: {1:F1} %"; break; case SensorType.Power: format = "\n{0}: {1:F0} W"; break; case SensorType.Data: format = "\n{0}: {1:F0} GB"; break; + case SensorType.Factor: format = "\n{0}: {1:F3} GB"; break; } string formattedValue = string.Format(format, sensor.Name, sensor.Value); string hardwareName = sensor.Hardware.Name; diff --git a/GUI/TypeNode.cs b/GUI/TypeNode.cs index 2fe57ff..37de3a9 100644 --- a/GUI/TypeNode.cs +++ b/GUI/TypeNode.cs @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2011 + Portions created by the Initial Developer are Copyright (C) 2009-2012 the Initial Developer. All Rights Reserved. Contributor(s): @@ -88,6 +88,10 @@ namespace OpenHardwareMonitor.GUI { this.Image = Utilities.EmbeddedResources.GetImage("data.png"); this.Text = "Data"; break; + case SensorType.Factor: + this.Image = Utilities.EmbeddedResources.GetImage("factor.png"); + this.Text = "Factors"; + break; } NodeAdded += new NodeEventHandler(TypeNode_NodeAdded); diff --git a/Hardware/HDD/AbstractHarddrive.cs b/Hardware/HDD/AbstractHarddrive.cs index 85a675d..df05aa4 100644 --- a/Hardware/HDD/AbstractHarddrive.cs +++ b/Hardware/HDD/AbstractHarddrive.cs @@ -179,8 +179,8 @@ namespace OpenHardwareMonitor.Hardware.HDD { if (!sensorTypeAndChannels.Contains(pair)) { Sensor sensor = new Sensor(attribute.Name, - attribute.SensorChannel, attribute.SensorType.Value, this, - settings); + attribute.SensorChannel, attribute.DefaultHiddenSensor, + attribute.SensorType.Value, this, null, settings); sensors.Add(attribute, sensor); ActivateSensor(sensor); diff --git a/Hardware/HDD/SSDSandforce.cs b/Hardware/HDD/SSDSandforce.cs index 94ae180..1f0e800 100644 --- a/Hardware/HDD/SSDSandforce.cs +++ b/Hardware/HDD/SSDSandforce.cs @@ -55,8 +55,8 @@ namespace OpenHardwareMonitor.Hardware.HDD { new SmartAttribute(0xB5, SmartNames.AlternativeProgramFailCount, RawToInt), new SmartAttribute(0xB6, SmartNames.AlternativeEraseFailCount, RawToInt), new SmartAttribute(0xBB, SmartNames.UncorrectableErrorCount, RawToInt), - new SmartAttribute(0xC2, SmartNames.Temperature, - (byte[] raw, byte value) => { return value; }), + new SmartAttribute(0xC2, SmartNames.Temperature, (byte[] raw, byte value) + => { return value; }, SensorType.Temperature, 0, true), new SmartAttribute(0xC3, SmartNames.UnrecoverableEcc), new SmartAttribute(0xC4, SmartNames.ReallocationEventCount, RawToInt), new SmartAttribute(0xE7, SmartNames.RemainingLife, null, @@ -78,7 +78,7 @@ namespace OpenHardwareMonitor.Hardware.HDD { : base(smart, name, firmwareRevision, index, smartAttributes, settings) { this.writeAmplification = new Sensor("Write Amplification", 1, - SensorType.Level, this, settings); + SensorType.Factor, this, settings); } public override void UpdateAdditionalSensors(DriveAttributeValue[] values) { @@ -92,7 +92,7 @@ namespace OpenHardwareMonitor.Hardware.HDD { hostWritesToController = RawToInt(value.RawValue, value.AttrValue); } if (controllerWritesToNAND.HasValue && hostWritesToController.HasValue) { - writeAmplification.Value = 100 * + writeAmplification.Value = controllerWritesToNAND.Value / hostWritesToController.Value; ActivateSensor(writeAmplification); } diff --git a/Hardware/HDD/SmartAttribute.cs b/Hardware/HDD/SmartAttribute.cs index 55686cd..510d98e 100644 --- a/Hardware/HDD/SmartAttribute.cs +++ b/Hardware/HDD/SmartAttribute.cs @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2011 + Portions created by the Initial Developer are Copyright (C) 2011-2012 the Initial Developer. All Rights Reserved. Contributor(s): @@ -75,15 +75,17 @@ 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. + /// True to hide the sensor initially. public SmartAttribute(byte identifier, string name, RawValueConversion rawValueConversion, SensorType? sensorType, - int sensorChannel) + int sensorChannel, bool defaultHiddenSensor = false) { this.Identifier = identifier; this.Name = name; this.rawValueConversion = rawValueConversion; this.SensorType = sensorType; this.SensorChannel = sensorChannel; + this.DefaultHiddenSensor = defaultHiddenSensor; } /// @@ -97,6 +99,8 @@ namespace OpenHardwareMonitor.Hardware.HDD { public int SensorChannel { get; private set; } + public bool DefaultHiddenSensor { get; private set; } + public bool HasRawValueConversion { get { return rawValueConversion != null; diff --git a/Hardware/ISensor.cs b/Hardware/ISensor.cs index dfae42e..237ab81 100644 --- a/Hardware/ISensor.cs +++ b/Hardware/ISensor.cs @@ -16,7 +16,7 @@ The Initial Developer of the Original Code is Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2011 + Portions created by the Initial Developer are Copyright (C) 2009-2012 the Initial Developer. All Rights Reserved. Contributor(s): @@ -50,8 +50,9 @@ namespace OpenHardwareMonitor.Hardware { Flow, // L/h Control, // % Level, // % + Factor, // 1 Power, // W - Data, // GB = 2^30 Bytes + Data, // GB = 2^30 Bytes } public struct SensorValue { diff --git a/OpenHardwareMonitor.csproj b/OpenHardwareMonitor.csproj index 6d52c81..399a5c3 100644 --- a/OpenHardwareMonitor.csproj +++ b/OpenHardwareMonitor.csproj @@ -225,6 +225,9 @@ + + + diff --git a/Properties/AssemblyVersion.cs b/Properties/AssemblyVersion.cs index 6a7cdf9..e9bcc49 100644 --- a/Properties/AssemblyVersion.cs +++ b/Properties/AssemblyVersion.cs @@ -37,5 +37,5 @@ using System.Reflection; -[assembly: AssemblyVersion("0.4.0.2")] -[assembly: AssemblyInformationalVersion("0.4.0.2 Alpha")] \ No newline at end of file +[assembly: AssemblyVersion("0.4.0.3")] +[assembly: AssemblyInformationalVersion("0.4.0.3 Alpha")] \ No newline at end of file diff --git a/Resources/factor.png b/Resources/factor.png new file mode 100644 index 0000000000000000000000000000000000000000..78fc347b38bf9bdd615773c942f336780e57f44a GIT binary patch literal 533 zcmV+w0_y#VP)Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RX0uB};3T*o#TL1t69cffpbVF}# zZDnqB0000007G(RVRU6=Aa`kWXdp*PO;BVmWd{HN0e(qDK~y-)rPDo+4FMPh;AiGu zVQp>}LF^EsKuDBA6sr@FDEtJCR;i$*6qO*NR)|6`L9L-63fruhl@NlBkGr!w3TKkZ z&5FV#Q_TBua?W|r@Sjidw?u@VG=2;x>rR{ix+gQeHe8=Sg z-^CNOXv-e`vpAID`_bHB6(y$eEC5|^rDL!GC!_a0USK6dn=uOYYxvj)?*L}vFucK+ z0JJ!Psnq5pYdOr6p}!HE0`LjHGBAsCxz5iCS#4d{ZO5R^3+r-`X