Added overview real calculation

This commit is contained in:
Samuele Locatelli
2020-06-05 19:38:30 +02:00
parent c28c77bec9
commit 9798b5a993
2 changed files with 35 additions and 22 deletions
+35 -20
View File
@@ -1621,15 +1621,14 @@ namespace Thermo.Active.NC
CmsError cmsError = NO_ERROR;
currOverview = new Dictionary<string, RecipeCatStatus>();
// !!!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<string, DTORecipeParam>();
cmsError = ReadFullRecipe(out currRecipe);
if (cmsError.IsError())
return cmsError;
// calcolo x categoria!
// leggo l'intero array delle DB... QUI FAKE sulle DB configurate...
List<DTORecipeConfigModel> 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
@@ -54,8 +54,6 @@ namespace Thermo.Active.Controllers.WebApi
}
}
[Route("update"), HttpPut]
public IHttpActionResult WriteParameters(Dictionary<string, double> parametersList)
{