Skip to content

Commit 75ac915

Browse files
author
fuzzy01
committed
Add DisableLHMReleaseOnSuspend configuration option
1 parent 11b1230 commit 75ac915

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CoolingControl/Config.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class Config
1010
public string LogLevel { get; set; } = "Information";
1111
public bool EnableCSVLogging { get; set; } = false;
1212
public LHMConfigParameters LHMConfig { get; set; } = new LHMConfigParameters();
13+
public bool DisableLHMReleaseOnSuspend { get; set; } = false;
1314
public List<ControlConfig> Controls { get; set; } = [];
1415
public List<SensorConfig> Sensors { get; set; } = [];
1516
}

CoolingControl/Platform/LHM/LHMAdapter.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ namespace CoolingControl.Platform.LHM;
1414
public class LHMAdapter : IPlatformAdapter, IDisposable
1515
{
1616
private readonly Computer _computer;
17+
private readonly ConfigHelper _config;
1718

1819
public LHMAdapter(ConfigHelper config)
1920
{
21+
_config = config;
2022
_computer = new Computer
2123
{
2224
IsCpuEnabled = config.Config.LHMConfig.CpuEnabled,
@@ -34,14 +36,21 @@ public LHMAdapter(ConfigHelper config)
3436

3537
public void Suspend()
3638
{
37-
Log.Debug("Suspending hardware monitoring");
38-
_computer.Close();
39+
if (!_config.Config.DisableLHMReleaseOnSuspend)
40+
{
41+
Log.Debug("Suspending hardware monitoring");
42+
_computer.Close();
43+
}
3944
}
4045

4146
public void Resume()
4247
{
43-
Log.Debug("Resuming hardware monitoring");
44-
_computer.Open();
48+
if (!_config.Config.DisableLHMReleaseOnSuspend)
49+
{
50+
51+
Log.Debug("Resuming hardware monitoring");
52+
_computer.Open();
53+
}
4554
}
4655

4756
public Dictionary<string, float?> GetSensorValues(HashSet<string> sensorIdentifiers)

0 commit comments

Comments
 (0)