diff --git a/LibreHardwareMonitor/UI/HardwareTypeImage.cs b/LibreHardwareMonitor/UI/HardwareTypeImage.cs index 4019fc9..c80401e 100644 --- a/LibreHardwareMonitor/UI/HardwareTypeImage.cs +++ b/LibreHardwareMonitor/UI/HardwareTypeImage.cs @@ -56,6 +56,9 @@ namespace LibreHardwareMonitor.UI case HardwareType.AquaComputer: image = Utilities.EmbeddedResources.GetImage("acicon.png"); break; + case HardwareType.AeroCool: + image = Utilities.EmbeddedResources.GetImage("chip.png"); + break; case HardwareType.Network: image = Utilities.EmbeddedResources.GetImage("nic.png"); break; diff --git a/LibreHardwareMonitor/Utilities/HttpServer.cs b/LibreHardwareMonitor/Utilities/HttpServer.cs index fe184ba..0ca8f2e 100644 --- a/LibreHardwareMonitor/Utilities/HttpServer.cs +++ b/LibreHardwareMonitor/Utilities/HttpServer.cs @@ -529,6 +529,8 @@ namespace LibreHardwareMonitor.Utilities return "ram.png"; case HardwareType.AquaComputer: return "acicon.png"; + case HardwareType.AeroCool: + return "chip.png"; case HardwareType.Network: return "nic.png"; default: diff --git a/LibreHardwareMonitorLib/Hardware/Computer.cs b/LibreHardwareMonitorLib/Hardware/Computer.cs index b60eaa5..b84f57c 100644 --- a/LibreHardwareMonitorLib/Hardware/Computer.cs +++ b/LibreHardwareMonitorLib/Hardware/Computer.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Security.Permissions; +using LibreHardwareMonitor.Hardware.Controller.AeroCool; using LibreHardwareMonitor.Hardware.Controller.AquaComputer; using LibreHardwareMonitor.Hardware.Controller.Heatmaster; using LibreHardwareMonitor.Hardware.Controller.TBalancer; @@ -92,12 +93,14 @@ namespace LibreHardwareMonitor.Hardware Add(new TBalancerGroup(_settings)); Add(new HeatmasterGroup(_settings)); Add(new AquaComputerGroup(_settings)); + Add(new AeroCoolGroup(_settings)); } else { RemoveType(); RemoveType(); RemoveType(); + RemoveType(); } } @@ -376,6 +379,7 @@ namespace LibreHardwareMonitor.Hardware Add(new TBalancerGroup(_settings)); Add(new HeatmasterGroup(_settings)); Add(new AquaComputerGroup(_settings)); + Add(new AeroCoolGroup(_settings)); } if (_storageEnabled) diff --git a/LibreHardwareMonitorLib/Hardware/Controller/AeroCool/AeroCoolGroup.cs b/LibreHardwareMonitorLib/Hardware/Controller/AeroCool/AeroCoolGroup.cs new file mode 100644 index 0000000..810ea8d --- /dev/null +++ b/LibreHardwareMonitorLib/Hardware/Controller/AeroCool/AeroCoolGroup.cs @@ -0,0 +1,58 @@ +// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. +// Copyright (C) LibreHardwareMonitor and Contributors. +// All Rights Reserved. + +using System.Collections.Generic; +using System.Text; +using HidLibrary; + +namespace LibreHardwareMonitor.Hardware.Controller.AeroCool +{ + public class AeroCoolGroup : IGroup + { + private readonly List _hardware = new List(); + private readonly StringBuilder _report = new StringBuilder(); + + public AeroCoolGroup(ISettings settings) + { + _report.AppendLine("AeroCool Hardware"); + _report.AppendLine(); + + foreach (HidDevice dev in HidDevices.Enumerate(0x2e97)) + { + int hubno = dev.Attributes.ProductId - 0x1000; + if (dev.DevicePath.Contains("mi_02") && (hubno >= 1) && (hubno <= 8)) + { + var device = new P7H1(dev, settings); + _report.AppendLine($"Device name: {device.Name}"); + _report.AppendLine($"HUB number: {device.HubNumber}"); + _report.AppendLine(); + _hardware.Add(device); + } + } + + if (_hardware.Count == 0) + { + _report.AppendLine("No AeroCool Hardware found."); + _report.AppendLine(); + } + } + + public IEnumerable Hardware => _hardware; + + public void Close() + { + foreach (IHardware iHardware in _hardware) + { + if (iHardware is Hardware hardware) + hardware.Close(); + } + } + + public string GetReport() + { + return _report.ToString(); + } + } +} diff --git a/LibreHardwareMonitorLib/Hardware/Controller/AeroCool/P7-H1.cs b/LibreHardwareMonitorLib/Hardware/Controller/AeroCool/P7-H1.cs new file mode 100644 index 0000000..a07df77 --- /dev/null +++ b/LibreHardwareMonitorLib/Hardware/Controller/AeroCool/P7-H1.cs @@ -0,0 +1,81 @@ +// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. +// Copyright (C) LibreHardwareMonitor and Contributors. +// All Rights Reserved. + +using System; +using HidLibrary; + +namespace LibreHardwareMonitor.Hardware.Controller.AeroCool +{ + internal class P7H1 : Hardware + { + private readonly HidDevice _device; + private readonly float[] _speeds = new float[5]; + private bool _running; + + private readonly Sensor[] _rpm = new Sensor[5]; + private const byte REPORT_ID = 0x0; + + public int HubNumber { get; private set; } + + public P7H1(HidDevice dev, ISettings settings) : base("AeroCool P7-H1", new Identifier(dev.DevicePath), settings) + { + _device = dev; + HubNumber = _device.Attributes.ProductId - 0x1000; + Name = $"AeroCool P7-H1 #{HubNumber}"; + _device.OpenDevice(); + _device.MonitorDeviceEvents = true; + _running = true; + _device.Read(OnDataReady); + + for (int i=0; i<5; i++) + { + _rpm[i] = new Sensor($"Fan #{i+1}", i, SensorType.Fan, this, settings); + ActivateSensor(_rpm[i]); + } + } + + public override HardwareType HardwareType + { + get + { + return HardwareType.AeroCool; + } + } + + public override void Close() + { + _running = false; + _device.CloseDevice(); + base.Close(); + } + + public override void Update() + { + for (int i = 0; i < 5; i++) + { + _rpm[i].Value = _speeds[i]; + } + } + + private void OnDataReady(HidDeviceData report) + { + if (!_running) // Do not register eventhandler again if device stopped + return; + if (report.Status == HidDeviceData.ReadStatus.Success) + { + byte[] rawData = report.Data; + if(rawData.Length == 16 && rawData[0] == REPORT_ID) + { + for (int i = 0; i < 5; i++) + { + int speed = rawData[i * 3 + 2] * 256 + rawData[i * 3 + 3]; + _speeds[i] = (float)speed; + } + } + } + _device.Read(OnDataReady); + } + } +} diff --git a/LibreHardwareMonitorLib/Hardware/IHardware.cs b/LibreHardwareMonitorLib/Hardware/IHardware.cs index 3db6800..2ab1325 100644 --- a/LibreHardwareMonitorLib/Hardware/IHardware.cs +++ b/LibreHardwareMonitorLib/Hardware/IHardware.cs @@ -20,7 +20,8 @@ namespace LibreHardwareMonitor.Hardware TBalancer, Heatmaster, Storage, - Network + Network, + AeroCool } public interface IHardware : IElement diff --git a/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj b/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj index 35ce023..db6e338 100644 --- a/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj +++ b/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj @@ -35,6 +35,8 @@ + +