diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index 36f057fd..10c8bfaa 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -603,7 +603,7 @@ public static class ThreadsFunctions if (libraryError.IsError()) ManageLibraryError(libraryError); - MessageServices.Current.Publish(SEND_THERMO_GAUGE_DATA, null, currentLiveProd); + //MessageServices.Current.Publish(SEND_THERMO_GAUGE_DATA, null, currentLiveProd); } else RestoreConnection(); diff --git a/Thermo.Active/Listeners/SignalR/SignalRListener.cs b/Thermo.Active/Listeners/SignalR/SignalRListener.cs index 1f28a167..08eda521 100644 --- a/Thermo.Active/Listeners/SignalR/SignalRListener.cs +++ b/Thermo.Active/Listeners/SignalR/SignalRListener.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading; +using TeamDev.SDK.FluentProgramming; using Thermo.Active.Config; using Thermo.Active.Controllers.SignalR; using Thermo.Active.Model.DTOModels; @@ -250,8 +251,9 @@ namespace Thermo.Active.Listeners.SignalR if (diffData.Count > 0) { - // salvo update - LastRecipeFullData = currRecipeFull; + // salvo update CLONANDO + //LastRecipeFullData = currRecipeFull; + LastRecipeFullData = currRecipeFull.Keys.ToDictionary(_ => _, _ => currRecipeFull[_].Clone()); var context = GlobalHost.ConnectionManager.GetHubContext(); context.Clients.Group("ncData").recipeFullData(diffData); @@ -389,14 +391,45 @@ namespace Thermo.Active.Listeners.SignalR public static void sendThermoGaugeData(object currentLiveProd) { Dictionary currLiveProd = currentLiveProd as Dictionary; + Dictionary diffGaugeData = new Dictionary(); + foreach (var item in currLiveProd) + { + if (!LastLiveProdData.ContainsKey(item.Key)) + { + diffGaugeData.Add(item.Key, item.Value); + } + else + { + // comparazione + if (!item.Value.Equals(LastLiveProdData[item.Key])) + { + diffGaugeData.Add(item.Key, item.Value); + } + } + } + + if (diffGaugeData.Count > 0) + { + // salvo update CLONANDO + //LastLiveProdData = currLiveProd; + LastLiveProdData = currLiveProd.Keys.ToDictionary(_ => _, _ => currLiveProd[_].Clone()); + + var context = GlobalHost.ConnectionManager.GetHubContext(); + context.Clients.Group("ncData").gaugeData(diffGaugeData); + } + + + +#if false if (!LastLiveProdData.Equals(currLiveProd)) { LastLiveProdData = currLiveProd; var context = GlobalHost.ConnectionManager.GetHubContext(); context.Clients.Group("ncData").gaugeData(currLiveProd); - } + } +#endif } public static void SendThermoProdPanelData(object prodPanelData) { @@ -438,31 +471,30 @@ namespace Thermo.Active.Listeners.SignalR public static void SendThermoAxisInfoData(object axisInfoData) { Dictionary currInfoAxes = axisInfoData as Dictionary; - Dictionary diffData = new Dictionary(); + Dictionary diffAxisData = new Dictionary(); foreach (var item in currInfoAxes) { if (!LastAxisInfoData.ContainsKey(item.Key)) { - diffData.Add(item.Key, item.Value); + diffAxisData.Add(item.Key, item.Value); } else { // comparazione if (!item.Value.Equals(LastAxisInfoData[item.Key])) { - diffData.Add(item.Key, item.Value); + diffAxisData.Add(item.Key, item.Value); } } } // se ho differenze invio! - if (diffData.Count > 0) + if (diffAxisData.Count > 0) { - // salvo update - LastAxisInfoData = currInfoAxes; - + // salvo update CLONANDO + LastAxisInfoData= currInfoAxes.Keys.ToDictionary(_ => _, _ => currInfoAxes[_].Clone()); var context = GlobalHost.ConnectionManager.GetHubContext(); - context.Clients.Group("ncData").axisInfo(diffData); + context.Clients.Group("ncData").axisInfo(diffAxisData); } }