From 3dd81652b5a9e02ae6dae168aeafe1ffb3d69c4d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 4 Nov 2020 09:23:55 +0100 Subject: [PATCH 1/2] Fix richiesta warmers SEMPRE senza cache --- Thermo.Active.Core/ThreadsFunctions.cs | 12 +++++++++--- .../Controllers/WebApi/WarmersController.cs | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index 26c4fb77..402deef1 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -1208,7 +1208,9 @@ public static class ThreadsFunctions if (libraryError.errorCode != 0) ManageLibraryError(libraryError); - int readCount = 0; +#if false + int readCount = 0; +#endif bool useCache = false; while (true) { @@ -1217,17 +1219,21 @@ public static class ThreadsFunctions // Check if client is connected if (ncAdapter.numericalControl.NC_IsConnected()) { +#if false // every 10 reads all data... - useCache = (readCount != 0); + useCache = (readCount != 0); +#endif // Get new data from PLC libraryError = ncAdapter.ReadWarmers(useCache, out Dictionary currWarmers); if (libraryError.IsError()) ManageLibraryError(libraryError); // pubblico MessageServices.Current.Publish(SEND_THERMO_WARMERS_DATA, null, currWarmers); +#if false readCount++; // ciclo resettato ogni 20 - readCount = readCount % 20; + readCount = readCount % 20; +#endif } else RestoreConnection(); diff --git a/Thermo.Active/Controllers/WebApi/WarmersController.cs b/Thermo.Active/Controllers/WebApi/WarmersController.cs index 1d03c5aa..e64c37bc 100644 --- a/Thermo.Active/Controllers/WebApi/WarmersController.cs +++ b/Thermo.Active/Controllers/WebApi/WarmersController.cs @@ -367,7 +367,7 @@ namespace Thermo.Active.Controllers.WebApi } // recupero valori attuali - libraryError = ncAdapter.ReadWarmers(true, out Dictionary currWarmers); + libraryError = ncAdapter.ReadWarmers(false, out Dictionary currWarmers); if (libraryError.IsError()) { ThermoActiveLogger.LogError($"SimReqFlirImg | GetRecipeOverview error | {libraryError.exception}"); From 7576b33e9370e9b32ff8cd55568777992f5d9b47 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 4 Nov 2020 10:04:57 +0100 Subject: [PATCH 2/2] update conf x gestione cache warmers --- Thermo.Active.Core/Thermo.Active.Core.csproj | 1 + Thermo.Active.Core/ThreadsFunctions.cs | 35 +++++++++++++------- Thermo.Active/App.config | 1 + 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Thermo.Active.Core/Thermo.Active.Core.csproj b/Thermo.Active.Core/Thermo.Active.Core.csproj index 04c4829d..cefca42b 100644 --- a/Thermo.Active.Core/Thermo.Active.Core.csproj +++ b/Thermo.Active.Core/Thermo.Active.Core.csproj @@ -33,6 +33,7 @@ + diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index 402deef1..211a283c 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -29,6 +29,7 @@ using static Thermo.Active.Model.Constants; using static Thermo.Active.Utils.ExceptionManager; using System.Windows; using System.Drawing; +using System.Configuration; public static class ThreadsFunctions { @@ -1196,6 +1197,19 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } + /// + /// Swap x/y requesto from FLIR camera + /// + internal static bool cacheWarmers + { + get + { + bool answ = false; + bool.TryParse(ConfigurationManager.AppSettings["cacheWarmers"], out answ); + return answ; + } + } + public static void ReadWarmersData() { @@ -1208,9 +1222,7 @@ public static class ThreadsFunctions if (libraryError.errorCode != 0) ManageLibraryError(libraryError); -#if false - int readCount = 0; -#endif + int readCount = 0; bool useCache = false; while (true) { @@ -1219,21 +1231,20 @@ public static class ThreadsFunctions // Check if client is connected if (ncAdapter.numericalControl.NC_IsConnected()) { -#if false - // every 10 reads all data... - useCache = (readCount != 0); -#endif + if (cacheWarmers) + { + // every 10 reads all data... + useCache = (readCount != 0); + readCount++; + // ciclo resettato ogni 20 + readCount = readCount % 20; + } // Get new data from PLC libraryError = ncAdapter.ReadWarmers(useCache, out Dictionary currWarmers); if (libraryError.IsError()) ManageLibraryError(libraryError); // pubblico MessageServices.Current.Publish(SEND_THERMO_WARMERS_DATA, null, currWarmers); -#if false - readCount++; - // ciclo resettato ogni 20 - readCount = readCount % 20; -#endif } else RestoreConnection(); diff --git a/Thermo.Active/App.config b/Thermo.Active/App.config index ecf5c46a..9f914b44 100644 --- a/Thermo.Active/App.config +++ b/Thermo.Active/App.config @@ -18,6 +18,7 @@ +