Draft for new overview calculation (to be checked)

This commit is contained in:
Samuele Locatelli
2020-06-24 19:14:59 +02:00
parent 1dd83f4e17
commit 4ea2cebfeb
3 changed files with 63 additions and 6 deletions
+34 -5
View File
@@ -1891,6 +1891,7 @@ namespace Thermo.Active.NC
public CmsError GetRecipeOverview(out Dictionary<string, RecipeCatStatus> currOverview)
{
CmsError libraryError = NO_ERROR;
// overview di base: ultima salvata...
currOverview = new Dictionary<string, RecipeCatStatus>();
// leggo la ricetta!
@@ -1915,15 +1916,36 @@ namespace Thermo.Active.NC
RecipeCatStatus currStatus = RecipeCatStatus.Unchanged;
// percorro conf ricetta...
// da conf ricetta --> verifico dati LIVE ricetta e se mancassero imposto unchanged..
currOverview = NcFileAdapter.RecipeLiveData.RecipeOverview;
bool changed = false;
foreach (var item in recipeConfig)
{
if (!currOverview.ContainsKey(item.Category))
{
currOverview.Add(item.Category, RecipeCatStatus.Unchanged);
changed = true;
}
}
// se cambiato --> salvo!
if (changed)
{
NcFileAdapter.RecipeLiveData.RecipeOverview = currOverview;
}
// ORA percorro conf ricetta x cercare eventuali ERRORI......
foreach (var item in recipeConfig)
{
#if false
currStatus = RecipeCatStatus.Unchanged;
// cerco SE ci sia già uno status...
if (currOverview.ContainsKey(item.Category))
{
currStatus = currOverview[item.Category];
}
}
#endif
currStatus = currOverview[item.Category];
// se lo stato è errore --> esco...
if (currStatus == RecipeCatStatus.HasError)
@@ -1936,8 +1958,12 @@ namespace Thermo.Active.NC
// se in errore --> registro...
if (currRecipe[item.Label].Status.HasError)
{
currStatus = RecipeCatStatus.HasError;
#if false
currStatus = RecipeCatStatus.HasError;
#endif
currOverview[item.Category] = RecipeCatStatus.HasError;
}
#if false
// FARE verificare il significato di questo changed (se è da file o da HMI/PLC)
else if (currRecipe[item.Label].SetpointHMI != currRecipe[item.Label].SetpointPLC)
{
@@ -1946,9 +1972,11 @@ namespace Thermo.Active.NC
else
{
currStatus = RecipeCatStatus.Unchanged;
}
}
#endif
}
#if false
// ora verifico overview finale: se non c'è aggiungo
if (!currOverview.ContainsKey(item.Category))
{
@@ -1958,7 +1986,8 @@ namespace Thermo.Active.NC
{
// se il valore è maggiore --> aggiorno
currOverview[item.Category] = (int)currStatus > (int)currOverview[item.Category] ? currStatus : currOverview[item.Category];
}
}
#endif
}
// restituisco cod errore se trovato
+16
View File
@@ -594,6 +594,22 @@ namespace Thermo.Active.NC
#region recipe file persistence
/// <summary>
/// Upsert recipe overview status
/// </summary>
/// <param name="section"></param>
/// <param name="status"></param>
public static void upsRecipeOverview(string section, RecipeCatStatus status)
{
if (RecipeLiveData.RecipeOverview.ContainsKey(section))
{
RecipeLiveData.RecipeOverview[section] = status;
}
else
{
RecipeLiveData.RecipeOverview.Add(section, status);
}
}
public static void ReadLastRecipe()
{
@@ -61,7 +61,7 @@ namespace Thermo.Active.Controllers.WebApi
}
[Route("update"), HttpPut]
public IHttpActionResult WriteParameters(Dictionary<string, double> parametersList)
public IHttpActionResult WriteParameters(Dictionary<string, double> parametersList, string section)
{
if (parametersList != null)
{
@@ -104,6 +104,18 @@ namespace Thermo.Active.Controllers.WebApi
// scrivo sul PLC
ncAdapter.WriteRecipeParams(updtRecipe);
// SE HO una section != null/empty --> salvo come modificata...
if (!string.IsNullOrEmpty(section))
{
try
{
NcFileAdapter.upsRecipeOverview(section, RecipeCatStatus.ChangedOk);
}
catch (Exception exc)
{
ThermoActiveLogger.LogError($"Error on set recipe overview | section: {section}{Environment.NewLine}{exc}");
}
}
// ritorno solo fatto!
return Ok();
}