Example #1
0
 public float ConvertValue(DriveAttributeValue value,
                           IReadOnlyArray <IParameter> parameters)
 {
     if (rawValueConversion == null)
     {
         return(value.AttrValue);
     }
     else
     {
         return(rawValueConversion(value.RawValue, value.AttrValue, parameters));
     }
 }
Example #2
0
            public Drive(string name, string firmware, int idBase, string value)
            {
                this.Name            = name;
                this.FirmwareVersion = firmware;

                string[] lines = value.Split(new[] { '\r', '\n' },
                                             StringSplitOptions.RemoveEmptyEntries);

                DriveAttributeValues = new DriveAttributeValue[lines.Length];
                List <DriveThresholdValue> thresholds = new List <DriveThresholdValue>();

                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();
                    }

                    DriveAttributeValue v = new DriveAttributeValue();
                    v.Identifier = Convert.ToByte(array[0], idBase);

                    v.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.AttrValue  = Convert.ToByte(array[3], 10);

                    DriveAttributeValues[i] = v;

                    if (array.Length == 5)
                    {
                        DriveThresholdValue t = new DriveThresholdValue();
                        t.Identifier = v.Identifier;
                        t.Threshold  = Convert.ToByte(array[4], 10);
                        thresholds.Add(t);
                    }
                }

                DriveThresholdValues = thresholds.ToArray();
            }