Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added smoothing to the hw monitor values #2082

Merged
merged 4 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Project-Aurora/Project-Aurora/Settings/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ public class Configuration : INotifyPropertyChanged
public float idle_frequency;

//Hardware Monitor
public int HardwareMonitorUpdateRate { get; set; } = 300;
public int HardwareMonitorUpdateRate { get; set; } = 500;
public bool HardwareMonitorUseAverageValues { get; set; } = true;

public VariableRegistry VarRegistry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@

<TextBlock HorizontalAlignment="Left" Margin="12,278,0,0" TextWrapping="Wrap" Text="Hardware sensors update rate:" VerticalAlignment="Top" ToolTip="Used for CPU and GPU usage, etc"/>
<xctk:IntegerUpDown HorizontalAlignment="Left" Height="24" Margin="178,278,0,0" VerticalAlignment="Top" Width="50" Value="{Binding HardwareMonitorUpdateRate}" Maximum="2000" Minimum="100" MouseWheelActiveOnFocus="True" />
<CheckBox Content="Use average hardware sensor values instead of real-time ones " ToolTip="This option should make sudden transitions in CPU / GPU usage smoother" HorizontalAlignment="Left" Margin="10,302,0,0" VerticalAlignment="Top" IsChecked="{Binding HardwareMonitorUseAverageValues}" />

</Grid>
</TabItem>
Expand Down
13 changes: 11 additions & 2 deletions Project-Aurora/Project-Aurora/Utils/HardwareMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static bool TryDump()
lines.Add("-----");
lines.Add(hw.Name);
lines.Add("Sensors:");
foreach (var sensor in hw.Sensors.OrderBy(s => s.SensorType))
foreach (var sensor in hw.Sensors.OrderBy(s => s.Identifier))
{
lines.Add($"Name: {sensor.Name}, Id: {sensor.Identifier}, Type: {sensor.SensorType}");
}
Expand Down Expand Up @@ -99,14 +99,17 @@ private static ISensor FindSensor(this IHardware hardware, SensorType type)

public abstract class HardwareUpdater
{
private const int MAX_QUEUE = 8;
protected IHardware hw;
protected bool inUse;

private readonly Timer _useTimer;
private readonly Timer _updateTimer;
private readonly Queue<float> _values;

protected HardwareUpdater()
{
_values = new Queue<float>(MAX_QUEUE);
_useTimer = new Timer(5000);
_useTimer.Elapsed += (a, b) =>
{
Expand All @@ -132,7 +135,13 @@ protected float GetValue(ISensor sensor)
_useTimer.Stop();
_useTimer.Start();

return sensor?.Value ?? 0;
if (_values.Count == MAX_QUEUE)
_values.Dequeue();
_values.Enqueue(sensor?.Value ?? 0);

return Global.Configuration.HardwareMonitorUseAverageValues ?
_values.Average() :
sensor?.Value ?? 0;
}
}

Expand Down