From 188ce800e8b8bad1a36f10bb4f3242949e1ea188 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 22 Sep 2020 11:16:47 +0200 Subject: [PATCH] FIx gestione starred "sovrascritta" in canceledit --- .../DTOModels/ThRecipe/DTORecipeStatus.cs | 1 + Thermo.Active.NC/NcFileAdapter.cs | 4 +--- .../Controllers/WebApi/RecipeController.cs | 24 +++++++++++-------- .../Listeners/SignalR/SignalRListener.cs | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Thermo.Active.Model/DTOModels/ThRecipe/DTORecipeStatus.cs b/Thermo.Active.Model/DTOModels/ThRecipe/DTORecipeStatus.cs index 891a6030..89443848 100644 --- a/Thermo.Active.Model/DTOModels/ThRecipe/DTORecipeStatus.cs +++ b/Thermo.Active.Model/DTOModels/ThRecipe/DTORecipeStatus.cs @@ -10,5 +10,6 @@ namespace Thermo.Active.Model.DTOModels.ThRecipe { public string recipeName { get; set; } = ""; public bool hasChanged { get; set; } = false; + public bool forceSend { get; set; } = false; } } diff --git a/Thermo.Active.NC/NcFileAdapter.cs b/Thermo.Active.NC/NcFileAdapter.cs index ba3c8de4..b95d5583 100644 --- a/Thermo.Active.NC/NcFileAdapter.cs +++ b/Thermo.Active.NC/NcFileAdapter.cs @@ -762,8 +762,6 @@ namespace Thermo.Active.NC bool answ = false; try { - // indico che ora รจ OK x salvataggio... - RecipeLiveData.hasChanged = false; // serialize string rawData = JsonConvert.SerializeObject(RecipeLiveData, Newtonsoft.Json.Formatting.Indented); // save live! @@ -839,7 +837,7 @@ namespace Thermo.Active.NC return SaveRecipe(RECIPE_TEMPLATE_PATH, data2save); } /// - /// Try to save live recipe to selected filePath + /// Try to save LIVE recipe to selected filePath /// public static bool SaveRecipe(string filePath, LiveData currRecipe) { diff --git a/Thermo.Active/Controllers/WebApi/RecipeController.cs b/Thermo.Active/Controllers/WebApi/RecipeController.cs index 8d0c7f24..92dcbbfd 100644 --- a/Thermo.Active/Controllers/WebApi/RecipeController.cs +++ b/Thermo.Active/Controllers/WebApi/RecipeController.cs @@ -204,7 +204,8 @@ namespace Thermo.Active.Controllers.WebApi currParams.Add(item.Key, item.Value.SetpointHMI); } - SaveCurrentRecipeParams(currParams); + // salvo ricetta LIVE + SaveLiveRecipeParams(currParams); // ritorno solo fatto! return Ok(); @@ -258,7 +259,7 @@ namespace Thermo.Active.Controllers.WebApi } // ora salvo ANCHE i dati live... - SaveCurrentRecipeParams(currParams); + SaveLiveRecipeParams(currParams); // ritorno solo fatto! return Ok(); @@ -367,7 +368,7 @@ namespace Thermo.Active.Controllers.WebApi NcFileAdapter.SaveRecipe($"{NcAdapter.RecipeLiveData.RecipeDir}{NcAdapter.RecipeLiveData.RecipeName}", NcAdapter.RecipeLiveData); // ora salvo ANCHE i dati live... - SaveCurrentRecipeParams(currParams); + SaveLiveRecipeParams(currParams); // ritorno solo fatto! return Ok(); @@ -412,19 +413,22 @@ namespace Thermo.Active.Controllers.WebApi // e salvo su disco NcFileAdapter.SaveRecipe(newName, NcAdapter.RecipeLiveData); - // invio copme modificata + // invio PRIMA invertendo campo modificata (x forzare invio) DTORecipeStatus message = new DTORecipeStatus() { recipeName = NcAdapter.RecipeLiveData.RecipeName, - hasChanged = true + hasChanged = NcAdapter.RecipeLiveData.hasChanged, + forceSend = true }; MessageServices.Current.Publish(SEND_THERMO_RECIPE_CHANGED, null, message); - System.Threading.Thread.Sleep(200); - - // ora mando vero valore +#if false + // attesa 100ms + System.Threading.Thread.Sleep(100); + // ora mando vero valore modificata! message.hasChanged = NcAdapter.RecipeLiveData.hasChanged; - MessageServices.Current.Publish(SEND_THERMO_RECIPE_CHANGED, null, message); + MessageServices.Current.Publish(SEND_THERMO_RECIPE_CHANGED, null, message); +#endif // ritorno solo fatto! return Ok(); @@ -600,7 +604,7 @@ namespace Thermo.Active.Controllers.WebApi /// Do actual recipe parameters FileSave /// /// - private static void SaveCurrentRecipeParams(Dictionary currParams) + private static void SaveLiveRecipeParams(Dictionary currParams) { try { diff --git a/Thermo.Active/Listeners/SignalR/SignalRListener.cs b/Thermo.Active/Listeners/SignalR/SignalRListener.cs index 8a0fc64f..d191e96d 100644 --- a/Thermo.Active/Listeners/SignalR/SignalRListener.cs +++ b/Thermo.Active/Listeners/SignalR/SignalRListener.cs @@ -310,7 +310,7 @@ namespace Thermo.Active.Listeners.SignalR { DTORecipeStatus currMessage = message as DTORecipeStatus; - if (currMessage.hasChanged != recipeHasChanged) + if (currMessage.hasChanged != recipeHasChanged || currMessage.forceSend) { // salvo update recipeHasChanged = currMessage.hasChanged;