forked from TBSniller/cmpinf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettings.cs
More file actions
95 lines (90 loc) · 3.71 KB
/
Settings.cs
File metadata and controls
95 lines (90 loc) · 3.71 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System.Collections.Generic;
using Newtonsoft.Json;
public class Settings
{
[JsonProperty("UpdateIntervalMs")]
public int UpdateIntervalMs { get; set; } = 1000;
[JsonProperty("Pages")]
public List<OledPage> Pages { get; set; } = new();
[JsonProperty("GameSenseRetryIntervalMs")]
public int GameSenseRetryIntervalMs { get; set; } = 5000; // Default: 5 seconds
[JsonProperty("GameSenseHeartbeatIntervalMs")]
public int GameSenseHeartbeatIntervalMs { get; set; } = 10000; // Default: 10 seconds
[JsonProperty("RunAsAdmin")]
public bool RunAsAdmin { get; set; } = false;
/// Returns a default Settings object with three example pages.
public static Settings GetDefault()
{
return new Settings
{
UpdateIntervalMs = 1000,
GameSenseRetryIntervalMs = 5000,
GameSenseHeartbeatIntervalMs = 10000,
Pages = new List<OledPage>
{
new OledPage
{
DurationMs = 5000,
IconId = 43,
Sensors = new List<SensorSelection>
{
new SensorSelection { Name = "CPU Package", Hardware = "Cpu", Type = "Temperature", Prefix = "CPU: ", Suffix = " °C", DecimalPlaces = 0 },
new SensorSelection { Name = "GPU Core", Hardware = "GpuNvidia", Type = "Temperature", Prefix = "GPU: ", Suffix = " °C", DecimalPlaces = 0 }
}
},
new OledPage
{
DurationMs = 3000,
IconId = 27,
Sensors = new List<SensorSelection>
{
new SensorSelection { Name = "CPU Total", Hardware = "Cpu", Type = "Load", Prefix = "CPU: ", Suffix = "%", DecimalPlaces = 0 },
new SensorSelection { Name = "GPU Core", Hardware = "GpuNvidia", Type = "Load", Prefix = "GPU: ", Suffix = "%", DecimalPlaces = 0 }
}
},
new OledPage
{
DurationMs = 3000,
IconId = 29,
Sensors = new List<SensorSelection>
{
new SensorSelection { Name = "Memory Used", Hardware = "Memory", Type = "Data", Prefix = "Mem: ", Suffix = "GB", DecimalPlaces = 1 }
}
}
}
};
}
}
public class OledPage
{
[JsonProperty("DurationMs")]
public int DurationMs { get; set; } = 5000;
[JsonProperty("IconId")]
public int IconId { get; set; } = 0;
[JsonProperty("Sensors")]
public List<SensorSelection> Sensors { get; set; } = new();
}
public class SensorSelection
{
[JsonProperty("Name")]
public string Name { get; set; } = string.Empty;
[JsonProperty("Hardware")]
public string Hardware { get; set; } = string.Empty;
[JsonProperty("Type")]
public string Type { get; set; } = string.Empty;
[JsonProperty("Prefix")]
public string Prefix { get; set; } = string.Empty;
[JsonProperty("Suffix")]
public string Suffix { get; set; } = string.Empty;
[JsonProperty("DecimalPlaces")]
public int DecimalPlaces { get; set; } = 1;
// Set during paging to ensure unique keys for duplicate sensors
public int KeyInstance { get; set; } = 1;
public string GetContextFrameKey()
{
if (string.IsNullOrWhiteSpace(Name) && string.IsNullOrWhiteSpace(Hardware) && string.IsNullOrWhiteSpace(Type))
return $"dummy_{KeyInstance}";
var baseKey = $"{Name}_{Hardware}_{Type}".ToLowerInvariant().Replace(" ", "_").Replace("-", "_");
return KeyInstance > 1 ? $"{baseKey}_{KeyInstance}" : baseKey;
}
}