forked from Rem0o/FanControl.HWInfo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HWInfoPlugin.cs
38 lines (31 loc) · 1.17 KB
/
HWInfoPlugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using FanControl.Plugins;
using System.Linq;
namespace FanControl.HWInfo
{
public class HWInfoPlugin : IPlugin
{
private HWInfo _hWInfo;
public string Name => "HWInfo";
public void Close()
{
_hWInfo?.Dispose();
_hWInfo = null;
}
public void Initialize() => _hWInfo = new HWInfo();
public void Load(IPluginSensorsContainer _container)
{
foreach (var source in _hWInfo?.SensorsSource)
foreach (var sensor in source.Sensors)
AddSensorToContainer(_container, source, sensor);
}
private static void AddSensorToContainer(IPluginSensorsContainer _container, HWInfo.HWInfoSensorSource source, HWInfo.HWInfoSensor sensor)
{
var sensorElement = sensor.GetUpdatedElement();
var pluginSensor = new HWInfoPluginSensor(source.Sensor.szSensorNameUser, sensor.GetUpdatedElement);
if (sensorElement.szUnit == "RPM")
_container.FanSensors.Add(pluginSensor);
else if (sensorElement.szUnit == "°C")
_container.TempSensors.Add(pluginSensor);
}
}
}