Added the hard drive firmware version to the report. This could be important if the SMART attribute layout changes with firmware versions on some drives.
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
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 public SmartAttribute(byte identifier, string name,
79 RawValueConversion rawValueConversion, SensorType? sensorType,
82 this.Identifier = identifier;
84 this.rawValueConversion = rawValueConversion;
85 this.SensorType = sensorType;
86 this.SensorChannel = sensorChannel;
90 /// Gets the SMART identifier.
92 public byte Identifier { get; private set; }
94 public string Name { get; private set; }
96 public SensorType? SensorType { get; private set; }
98 public int SensorChannel { get; private set; }
100 public bool HasRawValueConversion {
102 return rawValueConversion != null;
106 public float ConvertValue(DriveAttributeValue value) {
107 if (rawValueConversion == null) {
108 return value.AttrValue;
110 return rawValueConversion(value.RawValue, value.AttrValue);
114 public delegate float RawValueConversion(byte[] rawValue, byte value);