From 3efb160cd211c3c86e768a513f1037814904f513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rik=20Levente?= Date: Thu, 7 Dec 2023 22:59:29 +0100 Subject: [PATCH] Storage info backend --- core/Classes/HardwareInfo.cs | 36 +++++++++++++++++++++++++++++++++--- core/Classes/Interfaces.cs | 14 +++++++++++++- interface/layout/types.d.ts | 9 ++++++++- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/core/Classes/HardwareInfo.cs b/core/Classes/HardwareInfo.cs index 52d12f6..9bd539f 100644 --- a/core/Classes/HardwareInfo.cs +++ b/core/Classes/HardwareInfo.cs @@ -252,6 +252,7 @@ public void GetInfo() { if (firstRun) { var temp = new Disk { Name = computerHardware[i].Name, + Id = computerHardware[i].Identifier, }; // Get disk size @@ -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); + } + } } } } diff --git a/core/Classes/Interfaces.cs b/core/Classes/Interfaces.cs index 2b3d5a9..3b92c4e 100644 --- a/core/Classes/Interfaces.cs +++ b/core/Classes/Interfaces.cs @@ -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; } @@ -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 { diff --git a/interface/layout/types.d.ts b/interface/layout/types.d.ts index 1dc627e..9cf6433 100644 --- a/interface/layout/types.d.ts +++ b/interface/layout/types.d.ts @@ -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 { @@ -170,6 +172,11 @@ declare global { throughputDownload: number throughputUpload: number }[] + + storage: { + throughputRead: number + throughputWrite: number + }[] } interface HardwareStatistics {