From 9798b5a993a1e2a9b74f96a5d5fd69db4643bcbc Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 5 Jun 2020 19:38:30 +0200 Subject: [PATCH] Added overview real calculation --- Thermo.Active.NC/NcAdapter.cs | 55 ++++++++++++------- .../Controllers/WebApi/RecipeController.cs | 2 - 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index 9efc234e..c7b4fdd2 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -1621,15 +1621,14 @@ namespace Thermo.Active.NC CmsError cmsError = NO_ERROR; currOverview = new Dictionary(); - // !!!FARE davvero!!! -#if false - // gestione errore - cmsError = ReadScadaData(schema, out currParam); - if (cmsError.IsError()) - return cmsError; -#endif - // calcolo! + // leggo la ricetta! + var currRecipe = new Dictionary(); + cmsError = ReadFullRecipe(out currRecipe); + if (cmsError.IsError()) + return cmsError; + + // calcolo x categoria! // leggo l'intero array delle DB... QUI FAKE sulle DB configurate... List recipeConfig = RecipeConfig.Select(x => new DTORecipeConfigModel() @@ -1645,34 +1644,50 @@ namespace Thermo.Active.NC }).ToList(); RecipeCatStatus currStatus = RecipeCatStatus.Unchanged; - int countCat = 0; + + // percorro conf ricetta... foreach (var item in recipeConfig) { - // ogni 20 incremento... - if (countCat < 20) + // cerco SE ci sia già uno status... + if (currOverview.ContainsKey(item.Category)) { - currStatus = RecipeCatStatus.Unchanged; - } - else if (countCat < 40) - { - currStatus = RecipeCatStatus.ChangedOk; + currStatus = currOverview[item.Category]; } else { - currStatus = RecipeCatStatus.HasError; + currStatus = RecipeCatStatus.Unchanged; } - // se non c'è aggiungo + + // se lo stato è errore --> esco... + if (currStatus == RecipeCatStatus.HasError) + { + continue; + } + // altrimenti controllo + else + { + // se in errore --> registro... + if (currRecipe[item.Label].Status.HasError) + { + currStatus = RecipeCatStatus.HasError; + } + // FARE verificare il significato di questo changed (se è da file o da HMI/PLC) + else if (currRecipe[item.Label].SetpointHMI != currRecipe[item.Label].SetpointPLC) + { + currStatus = RecipeCatStatus.ChangedOk; + } + } + + // ora verifico overview finale: se non c'è aggiungo if (!currOverview.ContainsKey(item.Category)) { currOverview.Add(item.Category, currStatus); - countCat = 0; } else { // se il valore è maggiore --> aggiorno currOverview[item.Category] = (int)currStatus > (int)currOverview[item.Category] ? currStatus : currOverview[item.Category]; } - countCat++; } // restituisco cod errore se trovato diff --git a/Thermo.Active/Controllers/WebApi/RecipeController.cs b/Thermo.Active/Controllers/WebApi/RecipeController.cs index 92614144..6c26cf03 100644 --- a/Thermo.Active/Controllers/WebApi/RecipeController.cs +++ b/Thermo.Active/Controllers/WebApi/RecipeController.cs @@ -54,8 +54,6 @@ namespace Thermo.Active.Controllers.WebApi } } - - [Route("update"), HttpPut] public IHttpActionResult WriteParameters(Dictionary parametersList) {