Hardware/HDD/SSDSandforce.cs
author Stephane Lenclud
Sat, 30 Jan 2016 23:01:51 +0100
branchMiniDisplay
changeset 454 f84878f52cd9
parent 344 3145aadca3d2
permissions -rw-r--r--
Disabling Nuvoton NCT6791D because of fan full speed bug on Asus Z97 WS.
moel@324
     1
/*
moel@324
     2
 
moel@344
     3
  This Source Code Form is subject to the terms of the Mozilla Public
moel@344
     4
  License, v. 2.0. If a copy of the MPL was not distributed with this
moel@344
     5
  file, You can obtain one at http://mozilla.org/MPL/2.0/.
moel@324
     6
 
moel@344
     7
  Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
moel@344
     8
	Copyright (C) 2010 Paul Werelds
moel@344
     9
	
moel@324
    10
*/
moel@324
    11
moel@374
    12
using System.Collections.Generic;
moel@374
    13
using OpenHardwareMonitor.Collections;
moel@374
    14
moel@324
    15
namespace OpenHardwareMonitor.Hardware.HDD {
moel@324
    16
moel@338
    17
  [NamePrefix(""), RequireSmart(0xAB), RequireSmart(0xB1)]
moel@324
    18
  internal class SSDSandforce : AbstractHarddrive {
moel@324
    19
moel@324
    20
    private static readonly IEnumerable<SmartAttribute> smartAttributes =
moel@324
    21
      new List<SmartAttribute> {
moel@339
    22
      new SmartAttribute(0x01, SmartNames.RawReadErrorRate),
moel@339
    23
      new SmartAttribute(0x05, SmartNames.RetiredBlockCount, RawToInt),
moel@328
    24
      new SmartAttribute(0x09, SmartNames.PowerOnHours, RawToInt),
moel@328
    25
      new SmartAttribute(0x0C, SmartNames.PowerCycleCount, RawToInt),
moel@339
    26
      new SmartAttribute(0xAB, SmartNames.ProgramFailCount, RawToInt),
moel@339
    27
      new SmartAttribute(0xAC, SmartNames.EraseFailCount, RawToInt),
moel@339
    28
      new SmartAttribute(0xAE, SmartNames.UnexpectedPowerLossCount, RawToInt),
moel@339
    29
      new SmartAttribute(0xB1, SmartNames.WearRangeDelta, RawToInt),
moel@339
    30
      new SmartAttribute(0xB5, SmartNames.AlternativeProgramFailCount, RawToInt),
moel@339
    31
      new SmartAttribute(0xB6, SmartNames.AlternativeEraseFailCount, RawToInt),
moel@339
    32
      new SmartAttribute(0xBB, SmartNames.UncorrectableErrorCount, RawToInt),
moel@374
    33
      new SmartAttribute(0xC2, SmartNames.Temperature, 
moel@374
    34
        (byte[] raw, byte value, IReadOnlyArray<IParameter> p) 
moel@374
    35
          => { return value + (p == null ? 0 : p[0].Value); }, 
moel@374
    36
        SensorType.Temperature, 0, true, 
moel@374
    37
        new[] { new ParameterDescription("Offset [°C]", 
moel@374
    38
                  "Temperature offset of the thermal sensor.\n" + 
moel@374
    39
                  "Temperature = Value + Offset.", 0) }), 
moel@328
    40
      new SmartAttribute(0xC3, SmartNames.UnrecoverableEcc), 
moel@339
    41
      new SmartAttribute(0xC4, SmartNames.ReallocationEventCount, RawToInt),
moel@339
    42
      new SmartAttribute(0xE7, SmartNames.RemainingLife, null, 
moel@339
    43
        SensorType.Level, 0),
moel@339
    44
      new SmartAttribute(0xE9, SmartNames.ControllerWritesToNAND, RawToInt,
moel@324
    45
        SensorType.Data, 0),
moel@339
    46
      new SmartAttribute(0xEA, SmartNames.HostWritesToController, RawToInt, 
moel@339
    47
        SensorType.Data, 1),
moel@339
    48
      new SmartAttribute(0xF1, SmartNames.HostWrites, RawToInt, 
moel@339
    49
        SensorType.Data, 1),
moel@339
    50
      new SmartAttribute(0xF2, SmartNames.HostReads, RawToInt, 
moel@339
    51
        SensorType.Data, 2)
moel@324
    52
    };
moel@324
    53
moel@339
    54
    private Sensor writeAmplification;
moel@339
    55
moel@325
    56
    public SSDSandforce(ISmart smart, string name, string firmwareRevision, 
moel@325
    57
      int index, ISettings settings) 
moel@325
    58
      : base(smart, name, firmwareRevision,  index, smartAttributes, settings) 
moel@339
    59
    {
moel@339
    60
      this.writeAmplification = new Sensor("Write Amplification", 1, 
moel@340
    61
        SensorType.Factor, this, settings);    
moel@339
    62
    }
moel@339
    63
moel@339
    64
    public override void UpdateAdditionalSensors(DriveAttributeValue[] values) {
moel@339
    65
      float? controllerWritesToNAND = null;
moel@339
    66
      float? hostWritesToController = null;
moel@339
    67
      foreach (DriveAttributeValue value in values) {
moel@339
    68
        if (value.Identifier == 0xE9)
moel@374
    69
          controllerWritesToNAND = RawToInt(value.RawValue, value.AttrValue, null);
moel@339
    70
moel@339
    71
        if (value.Identifier == 0xEA)
moel@374
    72
          hostWritesToController = RawToInt(value.RawValue, value.AttrValue, null);
moel@339
    73
      }
moel@339
    74
      if (controllerWritesToNAND.HasValue && hostWritesToController.HasValue) {
moel@343
    75
        if (hostWritesToController.Value > 0)
moel@343
    76
          writeAmplification.Value =
moel@343
    77
            controllerWritesToNAND.Value / hostWritesToController.Value;
moel@343
    78
        else
moel@343
    79
          writeAmplification.Value = 0;
moel@339
    80
        ActivateSensor(writeAmplification);
moel@339
    81
      }
moel@339
    82
    }
moel@324
    83
  }
moel@324
    84
}