Hardware/HDD/SMART.cs
changeset 231 30f5a06f5d8a
parent 218 194186efdde9
child 233 c5139c236200
     1.1 --- a/Hardware/HDD/SMART.cs	Sun Oct 17 16:13:20 2010 +0000
     1.2 +++ b/Hardware/HDD/SMART.cs	Sun Oct 17 17:12:38 2010 +0000
     1.3 @@ -53,37 +53,100 @@
     1.4        SelfPreserving = 0x20
     1.5      }
     1.6  
     1.7 -    public enum AttributeID : byte {
     1.8 -      ReadErrorRate = 0x01,
     1.9 -      ThroughputPerformance = 0x02,
    1.10 -      SpinUpTime = 0x03,
    1.11 -      StartStopCount = 0x04,
    1.12 -      ReallocatedSectorsCount = 0x05,
    1.13 -      ReadChannelMargin = 0x06,
    1.14 -      SeekErrorRate = 0x07,
    1.15 -      SeekTimePerformance = 0x08,
    1.16 -      PowerOnHours = 0x09,
    1.17 -      SpinRetryCount = 0x0A,
    1.18 -      RecalibrationRetries = 0x0B,
    1.19 -      PowerCycleCount = 0x0C,
    1.20 -      SoftReadErrorRate = 0x0D,
    1.21 -      AirflowTemperature = 0xBE,
    1.22 -      Temperature = 0xC2,
    1.23 -      HardwareECCRecovered = 0xC3,
    1.24 -      ReallocationEventCount = 0xC4,
    1.25 -      CurrentPendingSectorCount = 0xC5,
    1.26 -      UncorrectableSectorCount = 0xC6,
    1.27 -      UltraDMACRCErrorCount = 0xC7,
    1.28 -      WriteErrorRate = 0xC8,
    1.29 -      DriveTemperature = 0xE7
    1.30 +    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    1.31 +    public struct AttributeID {
    1.32 +      private byte value;
    1.33 +
    1.34 +      public AttributeID(byte value) {
    1.35 +        this.value = value;
    1.36 +      }
    1.37 +
    1.38 +      public override bool Equals(Object obj) {
    1.39 +        return obj is AttributeID && this == (AttributeID)obj;
    1.40 +      }
    1.41 +      public override int GetHashCode() {
    1.42 +        return value.GetHashCode() ^ value.GetHashCode();
    1.43 +      }
    1.44 +      public static bool operator ==(AttributeID a, AttributeID b) {
    1.45 +        return a.value == b.value;
    1.46 +      }
    1.47 +      public static bool operator !=(AttributeID a, AttributeID b) {
    1.48 +        return !(a == b);
    1.49 +      }
    1.50 +
    1.51 +      public string ToString(string format) {
    1.52 +        return value.ToString(format);
    1.53 +      }
    1.54 +
    1.55 +      public static readonly AttributeID None = new AttributeID(0x00);
    1.56      }
    1.57  
    1.58 -    public enum SSDLifeID {
    1.59 -      None = 0x00,
    1.60 -      Indilinx = 0xD1,
    1.61 -      Intel = 0xE8,
    1.62 -      Samsung = 0xB4,
    1.63 -      SandForce = 0xE7
    1.64 +    // Common SMART attributes
    1.65 +    public static class CommonAttributes {      
    1.66 +      public static readonly AttributeID 
    1.67 +        ReadErrorRate = new AttributeID(0x01);
    1.68 +      public static readonly AttributeID 
    1.69 +        ThroughputPerformance = new AttributeID(0x02);
    1.70 +      public static readonly AttributeID 
    1.71 +        SpinUpTime = new AttributeID(0x03);
    1.72 +      public static readonly AttributeID 
    1.73 +        StartStopCount = new AttributeID(0x04);
    1.74 +      public static readonly AttributeID 
    1.75 +        ReallocatedSectorsCount = new AttributeID(0x05);
    1.76 +      public static readonly AttributeID 
    1.77 +        ReadChannelMargin = new AttributeID(0x06);
    1.78 +      public static readonly AttributeID 
    1.79 +        SeekErrorRate = new AttributeID(0x07);
    1.80 +      public static readonly AttributeID 
    1.81 +        SeekTimePerformance = new AttributeID(0x08);
    1.82 +      public static readonly AttributeID 
    1.83 +        PowerOnHours = new AttributeID(0x09);
    1.84 +      public static readonly AttributeID 
    1.85 +        SpinRetryCount = new AttributeID(0x0A);
    1.86 +      public static readonly AttributeID 
    1.87 +        RecalibrationRetries = new AttributeID(0x0B);
    1.88 +      public static readonly AttributeID 
    1.89 +        PowerCycleCount = new AttributeID(0x0C);
    1.90 +      public static readonly AttributeID 
    1.91 +        SoftReadErrorRate = new AttributeID(0x0D);
    1.92 +      public static readonly AttributeID 
    1.93 +        AirflowTemperature = new AttributeID(0xBE);
    1.94 +      public static readonly AttributeID 
    1.95 +        Temperature = new AttributeID(0xC2);
    1.96 +      public static readonly AttributeID 
    1.97 +        HardwareECCRecovered = new AttributeID(0xC3);
    1.98 +      public static readonly AttributeID 
    1.99 +        ReallocationEventCount = new AttributeID(0xC4);
   1.100 +      public static readonly AttributeID 
   1.101 +        CurrentPendingSectorCount = new AttributeID(0xC5);
   1.102 +      public static readonly AttributeID 
   1.103 +        UncorrectableSectorCount = new AttributeID(0xC6);
   1.104 +      public static readonly AttributeID 
   1.105 +        UltraDMACRCErrorCount = new AttributeID(0xC7);
   1.106 +      public static readonly AttributeID 
   1.107 +        WriteErrorRate = new AttributeID(0xC8);
   1.108 +      public static readonly AttributeID 
   1.109 +        DriveTemperature = new AttributeID(0xE7);
   1.110 +    }
   1.111 +
   1.112 +    // Indilinx SSD SMART attributes
   1.113 +    public static class IndilinxAttributes {      
   1.114 +      public static readonly AttributeID RemainingLife = new AttributeID(0xD1);
   1.115 +    }
   1.116 +
   1.117 +    // Intel SSD SMART attributes
   1.118 +    public static class IntelAttributes {      
   1.119 +      public static readonly AttributeID RemainingLife = new AttributeID(0xE8);
   1.120 +    }
   1.121 +
   1.122 +    // Samsung SSD SMART attributes
   1.123 +    public static class SamsungAttributes {      
   1.124 +      public static readonly AttributeID RemainingLife = new AttributeID(0xB4);
   1.125 +    }
   1.126 +
   1.127 +    // SandForce SSD SMART attributes
   1.128 +    public static class SandForceAttributes {      
   1.129 +      public static readonly AttributeID RemainingLife = new AttributeID(0xE7);
   1.130      }
   1.131  
   1.132      [StructLayout(LayoutKind.Sequential, Pack = 1)]