Fix errata duplicazione invio dati assi, fix anche x GAUGES e dati ricetta

This commit is contained in:
Samuele Locatelli
2020-09-23 23:24:19 +02:00
parent 216980b923
commit f13cadd145
2 changed files with 44 additions and 12 deletions
+1 -1
View File
@@ -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();
@@ -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<NcHub>();
context.Clients.Group("ncData").recipeFullData(diffData);
@@ -389,14 +391,45 @@ namespace Thermo.Active.Listeners.SignalR
public static void sendThermoGaugeData(object currentLiveProd)
{
Dictionary<string, DTOThermoProd> currLiveProd = currentLiveProd as Dictionary<string, DTOThermoProd>;
Dictionary<string, DTOThermoProd> diffGaugeData = new Dictionary<string, DTOThermoProd>();
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<NcHub>();
context.Clients.Group("ncData").gaugeData(diffGaugeData);
}
#if false
if (!LastLiveProdData.Equals(currLiveProd))
{
LastLiveProdData = currLiveProd;
var context = GlobalHost.ConnectionManager.GetHubContext<NcHub>();
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<int, DTOAxisInfoModel> currInfoAxes = axisInfoData as Dictionary<int, DTOAxisInfoModel>;
Dictionary<int, DTOAxisInfoModel> diffData = new Dictionary<int, DTOAxisInfoModel>();
Dictionary<int, DTOAxisInfoModel> diffAxisData = new Dictionary<int, DTOAxisInfoModel>();
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<NcHub>();
context.Clients.Group("ncData").axisInfo(diffData);
context.Clients.Group("ncData").axisInfo(diffAxisData);
}
}