forked from hexagon-oss/openhardwaremonitor
-
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.
Merge pull request hexagon-oss#23 from hexagon-oss/dotnet5_port
Upgraded to .NET 5.0 and add REST API instead of unreliable WMI for external monitoring
- Loading branch information
Showing
52 changed files
with
1,592 additions
and
1,320 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
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
bin | ||
obj | ||
launchSettings.json | ||
/*.nupkg |
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
using OpenHardwareMonitor.Hardware; | ||
|
||
namespace LibDemoConsole { | ||
internal class HWVisitor : IVisitor | ||
{ | ||
int depth = 0; | ||
public void VisitComputer(IComputer computer) | ||
{ | ||
Serilog.Log.Information("{computer}", computer); | ||
computer.Traverse(this); | ||
} | ||
|
||
public void VisitHardware(IHardware hardware) | ||
{ | ||
Serilog.Log.Information(new string('\t', depth) + "{type} {name} {identifier}", hardware.HardwareType, hardware.Name, hardware.Identifier); | ||
hardware.Update(); | ||
depth++; | ||
hardware.Traverse(this); | ||
depth--; | ||
} | ||
|
||
public void VisitParameter(IParameter parameter) | ||
{ | ||
Serilog.Log.Information(new string('\t', depth) + "{type} {value} {name} {identifier}", parameter.Sensor.SensorType, parameter.Value , parameter.Name, parameter.Identifier); | ||
} | ||
|
||
public void VisitSensor(ISensor sensor) | ||
{ | ||
Serilog.Log.Information(new string('\t', depth) + "{type} {value} {name} {identifier}", sensor.SensorType, sensor.Value, sensor.Name, sensor.Identifier); | ||
depth++; | ||
sensor.Traverse(this); | ||
depth--; | ||
} | ||
} | ||
} |
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,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net5.0-windows7.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\OpenHardwareMonitorLib\OpenHardwareMonitorLib.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,40 @@ | ||
using OpenHardwareMonitor.Hardware; | ||
using Serilog; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace LibDemoConsole | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Log.Logger = new LoggerConfiguration() | ||
.WriteTo.Console() | ||
.CreateLogger(); | ||
|
||
Computer c = new Computer() | ||
{ | ||
CPUEnabled = true, | ||
FanControllerEnabled = true, | ||
GPUEnabled = true, | ||
HDDEnabled = true, | ||
MainboardEnabled = true, | ||
RAMEnabled = true, | ||
}; | ||
try | ||
{ | ||
c.Open(); | ||
var visitor = new HWVisitor(); | ||
c.Accept(visitor); | ||
} | ||
finally | ||
{ | ||
c.Close(); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.