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).
3 Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 The contents of this file are subject to the Mozilla Public License Version
6 1.1 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.mozilla.org/MPL/
11 Software distributed under the License is distributed on an "AS IS" basis,
12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 for the specific language governing rights and limitations under the License.
15 The Original Code is the Open Hardware Monitor code.
17 The Initial Developer of the Original Code is
18 Michael Möller <m.moeller@gmx.ch>.
19 Portions created by the Initial Developer are Copyright (C) 2011-2012
20 the Initial Developer. All Rights Reserved.
23 Roland Reinl <roland-reinl@gmx.de>
25 Alternatively, the contents of this file may be used under the terms of
26 either the GNU General Public License Version 2 or later (the "GPL"), or
27 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 in which case the provisions of the GPL or the LGPL are applicable instead
29 of those above. If you wish to allow use of your version of this file only
30 under the terms of either the GPL or the LGPL, and not to allow others to
31 use your version of this file under the terms of the MPL, indicate your
32 decision by deleting the provisions above and replace them with the notice
33 and other provisions required by the GPL or the LGPL. If you do not delete
34 the provisions above, a recipient may use your version of this file under
35 the terms of any one of the MPL, the GPL or the LGPL.
40 using System.Collections.Generic;
42 namespace OpenHardwareMonitor.Hardware.HDD {
43 internal class SmartAttribute {
45 private RawValueConversion rawValueConversion;
48 /// Initializes a new instance of the <see cref="SmartAttribute"/> class.
50 /// <param name="identifier">The SMART identifier of the attribute.</param>
51 /// <param name="name">The name of the attribute.</param>
52 public SmartAttribute(byte identifier, string name) :
53 this(identifier, name, null, null, 0) { }
56 /// Initializes a new instance of the <see cref="SmartAttribute"/> class.
58 /// <param name="identifier">The SMART identifier of the attribute.</param>
59 /// <param name="name">The name of the attribute.</param>
60 /// <param name="rawValueConversion">A delegate for converting the raw byte
61 /// array into a value (or null to use the attribute value).</param>
62 public SmartAttribute(byte identifier, string name,
63 RawValueConversion rawValueConversion) :
64 this(identifier, name, rawValueConversion, null, 0) { }
67 /// Initializes a new instance of the <see cref="SmartAttribute"/> class.
69 /// <param name="identifier">The SMART identifier of the attribute.</param>
70 /// <param name="name">The name of the attribute.</param>
71 /// <param name="rawValueConversion">A delegate for converting the raw byte
72 /// array into a value (or null to use the attribute value).</param>
73 /// <param name="sensorType">Type of the sensor or null if no sensor is to
74 /// be created.</param>
75 /// <param name="sensorChannel">If there exists more than one attribute with
76 /// the same sensor channel and type, then a sensor is created only for the
77 /// first attribute.</param>
78 /// <param name="defaultHiddenSensor">True to hide the sensor initially.</param>
79 public SmartAttribute(byte identifier, string name,
80 RawValueConversion rawValueConversion, SensorType? sensorType,
81 int sensorChannel, bool defaultHiddenSensor = false)
83 this.Identifier = identifier;
85 this.rawValueConversion = rawValueConversion;
86 this.SensorType = sensorType;
87 this.SensorChannel = sensorChannel;
88 this.DefaultHiddenSensor = defaultHiddenSensor;
92 /// Gets the SMART identifier.
94 public byte Identifier { get; private set; }
96 public string Name { get; private set; }
98 public SensorType? SensorType { get; private set; }
100 public int SensorChannel { get; private set; }
102 public bool DefaultHiddenSensor { get; private set; }
104 public bool HasRawValueConversion {
106 return rawValueConversion != null;
110 public float ConvertValue(DriveAttributeValue value) {
111 if (rawValueConversion == null) {
112 return value.AttrValue;
114 return rawValueConversion(value.RawValue, value.AttrValue);
118 public delegate float RawValueConversion(byte[] rawValue, byte value);