Skip to content

Commit

Permalink
Add power classes in diagnostic message
Browse files Browse the repository at this point in the history
  • Loading branch information
arkypita committed Aug 9, 2023
1 parent c0b1dce commit e513d69
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion LaserGRBL/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
28 changes: 24 additions & 4 deletions LaserGRBL/Core/GrblCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
};
Expand Down Expand Up @@ -4176,8 +4176,23 @@ private static string BuildJson(List<LaserLifeCounter> 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(" } ");
Expand All @@ -4191,7 +4206,12 @@ private static string BuildJson(List<LaserLifeCounter> 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
Expand Down
2 changes: 1 addition & 1 deletion setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e513d69

Please sign in to comment.