Implemented storage update interval at the UI side (#1706)

* Minor refactoring for #1699

* Implemented storage update interval for the UI

* Revert "Implemented storage update interval for the UI"

This reverts commit 977ff2f5518d420e35cadad17054f4e69c260df1.

* Revert "Minor refactoring for #1699"

This reverts commit 923f6d6f636a2a10ff44b8c23f84e8985ccbf667.

* Made update interval configurable for storage devices

* Changed label text m to min for consistency

* Revised 8e6c669 as requested

* ATA Update interval defaults to 1s in the UI

* Simplified storage update interval menu
This commit is contained in:
Shinyeong Hyun
2025-05-02 20:07:43 +02:00
committed by GitHub
parent 56a7fc1206
commit bdafcd92b8
3 changed files with 50 additions and 2 deletions
@@ -22,6 +22,9 @@ public abstract class AtaStorage : AbstractStorage
private IDictionary<SmartAttribute, Sensor> _sensors;
private static TimeSpan _throttleInterval = TimeSpan.Zero;
private DateTime _lastUpdate = DateTime.MinValue;
/// <summary>
/// Gets the SMART data.
/// </summary>
@@ -187,10 +190,28 @@ public abstract class AtaStorage : AbstractStorage
base.CreateSensors();
}
public static TimeSpan ThrottleInterval
{
get
{
return _throttleInterval;
}
set
{
_throttleInterval = value;
}
}
protected virtual void UpdateAdditionalSensors(Kernel32.SMART_ATTRIBUTE[] values) { }
protected override void UpdateSensors()
{
if (DateTime.UtcNow - _lastUpdate < ThrottleInterval)
{
return;
}
_lastUpdate = DateTime.UtcNow;
if (Smart.IsValid)
{
Kernel32.SMART_ATTRIBUTE[] smartAttributes = Smart.ReadSmartData();
@@ -289,4 +310,4 @@ public abstract class AtaStorage : AbstractStorage
Smart.Close();
base.Close();
}
}
}