Hardware/HDD/DebugSmart.cs
author moel.mich
Mon, 02 Jul 2012 21:14:40 +0000
changeset 357 fb8dc26f65a4
parent 338 f580591971ce
child 358 7962499f9cd6
permissions -rw-r--r--
Added mainboard specific configurations for the following Gigabyte mainboards: EX58-UD3R, G41M-Combo, G41MT-S2, G41MT-S2P, GA-MA770T-UD3P, GA-MA785GM-US2H, GA-MA78LM-S2H, GA-MA790X-UD3P, H55-USB3, H55N-USB3, H61M-DS2 REV 1.2, H61M-USB3-B3 REV 2.0, H67A-USB3-B3, P55A-UD3, P67A-UD3-B3, P67A-UD3R-B3, Z68A-D3H-B3, Z68AP-D3, Z68X-UD3H-B3.
     1 /*
     2  
     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/.
     6  
     7   Copyright (C) 2011-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
     8 	
     9 */
    10 
    11 using System;
    12 using System.Collections.Generic;
    13 using System.Text;
    14 
    15 namespace OpenHardwareMonitor.Hardware.HDD {
    16 
    17 #if DEBUG
    18 
    19   internal class DebugSmart : ISmart {
    20 
    21     private Drive[] drives = {
    22       new Drive("KINGSTON SNV425S264GB", null, 16,
    23         @" 01 000000000000 100 100      
    24            02 000000000000 100 100      
    25            03 000000000000 100 100      
    26            05 000000000000 100 100      
    27            07 000000000000 100 100      
    28            08 000000000000 100 100      
    29            09 821E00000000 100 100      
    30            0A 000000000000 100 100      
    31            0C 950200000000 100 100      
    32            A8 000000000000 100 100      
    33            AF 000000000000 100 100      
    34            C0 000000000000 100 100      
    35            C2 290014002B00 100 41       
    36            C5 000000000000 100 100      
    37            F0 000000000000 100 100      
    38            AA 07007B000000 100 100      
    39            AD 0E1E71304919 100 100"),
    40 
    41       new Drive("PLEXTOR  PX-128M2S", "1.03", 16, 
    42         @" 01 000000000000 100 100 0   
    43            03 000000000000 100 100 0   
    44            04 000000000000 100 100 0   
    45            05 000000000000 100 100 0   
    46            09 250100000000 100 100 0   
    47            0A 000000000000 100 100 0   
    48            0C D10000000000 100 100 0   
    49            B2 000000000000 100 100 0   
    50            BB 000000000000 100 100 0   
    51            BE 000000000000 100 100 0   
    52            C0 000000000000 100 100 0   
    53            C1 000000000000 100 100 0   
    54            C2 000000000000 100 100 0   
    55            C3 000000000000 100 100 0   
    56            C5 000000000000 100 100 0   
    57            C6 000000000000 100 100 0   
    58            C7 000000000000 100 100 0"),
    59 
    60       new Drive("OCZ-VERTEX2", "1.25", 16, 
    61         @" 01 DADAD5000000 100 106 50
    62            05 000000000000 100 100 3 
    63            09 DF0900004A2F 100 100 0 
    64            0C FC0100000000 100 100 0 
    65            AB 000000000000 0   0   0 
    66            AC 000000000000 0   0   0 
    67            AE 1F0000000000 0   0   0 
    68            B1 000000000000 0   0   0 
    69            B5 000000000000 0   0   0 
    70            B6 000000000000 0   0   0 
    71            BB 000000000000 100 100 0 
    72            C2 010081007F00 129 1   0 
    73            C3 DADAD5000000 100 106 0 
    74            C4 000000000000 100 100 0 
    75            E7 000000000000 100 100 10
    76            E9 800400000000 0   0   0 
    77            EA 000600000000 0   0   0 
    78            F1 000600000000 0   0   0 
    79            F2 801200000000 0   0   0"),
    80       
    81       new Drive("WDC WD5000AADS-00S9B0", null, 10, 
    82         @" 1   000000000000 200 200         
    83            3   820D00000000 149 150         
    84            4   610800000000 98  98          
    85            5   000000000000 200 200         
    86            7   000000000000 253 100         
    87            9   0F1F00000000 90  90          
    88            10  000000000000 100 100         
    89            11  000000000000 100 100         
    90            12  880200000000 100 100         
    91            192 6B0000000000 200 200         
    92            193 E9CB03000000 118 118         
    93            194 280000000000 94  103         
    94            196 000000000000 200 200         
    95            197 000000000000 200 200         
    96            198 000000000000 200 200         
    97            199 000000000000 200 200         
    98            200 000000000000 200 200         
    99            130 7B0300010002 1   41          
   100            5   000000000000 0   0           
   101            1   000000000000 0   0"),
   102 
   103       new Drive("INTEL SSDSA2M080G2GC", null, 10, 
   104         @" 3   000000000000 100 100         
   105            4   000000000000 100 100         
   106            5   010000000000 100 100         
   107            9   B10B00000000 100 100         
   108            12  DD0300000000 100 100         
   109            192 480000000000 100 100         
   110            225 89DB00000000 200 200         
   111            226 3D1B00000000 100 100         
   112            227 030000000000 100 100         
   113            228 7F85703C0000 100 100         
   114            232 000000000000 99  99          
   115            233 000000000000 98  98          
   116            184 000000000000 100 100         
   117            1   000000000000 0   0"),
   118 
   119       new Drive("OCZ-VERTEX", null, 10, 
   120         @" 1   000000000000 0   8   
   121            9   000000000000 30  99  
   122            12  000000000000 0   15  
   123            184 000000000000 0   7   
   124            195 000000000000 0   0   
   125            196 000000000000 0   2   
   126            197 000000000000 0   0   
   127            198 B9ED00000000 214 176 
   128            199 352701000000 143 185 
   129            200 B10500000000 105 55  
   130            201 F40A00000000 238 194 
   131            202 020000000000 137 35  
   132            203 020000000000 125 63  
   133            204 000000000000 0   0   
   134            205 000000000000 19  136 
   135            206 000000000000 22  54  
   136            207 010000000000 113 226 
   137            208 000000000000 49  232 
   138            209 000000000000 0   98  
   139            211 000000000000 0   0   
   140            212 000000000000 0   0   
   141            213 000000000000 0   0"),
   142  
   143       new Drive("INTEL SSDSA2CW120G3", null, 16,
   144         @"03 000000000000 100 100 0
   145           04 000000000000 100 100 0
   146           05 000000000000 100 100 0
   147           09 830200000000 100 100 0
   148           0C 900100000000 100 100 0
   149           AA 000000000000 100 100 0
   150           AB 000000000000 100 100 0
   151           AC 000000000000 100 100 0
   152           B8 000000000000 100 100 0
   153           BB 000000000000 100 100 0
   154           C0 040000000000 100 100 0
   155           E1 FF4300000000 100 100 0
   156           E2 E57D14000000 100 100 0
   157           E3 000000000000 100 100 0
   158           E4 E39600000000 100 100 0
   159           E8 000000000000 100 100 0
   160           E9 000000000000 100 100 0
   161           F1 FF4300000000 100 100 0
   162           F2 264F00000000 100 100 0"),
   163 
   164      new Drive("CORSAIR CMFSSD-128GBG2D", "VBM19C1Q", 16, 
   165        @"09 100900000000 99  99  0 
   166          0C 560200000000 99  99  0 
   167          AF 000000000000 100 100 10
   168          B0 000000000000 100 100 10
   169          B1 2A0000000000 99  99  17
   170          B2 180000000000 60  60  10
   171          B3 4B0000000000 98  98  10
   172          B4 B50E00000000 98  98  10
   173          B5 000000000000 100 100 10
   174          B6 000000000000 100 100 10
   175          B7 000000000000 100 100 10
   176          BB 000000000000 100 100 0 
   177          C3 000000000000 200 200 0 
   178          C6 000000000000 100 100 0 
   179          C7 810100000000 253 253 0 
   180          E8 240000000000 60  60  10
   181          E9 630594120000 92  92  0"),
   182 
   183       new Drive("Maxtor 6L300R0", null, 10,    
   184         @"3   9E5500000000 183 193         
   185           4   0A0D00000000 252 252         
   186           5   010000000000 253 253         
   187           6   000000000000 253 253         
   188           7   000000000000 252 253         
   189           8   DFA700000000 224 245         
   190           9   CE5700000000 155 155         
   191           10  000000000000 252 253         
   192           11  000000000000 252 253         
   193           12  BA0400000000 250 250         
   194           192 000000000000 253 253         
   195           193 000000000000 253 253         
   196           194 3D0000000000 253 42          
   197           195 5D1F00000000 252 253         
   198           196 000000000000 253 253         
   199           197 010000000000 253 253         
   200           198 000000000000 253 253         
   201           199 030000000000 196 199         
   202           200 000000000000 252 253         
   203           201 000000000000 252 253         
   204           202 000000000000 252 253         
   205           203 000000000000 252 253         
   206           204 000000000000 252 253         
   207           205 000000000000 252 253         
   208           207 000000000000 252 253         
   209           208 000000000000 252 253         
   210           209 EA0000000000 234 234         
   211           210 000000000000 252 253         
   212           211 000000000000 252 253         
   213           212 000000000000 252 253         
   214           130 5B0300010002 1   9           
   215           59  FC3203030100 205 0           
   216           1   000000000000 0   0           
   217           144 000000000000 0   34 "),
   218 
   219         new Drive("M4-CT256M4SSD2", "0309", 16, 
   220           @"01 000000000000 100 100 50     
   221             05 000000000000 100 100 10     
   222             09 AB0100000000 100 100 1      
   223             0C 6E0000000000 100 100 1      
   224             AA 000000000000 100 100 10     
   225             AB 000000000000 100 100 1      
   226             AC 000000000000 100 100 1      
   227             AD 060000000000 100 100 10     
   228             AE 000000000000 100 100 1      
   229             B5 79003D00B700 100 100 1      
   230             B7 000000000000 100 100 1      
   231             B8 000000000000 100 100 50     
   232             BB 000000000000 100 100 1      
   233             BC 000000000000 100 100 1      
   234             BD 5B0000000000 100 100 1      
   235             C2 000000000000 100 100 0      
   236             C3 000000000000 100 100 1      
   237             C4 000000000000 100 100 1      
   238             C5 000000000000 100 100 1      
   239             C6 000000000000 100 100 1      
   240             C7 000000000000 100 100 1      
   241             CA 000000000000 100 100 1      
   242             CE 000000000000 100 100 1 "),
   243 
   244         new Drive("C300-CTFDDAC256MAG", "0007", 16, 
   245           @"01 000000000000 100 100 0  
   246             05 000000000000 100 100 0  
   247             09 4C0A00000000 100 100 0  
   248             0C 0F0100000000 100 100 0  
   249             AA 000000000000 100 100 0  
   250             AB 000000000000 100 100 0  
   251             AC 000000000000 100 100 0  
   252             AD 1B0000000000 100 100 0  
   253             AE 000000000000 100 100 0  
   254             B5 D30357012B05 100 100 0  
   255             B7 000000000000 100 100 0  
   256             B8 000000000000 100 100 0  
   257             BB 000000000000 100 100 0  
   258             BC 000000000000 100 100 0  
   259             BD C60100000000 100 100 0  
   260             C3 000000000000 100 100 0  
   261             C4 000000000000 100 100 0  
   262             C5 000000000000 100 100 0  
   263             C6 000000000000 100 100 0  
   264             C7 000000000000 100 100 0  
   265             CA 000000000000 100 100 0  
   266             CE 000000000000 100 100 0")
   267       };
   268 
   269     public IntPtr OpenDrive(int driveNumber) {
   270       if (driveNumber < drives.Length)
   271         return (IntPtr)driveNumber;
   272       else
   273         return InvalidHandle;
   274     }
   275 
   276     public bool EnableSmart(IntPtr handle, int driveNumber) {
   277       if (handle != (IntPtr)driveNumber)
   278         throw new ArgumentOutOfRangeException();
   279 
   280       return true;
   281     }
   282 
   283     public DriveAttributeValue[] ReadSmartData(IntPtr handle, int driveNumber) {
   284       if (handle != (IntPtr)driveNumber)
   285         throw new ArgumentOutOfRangeException();
   286 
   287       return drives[driveNumber].DriveAttributeValues;
   288     }
   289 
   290     public DriveThresholdValue[] ReadSmartThresholds(IntPtr handle, 
   291       int driveNumber) 
   292     {
   293       if (handle != (IntPtr)driveNumber)
   294         throw new ArgumentOutOfRangeException();
   295 
   296       return drives[driveNumber].DriveThresholdValues;
   297     }
   298 
   299     public bool ReadNameAndFirmwareRevision(IntPtr handle, int driveNumber, 
   300       out string name, out string firmwareRevision) {
   301       if (handle != (IntPtr)driveNumber)
   302         throw new ArgumentOutOfRangeException();
   303 
   304       name = drives[driveNumber].Name;
   305       firmwareRevision = drives[driveNumber].FirmwareVersion;
   306       return true;
   307     }
   308 
   309     public void CloseHandle(IntPtr handle) { }
   310 
   311 
   312     private class Drive {
   313 
   314       public Drive(string name, string firmware, int idBase, string value) {
   315         this.Name = name;
   316         this.FirmwareVersion = firmware;
   317 
   318         string[] lines = value.Split(new[] { '\r', '\n' }, 
   319           StringSplitOptions.RemoveEmptyEntries);
   320 
   321         DriveAttributeValues = new DriveAttributeValue[lines.Length];
   322         List<DriveThresholdValue> thresholds = new List<DriveThresholdValue>();
   323 
   324         for (int i = 0; i < lines.Length; i++) {
   325 
   326           string[] array = lines[i].Split(new[] { ' ' },
   327             StringSplitOptions.RemoveEmptyEntries);
   328 
   329           if (array.Length != 4 && array.Length != 5)
   330             throw new Exception();
   331 
   332           DriveAttributeValue v = new DriveAttributeValue();
   333           v.Identifier = Convert.ToByte(array[0], idBase);
   334 
   335           v.RawValue = new byte[6];
   336           for (int j = 0; j < 6; j++) {
   337             v.RawValue[j] = Convert.ToByte(array[1].Substring(2 * j, 2), 16);
   338           }
   339 
   340           v.WorstValue = Convert.ToByte(array[2], 10);
   341           v.AttrValue = Convert.ToByte(array[3], 10);
   342 
   343           DriveAttributeValues[i] = v;
   344 
   345           if (array.Length == 5) {
   346             DriveThresholdValue t = new DriveThresholdValue();
   347             t.Identifier = v.Identifier;
   348             t.Threshold = Convert.ToByte(array[4], 10);
   349             thresholds.Add(t);
   350           }
   351         }
   352 
   353         DriveThresholdValues = thresholds.ToArray();
   354       }
   355 
   356       public DriveAttributeValue[] DriveAttributeValues { get; private set; }
   357 
   358       public DriveThresholdValue[] DriveThresholdValues { get; private set; }
   359 
   360       public string Name { get; private set; }
   361 
   362       public string FirmwareVersion { get; private set; }
   363     }
   364 
   365     public IntPtr InvalidHandle { get { return (IntPtr)(-1); } }
   366   }
   367 
   368 #endif
   369 
   370 }