Skip to content

Commit 1ca4ebc

Browse files
authored
Improve HidDevice Identifier (#1476)
1 parent 5421af5 commit 1ca4ebc

14 files changed

Lines changed: 244 additions & 215 deletions

File tree

LibreHardwareMonitorLib/Hardware/Controller/AeroCool/P7-H1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal sealed class P7H1 : Hardware
1919
private readonly HidStream _stream;
2020
private bool _running;
2121

22-
public P7H1(HidDevice dev, ISettings settings) : base("AeroCool P7-H1", new Identifier(dev.DevicePath), settings)
22+
public P7H1(HidDevice dev, ISettings settings) : base("AeroCool P7-H1", new Identifier(dev), settings)
2323
{
2424
_device = dev;
2525
HubNumber = _device.ProductID - 0x1000;
@@ -93,4 +93,4 @@ public override void Update()
9393
_rpm[i].Value = _speeds[i];
9494
}
9595
}
96-
}
96+
}

LibreHardwareMonitorLib/Hardware/Controller/AquaComputer/AquastreamUltimate.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ internal sealed class AquastreamUltimate : Hardware
2020
private readonly Sensor[] _powers = new Sensor[2];
2121
private readonly Sensor[] _flows = new Sensor[2];
2222

23-
public AquastreamUltimate(HidDevice dev, ISettings settings) : base("AquastreamUltimate", new Identifier(dev.DevicePath), settings)
23+
public AquastreamUltimate(HidDevice dev, ISettings settings) : base("AquastreamUltimate", new Identifier(dev), settings)
2424
{
2525
if (dev.TryOpen(out _stream))
2626
{
2727
// Reading output report instead of feature report, as the measurements are in the output report.
2828
_stream.Read(_rawData);
29-
29+
3030
FirmwareVersion = GetConvertedValue(0xD).GetValueOrDefault(0);
31-
31+
3232
Name = "Aquastream ULTIMATE";
3333

3434
_temperatures[0] = new Sensor("Coolant", 0, SensorType.Temperature, this, Array.Empty<ParameterDescription>(), settings);
3535
ActivateSensor(_temperatures[0]);
36-
36+
3737
_temperatures[1] = new Sensor("External Sensor", 1, SensorType.Temperature, this, Array.Empty<ParameterDescription>(), settings);
3838
ActivateSensor(_temperatures[1]);
3939

@@ -88,20 +88,20 @@ public override void Update()
8888
// Reading output report instead of feature report, as the measurements are in the output report
8989
_stream.Read(_rawData);
9090

91-
_rpmSensors[0].Value = GetConvertedValue(0x51) ; // Pump speed.
92-
_rpmSensors[1].Value = GetConvertedValue(0x41+0x06); // Fan speed.
91+
_rpmSensors[0].Value = GetConvertedValue(0x51); // Pump speed.
92+
_rpmSensors[1].Value = GetConvertedValue(0x41 + 0x06); // Fan speed.
9393

9494
_temperatures[0].Value = GetConvertedValue(0x2D) / 100f; // Water temp.
9595
_temperatures[1].Value = GetConvertedValue(0x2F) / 100f; // Ext sensor temp.
9696

9797
_voltages[0].Value = GetConvertedValue(0x3D) / 100f; // Pump input voltage.
98-
_voltages[1].Value = GetConvertedValue(0x41+0x02) / 100f; // Fan output voltage.
98+
_voltages[1].Value = GetConvertedValue(0x41 + 0x02) / 100f; // Fan output voltage.
9999

100100
_currents[0].Value = GetConvertedValue(0x53) / 1000f; // Pump current.
101-
_currents[1].Value = GetConvertedValue(0x41+0x00) / 1000f; // Fan current.
101+
_currents[1].Value = GetConvertedValue(0x41 + 0x00) / 1000f; // Fan current.
102102

103103
_powers[0].Value = GetConvertedValue(0x55) / 100f; // Pump power.
104-
_powers[1].Value = GetConvertedValue(0x41+0x04) / 100f; // Fan power.
104+
_powers[1].Value = GetConvertedValue(0x41 + 0x04) / 100f; // Fan power.
105105

106106
_flows[0].Value = GetConvertedValue(0x37); // Flow.
107107
_flows[1].Value = GetConvertedValue(0x57) / 1000f; // Pressure.
@@ -111,7 +111,7 @@ public override void Update()
111111
{
112112
if (_rawData[index] == sbyte.MaxValue)
113113
return null;
114-
114+
115115
return Convert.ToUInt16(_rawData[index + 1] | (_rawData[index] << 8));
116-
}
116+
}
117117
}

LibreHardwareMonitorLib/Hardware/Controller/AquaComputer/AquastreamXT.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal sealed class AquastreamXT : Hardware
2626
private readonly Sensor[] _temperatures = new Sensor[3];
2727
private readonly Sensor[] _voltages = new Sensor[2];
2828

29-
public AquastreamXT(HidDevice dev, ISettings settings) : base("Aquastream XT", new Identifier(dev.DevicePath), settings)
29+
public AquastreamXT(HidDevice dev, ISettings settings) : base("Aquastream XT", new Identifier(dev), settings)
3030
{
3131
if (dev.TryOpen(out _stream))
3232
{
@@ -129,7 +129,7 @@ public override void Update()
129129
{
130130
return;
131131
}
132-
132+
133133

134134
if (_rawData[0] != 0x4)
135135
return;

LibreHardwareMonitorLib/Hardware/Controller/AquaComputer/D5Next.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal sealed class D5Next : Hardware
2525
private readonly HidStream _stream;
2626
private readonly Sensor[] _temperatures = new Sensor[1];
2727

28-
public D5Next(HidDevice dev, ISettings settings) : base("D5Next", new Identifier(dev.DevicePath), settings)
28+
public D5Next(HidDevice dev, ISettings settings) : base("D5Next", new Identifier(dev), settings)
2929
{
3030
if (dev.TryOpen(out _stream))
3131
{

LibreHardwareMonitorLib/Hardware/Controller/AquaComputer/Farbwerk.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal sealed class Farbwerk : Hardware
2727
private readonly Sensor[] _temperatures = new Sensor[TEMPERATURE_COUNT];
2828
private readonly Sensor[] _colors = new Sensor[COLOR_VALUE_COUNT];
2929

30-
public Farbwerk(HidDevice dev, ISettings settings) : base("Farbwerk", new Identifier(dev.DevicePath), settings)
30+
public Farbwerk(HidDevice dev, ISettings settings) : base("Farbwerk", new Identifier(dev), settings)
3131
{
3232
if (dev.TryOpen(out _stream))
3333
{

LibreHardwareMonitorLib/Hardware/Controller/AquaComputer/HighFlowNext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal sealed class HighFlowNext : Hardware
2020
private readonly Sensor[] _voltages = new Sensor[2];
2121
private readonly Sensor[] _alarms = new Sensor[4];
2222

23-
public HighFlowNext(HidDevice dev, ISettings settings) : base("high flow NEXT", new Identifier(dev.DevicePath), settings)
23+
public HighFlowNext(HidDevice dev, ISettings settings) : base("high flow NEXT", new Identifier(dev), settings)
2424
{
2525
if (dev.TryOpen(out _stream))
2626
{
@@ -93,7 +93,7 @@ public override void Update()
9393

9494
if (externalTempSensorConnected)
9595
{
96-
_temperatures[1].Value = rawExtTempValue / 100f;
96+
_temperatures[1].Value = rawExtTempValue / 100f;
9797
}
9898
else
9999
{

LibreHardwareMonitorLib/Hardware/Controller/AquaComputer/MPS.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal sealed class MPS : Hardware
2323

2424
private ushort _externalTemperature;
2525

26-
public MPS(HidDevice dev, ISettings settings) : base("MPS", new Identifier(dev.DevicePath), settings)
26+
public MPS(HidDevice dev, ISettings settings) : base("MPS", new Identifier(dev), settings)
2727
{
2828
if (dev.TryOpen(out _stream))
2929
{

LibreHardwareMonitorLib/Hardware/Controller/AquaComputer/Octo.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,30 @@ internal sealed class Octo : Hardware
1818
private readonly Sensor[] _currents = new Sensor[8];
1919
private readonly Sensor[] _powers = new Sensor[8];
2020

21-
public Octo(HidDevice dev, ISettings settings) : base("Octo", new Identifier(dev.DevicePath), settings)
21+
public Octo(HidDevice dev, ISettings settings) : base("Octo", new Identifier(dev), settings)
2222
{
2323
if (dev.TryOpen(out _stream))
2424
{
2525
//Reading output report instead of feature report, as the measurements are in the output report
2626
_stream.Read(_rawData);
27-
27+
2828
Name = "OCTO";
2929
FirmwareVersion = GetConvertedValue(OctoDataIndexes.FIRMWARE_VERSION).GetValueOrDefault(0);
3030

3131
// Initialize the 4 temperature sensors
3232
for (int i = 0; i < 4; i++)
3333
{
34-
_temperatures[i] = new Sensor($"Temperature {i+1}", i, SensorType.Temperature, this, Array.Empty<ParameterDescription>(), settings);
34+
_temperatures[i] = new Sensor($"Temperature {i + 1}", i, SensorType.Temperature, this, Array.Empty<ParameterDescription>(), settings);
3535
ActivateSensor(_temperatures[i]);
3636
}
3737

3838
// Initialize the 8 fan speed sensors
3939
for (int i = 0; i < 8; i++)
4040
{
41-
_rpmSensors[i] = new Sensor($"Fan {i+1}", i, SensorType.Fan, this, Array.Empty<ParameterDescription>(), settings);
41+
_rpmSensors[i] = new Sensor($"Fan {i + 1}", i, SensorType.Fan, this, Array.Empty<ParameterDescription>(), settings);
4242
ActivateSensor(_rpmSensors[i]);
4343
}
44-
44+
4545
// Initialize the input voltage sensor
4646
_voltages[0] = new Sensor("Input", 0, SensorType.Voltage, this, Array.Empty<ParameterDescription>(), settings);
4747
ActivateSensor(_voltages[0]);
@@ -52,18 +52,18 @@ internal sealed class Octo : Hardware
5252
_voltages[i] = new Sensor($"Fan {i}", i, SensorType.Voltage, this, Array.Empty<ParameterDescription>(), settings);
5353
ActivateSensor(_voltages[i]);
5454
}
55-
55+
5656
// Initialize the 8 fan current sensors
5757
for (int i = 0; i < 8; i++)
5858
{
59-
_currents[i] = new Sensor($"Fan {i+1}", i, SensorType.Current, this, Array.Empty<ParameterDescription>(), settings);
59+
_currents[i] = new Sensor($"Fan {i + 1}", i, SensorType.Current, this, Array.Empty<ParameterDescription>(), settings);
6060
ActivateSensor(_currents[i]);
6161
}
62-
62+
6363
// Initialize the 8 fan power sensors
6464
for (int i = 0; i < 8; i++)
6565
{
66-
_powers[i] = new Sensor($"Fan {i+1}", i, SensorType.Power, this, Array.Empty<ParameterDescription>(), settings);
66+
_powers[i] = new Sensor($"Fan {i + 1}", i, SensorType.Power, this, Array.Empty<ParameterDescription>(), settings);
6767
ActivateSensor(_powers[i]);
6868
}
6969
}
@@ -86,7 +86,7 @@ public override void Update()
8686
{
8787
//Reading output report instead of feature report, as the measurements are in the output report
8888
_stream.Read(_rawData);
89-
89+
9090
_temperatures[0].Value = GetConvertedValue(OctoDataIndexes.TEMP_1) / 100f; // Temp 1
9191
_temperatures[1].Value = GetConvertedValue(OctoDataIndexes.TEMP_2) / 100f; // Temp 2
9292
_temperatures[2].Value = GetConvertedValue(OctoDataIndexes.TEMP_3) / 100f; // Temp 3
@@ -100,7 +100,7 @@ public override void Update()
100100
_rpmSensors[5].Value = GetConvertedValue(OctoDataIndexes.FAN_SPEED_6); // Fan 6 speed
101101
_rpmSensors[6].Value = GetConvertedValue(OctoDataIndexes.FAN_SPEED_7); // Fan 7 speed
102102
_rpmSensors[7].Value = GetConvertedValue(OctoDataIndexes.FAN_SPEED_8); // Fan 8 speed
103-
103+
104104
_voltages[0].Value = GetConvertedValue(OctoDataIndexes.VOLTAGE) / 100f; // Input voltage
105105
_voltages[1].Value = GetConvertedValue(OctoDataIndexes.FAN_VOLTAGE_1) / 100f; // Fan 1 voltage
106106
_voltages[2].Value = GetConvertedValue(OctoDataIndexes.FAN_VOLTAGE_2) / 100f; // Fan 2 voltage
@@ -110,7 +110,7 @@ public override void Update()
110110
_voltages[6].Value = GetConvertedValue(OctoDataIndexes.FAN_VOLTAGE_6) / 100f; // Fan 6 voltage
111111
_voltages[7].Value = GetConvertedValue(OctoDataIndexes.FAN_VOLTAGE_7) / 100f; // Fan 7 voltage
112112
_voltages[8].Value = GetConvertedValue(OctoDataIndexes.FAN_VOLTAGE_8) / 100f; // Fan 8 voltage
113-
113+
114114
_currents[0].Value = GetConvertedValue(OctoDataIndexes.FAN_CURRENT_1) / 1000f; // Fan 1 current
115115
_currents[1].Value = GetConvertedValue(OctoDataIndexes.FAN_CURRENT_2) / 1000f; // Fan 2 current
116116
_currents[2].Value = GetConvertedValue(OctoDataIndexes.FAN_CURRENT_3) / 1000f; // Fan 3 current
@@ -119,7 +119,7 @@ public override void Update()
119119
_currents[5].Value = GetConvertedValue(OctoDataIndexes.FAN_CURRENT_6) / 1000f; // Fan 6 current
120120
_currents[6].Value = GetConvertedValue(OctoDataIndexes.FAN_CURRENT_7) / 1000f; // Fan 7 current
121121
_currents[7].Value = GetConvertedValue(OctoDataIndexes.FAN_CURRENT_8) / 1000f; // Fan 8 current
122-
122+
123123
_powers[0].Value = GetConvertedValue(OctoDataIndexes.FAN_POWER_1) / 100f; // Fan 1 power
124124
_powers[1].Value = GetConvertedValue(OctoDataIndexes.FAN_POWER_2) / 100f; // Fan 2 power
125125
_powers[2].Value = GetConvertedValue(OctoDataIndexes.FAN_POWER_3) / 100f; // Fan 3 power
@@ -133,7 +133,7 @@ public override void Update()
133133
private sealed class OctoDataIndexes
134134
{
135135
public const int FIRMWARE_VERSION = 13;
136-
136+
137137
public const int TEMP_1 = 61;
138138
public const int TEMP_2 = 63;
139139
public const int TEMP_3 = 65;
@@ -147,7 +147,7 @@ private sealed class OctoDataIndexes
147147
public const int FAN_SPEED_6 = 198;
148148
public const int FAN_SPEED_7 = 211;
149149
public const int FAN_SPEED_8 = 224;
150-
150+
151151
public const int FAN_POWER_1 = 131;
152152
public const int FAN_POWER_2 = 144;
153153
public const int FAN_POWER_3 = 157;
@@ -166,7 +166,7 @@ private sealed class OctoDataIndexes
166166
public const int FAN_VOLTAGE_6 = 192;
167167
public const int FAN_VOLTAGE_7 = 205;
168168
public const int FAN_VOLTAGE_8 = 218;
169-
169+
170170
public const int FAN_CURRENT_1 = 129;
171171
public const int FAN_CURRENT_2 = 142;
172172
public const int FAN_CURRENT_3 = 155;
@@ -181,7 +181,7 @@ private sealed class OctoDataIndexes
181181
{
182182
if (_rawData[index] == sbyte.MaxValue)
183183
return null;
184-
184+
185185
return Convert.ToUInt16(_rawData[index + 1] | (_rawData[index] << 8));
186186
}
187-
}
187+
}

0 commit comments

Comments
 (0)