From e513d697148a78a8d54050c2ea21e8f3eb88a2e9 Mon Sep 17 00:00:00 2001 From: arkypita Date: Wed, 9 Aug 2023 19:39:39 +0200 Subject: [PATCH] Add power classes in diagnostic message --- LaserGRBL/AssemblyInfo.cs | 2 +- LaserGRBL/Core/GrblCore.cs | 28 ++++++++++++++++++++++++---- setup.iss | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/LaserGRBL/AssemblyInfo.cs b/LaserGRBL/AssemblyInfo.cs index 56a367c3..1bb6a01a 100644 --- a/LaserGRBL/AssemblyInfo.cs +++ b/LaserGRBL/AssemblyInfo.cs @@ -31,5 +31,5 @@ // È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build // utilizzando l'asterisco (*) come descritto di seguito: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion ("5.3.0")] +[assembly: AssemblyVersion ("5.4.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/LaserGRBL/Core/GrblCore.cs b/LaserGRBL/Core/GrblCore.cs index 60203d40..acf46098 100644 --- a/LaserGRBL/Core/GrblCore.cs +++ b/LaserGRBL/Core/GrblCore.cs @@ -4132,7 +4132,7 @@ private static void RealDoSend(object state) { System.Collections.Specialized.NameValueCollection postData = new System.Collections.Specialized.NameValueCollection() { - { "version" , "1" }, + { "version" , "2" }, { "guid", UsageStats.GetID() }, { "data", BuildJson(tosave) }, }; @@ -4176,8 +4176,23 @@ private static string BuildJson(List tosend) sb.Append($"\"LastUsage\": {EscapeJson(LLC.LastUsage?.ToString("yyyy-MM-dd HH:mm:ss"))},"); sb.Append($"\"TimeInRun\": {EscapeJson(LLC.TimeInRun.TotalHours)},"); sb.Append($"\"TimeUsageNormalizedPower\": {EscapeJson(LLC.TimeUsageNormalizedPower.TotalHours)},"); - sb.Append($"\"StressTime\": {EscapeJson(LLC.StressTime.TotalHours)},"); - sb.Append($"\"AveragePowerFactor\": {EscapeJson(LLC.AveragePowerFactor)}"); + sb.Append($"\"AveragePowerFactor\": {EscapeJson(LLC.AveragePowerFactor)},"); + + sb.Append($"\"Classes\": "); + { + sb.Append("{ "); + + for (int j = 0; j < LLC.Classes.Length; j++) + { + sb.Append($"{LLC.Classes[j].TotalHours.ToString("0.000", NumberFormatInfo.InvariantInfo)}"); + + if (j == LLC.Classes.Length - 1) //ultimo + sb.Append(" } "); + else + sb.Append(", "); + + } + } if (i == tosend.Count - 1) //ultimo sb.Append(" } "); @@ -4191,7 +4206,12 @@ private static string BuildJson(List tosend) static string EscapeJson(object o) { - return HttpUtility.JavaScriptStringEncode(o != null ? o.ToString() : "", true); + if (o is double?) + return $"\"{(o as double?).GetValueOrDefault().ToString("0.000", NumberFormatInfo.InvariantInfo)}\""; + else if (o is double) + return $"\"{((double)o).ToString("0.000", NumberFormatInfo.InvariantInfo)}\""; + else + return HttpUtility.JavaScriptStringEncode(o != null ? o.ToString() : "", true); } public class RealDoSendRV diff --git a/setup.iss b/setup.iss index 2aba72fb..24961d08 100644 --- a/setup.iss +++ b/setup.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "LaserGRBL" -#define MyAppVersion "5.3.0" +#define MyAppVersion "5.4.0" #define MyAppVersionName "Rhydon" #define MyAppPublisher "LaserGRBL" #define MyAppURL "https://lasergrbl.com"