From 3a4b2d2741cd4d3f139d9612d7bb5d6c88cca9bb Mon Sep 17 00:00:00 2001 From: SIRprise Date: Wed, 5 Apr 2023 18:12:11 +0200 Subject: [PATCH] fix #16 handle negative values for speed --- SSD-LED/Form1.cs | 31 ++++++++++++++++++++++++++--- SSD-LED/Properties/AssemblyInfo.cs | 6 +++--- SSD-LED/SSD-LED.csproj | 4 ++-- SSD-LED/bin/Release/SSD-LED.exe | Bin 38400 -> 38912 bytes 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/SSD-LED/Form1.cs b/SSD-LED/Form1.cs index f26c6d7..7203bed 100644 --- a/SSD-LED/Form1.cs +++ b/SSD-LED/Form1.cs @@ -265,8 +265,8 @@ public void SSDActivityWMI() public bool SSDActivityPerfCount() { - float bytesPSRead; - float bytesPSWrite; + float bytesPSRead=0f; + float bytesPSWrite=0f; if (!checkBox1.Checked || (diskSelectionPFCStr == null)) { @@ -277,7 +277,7 @@ public bool SSDActivityPerfCount() } catch (Exception ex) { - Log.Error("PhysicalDisk->_Total could not captured - Exception here: {exc}", ex); + Log.Error("PhysicalDisk->_Total could not be captured - Exception here: {exc}", ex); return false; } } @@ -295,6 +295,19 @@ public bool SSDActivityPerfCount() } } + //this cases should never happen (but happened probably caused by uninitialized floats bytesPSRead/Write - fixed now) + if (bytesPSRead<0) + { + Log.Error("PhysicalDisk _diskReadCounter was negative:{numb}", bytesPSRead); + return false; + } + + if (bytesPSWrite < 0) + { + Log.Error("PhysicalDisk _diskWriteCounter was negative:{numb}", bytesPSWrite); + return false; + } + //notifyIcon.Text = Math.Round(bytesPSRead / 1024, 2).ToString() + " KB/s read / " + Math.Round(bytesPSWrite / 1024, 2).ToString() + " KB/s write"; Color newColor = CalculateColor(bytesPSRead, bytesPSWrite); @@ -343,6 +356,18 @@ private Color CalculateColor(float bytesPSRead, float bytesPSWrite) scaledKBSRead = scaledKBSRead > 255 ? 255 : scaledKBSRead; scaledKBSWrite = scaledKBSWrite > 255 ? 255 : scaledKBSWrite; + if(scaledKBSRead < 0) + { + scaledKBSRead = 0; + Log.Error("scaledKBSRead < 0 --> {numb}",scaledKBSRead); + } + + if(scaledKBSWrite < 0) + { + scaledKBSWrite = 0; + Log.Error("scaledKBSWrite < 0 --> {numb}", scaledKBSWrite); + } + int R = (int)(((readColor.R / 255f) * scaledKBSRead + (writeColor.R / 255f) * scaledKBSWrite));// / 2); int G = (int)(((readColor.G / 255f) * scaledKBSRead + (writeColor.G / 255f) * scaledKBSWrite));// / 2); diff --git a/SSD-LED/Properties/AssemblyInfo.cs b/SSD-LED/Properties/AssemblyInfo.cs index 0d65761..58f83ea 100644 --- a/SSD-LED/Properties/AssemblyInfo.cs +++ b/SSD-LED/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SSD-LED")] -[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.7.1")] -[assembly: AssemblyFileVersion("1.0.7.1")] +[assembly: AssemblyVersion("1.0.7.5")] +[assembly: AssemblyFileVersion("1.0.7.5")] diff --git a/SSD-LED/SSD-LED.csproj b/SSD-LED/SSD-LED.csproj index b094d10..80834a9 100644 --- a/SSD-LED/SSD-LED.csproj +++ b/SSD-LED/SSD-LED.csproj @@ -24,8 +24,8 @@ false true true - 4 - 1.0.7.4 + 5 + 1.0.7.5 false true true diff --git a/SSD-LED/bin/Release/SSD-LED.exe b/SSD-LED/bin/Release/SSD-LED.exe index eedab157a64da622ebd4a3cfe73d35604e695b53..e2bd6de249ed6e6cce98a4a22cfe229214135298 100644 GIT binary patch delta 5091 zcmbVQ33OG})!t{{;SG7yePa?JWaecg!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