Fix load Recipe

This commit is contained in:
Thermo_SIM
2021-03-26 18:10:32 +01:00
parent 44415f41ee
commit 2feb30bef6
4 changed files with 27 additions and 7 deletions
+13
View File
@@ -50,6 +50,7 @@ public static class ThreadsFunctions
public static int recipeRtCounter = 0;
public static bool reconnectionIsRunning = false;
public static bool forcetakeSnapshot = false;
public static bool ReloadAfterLoad = false;
#endregion Public Fields
@@ -1382,6 +1383,13 @@ public static class ThreadsFunctions
if (libraryError.errorCode != 0)
ManageLibraryError(libraryError);
MessageServices.Current.Subscribe(RECIPE_LOADED, (a, b) =>
{
ReloadAfterLoad = true;
recipeRtCounter = 0;
});
while (true)
{
// ogni n counter leggo anche dati NON RT
@@ -1426,6 +1434,11 @@ public static class ThreadsFunctions
// ora gestisco l'ack della richiesta
libraryError = ncAdapter.doAckSetpointInvalidated();
}
if(ReloadAfterLoad)
{
ReloadAfterLoad = false;
setpointHmiInvalidated = true;
}
// pubblico booleana dei setpointHMI invalidati
MessageServices.Current.Publish(SEND_THERMO_RECIPE_SETPOINTHMI_CHANGED, null, setpointHmiInvalidated);
}
+1
View File
@@ -143,6 +143,7 @@ namespace Thermo.Active.Model
public const string SEND_THERMO_WARMERS_DATA = "SEND_THERMO_WARMERS_DATA";
public const string SEND_THREADS_STATUS = "THREAD_STATUS";
public const string SEND_USER_SOFTKEYS_DATA = "SEND_USER_SOFTKEYS_DATA";
public const string RECIPE_LOADED = "RECIPE_LOADED";
// Names in the xml file
public const string SERVER_CONFIG_KEY = "serverConfig";
+7 -6
View File
@@ -724,7 +724,6 @@ namespace Thermo.Active.NC
// check filePath...
if (File.Exists(RECIPE_TEMPLATE_PATH))
{
answ = true;
// load all text data
var rawData = File.ReadAllText(RECIPE_TEMPLATE_PATH);
@@ -737,18 +736,20 @@ namespace Thermo.Active.NC
// fix Modifica dati
RecipeLiveData.hasChanged = false;
// from template --> reset (if present) overview data...
if (RecipeLiveData.RecipeOverview != null)
/*if (RecipeLiveData.RecipeOverview != null)
{
foreach (var item in RecipeLiveData.RecipeOverview)
{
RecipeLiveData.RecipeOverview[item.Key] = RecipeCatStatus.Unchanged;
}
}
}*/
// update NAME
RecipeLiveData.RecipeName = $"{DateTime.Now:yyyyMMss_HHmmss}.json";
RecipeLiveData.RecipeName = $"NEW_RECIPE_{DateTime.Now:HH_mm_ss}";
answ = true;
}
catch
{ }
catch(Exception e)
{ return answ; }
// update current live data!
SaveRecipeCurrent();
}
@@ -7,6 +7,7 @@ using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
@@ -140,7 +141,8 @@ namespace Thermo.Active.Controllers.WebApi
var originalRecipe = NcFileAdapter.LoadRecipe($"{NcAdapter.RecipeLiveData.RecipeDir}{NcAdapter.RecipeLiveData.RecipeName}");
// comparazione parametri...
bool isEqual = false;
ncAdapter.paramsComparer(originalRecipe.RecipeParameters, NcAdapter.RecipeLiveData.RecipeParameters, out isEqual);
if(originalRecipe != null)
ncAdapter.paramsComparer(originalRecipe.RecipeParameters, NcAdapter.RecipeLiveData.RecipeParameters, out isEqual);
// salvo se la ricetta SIA cambiata
NcAdapter.RecipeLiveData.hasChanged = !isEqual;
@@ -323,6 +325,7 @@ namespace Thermo.Active.Controllers.WebApi
notifyHmi();
// Get new data from PLC
/*
libraryError = ncAdapter.ReadWarmers(false, out Dictionary<int, DTOWarmers> currWarmers);
if (libraryError.IsError())
{
@@ -331,6 +334,8 @@ namespace Thermo.Active.Controllers.WebApi
}
// pubblico
MessageServices.Current.Publish(SEND_THERMO_WARMERS_DATA, null, currWarmers);
*/
MessageServices.Current.Publish(RECIPE_LOADED, null);
// ritorno solo fatto!
return Ok();