Skip to content

Commit ff376d3

Browse files
authored
Add files via upload
1 parent d5ac183 commit ff376d3

File tree

1 file changed

+45
-4
lines changed

1 file changed

+45
-4
lines changed

DellFanManagementApp/ConsistencyModeHandlers/LegacyConsistencyModeHandler.cs

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public LegacyConsistencyModeHandler(Core core, State state, FanController fanCon
2424
/// <summary>
2525
/// Consistency mode logic; lock the fans if temperature and RPM thresholds are met.
2626
/// </summary>
27+
static int cpu_cool_loops = 0;
28+
const short CPU_COOL_DELAY = 5;
29+
2730
public override void RunConsistencyModeLogic()
2831
{
2932
if (_core.LowerTemperatureThreshold != null && _core.UpperTemperatureThreshold != null && _core.RpmThreshold != null)
@@ -38,8 +41,16 @@ public override void RunConsistencyModeLogic()
3841
{
3942
if (_state.Fan1Rpm == 0 && (!_state.Fan2Present || _state.Fan2Rpm == 0))
4043
{
41-
thresholdsMet = false;
42-
_state.ConsistencyModeStatus = string.Format("风扇未启动,等待EC激活{0}风扇", _state.Fan2Present ? "全部": "");// Waiting for embedded controller to activate the fan{0}", _state.Fan2Present ? "s" : string.Empty);
44+
if (!_core.EnableStopFan ||
45+
LegacyConsistencyModeHandler.cpu_cool_loops <= 0)
46+
{
47+
thresholdsMet = false;
48+
_state.ConsistencyModeStatus = string.Format("风扇未启动,等待EC激活{0}风扇", _state.Fan2Present ? "全部" : "");// Waiting for embedded controller to activate the fan{0}", _state.Fan2Present ? "s" : string.Empty);
49+
}
50+
else
51+
{
52+
_state.ConsistencyModeStatus = string.Format("风扇未启动,自动调节等待中...");
53+
}
4354
}
4455
else
4556
{
@@ -121,7 +132,9 @@ public override void RunConsistencyModeLogic()
121132
_fanController.SetFanLevel(FanLevel.Medium, FanIndex.AllFans);
122133
_state.ConsistencyModeStatus = "温度在设定范围内,但风扇速度超过设定限值,尝试保持中速";
123134
}
124-
else if (is_cpu_cool)
135+
else if (is_cpu_cool &&
136+
LegacyConsistencyModeHandler.cpu_cool_loops >= _core.CpuCoolDelay &&
137+
_core.EnableStopFan)
125138
{
126139
_fanController.SetFanLevel(FanLevel.Off, FanIndex.AllFans);
127140
_state.ConsistencyModeStatus = "温度低于下限,但风扇速度超过设定限值,尝试关闭风扇";
@@ -132,11 +145,14 @@ public override void RunConsistencyModeLogic()
132145
}
133146

134147
//if (is_cpu_cool) thresholdsMet = false;
148+
if (is_cpu_warm || !thresholdsMet) LegacyConsistencyModeHandler.cpu_cool_loops = 0;
135149

136150
if (thresholdsMet)
137151
{
138152
if (!is_cpu_cool)
139153
{
154+
LegacyConsistencyModeHandler.cpu_cool_loops -= 1;
155+
140156
if (_state.EcFanControlEnabled)
141157
{
142158
_state.EcFanControlEnabled = false;
@@ -153,11 +169,36 @@ public override void RunConsistencyModeLogic()
153169
}
154170
else
155171
{
156-
if (!_state.EcFanControlEnabled)
172+
if (LegacyConsistencyModeHandler.cpu_cool_loops < 0)
173+
LegacyConsistencyModeHandler.cpu_cool_loops = 0;
174+
LegacyConsistencyModeHandler.cpu_cool_loops += 1;
175+
176+
if (!_state.EcFanControlEnabled &&
177+
(!_core.EnableStopFan || LegacyConsistencyModeHandler.cpu_cool_loops < _core.CpuCoolDelay))
157178
{
158179
_state.EcFanControlEnabled = true;
159180
_fanController.EnableAutomaticFanControl();
160181
_state.ConsistencyModeStatus = "温度低于下限,等待减小风速";
182+
_core.TrayIconColor = TrayIconColor.Blue;
183+
}
184+
else if (LegacyConsistencyModeHandler.cpu_cool_loops >= _core.CpuCoolDelay) // stop fan after cpu was cooling for 15 secs
185+
{
186+
// EC did control the fan speed and cpu has been kept on cooling for a longer, then we'll try to shutdown the fan.
187+
if (_core.EnableStopFan && (_state.Fan1Rpm > 0 || (_state.Fan2Present && _state.Fan2Rpm > 0)))
188+
{
189+
_state.EcFanControlEnabled = false;
190+
_fanController.DisableAutomaticFanControl();
191+
_fanController.SetFanLevel(FanLevel.Off, FanIndex.AllFans);
192+
_state.ConsistencyModeStatus = "温度低于下限,尝试关闭风扇";
193+
_core.TrayIconColor = TrayIconColor.Blue;
194+
}
195+
}
196+
//else
197+
{
198+
if (_state.Fan1Rpm > 0 || (_state.Fan2Present && _state.Fan2Rpm > 0))
199+
_core.TrayIconColor = TrayIconColor.Blue;
200+
else
201+
_core.TrayIconColor = TrayIconColor.Gray;
161202
}
162203
}
163204
}

0 commit comments

Comments
 (0)