Add index to superIO identifier if required (#1183)

* Add index to superIO identifier if required

* Simplify the index logic to 1 dictionary

* Unwanted B660M config delete.

* Simplify SuperIOHardware indexing
This commit is contained in:
Rem0o
2023-11-17 10:54:55 +01:00
committed by GitHub
parent 137e91e0ad
commit a84e6c6e8d
2 changed files with 41 additions and 27 deletions
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LibreHardwareMonitor.Hardware.Motherboard.Lpc;
using LibreHardwareMonitor.Hardware.Motherboard.Lpc.EC;
@@ -71,14 +72,26 @@ public class Motherboard : IHardware
superIO = _lpcIO.SuperIO;
}
EmbeddedController embeddedController = EmbeddedController.Create(Model, settings);
SubHardware = new IHardware[superIO.Count + (embeddedController != null ? 1 : 0)];
for (int i = 0; i < superIO.Count; i++)
SubHardware[i] = new SuperIOHardware(this, superIO[i], Manufacturer, Model, settings);
List<IHardware> subHardwareList = new List<IHardware>();
// there may be more than 1 of the same SuperIO chip
// group by chip
foreach (IGrouping<Chip, ISuperIO> group in superIO.GroupBy(x => x.Chip))
{
// index by group
foreach ((ISuperIO superIo, int i) in group.Select((x, i) => (x, i)))
{
subHardwareList.Add(new SuperIOHardware(this, superIo, Manufacturer, Model, settings, i));
}
}
if (embeddedController != null)
SubHardware[superIO.Count] = embeddedController;
subHardwareList.Add(embeddedController);
SubHardware = subHardwareList.ToArray();
}
/// <inheritdoc />
@@ -27,8 +27,8 @@ internal sealed class SuperIOHardware : Hardware
private readonly List<Sensor> _temperatures = new();
private readonly List<Sensor> _voltages = new();
public SuperIOHardware(Motherboard motherboard, ISuperIO superIO, Manufacturer manufacturer, Model model, ISettings settings)
: base(ChipName.GetName(superIO.Chip), new Identifier("lpc", superIO.Chip.ToString().ToLowerInvariant()), settings)
public SuperIOHardware(Motherboard motherboard, ISuperIO superIO, Manufacturer manufacturer, Model model, ISettings settings, int index)
: base(ChipName.GetName(superIO.Chip), new Identifier("lpc", superIO.Chip.ToString().ToLowerInvariant(), index.ToString()), settings)
{
_motherboard = motherboard;
_superIO = superIO;
@@ -1681,27 +1681,28 @@ internal sealed class SuperIOHardware : Hardware
break;
case Model.B660M_DS3H_AX_DDR4:
v.Add(new Voltage("Vcore",0));
v.Add(new Voltage("VAXG",1));
v.Add(new Voltage("VCCIN AUX",2));
v.Add(new Voltage("DIMM AB",3));
v.Add(new Voltage("+12V",4));
v.Add(new Voltage("+3.3V",5));
v.Add(new Voltage("+5V",6));
t.Add(new Temperature("CPU",0));
t.Add(new Temperature("PCH",1));
t.Add(new Temperature("PCIEX16",2));
t.Add(new Temperature("System #1",3));
t.Add(new Temperature("System #2",4));
t.Add(new Temperature("VRAM MOS",5));
f.Add(new Fan("CPU Fan",0));
f.Add(new Fan("System Fan #1",2));
f.Add(new Fan("System Fan #2",3));
f.Add(new Fan("System Fan #3",4));
c.Add(new Control("CPU Fan",0));
c.Add(new Control("System Fan #1",2));
c.Add(new Control("System Fan #2",3));
c.Add(new Control("System Fan #3",4));
v.Add(new Voltage("Vcore", 0));
v.Add(new Voltage("VAXG", 1));
v.Add(new Voltage("VCCIN AUX", 2));
v.Add(new Voltage("DIMM AB", 3));
v.Add(new Voltage("+12V", 4));
v.Add(new Voltage("+3.3V", 5));
v.Add(new Voltage("+5V", 6));
t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("PCH", 1));
t.Add(new Temperature("PCIEX16", 2));
t.Add(new Temperature("System #1", 3));
t.Add(new Temperature("System #2", 4));
t.Add(new Temperature("VRAM MOS", 5));
f.Add(new Fan("CPU Fan", 0));
f.Add(new Fan("System Fan #1", 2));
f.Add(new Fan("System Fan #2", 3));
f.Add(new Fan("System Fan #3", 4));
c.Add(new Control("CPU Fan", 0));
c.Add(new Control("System Fan #1", 2));
c.Add(new Control("System Fan #2", 3));
c.Add(new Control("System Fan #3", 4));
break;
default: