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

Removed inconsistent hardwaremonitor sensors #2018

Merged
merged 3 commits into from
May 17, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Binary file modified Project-Aurora/Project-Aurora/LibreHardwareMonitorLib.dll
Binary file not shown.
14 changes: 3 additions & 11 deletions Project-Aurora/Project-Aurora/Profiles/LocalPCInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ public class CPUInfo : Node
/// <summary>
/// Represents the CPU usage from 0 to 100
/// </summary>
public float Usage => HardwareMonitor.CPU.CPUTotalLoad;
public float Usage => HardwareMonitor.CPU.CPULoad;

/// <summary>
/// Represents the temperature of the cpu die in celsius
/// </summary>
public float Temperature => HardwareMonitor.CPU.CPUDieTemp;
public float Temperature => HardwareMonitor.CPU.CPUTemp;

/// <summary>
/// Represents the CPU power draw in watts
Expand Down Expand Up @@ -206,18 +206,10 @@ public class RAMInfo : Node

public class GPUInfo : Node
{
public float Usage => HardwareMonitor.GPU.GPUCoreLoad;
public float Usage => HardwareMonitor.GPU.GPULoad;
public float Temperature => HardwareMonitor.GPU.GPUCoreTemp;
public float PowerUsage => HardwareMonitor.GPU.GPUPower;
public float FanRPM => HardwareMonitor.GPU.GPUFan;
public float CoreClock => HardwareMonitor.GPU.GPUCoreClock;
public float MemoryClock => HardwareMonitor.GPU.GPUMemoryClock;
public float ShaderClock => HardwareMonitor.GPU.GPUShaderClock;
public float MemoryControllerUsage => HardwareMonitor.GPU.GPUMemoryCLoad;
public float VideoEngineUsage => HardwareMonitor.GPU.GPUVideoEngineLoad;
public float MemoryUsed => HardwareMonitor.GPU.GPUMemoryUsed;
public float MemoryFree => MemoryTotal - MemoryUsed;
public float MemoryTotal => HardwareMonitor.GPU.GPUMemoryTotal;
}

public class NETInfo : Node
Expand Down
7 changes: 7 additions & 0 deletions Project-Aurora/Project-Aurora/Settings/Control_Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,13 @@
Width="150"
Height="30"
/>
<Button
x:Name="btnDumpSensors"
Margin="0,10,0,0"
Width="150"
Height="30"
Content="Dump hardware sensors" Click="btnDumpSensors_Click"
/>
</StackPanel>
</Grid>
</TabItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,5 +941,13 @@ private void startDelayAmount_ValueChanged(object sender, RoutedPropertyChangedE
}
}
}

private void btnDumpSensors_Click(object sender, RoutedEventArgs e)
{
if (HardwareMonitor.TryDump())
Xceed.Wpf.Toolkit.MessageBox.Show("Successfully wrote sensor info to logs folder");
else
Xceed.Wpf.Toolkit.MessageBox.Show("Eror dumping file. Consult log for details.");
}
}
}
101 changes: 54 additions & 47 deletions Project-Aurora/Project-Aurora/Utils/HardwareMonitor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -48,6 +49,32 @@ static HardwareMonitor()
}
}

public static bool TryDump()
{
var lines = new List<string>();
foreach (var hw in _hardware)
{
lines.Add("-----");
lines.Add(hw.Name);
lines.Add("Sensors:");
foreach (var sensor in hw.Sensors.OrderBy(s => s.SensorType))
{
lines.Add($"Name: {sensor.Name}, Id: {sensor.Identifier}, Type: {sensor.SensorType}");
}
lines.Add("-----");
}
try
{
File.WriteAllLines(Path.Combine(Global.LogsDirectory, "sensors.txt"), lines);
return true;
}
catch (IOException e)
{
Global.logger.Error("Failed to write sensors dump: " + e);
return false;
}
}

private static ISensor FindSensor(this IHardware hardware, string identifier)
{
var result = Array.Find(hardware.Sensors, s => s.Identifier.ToString().Contains(identifier));
Expand All @@ -59,6 +86,17 @@ private static ISensor FindSensor(this IHardware hardware, string identifier)
return result;
}

private static ISensor FindSensor(this IHardware hardware, SensorType type)
{
var result = Array.Find(hardware.Sensors, s => s.SensorType == type);
if (result is null)
{
Global.logger.Error(
$"[HardwareMonitor] Failed to find sensor of type \"{type}\" in {hardware.Name} of type {hardware.HardwareType}.");
}
return result;
}

public abstract class HardwareUpdater
{
protected IHardware hw;
Expand Down Expand Up @@ -105,35 +143,14 @@ public void SetUpdateTimer(int interval)
public sealed class GPUUpdater : HardwareUpdater
{
#region Sensors
private readonly ISensor _GPUCoreTemp;
public float GPUCoreTemp => GetValue(_GPUCoreTemp);
private readonly ISensor _GPUTemp;
public float GPUCoreTemp => GetValue(_GPUTemp);

private readonly ISensor _GPUFan;
public float GPUFan => GetValue(_GPUFan);

private readonly ISensor _GPUCoreClock;
public float GPUCoreClock => GetValue(_GPUCoreClock);

private readonly ISensor _GPUMemoryClock;
public float GPUMemoryClock => GetValue(_GPUMemoryClock);

private readonly ISensor _GPUShaderClock;
public float GPUShaderClock => GetValue(_GPUShaderClock);

private readonly ISensor _GPUCoreLoad;
public float GPUCoreLoad => GetValue(_GPUCoreLoad);

private readonly ISensor _GPUMemoryCLoad;
public float GPUMemoryCLoad => GetValue(_GPUMemoryCLoad);

private readonly ISensor _GPUVideoEngineLoad;
public float GPUVideoEngineLoad => GetValue(_GPUVideoEngineLoad);

private readonly ISensor _GPUMemoryTotal;
public float GPUMemoryTotal => GetValue(_GPUMemoryTotal);

private readonly ISensor _GPUMemoryUsed;
public float GPUMemoryUsed => GetValue(_GPUMemoryUsed);
private readonly ISensor _GPULoad;
public float GPULoad => GetValue(_GPULoad);

private readonly ISensor _GPUPower;
public float GPUPower => GetValue(_GPUPower);
Expand All @@ -148,31 +165,21 @@ public GPUUpdater(IEnumerable<IHardware> hardware)
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");

_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");
_GPULoad = hw.FindSensor(SensorType.Load);
_GPUTemp = hw.FindSensor(SensorType.Temperature);
_GPUFan = hw.FindSensor(SensorType.Fan);
_GPUPower = hw.FindSensor(SensorType.Power);
}
}

public sealed class CPUUpdater : HardwareUpdater
{
#region Sensors
private readonly ISensor _CPUDieTemp;
public float CPUDieTemp => GetValue(_CPUDieTemp);
private readonly ISensor _CPUTemp;
public float CPUTemp => GetValue(_CPUTemp);

private readonly ISensor _CPUTotalLoad;
public float CPUTotalLoad => GetValue(_CPUTotalLoad);
private readonly ISensor _CPULoad;
public float CPULoad => GetValue(_CPULoad);

private readonly ISensor _CPUPower;
public float CPUPower => GetValue(_CPUPower);
Expand All @@ -186,9 +193,9 @@ public CPUUpdater(IEnumerable<IHardware> hardware)
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");
_CPUTemp = hw.FindSensor(SensorType.Temperature);
_CPULoad = hw.FindSensor(SensorType.Load);
_CPUPower = hw.FindSensor(SensorType.Power);
}
}

Expand Down Expand Up @@ -236,7 +243,7 @@ public NETUpdater(IEnumerable<IHardware> hws)
Global.logger.Error("[HardwareMonitor] Could not find hardware of type Network");
return;
}
_BandwidthUsed = hw.FindSensor("load");
_BandwidthUsed = hw.FindSensor(SensorType.Load);
_UploadSpeed = hw.FindSensor("throughput/7");
_DownloadSpeed = hw.FindSensor("throughput/8");
}
Expand Down