-
Notifications
You must be signed in to change notification settings - Fork 0
/
LiquidctlDevice.cs
48 lines (43 loc) · 1.4 KB
/
LiquidctlDevice.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
namespace LiquidCtlAfterburnerPlugin
{
internal class LiquidctlDevice
{
public LiquidctlDevice(LiquidctlStatusJSON output)
{
address = output.address;
name = output.description;
status = output.status;
}
public string address;
public string name;
public List<LiquidctlStatusJSON.StatusRecord> status = new List<LiquidctlStatusJSON.StatusRecord>();
public void LoadJSON()
{
try
{
LiquidctlStatusJSON output = LiquidctlCLIWrapper.ReadStatus(address).First();
UpdateFromJSON(output);
}
catch (InvalidOperationException)
{
throw new Exception($"Device {address} not showing up");
}
}
public void UpdateFromJSON(LiquidctlStatusJSON output)
{
foreach (LiquidctlStatusJSON.StatusRecord status in this.status) {
status.value = output.status.Find(s => s.key == status.key).value;
}
}
public String GetDeviceInfo() {
String ret = $"Device @ {address}";
foreach (LiquidctlStatusJSON.StatusRecord status in this.status) {
ret += $", {status.key}: {status.value}";
}
return ret;
}
}
}