diff --git a/Project-Aurora/Project-Aurora/LibreHardwareMonitorLib.dll b/Project-Aurora/Project-Aurora/LibreHardwareMonitorLib.dll
index 3e001386d..21df27a6d 100644
Binary files a/Project-Aurora/Project-Aurora/LibreHardwareMonitorLib.dll and b/Project-Aurora/Project-Aurora/LibreHardwareMonitorLib.dll differ
diff --git a/Project-Aurora/Project-Aurora/Profiles/GameState.cs b/Project-Aurora/Project-Aurora/Profiles/GameState.cs
index 96dce4896..041aba68a 100644
--- a/Project-Aurora/Project-Aurora/Profiles/GameState.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/GameState.cs
@@ -260,6 +260,11 @@ private MMDevice DefaultAudioInDevice {
public GPUInfo GPU => _gpuInfo ?? (_gpuInfo = new GPUInfo());
#endregion
+ #region NET Properties
+ private static NETInfo _netInfo;
+ public NETInfo NET => _netInfo ?? (_netInfo = new NETInfo());
+ #endregion
+
///
/// Returns whether or not the device dession is in a locked state.
///
@@ -336,4 +341,9 @@ public class GPUInfo : Node
public float MemoryFree => MemoryTotal - MemoryUsed;
public float MemoryTotal => Utils.HardwareMonitor.GPU.GPUMemoryTotal;
}
+
+ public class NETInfo : Node
+ {
+ public float Usage => Utils.HardwareMonitor.NET.BandwidthUsed;
+ }
}
diff --git a/Project-Aurora/Project-Aurora/Settings/Configuration.cs b/Project-Aurora/Project-Aurora/Settings/Configuration.cs
index 5ebe72ffa..39ff85f4e 100755
--- a/Project-Aurora/Project-Aurora/Settings/Configuration.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Configuration.cs
@@ -471,6 +471,9 @@ public class Configuration : Settings
public int idle_amount;
public float idle_frequency;
+ //Hardware Monitor
+ public int HardwareMonitorUpdateRate;
+
public VariableRegistry VarRegistry;
//BitmapDebug Data
@@ -559,6 +562,8 @@ public Configuration()
idle_amount = 5;
idle_frequency = 2.5f;
+ HardwareMonitorUpdateRate = 200;
+
//Debug
bitmapDebugTopMost = false;
httpDebugTopMost = false;
diff --git a/Project-Aurora/Project-Aurora/Utils/HardwareMonitor.cs b/Project-Aurora/Project-Aurora/Utils/HardwareMonitor.cs
index 999700204..99f8a5b2b 100644
--- a/Project-Aurora/Project-Aurora/Utils/HardwareMonitor.cs
+++ b/Project-Aurora/Project-Aurora/Utils/HardwareMonitor.cs
@@ -23,13 +23,19 @@ public static class HardwareMonitor
private static RAMUpdater _ram;
public static RAMUpdater RAM => _ram ?? (_ram = new RAMUpdater(_hardware));
+ private static NETUpdater _net;
+ public static NETUpdater NET => _net ?? (_net = new NETUpdater(_hardware));
+
+#pragma warning disable CA1810 // Initialize reference type static fields inline
static HardwareMonitor()
+#pragma warning restore CA1810 // Initialize reference type static fields inline
{
_computer = new Computer()
{
IsCpuEnabled = true,
IsGpuEnabled = true,
- IsMemoryEnabled = true
+ IsMemoryEnabled = true,
+ IsNetworkEnabled = true
};
try
{
@@ -44,7 +50,13 @@ static HardwareMonitor()
private static ISensor FindSensor(this IHardware hardware, string identifier)
{
- return Array.Find(hardware.Sensors, s => s.Identifier.ToString().Contains(identifier));
+ var result = Array.Find(hardware.Sensors, s => s.Identifier.ToString().Contains(identifier));
+ if (result is null)
+ {
+ Global.logger.Error(
+ $"[HardwareMonitor] Failed to find sensor \"{identifier}\" in {hardware.Name} of type {hardware.HardwareType}.");
+ }
+ return result;
}
public abstract class HardwareUpdater
@@ -65,7 +77,7 @@ protected HardwareUpdater()
};
_useTimer.Start();
- _updateTimer = new Timer(200);
+ _updateTimer = new Timer(Global.Configuration.HardwareMonitorUpdateRate);
_updateTimer.Elapsed += (a, b) =>
{
if (inUse)
@@ -79,7 +91,7 @@ protected float GetValue(ISensor sensor)
inUse = true;
_useTimer.Stop();
_useTimer.Start();
- return sensor.Value ?? 0;
+ return sensor?.Value ?? 0;
}
public void SetUpdateTimer(int interval)
@@ -90,7 +102,7 @@ public void SetUpdateTimer(int interval)
}
}
- public class GPUUpdater : HardwareUpdater
+ public sealed class GPUUpdater : HardwareUpdater
{
#region Sensors
private readonly ISensor _GPUCoreTemp;
@@ -131,27 +143,29 @@ public GPUUpdater(IEnumerable hardware)
{
hw = hardware.FirstOrDefault(hw => hw.HardwareType == HardwareType.GpuAmd ||
hw.HardwareType == HardwareType.GpuNvidia);
- if (hw != null)
+ if (hw is null)
{
- _GPUCoreLoad = hw.FindSensor("load/0");
- _GPUMemoryCLoad = hw.FindSensor("load/1");
- _GPUVideoEngineLoad = hw.FindSensor("load/2");
+ Global.logger.Error("[HardwareMonitor] Could not find hardware of type GPU");
+ return;
+ }
+ _GPUCoreLoad = hw.FindSensor("load/0");
+ _GPUMemoryCLoad = hw.FindSensor("load/1");
+ _GPUVideoEngineLoad = hw.FindSensor("load/2");
- _GPUCoreClock = hw.FindSensor("clock/0");
- _GPUMemoryClock = hw.FindSensor("clock/1");
- _GPUShaderClock = hw.FindSensor("clock/2");
+ _GPUCoreClock = hw.FindSensor("clock/0");
+ _GPUMemoryClock = hw.FindSensor("clock/1");
+ _GPUShaderClock = hw.FindSensor("clock/2");
- _GPUCoreTemp = hw.FindSensor("temperature/0");
- _GPUFan = hw.FindSensor("fan/0");
- _GPUPower = hw.FindSensor("power/0");
+ _GPUCoreTemp = hw.FindSensor("temperature/0");
+ _GPUFan = hw.FindSensor("fan/0");
+ _GPUPower = hw.FindSensor("power/0");
- _GPUMemoryTotal = hw.FindSensor("smalldata/3");
- _GPUMemoryUsed = hw.FindSensor("smalldata/2");
- }
+ _GPUMemoryTotal = hw.FindSensor("smalldata/3");
+ _GPUMemoryUsed = hw.FindSensor("smalldata/2");
}
}
- public class CPUUpdater : HardwareUpdater
+ public sealed class CPUUpdater : HardwareUpdater
{
#region Sensors
private readonly ISensor _CPUDieTemp;
@@ -167,16 +181,18 @@ public class CPUUpdater : HardwareUpdater
public CPUUpdater(IEnumerable hardware)
{
hw = hardware.FirstOrDefault(hw => hw.HardwareType == HardwareType.Cpu);
- if (hw != null)
+ if (hw is null)
{
- _CPUDieTemp = hw.FindSensor("temperature/0");
- _CPUTotalLoad = hw.FindSensor("load/0");
- _CPUPower = hw.FindSensor("power/0");
+ Global.logger.Error("[HardwareMonitor] Could not find hardware of type CPU");
+ return;
}
+ _CPUDieTemp = hw.FindSensor("temperature/0");
+ _CPUTotalLoad = hw.FindSensor("load/0");
+ _CPUPower = hw.FindSensor("power/0");
}
}
- public class RAMUpdater : HardwareUpdater
+ public sealed class RAMUpdater : HardwareUpdater
{
#region Sensors
private readonly ISensor _RAMUsed;
@@ -189,11 +205,32 @@ public class RAMUpdater : HardwareUpdater
public RAMUpdater(IEnumerable hws)
{
hw = hws.FirstOrDefault(h => h.HardwareType == HardwareType.Memory);
- if (hw != null)
+ if (hw is null)
+ {
+ Global.logger.Error("[HardwareMonitor] Could not find hardware of type RAM");
+ return;
+ }
+ _RAMUsed = hw.FindSensor("data/0");
+ _RAMFree = hw.FindSensor("data/1");
+ }
+ }
+
+ public sealed class NETUpdater : HardwareUpdater
+ {
+ #region Sensors
+ private readonly ISensor _BandwidthUsed;
+ public float BandwidthUsed => GetValue(_BandwidthUsed);
+ #endregion
+
+ public NETUpdater(IEnumerable hws)
+ {
+ hw = hws.FirstOrDefault(h => h.HardwareType == HardwareType.Network);
+ if (hw is null)
{
- _RAMUsed = hw.FindSensor("data/0");
- _RAMFree = hw.FindSensor("data/1");
+ Global.logger.Error("[HardwareMonitor] Could not find hardware of type Network");
+ return;
}
+ _BandwidthUsed = hw.FindSensor("load");
}
}
}