diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index 3e7f0ca2..3bba3582 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -763,6 +763,18 @@ public static class ThreadsFunctions }; MessageServices.Current.Publish(SEND_THERMO_RECIPE_CHANGED, null, message); + + // verifico se dal PLC è segnalato che i setpointHMI sono invalidati, nel qual caso INVIO + bool setpointHmiInvalidated = false; + libraryError = ncAdapter.checkSetpointInvalidated(out setpointHmiInvalidated); + if (setpointHmiInvalidated) + { + // pubblico booleana dei setpointHMI invalidati + MessageServices.Current.Publish(SEND_THERMO_RECIPE_SETPOINTHMI_CHANGED, null, setpointHmiInvalidated); + // ora gestisco l'ack della richiesta + libraryError = ncAdapter.doAckSetpointInvalidated(); + } + } else RestoreConnection(); diff --git a/Thermo.Active.Model/Constants.cs b/Thermo.Active.Model/Constants.cs index 85cd6b0b..686c8649 100644 --- a/Thermo.Active.Model/Constants.cs +++ b/Thermo.Active.Model/Constants.cs @@ -327,6 +327,7 @@ namespace Thermo.Active.Model public const string SEND_THERMO_RECIPE_FULL = "SEND_THERMO_RECIPE_FULL"; public const string SEND_THERMO_RECIPE_OVERWIEW = "SEND_THERMO_RECIPE_OVERWIEW"; public const string SEND_THERMO_RECIPE_CHANGED = "SEND_THERMO_RECIPE_CHANGED"; + public const string SEND_THERMO_RECIPE_SETPOINTHMI_CHANGED = "SEND_THERMO_RECIPE_SETPOINTHMI_CHANGED"; public const string SEND_THERMO_MODULE_DATA = "SEND_THERMO_MODULE_DATA"; public const string SEND_THERMO_WARMERS_DATA = "SEND_THERMO_WARMERS_DATA"; public const string SEND_THERMO_AREA_DATA = "SEND_THERMO_AREA_DATA"; diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index 8cfd783d..7f4778e4 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -272,7 +272,7 @@ namespace Thermo.Active.NC return answ; } } - private static bool ThermoParamHmiInvalidated + private static bool ThermoSetpointHmiInvalidated { get { @@ -1358,7 +1358,19 @@ namespace Thermo.Active.NC } - public CmsError WriteM154Ack(int processId) + public CmsError checkSetpointInvalidated(out bool setpointHmiInvalidated) + { + setpointHmiInvalidated = ThermoSetpointHmiInvalidated; + return NO_ERROR; + } + + public CmsError doAckSetpointInvalidated() + { + numericalControl.PLC_WAckSetpointInvalidated(); + return NO_ERROR; + } + + public CmsError WriteM154Ack(int processId) { return numericalControl.PLC_W154ManageAck(processId); } diff --git a/Thermo.Active/Listeners/ListenersHandler.cs b/Thermo.Active/Listeners/ListenersHandler.cs index 69fd6509..ec75eaa5 100644 --- a/Thermo.Active/Listeners/ListenersHandler.cs +++ b/Thermo.Active/Listeners/ListenersHandler.cs @@ -100,6 +100,10 @@ namespace Thermo.Active.Listeners { SignalRListener.SendThermoRecipeChangedData(a); })); + infos.Add(MessageServices.Current.Subscribe(SEND_THERMO_RECIPE_SETPOINTHMI_CHANGED, (a, b) => + { + SignalRListener.SendThermoSetpointHmiInvalidated(a); + })); infos.Add(MessageServices.Current.Subscribe(SEND_THERMO_MODULE_DATA, (a, b) => { SignalRListener.SendThermoModulesData(a); diff --git a/Thermo.Active/Listeners/SignalR/SignalRListener.cs b/Thermo.Active/Listeners/SignalR/SignalRListener.cs index 54119fbc..330a6e7a 100644 --- a/Thermo.Active/Listeners/SignalR/SignalRListener.cs +++ b/Thermo.Active/Listeners/SignalR/SignalRListener.cs @@ -299,6 +299,21 @@ namespace Thermo.Active.Listeners.SignalR context.Clients.Group("ncData").recipeChangedData(currMessage); } } + + public static void SendThermoSetpointHmiInvalidated(object message) + { + bool currMessage = false; + bool.TryParse(message.ToString(), out currMessage); + if (lastSetpointHmiInvalid == null || currMessage != lastSetpointHmiInvalid) + { + // salvo update + lastSetpointHmiInvalid = currMessage; + var context = GlobalHost.ConnectionManager.GetHubContext(); + context.Clients.Group("ncData").setpointHmiInvalid(currMessage); + } + } + + public static void SendThermoModulesData(object modules) { Dictionary currModules = modules as Dictionary; @@ -477,7 +492,7 @@ namespace Thermo.Active.Listeners.SignalR if (diffAxisData.Count > 0) { // salvo update CLONANDO - LastAxisInfoData= currInfoAxes.Keys.ToDictionary(_ => _, _ => currInfoAxes[_].Clone()); + LastAxisInfoData = currInfoAxes.Keys.ToDictionary(_ => _, _ => currInfoAxes[_].Clone()); var context = GlobalHost.ConnectionManager.GetHubContext(); context.Clients.Group("ncData").axisInfo(diffAxisData); } @@ -549,6 +564,7 @@ namespace Thermo.Active.Listeners.SignalR // Send THERMO Recipe data group.recipeFullData(LastRecipeFullData); group.recipeOverData(LastRecipeOverData); + group.setpointHmiInvalid(); // Send THERMO Modules data group.modulesData(LastModulesData); // Send THERMO Warmers data diff --git a/Thermo.Active/Listeners/SignalRStaticObjects.cs b/Thermo.Active/Listeners/SignalRStaticObjects.cs index 3ed9fb28..df07bf23 100644 --- a/Thermo.Active/Listeners/SignalRStaticObjects.cs +++ b/Thermo.Active/Listeners/SignalRStaticObjects.cs @@ -35,6 +35,7 @@ namespace Thermo.Active.Listeners // Oggetti specifici per THERMO (1° definizione) public static Dictionary LastRecipeFullData = new Dictionary(); public static Dictionary LastRecipeOverData = new Dictionary(); + public static bool? lastSetpointHmiInvalid = null; public static bool? recipeHasChanged = null; public static Dictionary LastModulesData = new Dictionary(); public static Dictionary LastWarmersData = new Dictionary();