internal float ConvertValue(Kernel32.SMART_ATTRIBUTE value, IReadOnlyList <IParameter> parameters) { if (_rawValueConversion == null) { return(value.CurrentValue); } return(_rawValueConversion(value.RawValue, value.CurrentValue, parameters)); }
public Drive(string name, string firmware, int idBase, string value) { Name = name; FirmwareVersion = firmware; string[] lines = value.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); DriveAttributeValues = new Kernel32.SMART_ATTRIBUTE[lines.Length]; var thresholds = new List <Kernel32.SMART_THRESHOLD>(); for (int i = 0; i < lines.Length; i++) { string[] array = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length != 4 && array.Length != 5) { throw new Exception(); } var v = new Kernel32.SMART_ATTRIBUTE { Id = Convert.ToByte(array[0], idBase), RawValue = new byte[6] }; for (int j = 0; j < 6; j++) { v.RawValue[j] = Convert.ToByte(array[1].Substring(2 * j, 2), 16); } v.WorstValue = Convert.ToByte(array[2], 10); v.CurrentValue = Convert.ToByte(array[3], 10); DriveAttributeValues[i] = v; if (array.Length == 5) { var t = new Kernel32.SMART_THRESHOLD { Id = v.Id, Threshold = Convert.ToByte(array[4], 10) }; thresholds.Add(t); } } DriveThresholdValues = thresholds.ToArray(); }