1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Hardware/HDD/DebugSmart.cs Sat Dec 31 17:31:04 2011 +0000
1.3 @@ -0,0 +1,287 @@
1.4 +/*
1.5 +
1.6 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
1.7 +
1.8 + The contents of this file are subject to the Mozilla Public License Version
1.9 + 1.1 (the "License"); you may not use this file except in compliance with
1.10 + the License. You may obtain a copy of the License at
1.11 +
1.12 + http://www.mozilla.org/MPL/
1.13 +
1.14 + Software distributed under the License is distributed on an "AS IS" basis,
1.15 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1.16 + for the specific language governing rights and limitations under the License.
1.17 +
1.18 + The Original Code is the Open Hardware Monitor code.
1.19 +
1.20 + The Initial Developer of the Original Code is
1.21 + Michael Möller <m.moeller@gmx.ch>.
1.22 + Portions created by the Initial Developer are Copyright (C) 2011
1.23 + the Initial Developer. All Rights Reserved.
1.24 +
1.25 + Contributor(s):
1.26 +
1.27 + Alternatively, the contents of this file may be used under the terms of
1.28 + either the GNU General Public License Version 2 or later (the "GPL"), or
1.29 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1.30 + in which case the provisions of the GPL or the LGPL are applicable instead
1.31 + of those above. If you wish to allow use of your version of this file only
1.32 + under the terms of either the GPL or the LGPL, and not to allow others to
1.33 + use your version of this file under the terms of the MPL, indicate your
1.34 + decision by deleting the provisions above and replace them with the notice
1.35 + and other provisions required by the GPL or the LGPL. If you do not delete
1.36 + the provisions above, a recipient may use your version of this file under
1.37 + the terms of any one of the MPL, the GPL or the LGPL.
1.38 +
1.39 +*/
1.40 +
1.41 +using System;
1.42 +using System.Collections.Generic;
1.43 +using System.Text;
1.44 +
1.45 +namespace OpenHardwareMonitor.Hardware.HDD {
1.46 +
1.47 +#if DEBUG
1.48 +
1.49 + internal class DebugSmart : ISmart {
1.50 +
1.51 + private Drive[] drives = {
1.52 + new Drive("KINGSTON SNV425S264GB", 16,
1.53 + @" 01 000000000000 100 100
1.54 + 02 000000000000 100 100
1.55 + 03 000000000000 100 100
1.56 + 05 000000000000 100 100
1.57 + 07 000000000000 100 100
1.58 + 08 000000000000 100 100
1.59 + 09 821E00000000 100 100
1.60 + 0A 000000000000 100 100
1.61 + 0C 950200000000 100 100
1.62 + A8 000000000000 100 100
1.63 + AF 000000000000 100 100
1.64 + C0 000000000000 100 100
1.65 + C2 290014002B00 100 41
1.66 + C5 000000000000 100 100
1.67 + F0 000000000000 100 100
1.68 + AA 07007B000000 100 100
1.69 + AD 0E1E71304919 100 100"),
1.70 +
1.71 + new Drive("PLEXTOR PX-128M2S", 16,
1.72 + @" 01 000000000000 100 100 0
1.73 + 03 000000000000 100 100 0
1.74 + 04 000000000000 100 100 0
1.75 + 05 000000000000 100 100 0
1.76 + 09 250100000000 100 100 0
1.77 + 0A 000000000000 100 100 0
1.78 + 0C D10000000000 100 100 0
1.79 + B2 000000000000 100 100 0
1.80 + BB 000000000000 100 100 0
1.81 + BE 000000000000 100 100 0
1.82 + C0 000000000000 100 100 0
1.83 + C1 000000000000 100 100 0
1.84 + C2 000000000000 100 100 0
1.85 + C3 000000000000 100 100 0
1.86 + C5 000000000000 100 100 0
1.87 + C6 000000000000 100 100 0
1.88 + C7 000000000000 100 100 0"),
1.89 +
1.90 + new Drive("OCZ-VERTEX2", 16,
1.91 + @" 01 DADAD5000000 100 106 50
1.92 + 05 000000000000 100 100 3
1.93 + 09 DF0900004A2F 100 100 0
1.94 + 0C FC0100000000 100 100 0
1.95 + AB 000000000000 0 0 0
1.96 + AC 000000000000 0 0 0
1.97 + AE 1F0000000000 0 0 0
1.98 + B1 000000000000 0 0 0
1.99 + B5 000000000000 0 0 0
1.100 + B6 000000000000 0 0 0
1.101 + BB 000000000000 100 100 0
1.102 + C2 010081007F00 129 1 0
1.103 + C3 DADAD5000000 100 106 0
1.104 + C4 000000000000 100 100 0
1.105 + E7 000000000000 100 100 10
1.106 + E9 800400000000 0 0 0
1.107 + EA 000600000000 0 0 0
1.108 + F1 000600000000 0 0 0
1.109 + F2 801200000000 0 0 0"),
1.110 +
1.111 + new Drive("WDC WD5000AADS-00S9B0", 10,
1.112 + @" 1 000000000000 200 200
1.113 + 3 820D00000000 149 150
1.114 + 4 610800000000 98 98
1.115 + 5 000000000000 200 200
1.116 + 7 000000000000 253 100
1.117 + 9 0F1F00000000 90 90
1.118 + 10 000000000000 100 100
1.119 + 11 000000000000 100 100
1.120 + 12 880200000000 100 100
1.121 + 192 6B0000000000 200 200
1.122 + 193 E9CB03000000 118 118
1.123 + 194 280000000000 94 103
1.124 + 196 000000000000 200 200
1.125 + 197 000000000000 200 200
1.126 + 198 000000000000 200 200
1.127 + 199 000000000000 200 200
1.128 + 200 000000000000 200 200
1.129 + 130 7B0300010002 1 41
1.130 + 5 000000000000 0 0
1.131 + 1 000000000000 0 0"),
1.132 +
1.133 + new Drive("INTEL SSDSA2M080G2GC", 10,
1.134 + @" 3 000000000000 100 100
1.135 + 4 000000000000 100 100
1.136 + 5 010000000000 100 100
1.137 + 9 B10B00000000 100 100
1.138 + 12 DD0300000000 100 100
1.139 + 192 480000000000 100 100
1.140 + 225 89DB00000000 200 200
1.141 + 226 3D1B00000000 100 100
1.142 + 227 030000000000 100 100
1.143 + 228 7F85703C0000 100 100
1.144 + 232 000000000000 99 99
1.145 + 233 000000000000 98 98
1.146 + 184 000000000000 100 100
1.147 + 1 000000000000 0 0"),
1.148 +
1.149 + new Drive("OCZ-VERTEX", 10,
1.150 + @" 1 000000000000 0 8
1.151 + 9 000000000000 30 99
1.152 + 12 000000000000 0 15
1.153 + 184 000000000000 0 7
1.154 + 195 000000000000 0 0
1.155 + 196 000000000000 0 2
1.156 + 197 000000000000 0 0
1.157 + 198 B9ED00000000 214 176
1.158 + 199 352701000000 143 185
1.159 + 200 B10500000000 105 55
1.160 + 201 F40A00000000 238 194
1.161 + 202 020000000000 137 35
1.162 + 203 020000000000 125 63
1.163 + 204 000000000000 0 0
1.164 + 205 000000000000 19 136
1.165 + 206 000000000000 22 54
1.166 + 207 010000000000 113 226
1.167 + 208 000000000000 49 232
1.168 + 209 000000000000 0 98
1.169 + 211 000000000000 0 0
1.170 + 212 000000000000 0 0
1.171 + 213 000000000000 0 0"),
1.172 +
1.173 + new Drive("INTEL SSDSA2CW120G3", 16,
1.174 + @"03 000000000000 100 100 0
1.175 + 04 000000000000 100 100 0
1.176 + 05 000000000000 100 100 0
1.177 + 09 830200000000 100 100 0
1.178 + 0C 900100000000 100 100 0
1.179 + AA 000000000000 100 100 0
1.180 + AB 000000000000 100 100 0
1.181 + AC 000000000000 100 100 0
1.182 + B8 000000000000 100 100 0
1.183 + BB 000000000000 100 100 0
1.184 + C0 040000000000 100 100 0
1.185 + E1 FF4300000000 100 100 0
1.186 + E2 E57D14000000 100 100 0
1.187 + E3 000000000000 100 100 0
1.188 + E4 E39600000000 100 100 0
1.189 + E8 000000000000 100 100 0
1.190 + E9 000000000000 100 100 0
1.191 + F1 FF4300000000 100 100 0
1.192 + F2 264F00000000 100 100 0")
1.193 + };
1.194 +
1.195 + public IntPtr OpenDrive(int driveNumber) {
1.196 + if (driveNumber < drives.Length)
1.197 + return (IntPtr)driveNumber;
1.198 + else
1.199 + return InvalidHandle;
1.200 + }
1.201 +
1.202 + public bool EnableSmart(IntPtr handle, int driveNumber) {
1.203 + if (handle != (IntPtr)driveNumber)
1.204 + throw new ArgumentOutOfRangeException();
1.205 +
1.206 + return true;
1.207 + }
1.208 +
1.209 + public DriveAttributeValue[] ReadSmartData(IntPtr handle, int driveNumber) {
1.210 + if (handle != (IntPtr)driveNumber)
1.211 + throw new ArgumentOutOfRangeException();
1.212 +
1.213 + return drives[driveNumber].DriveAttributeValues;
1.214 + }
1.215 +
1.216 + public DriveThresholdValue[] ReadSmartThresholds(IntPtr handle,
1.217 + int driveNumber)
1.218 + {
1.219 + if (handle != (IntPtr)driveNumber)
1.220 + throw new ArgumentOutOfRangeException();
1.221 +
1.222 + return drives[driveNumber].DriveThresholdValues;
1.223 + }
1.224 +
1.225 + public string ReadName(IntPtr handle, int driveNumber) {
1.226 + if (handle != (IntPtr)driveNumber)
1.227 + throw new ArgumentOutOfRangeException();
1.228 +
1.229 + return drives[driveNumber].Name;
1.230 + }
1.231 +
1.232 + public void CloseHandle(IntPtr handle) { }
1.233 +
1.234 +
1.235 + private class Drive {
1.236 +
1.237 + public Drive(string name, int idBase, string value) {
1.238 + this.Name = name;
1.239 +
1.240 + string[] lines = value.Split(new[] { '\r', '\n' },
1.241 + StringSplitOptions.RemoveEmptyEntries);
1.242 +
1.243 + DriveAttributeValues = new DriveAttributeValue[lines.Length];
1.244 + List<DriveThresholdValue> thresholds = new List<DriveThresholdValue>();
1.245 +
1.246 + for (int i = 0; i < lines.Length; i++) {
1.247 +
1.248 + string[] array = lines[i].Split(new[] { ' ' },
1.249 + StringSplitOptions.RemoveEmptyEntries);
1.250 +
1.251 + if (array.Length != 4 && array.Length != 5)
1.252 + throw new Exception();
1.253 +
1.254 + DriveAttributeValue v = new DriveAttributeValue();
1.255 + v.Identifier = Convert.ToByte(array[0], idBase);
1.256 +
1.257 + v.RawValue = new byte[6];
1.258 + for (int j = 0; j < 6; j++) {
1.259 + v.RawValue[j] = Convert.ToByte(array[1].Substring(2 * j, 2), 16);
1.260 + }
1.261 +
1.262 + v.WorstValue = Convert.ToByte(array[2], 10);
1.263 + v.AttrValue = Convert.ToByte(array[3], 10);
1.264 +
1.265 + DriveAttributeValues[i] = v;
1.266 +
1.267 + if (array.Length == 5) {
1.268 + DriveThresholdValue t = new DriveThresholdValue();
1.269 + t.Identifier = v.Identifier;
1.270 + t.Threshold = Convert.ToByte(array[4], 10);
1.271 + thresholds.Add(t);
1.272 + }
1.273 + }
1.274 +
1.275 + DriveThresholdValues = thresholds.ToArray();
1.276 + }
1.277 +
1.278 + public DriveAttributeValue[] DriveAttributeValues { get; private set; }
1.279 +
1.280 + public DriveThresholdValue[] DriveThresholdValues { get; private set; }
1.281 +
1.282 + public string Name { get; private set; }
1.283 + }
1.284 +
1.285 + public IntPtr InvalidHandle { get { return (IntPtr)(-1); } }
1.286 + }
1.287 +
1.288 +#endif
1.289 +
1.290 +}