-
Notifications
You must be signed in to change notification settings - Fork 8
/
DellFanManagementControlSensor.cs
53 lines (42 loc) · 1.48 KB
/
DellFanManagementControlSensor.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using DellFanManagement.DellSmbiozBzhLib;
using FanControl.Plugins;
namespace FanControl.DellPlugin
{
public class DellFanManagementControlSensor: IPluginControlSensor
{
private readonly BzhFanIndex _fanIndex;
private bool _isSet = false;
private float? _val;
public DellFanManagementControlSensor(BzhFanIndex fanIndex) => _fanIndex = fanIndex;
public float? Value { get; private set; }
public string Name => $"Dell Control {(int)_fanIndex + 1}";
public string Origin => $"DellSmbiosBzh";
public string Id => "Control_" + _fanIndex.ToString();
public void Reset()
{
DellSmbiosBzh.EnableAutomaticFanControl(_fanIndex == BzhFanIndex.Fan1 ? false : true);
_isSet = false;
}
public void Set(float val)
{
if (!_isSet)
{
DellSmbiosBzh.DisableAutomaticFanControl(_fanIndex == BzhFanIndex.Fan1 ? false : true);
_isSet = true;
}
_val = val;
BzhFanLevel fanLevel = GetFanLevel(val);
DellSmbiosBzh.SetFanLevel(_fanIndex, fanLevel);
}
public void Update() => Value = _val;
private BzhFanLevel GetFanLevel(float val)
{
if (val < 33.33)
return BzhFanLevel.Level0;
else if (val < 66.66)
return BzhFanLevel.Level1;
else
return BzhFanLevel.Level2;
}
}
}