Skip to content

Commit

Permalink
Storage info backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Dec 7, 2023
1 parent 05bcf69 commit 3efb160
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
36 changes: 33 additions & 3 deletions core/Classes/HardwareInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public void GetInfo() {
if (firstRun) {
var temp = new Disk {
Name = computerHardware[i].Name,
Id = computerHardware[i].Identifier,
};

// Get disk size
Expand Down Expand Up @@ -305,10 +306,39 @@ public void GetInfo() {
for (int j = 0; j < hardware.Sensors.Length; j++) {
// Drive temperature
if (sensor[j].SensorType == SensorType.Temperature) {
// find disk by name and overwrite value
// find disk by id and overwrite value
for (int k = 0; k < API.System.Storage.Disks.Count; k++) {
if (API.System.Storage.Disks[k].Name == computerHardware[i].Name) {
API.System.Storage.Disks[k].Temperature = (float)sensor[j].Value;
if (API.System.Storage.Disks[k].Id == computerHardware[i].Identifier) {
API.System.Storage.Disks[k].Temperature = new Sensor {
Name = sensor[j].Name,
Value = (float)Math.Round((float)sensor[j].Value),
Min = (float)Math.Round((float)sensor[j].Min),
Max = (float)Math.Round((float)sensor[j].Max),
};
}
}
}

// Drive throughput
if (sensor[j].SensorType == SensorType.Throughput) {
// find disk by ide and overwrite value
for (int k = 0; k < API.System.Storage.Disks.Count; k++) {
if (API.System.Storage.Disks[k].Id == computerHardware[i].Identifier) {
if (sensor[j].Name.Contains("Read")) {
if (sensor[j].Value.ToString() == "0" || sensor[j].Value == null) {
API.System.Storage.Disks[k].ThroughputRead = 0;
} else {
API.System.Storage.Disks[k].ThroughputRead = (float)Math.Round((float)sensor[j].Value, 1);
}
}

if (sensor[j].Name.Contains("Write")) {
if (sensor[j].Value.ToString() == "0" || sensor[j].Value == null) {
API.System.Storage.Disks[k].ThroughputWrite = 0;
} else {
API.System.Storage.Disks[k].ThroughputWrite = (float)Math.Round((float)sensor[j].Value, 1);
}
}
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion core/Classes/Interfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ public string Name {
get; set;
}

public float Temperature {
public Identifier Id {
get; set;
}

public Sensor Temperature {
get; set;
} = new();

public int TotalSpace {
get; set;
}
Expand All @@ -70,6 +74,14 @@ public int FreeSpace {
public string Health {
get; set;
}

public float ThroughputRead {
get; set;
}

public float ThroughputWrite {
get; set;
}
}

public class Monitor {
Expand Down
9 changes: 8 additions & 1 deletion interface/layout/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ declare global {

interface Disk {
name: string
temperature: number
temperature: Sensor
freeSpace: number
totalSpace: number
health: string
throughputRead: number
throughputWrite: number
}

interface RAMModule {
Expand Down Expand Up @@ -170,6 +172,11 @@ declare global {
throughputDownload: number
throughputUpload: number
}[]

storage: {
throughputRead: number
throughputWrite: number
}[]
}

interface HardwareStatistics {
Expand Down

0 comments on commit 3efb160

Please sign in to comment.