moel@324: /* moel@324: moel@324: Version: MPL 1.1/GPL 2.0/LGPL 2.1 moel@324: moel@324: The contents of this file are subject to the Mozilla Public License Version moel@324: 1.1 (the "License"); you may not use this file except in compliance with moel@324: the License. You may obtain a copy of the License at moel@324: moel@324: http://www.mozilla.org/MPL/ moel@324: moel@324: Software distributed under the License is distributed on an "AS IS" basis, moel@324: WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License moel@324: for the specific language governing rights and limitations under the License. moel@324: moel@324: The Original Code is the Open Hardware Monitor code. moel@324: moel@324: The Initial Developer of the Original Code is moel@324: Michael Möller . moel@324: Portions created by the Initial Developer are Copyright (C) 2011 moel@324: the Initial Developer. All Rights Reserved. moel@324: moel@324: Contributor(s): moel@324: moel@324: Alternatively, the contents of this file may be used under the terms of moel@324: either the GNU General Public License Version 2 or later (the "GPL"), or moel@324: the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), moel@324: in which case the provisions of the GPL or the LGPL are applicable instead moel@324: of those above. If you wish to allow use of your version of this file only moel@324: under the terms of either the GPL or the LGPL, and not to allow others to moel@324: use your version of this file under the terms of the MPL, indicate your moel@324: decision by deleting the provisions above and replace them with the notice moel@324: and other provisions required by the GPL or the LGPL. If you do not delete moel@324: the provisions above, a recipient may use your version of this file under moel@324: the terms of any one of the MPL, the GPL or the LGPL. moel@324: moel@324: */ moel@324: moel@324: using System; moel@324: using System.Collections.Generic; moel@324: using System.Text; moel@324: moel@324: namespace OpenHardwareMonitor.Hardware.HDD { moel@324: moel@324: #if DEBUG moel@324: moel@324: internal class DebugSmart : ISmart { moel@324: moel@324: private Drive[] drives = { moel@324: new Drive("KINGSTON SNV425S264GB", 16, moel@324: @" 01 000000000000 100 100 moel@324: 02 000000000000 100 100 moel@324: 03 000000000000 100 100 moel@324: 05 000000000000 100 100 moel@324: 07 000000000000 100 100 moel@324: 08 000000000000 100 100 moel@324: 09 821E00000000 100 100 moel@324: 0A 000000000000 100 100 moel@324: 0C 950200000000 100 100 moel@324: A8 000000000000 100 100 moel@324: AF 000000000000 100 100 moel@324: C0 000000000000 100 100 moel@324: C2 290014002B00 100 41 moel@324: C5 000000000000 100 100 moel@324: F0 000000000000 100 100 moel@324: AA 07007B000000 100 100 moel@324: AD 0E1E71304919 100 100"), moel@324: moel@324: new Drive("PLEXTOR PX-128M2S", 16, moel@324: @" 01 000000000000 100 100 0 moel@324: 03 000000000000 100 100 0 moel@324: 04 000000000000 100 100 0 moel@324: 05 000000000000 100 100 0 moel@324: 09 250100000000 100 100 0 moel@324: 0A 000000000000 100 100 0 moel@324: 0C D10000000000 100 100 0 moel@324: B2 000000000000 100 100 0 moel@324: BB 000000000000 100 100 0 moel@324: BE 000000000000 100 100 0 moel@324: C0 000000000000 100 100 0 moel@324: C1 000000000000 100 100 0 moel@324: C2 000000000000 100 100 0 moel@324: C3 000000000000 100 100 0 moel@324: C5 000000000000 100 100 0 moel@324: C6 000000000000 100 100 0 moel@324: C7 000000000000 100 100 0"), moel@324: moel@324: new Drive("OCZ-VERTEX2", 16, moel@324: @" 01 DADAD5000000 100 106 50 moel@324: 05 000000000000 100 100 3 moel@324: 09 DF0900004A2F 100 100 0 moel@324: 0C FC0100000000 100 100 0 moel@324: AB 000000000000 0 0 0 moel@324: AC 000000000000 0 0 0 moel@324: AE 1F0000000000 0 0 0 moel@324: B1 000000000000 0 0 0 moel@324: B5 000000000000 0 0 0 moel@324: B6 000000000000 0 0 0 moel@324: BB 000000000000 100 100 0 moel@324: C2 010081007F00 129 1 0 moel@324: C3 DADAD5000000 100 106 0 moel@324: C4 000000000000 100 100 0 moel@324: E7 000000000000 100 100 10 moel@324: E9 800400000000 0 0 0 moel@324: EA 000600000000 0 0 0 moel@324: F1 000600000000 0 0 0 moel@324: F2 801200000000 0 0 0"), moel@324: moel@324: new Drive("WDC WD5000AADS-00S9B0", 10, moel@324: @" 1 000000000000 200 200 moel@324: 3 820D00000000 149 150 moel@324: 4 610800000000 98 98 moel@324: 5 000000000000 200 200 moel@324: 7 000000000000 253 100 moel@324: 9 0F1F00000000 90 90 moel@324: 10 000000000000 100 100 moel@324: 11 000000000000 100 100 moel@324: 12 880200000000 100 100 moel@324: 192 6B0000000000 200 200 moel@324: 193 E9CB03000000 118 118 moel@324: 194 280000000000 94 103 moel@324: 196 000000000000 200 200 moel@324: 197 000000000000 200 200 moel@324: 198 000000000000 200 200 moel@324: 199 000000000000 200 200 moel@324: 200 000000000000 200 200 moel@324: 130 7B0300010002 1 41 moel@324: 5 000000000000 0 0 moel@324: 1 000000000000 0 0"), moel@324: moel@324: new Drive("INTEL SSDSA2M080G2GC", 10, moel@324: @" 3 000000000000 100 100 moel@324: 4 000000000000 100 100 moel@324: 5 010000000000 100 100 moel@324: 9 B10B00000000 100 100 moel@324: 12 DD0300000000 100 100 moel@324: 192 480000000000 100 100 moel@324: 225 89DB00000000 200 200 moel@324: 226 3D1B00000000 100 100 moel@324: 227 030000000000 100 100 moel@324: 228 7F85703C0000 100 100 moel@324: 232 000000000000 99 99 moel@324: 233 000000000000 98 98 moel@324: 184 000000000000 100 100 moel@324: 1 000000000000 0 0"), moel@324: moel@324: new Drive("OCZ-VERTEX", 10, moel@324: @" 1 000000000000 0 8 moel@324: 9 000000000000 30 99 moel@324: 12 000000000000 0 15 moel@324: 184 000000000000 0 7 moel@324: 195 000000000000 0 0 moel@324: 196 000000000000 0 2 moel@324: 197 000000000000 0 0 moel@324: 198 B9ED00000000 214 176 moel@324: 199 352701000000 143 185 moel@324: 200 B10500000000 105 55 moel@324: 201 F40A00000000 238 194 moel@324: 202 020000000000 137 35 moel@324: 203 020000000000 125 63 moel@324: 204 000000000000 0 0 moel@324: 205 000000000000 19 136 moel@324: 206 000000000000 22 54 moel@324: 207 010000000000 113 226 moel@324: 208 000000000000 49 232 moel@324: 209 000000000000 0 98 moel@324: 211 000000000000 0 0 moel@324: 212 000000000000 0 0 moel@324: 213 000000000000 0 0"), moel@324: moel@324: new Drive("INTEL SSDSA2CW120G3", 16, moel@324: @"03 000000000000 100 100 0 moel@324: 04 000000000000 100 100 0 moel@324: 05 000000000000 100 100 0 moel@324: 09 830200000000 100 100 0 moel@324: 0C 900100000000 100 100 0 moel@324: AA 000000000000 100 100 0 moel@324: AB 000000000000 100 100 0 moel@324: AC 000000000000 100 100 0 moel@324: B8 000000000000 100 100 0 moel@324: BB 000000000000 100 100 0 moel@324: C0 040000000000 100 100 0 moel@324: E1 FF4300000000 100 100 0 moel@324: E2 E57D14000000 100 100 0 moel@324: E3 000000000000 100 100 0 moel@324: E4 E39600000000 100 100 0 moel@324: E8 000000000000 100 100 0 moel@324: E9 000000000000 100 100 0 moel@324: F1 FF4300000000 100 100 0 moel@324: F2 264F00000000 100 100 0") moel@324: }; moel@324: moel@324: public IntPtr OpenDrive(int driveNumber) { moel@324: if (driveNumber < drives.Length) moel@324: return (IntPtr)driveNumber; moel@324: else moel@324: return InvalidHandle; moel@324: } moel@324: moel@324: public bool EnableSmart(IntPtr handle, int driveNumber) { moel@324: if (handle != (IntPtr)driveNumber) moel@324: throw new ArgumentOutOfRangeException(); moel@324: moel@324: return true; moel@324: } moel@324: moel@324: public DriveAttributeValue[] ReadSmartData(IntPtr handle, int driveNumber) { moel@324: if (handle != (IntPtr)driveNumber) moel@324: throw new ArgumentOutOfRangeException(); moel@324: moel@324: return drives[driveNumber].DriveAttributeValues; moel@324: } moel@324: moel@324: public DriveThresholdValue[] ReadSmartThresholds(IntPtr handle, moel@324: int driveNumber) moel@324: { moel@324: if (handle != (IntPtr)driveNumber) moel@324: throw new ArgumentOutOfRangeException(); moel@324: moel@324: return drives[driveNumber].DriveThresholdValues; moel@324: } moel@324: moel@324: public string ReadName(IntPtr handle, int driveNumber) { moel@324: if (handle != (IntPtr)driveNumber) moel@324: throw new ArgumentOutOfRangeException(); moel@324: moel@324: return drives[driveNumber].Name; moel@324: } moel@324: moel@324: public void CloseHandle(IntPtr handle) { } moel@324: moel@324: moel@324: private class Drive { moel@324: moel@324: public Drive(string name, int idBase, string value) { moel@324: this.Name = name; moel@324: moel@324: string[] lines = value.Split(new[] { '\r', '\n' }, moel@324: StringSplitOptions.RemoveEmptyEntries); moel@324: moel@324: DriveAttributeValues = new DriveAttributeValue[lines.Length]; moel@324: List thresholds = new List(); moel@324: moel@324: for (int i = 0; i < lines.Length; i++) { moel@324: moel@324: string[] array = lines[i].Split(new[] { ' ' }, moel@324: StringSplitOptions.RemoveEmptyEntries); moel@324: moel@324: if (array.Length != 4 && array.Length != 5) moel@324: throw new Exception(); moel@324: moel@324: DriveAttributeValue v = new DriveAttributeValue(); moel@324: v.Identifier = Convert.ToByte(array[0], idBase); moel@324: moel@324: v.RawValue = new byte[6]; moel@324: for (int j = 0; j < 6; j++) { moel@324: v.RawValue[j] = Convert.ToByte(array[1].Substring(2 * j, 2), 16); moel@324: } moel@324: moel@324: v.WorstValue = Convert.ToByte(array[2], 10); moel@324: v.AttrValue = Convert.ToByte(array[3], 10); moel@324: moel@324: DriveAttributeValues[i] = v; moel@324: moel@324: if (array.Length == 5) { moel@324: DriveThresholdValue t = new DriveThresholdValue(); moel@324: t.Identifier = v.Identifier; moel@324: t.Threshold = Convert.ToByte(array[4], 10); moel@324: thresholds.Add(t); moel@324: } moel@324: } moel@324: moel@324: DriveThresholdValues = thresholds.ToArray(); moel@324: } moel@324: moel@324: public DriveAttributeValue[] DriveAttributeValues { get; private set; } moel@324: moel@324: public DriveThresholdValue[] DriveThresholdValues { get; private set; } moel@324: moel@324: public string Name { get; private set; } moel@324: } moel@324: moel@324: public IntPtr InvalidHandle { get { return (IntPtr)(-1); } } moel@324: } moel@324: moel@324: #endif moel@324: moel@324: }