2022-10-15 16:53:24 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using LibreHardwareMonitor.Hardware;
|
|
|
|
|
|
|
|
|
|
|
|
namespace FanControl
|
|
|
|
|
|
{
|
|
|
|
|
|
internal class Program
|
|
|
|
|
|
{
|
|
|
|
|
|
public class UpdateVisitor : IVisitor
|
|
|
|
|
|
{
|
|
|
|
|
|
public void VisitComputer(IComputer computer)
|
|
|
|
|
|
{
|
|
|
|
|
|
computer.Traverse(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void VisitHardware(IHardware hardware)
|
|
|
|
|
|
{
|
|
|
|
|
|
hardware.Update();
|
|
|
|
|
|
foreach (IHardware subHardware in hardware.SubHardware) subHardware.Accept(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void VisitSensor(ISensor sensor) { }
|
|
|
|
|
|
public void VisitParameter(IParameter parameter) { }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void Monitor()
|
|
|
|
|
|
{
|
|
|
|
|
|
Computer computer = new Computer
|
|
|
|
|
|
{
|
|
|
|
|
|
IsCpuEnabled = true,
|
|
|
|
|
|
IsGpuEnabled = true,
|
|
|
|
|
|
IsMemoryEnabled = true,
|
|
|
|
|
|
IsMotherboardEnabled = true,
|
|
|
|
|
|
IsControllerEnabled = true,
|
|
|
|
|
|
IsNetworkEnabled = true,
|
2022-11-12 10:14:09 +01:00
|
|
|
|
IsStorageEnabled = true,
|
|
|
|
|
|
IsPsuEnabled = true,
|
|
|
|
|
|
IsBatteryEnabled = true
|
2022-10-15 16:53:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
computer.Open();
|
2022-11-12 10:14:09 +01:00
|
|
|
|
//computer.Accept(new UpdateVisitor());
|
2022-10-15 16:53:24 +02:00
|
|
|
|
|
|
|
|
|
|
foreach (IHardware hardware in computer.Hardware)
|
|
|
|
|
|
{
|
2022-11-12 10:14:09 +01:00
|
|
|
|
Console.WriteLine("Hardware: {0}. Type: {1}", hardware.Name, hardware.HardwareType);
|
2022-10-15 16:53:24 +02:00
|
|
|
|
|
|
|
|
|
|
foreach (IHardware subhardware in hardware.SubHardware)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine("\tSubhardware: {0}", subhardware.Name);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (ISensor sensor in subhardware.Sensors)
|
|
|
|
|
|
{
|
2022-11-12 10:14:09 +01:00
|
|
|
|
Console.WriteLine("\t\tSensor: {0}, value: {1}, type: {2}", sensor.Name, sensor.Value, sensor.SensorType);
|
2022-10-15 16:53:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (ISensor sensor in hardware.Sensors)
|
|
|
|
|
|
{
|
2022-11-12 10:14:09 +01:00
|
|
|
|
Console.WriteLine("\tSensor: {0}, value: {1}, type: {2}", sensor.Name, sensor.Value, sensor.SensorType);
|
2022-10-15 16:53:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
computer.Close();
|
|
|
|
|
|
}
|
2022-11-11 19:56:08 +01:00
|
|
|
|
static void ConsoleMain(string[] args)
|
2022-10-15 16:53:24 +02:00
|
|
|
|
{
|
2022-11-12 10:14:09 +01:00
|
|
|
|
Monitor();
|
2022-10-15 16:53:24 +02:00
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
|
{
|
|
|
|
|
|
Thread.Sleep(300);
|
|
|
|
|
|
|
|
|
|
|
|
Vlv0100.SetFanControl(false);
|
|
|
|
|
|
Vlv0100.SetFanDesiredRPM(6000);
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Fan RPM: {0}", Vlv0100.GetFanRPM());
|
|
|
|
|
|
Console.WriteLine("Fan Desired RPM: {0}", Vlv0100.GetFanDesiredRPM());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-11-11 19:56:08 +01:00
|
|
|
|
|
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Environment.UserInteractive && !Console.IsInputRedirected)
|
|
|
|
|
|
{
|
|
|
|
|
|
ConsoleMain(args);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Application.Run(new FanControlForm());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-10-15 16:53:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|