Added support for IT8705F super I/O chips.
3 This Source Code Form is subject to the terms of the Mozilla Public
4 License, v. 2.0. If a copy of the MPL was not distributed with this
5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 Copyright (C) 2011-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
8 Copyright (C) 2011 Roland Reinl <roland-reinl@gmx.de>
13 using System.Collections.Generic;
15 namespace OpenHardwareMonitor.Hardware.HDD {
16 internal class SmartAttribute {
18 private RawValueConversion rawValueConversion;
21 /// Initializes a new instance of the <see cref="SmartAttribute"/> class.
23 /// <param name="identifier">The SMART identifier of the attribute.</param>
24 /// <param name="name">The name of the attribute.</param>
25 public SmartAttribute(byte identifier, string name) :
26 this(identifier, name, null, null, 0) { }
29 /// Initializes a new instance of the <see cref="SmartAttribute"/> class.
31 /// <param name="identifier">The SMART identifier of the attribute.</param>
32 /// <param name="name">The name of the attribute.</param>
33 /// <param name="rawValueConversion">A delegate for converting the raw byte
34 /// array into a value (or null to use the attribute value).</param>
35 public SmartAttribute(byte identifier, string name,
36 RawValueConversion rawValueConversion) :
37 this(identifier, name, rawValueConversion, null, 0) { }
40 /// Initializes a new instance of the <see cref="SmartAttribute"/> class.
42 /// <param name="identifier">The SMART identifier of the attribute.</param>
43 /// <param name="name">The name of the attribute.</param>
44 /// <param name="rawValueConversion">A delegate for converting the raw byte
45 /// array into a value (or null to use the attribute value).</param>
46 /// <param name="sensorType">Type of the sensor or null if no sensor is to
47 /// be created.</param>
48 /// <param name="sensorChannel">If there exists more than one attribute with
49 /// the same sensor channel and type, then a sensor is created only for the
50 /// first attribute.</param>
51 /// <param name="defaultHiddenSensor">True to hide the sensor initially.</param>
52 public SmartAttribute(byte identifier, string name,
53 RawValueConversion rawValueConversion, SensorType? sensorType,
54 int sensorChannel, bool defaultHiddenSensor = false)
56 this.Identifier = identifier;
58 this.rawValueConversion = rawValueConversion;
59 this.SensorType = sensorType;
60 this.SensorChannel = sensorChannel;
61 this.DefaultHiddenSensor = defaultHiddenSensor;
65 /// Gets the SMART identifier.
67 public byte Identifier { get; private set; }
69 public string Name { get; private set; }
71 public SensorType? SensorType { get; private set; }
73 public int SensorChannel { get; private set; }
75 public bool DefaultHiddenSensor { get; private set; }
77 public bool HasRawValueConversion {
79 return rawValueConversion != null;
83 public float ConvertValue(DriveAttributeValue value) {
84 if (rawValueConversion == null) {
85 return value.AttrValue;
87 return rawValueConversion(value.RawValue, value.AttrValue);
91 public delegate float RawValueConversion(byte[] rawValue, byte value);