1.1 --- a/Hardware/HDD/HDDGroup.cs Sun Oct 17 16:13:20 2010 +0000
1.2 +++ b/Hardware/HDD/HDDGroup.cs Sun Oct 17 17:12:38 2010 +0000
1.3 @@ -76,16 +76,18 @@
1.4 continue;
1.5 }
1.6
1.7 - SMART.SSDLifeID ssdLifeID = GetSSDLifeID(attributes);
1.8 - if (ssdLifeID == SMART.SSDLifeID.None) {
1.9 + SMART.AttributeID ssdLifeID = GetSSDLifeID(attributes);
1.10 + if (ssdLifeID == SMART.AttributeID.None) {
1.11 SMART.AttributeID temperatureID = GetTemperatureIndex(attributes);
1.12
1.13 - if (temperatureID != 0x00) {
1.14 - hardware.Add(new HDD(name, handle, drive, temperatureID, settings));
1.15 + if (temperatureID != SMART.AttributeID.None) {
1.16 + hardware.Add(new HDD(name, handle, drive, temperatureID,
1.17 + SMART.AttributeID.None, settings));
1.18 continue;
1.19 }
1.20 } else {
1.21 - hardware.Add(new HDD(name, handle, drive, ssdLifeID, settings));
1.22 + hardware.Add(new HDD(name, handle, drive, SMART.AttributeID.None,
1.23 + ssdLifeID, settings));
1.24 continue;
1.25 }
1.26
1.27 @@ -93,29 +95,28 @@
1.28 }
1.29 }
1.30
1.31 - private SMART.SSDLifeID GetSSDLifeID(List<SMART.DriveAttribute> attributes) {
1.32 + private SMART.AttributeID GetSSDLifeID(List<SMART.DriveAttribute> attributes) {
1.33 // ID E9 is present on Intel, JM, SF and Samsung
1.34 // ID D2 is present on Indilinx
1.35 // Neither ID has been found on a mechanical hard drive (yet),
1.36 // So this seems like a good way to check if it's an SSD.
1.37 - bool isKnownSSD = (attributes.Exists(attr => (int)attr.ID == 0xE9) ||
1.38 - attributes.Exists(attr => (int)attr.ID == 0xD2)
1.39 + bool isKnownSSD = (
1.40 + attributes.Exists(attr => attr.ID == new SMART.AttributeID(0xE9)) ||
1.41 + attributes.Exists(attr => attr.ID == new SMART.AttributeID(0xD2))
1.42 );
1.43
1.44 - if (!isKnownSSD) return SMART.SSDLifeID.None;
1.45 + if (!isKnownSSD) return SMART.AttributeID.None;
1.46
1.47 // We start with a traditional loop, because there are 4 unique ID's
1.48 // that potentially identify one of the vendors
1.49 for (int i = 0; i < attributes.Count; i++) {
1.50
1.51 - switch ((int)attributes[i].ID) {
1.52 - case 0xB4:
1.53 - return SMART.SSDLifeID.Samsung;
1.54 - case 0xAB:
1.55 - return SMART.SSDLifeID.SandForce;
1.56 - case 0xD2:
1.57 - return SMART.SSDLifeID.Indilinx;
1.58 - }
1.59 + if (attributes[i].ID == SMART.SamsungAttributes.RemainingLife)
1.60 + return SMART.SamsungAttributes.RemainingLife;
1.61 + else if (attributes[i].ID == new SMART.AttributeID(0xAB))
1.62 + return SMART.SandForceAttributes.RemainingLife;
1.63 + else if (attributes[i].ID == new SMART.AttributeID(0xD2))
1.64 + return SMART.IndilinxAttributes.RemainingLife;
1.65 }
1.66
1.67 // TODO: Find out JMicron's Life attribute ID; their unique ID = 0xE4
1.68 @@ -125,25 +126,25 @@
1.69 // is whether we can find all 3; pointless to use Exists()
1.70 int intelRegisterCount = 0;
1.71 foreach (SMART.DriveAttribute attribute in attributes) {
1.72 - if ((int)attribute.ID == 0xE1 ||
1.73 - (int)attribute.ID == 0xE8 ||
1.74 - (int)attribute.ID == 0xE9
1.75 + if (attribute.ID == new SMART.AttributeID(0xE1) ||
1.76 + attribute.ID == new SMART.AttributeID(0xE8) ||
1.77 + attribute.ID == new SMART.AttributeID(0xE9)
1.78 )
1.79 intelRegisterCount++;
1.80 }
1.81
1.82 return (intelRegisterCount == 3)
1.83 - ? SMART.SSDLifeID.Intel
1.84 - : SMART.SSDLifeID.None;
1.85 + ? SMART.IntelAttributes.RemainingLife
1.86 + : SMART.AttributeID.None;
1.87 }
1.88
1.89 private SMART.AttributeID GetTemperatureIndex(
1.90 List<SMART.DriveAttribute> attributes)
1.91 {
1.92 SMART.AttributeID[] validIds = new[] {
1.93 - SMART.AttributeID.Temperature,
1.94 - SMART.AttributeID.DriveTemperature,
1.95 - SMART.AttributeID.AirflowTemperature
1.96 + SMART.CommonAttributes.Temperature,
1.97 + SMART.CommonAttributes.DriveTemperature,
1.98 + SMART.CommonAttributes.AirflowTemperature
1.99 };
1.100
1.101 foreach (SMART.AttributeID validId in validIds) {
1.102 @@ -152,7 +153,7 @@
1.103 return validId;
1.104 }
1.105
1.106 - return 0x00;
1.107 + return SMART.AttributeID.None;
1.108 }
1.109
1.110 public IHardware[] Hardware {
1.111 @@ -201,7 +202,7 @@
1.112 Environment.NewLine);
1.113
1.114 foreach (SMART.DriveAttribute a in attributes) {
1.115 - if (a.ID == 0) continue;
1.116 + if (a.ID == SMART.AttributeID.None) continue;
1.117 string raw = BitConverter.ToString(a.RawValue);
1.118 r.AppendFormat(CultureInfo.InvariantCulture, " {0}{1}{2}{3}{4}{5}",
1.119 a.ID.ToString("d").PadRight(6),