-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add NVIDIA fan speed sensors based on NvAPI_GPU_ClientFanCoolersGet…
…Status.
- Loading branch information
Showing
5 changed files
with
197 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Exo.Sensors; | ||
|
||
namespace Exo.Devices.NVidia; | ||
|
||
public partial class NVidiaGpuDriver | ||
{ | ||
private sealed class FanCoolerSensor : GroupQueriedSensor, IPolledSensor<uint> | ||
{ | ||
private static Guid GetGuidForFan(uint fanId) | ||
=> fanId switch | ||
{ | ||
1 => Fan1SpeedSensorId, | ||
2 => Fan2SpeedSensorId, | ||
_ => throw new InvalidOperationException("Unsupported fan.") | ||
}; | ||
|
||
private uint _currentValue; | ||
private readonly byte _fanId; | ||
|
||
public Guid SensorId => GetGuidForFan(_fanId); | ||
|
||
public FanCoolerSensor(NvApi.PhysicalGpu gpu, NvApi.GpuFanStatus fanStatus) | ||
: base(gpu) | ||
{ | ||
_currentValue = fanStatus.SpeedInRotationsPerMinute; | ||
_fanId = (byte)fanStatus.FanId; | ||
} | ||
|
||
public uint? ScaleMinimumValue => null; | ||
public uint? ScaleMaximumValue => null; | ||
|
||
public SensorUnit Unit => SensorUnit.RotationsPerMinute; | ||
|
||
public ValueTask<uint> GetValueAsync(CancellationToken cancellationToken) | ||
=> ValueTask.FromResult(GroupedQueryMode == GroupedQueryMode.Enabled ? _currentValue : QueryValue()); | ||
|
||
public bool TryGetLastValue(out uint lastValue) | ||
{ | ||
lastValue = _currentValue; | ||
return true; | ||
} | ||
|
||
private uint QueryValue() => throw new NotSupportedException("Non-grouped queries are not supported for this sensor."); | ||
|
||
public void OnValueRead(uint value) => _currentValue = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters