public HDDGroup(ISettings settings) { int p = (int)Environment.OSVersion.Platform; if (p == 4 || p == 128) { return; } for (int drive = 0; drive < MAX_DRIVES; drive++) { IntPtr handle = SMART.OpenPhysicalDrive(drive); if (handle == SMART.INVALID_HANDLE_VALUE) { continue; } if (!SMART.EnableSmart(handle, drive)) { SMART.CloseHandle(handle); continue; } string name = SMART.ReadName(handle, drive); if (name == null) { SMART.CloseHandle(handle); continue; } List <SMART.DriveAttribute> attributes = new List <SMART.DriveAttribute>(SMART.ReadSmart(handle, drive)); if (!(attributes.Count > 0)) { SMART.CloseHandle(handle); continue; } SMART.SSDLifeID ssdLifeID = GetSSDLifeID(attributes); if (ssdLifeID == SMART.SSDLifeID.None) { SMART.AttributeID temperatureID = GetTemperatureIndex(attributes); if (temperatureID != 0x00) { hardware.Add(new HDD(name, handle, drive, temperatureID, settings)); continue; } } else { hardware.Add(new HDD(name, handle, drive, ssdLifeID, settings)); continue; } SMART.CloseHandle(handle); } }
public HDD(string name, IntPtr handle, int drive, SMART.AttributeID temperatureID, ISettings settings) { this.name = name; this.handle = handle; this.drive = drive; this.count = 0; this.temperatureID = temperatureID; this.temperatureSensor = new Sensor("HDD", 0, SensorType.Temperature, this, settings); Update(); }
private SMART.AttributeID GetTemperatureIndex( List <SMART.DriveAttribute> attributes) { SMART.AttributeID[] validIds = new[] { SMART.AttributeID.Temperature, SMART.AttributeID.DriveTemperature, SMART.AttributeID.AirflowTemperature }; foreach (SMART.AttributeID validId in validIds) { SMART.AttributeID id = validId; if (attributes.Exists(attr => attr.ID == id)) { return(validId); } } return(0x00); }
private SMART.AttributeID GetTemperatureIndex( SMART.DriveAttribute[] attributes) { SMART.AttributeID[] validIds = new[] { SMART.CommonAttributes.Temperature, SMART.CommonAttributes.DriveTemperature, SMART.CommonAttributes.AirflowTemperature }; foreach (SMART.AttributeID validId in validIds) { SMART.AttributeID id = validId; if (Array.Exists(attributes, attr => attr.ID == id)) { return(validId); } } return(SMART.AttributeID.None); }
public HDD(string name, IntPtr handle, int drive, SMART.AttributeID temperatureID, SMART.AttributeID lifeID, ISettings settings) : base(name, new Identifier("hdd", drive.ToString(CultureInfo.InvariantCulture)), settings) { this.handle = handle; this.drive = drive; this.count = 0; if (temperatureID != SMART.AttributeID.None) { this.temperatureID = temperatureID; this.temperatureSensor = new Sensor("HDD", 0, SensorType.Temperature, this, settings); } if (lifeID != SMART.AttributeID.None) { this.lifeID = lifeID; this.lifeSensor = new Sensor("Remaining life", 0, SensorType.Level, this, settings); } Update(); }
public HDD(string name, IntPtr handle, int drive, SMART.AttributeID temperatureID, SMART.AttributeID lifeID, ISettings settings) { this.name = name; this.handle = handle; this.drive = drive; this.count = 0; if (temperatureID != SMART.AttributeID.None) { this.temperatureID = temperatureID; this.temperatureSensor = new Sensor("HDD", 0, SensorType.Temperature, this, settings); } if (lifeID != SMART.AttributeID.None) { this.lifeID = lifeID; this.lifeSensor = new Sensor("Remaining life", 0, SensorType.Level, this, settings); } Update(); }