From 45505d70e184f00ada043b65ac10aa20d4a998fe Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 3 Nov 2020 17:19:46 +0100 Subject: [PATCH 1/2] new rel --- Thermo.Active/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs index 63d59523..244026a6 100644 --- a/Thermo.Active/Properties/AssemblyInfo.cs +++ b/Thermo.Active/Properties/AssemblyInfo.cs @@ -30,4 +30,4 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.110.143")] \ No newline at end of file +[assembly: AssemblyVersion("0.110.144")] \ No newline at end of file From fa3916c2a4a35a50a310e0216c6a2e60fbe6788f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 3 Nov 2020 19:10:59 +0100 Subject: [PATCH 2/2] Update metodi cancel/confirm x ricetta... --- .../Controllers/WebApi/RecipeController.cs | 2 +- .../Controllers/WebApi/WarmersController.cs | 310 ++++++++++-------- 2 files changed, 179 insertions(+), 133 deletions(-) diff --git a/Thermo.Active/Controllers/WebApi/RecipeController.cs b/Thermo.Active/Controllers/WebApi/RecipeController.cs index b22283d4..ab7b5ef2 100644 --- a/Thermo.Active/Controllers/WebApi/RecipeController.cs +++ b/Thermo.Active/Controllers/WebApi/RecipeController.cs @@ -672,7 +672,7 @@ namespace Thermo.Active.Controllers.WebApi libraryError = ncAdapter.ReadWarmers(false, out Dictionary currWarmers); if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"Load error | ReadWarmers | {libraryError.errorCode} | {libraryError.exception} | {libraryError.localizationKey}"); + ThermoActiveLogger.LogError($"Load error | ReadWarmers | {libraryError.errorCode} | {libraryError.exception} | {libraryError.localizationKey}"); return libraryError; } // pubblico diff --git a/Thermo.Active/Controllers/WebApi/WarmersController.cs b/Thermo.Active/Controllers/WebApi/WarmersController.cs index 99a605e7..1d03c5aa 100644 --- a/Thermo.Active/Controllers/WebApi/WarmersController.cs +++ b/Thermo.Active/Controllers/WebApi/WarmersController.cs @@ -4,17 +4,20 @@ using System.Collections.Generic; using System.Web.Http; using TeamDev.SDK.MVVM; using Thermo.Active.Config; +using Thermo.Active.Model.DTOModels.ThRecipe; using Thermo.Active.Model.DTOModels.ThWarmers; using Thermo.Active.NC; using Thermo.Active.Utils; using static Thermo.Active.Config.ServerConfig; using static Thermo.Active.Model.Constants; +using static CMS_CORE_Library.Models.DataStructures; namespace Thermo.Active.Controllers.WebApi { [RoutePrefix("api/warmers")] public class WarmersController : ApiController { + #region Fields /// @@ -50,6 +53,8 @@ namespace Thermo.Active.Controllers.WebApi return BadRequest(libraryError.localizationKey); } + + // recupero i dati LIVE dei parametri HMI dei riscaldi... libraryError = ncAdapter.ReadWarmers(false, out Dictionary currWarmers); if (libraryError.IsError()) @@ -102,6 +107,17 @@ namespace Thermo.Active.Controllers.WebApi return BadRequest(libraryError.localizationKey); } + // sezione riscaldi --> salvo come modificata... + RecipeSection section = RecipeSection.Heats; + try + { + NcFileAdapter.upsRecipeOverview(section, RecipeCatStatus.ChangedOk); + } + catch (Exception exc) + { + ThermoActiveLogger.LogError($"Error on set recipe overview | section: {section}{Environment.NewLine}{exc}"); + } + // scrivo sul PLC il comando conferma! libraryError = ncAdapter.ConfirmRecipeData(true); if (libraryError.IsError()) @@ -172,31 +188,6 @@ namespace Thermo.Active.Controllers.WebApi return Ok(currAreaPerc); } - /// - /// Current channels status - /// - /// - [Route("channels"), HttpGet] - public IHttpActionResult GetCurrentWarmersChannels() - { - // Try connection - CmsError libraryError = ncAdapter.Connect(); - if (libraryError.IsError()) - { - ThermoActiveLogger.LogError($"NC Not connected! | GetCurrentWarmersChannels | {libraryError.exception}"); - return BadRequest(libraryError.localizationKey); - } - - libraryError = ncAdapter.ReadWarmers(false, out Dictionary currWarmers); - if (libraryError.IsError()) - { - ThermoActiveLogger.LogError($"GetCurrentWarmersChannels error | {libraryError.exception}"); - return BadRequest(libraryError.localizationKey); - } - - return Ok(currWarmers); - } - /// /// Current status related to ThermoCamera /// @@ -222,6 +213,30 @@ namespace Thermo.Active.Controllers.WebApi return Ok(currTCamData); } + /// + /// Current channels status + /// + /// + [Route("channels"), HttpGet] + public IHttpActionResult GetCurrentWarmersChannels() + { + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"NC Not connected! | GetCurrentWarmersChannels | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + + libraryError = ncAdapter.ReadWarmers(false, out Dictionary currWarmers); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"GetCurrentWarmersChannels error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + + return Ok(currWarmers); + } /// /// Resistance setup info /// @@ -276,113 +291,6 @@ namespace Thermo.Active.Controllers.WebApi return Ok(); } - /// - /// Write SetpointHMI (%) - /// - /// - /// - [Route("update"), HttpPut] - [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)] - public IHttpActionResult WriteSetpoints(Dictionary channelsLoad) - { - // scrive su CHp da ricetta oppure da override x parametri utente... - if (channelsLoad != null) - { - // Try connection - CmsError libraryError = ncAdapter.Connect(); - if (libraryError.IsError()) - { - ThermoActiveLogger.LogError($"NC Not connected! | WriteSetpoints | {libraryError.exception}"); - return BadRequest(libraryError.localizationKey); - } - // scrivo sul PLC - libraryError = ncAdapter.WriteRecipeWarmChSetpHMI(channelsLoad); - if (libraryError.IsError()) - { - ThermoActiveLogger.LogError($"WriteSetpoints error | {libraryError.exception}"); - return BadRequest(libraryError.localizationKey); - } - - // ritorno solo fatto! - return Ok(); - } - else - { - return NotFound(); - } - } - - /// - /// Write Termocam Temperature Setpoint (°C) - /// - /// - /// - [Route("updateTCamTemp"), HttpPut] - [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)] - public IHttpActionResult WriteTCamTempSet(Dictionary channelsTemp) - { - // scrive su CHp da ricetta oppure da override x parametri utente... - if (channelsTemp != null) - { - // Try connection - CmsError libraryError = ncAdapter.Connect(); - if (libraryError.IsError()) - { - ThermoActiveLogger.LogError($"NC Not connected! | WriteTCamTempSet | {libraryError.exception}"); - return BadRequest(libraryError.localizationKey); - } - // scrivo sul PLC - libraryError = ncAdapter.WriteRecipeWarmChTCamTempSet(channelsTemp); - if (libraryError.IsError()) - { - ThermoActiveLogger.LogError($"WriteTCamTempSet error | {libraryError.exception}"); - return BadRequest(libraryError.localizationKey); - } - - // ritorno solo fatto! - return Ok(); - } - else - { - return NotFound(); - } - } - - /// - /// Write Termocam channels ENABLED - /// - /// - /// - [Route("updateTCamEnab"), HttpPut] - [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)] - public IHttpActionResult WriteTCamEnab(Dictionary channelsEnab) - { - // scrive su CHp da ricetta oppure da override x parametri utente... - if (channelsEnab != null) - { - // Try connection - CmsError libraryError = ncAdapter.Connect(); - if (libraryError.IsError()) - { - ThermoActiveLogger.LogError($"NC Not connected! | WriteTCamEnab | {libraryError.exception}"); - return BadRequest(libraryError.localizationKey); - } - // scrivo sul PLC - libraryError = ncAdapter.WriteRecipeWarmChTCamEnab(channelsEnab); - if (libraryError.IsError()) - { - ThermoActiveLogger.LogError($"WriteTCamEnab error | {libraryError.exception}"); - return BadRequest(libraryError.localizationKey); - } - // ritorno solo fatto! - return Ok(); - } - else - { - return NotFound(); - } - } - /// /// Set/Unset ThermoCam mode /// @@ -411,6 +319,7 @@ namespace Thermo.Active.Controllers.WebApi // ritorno solo fatto! return Ok(); } + /// /// Set ThermoCam On/Off /// @@ -501,6 +410,142 @@ namespace Thermo.Active.Controllers.WebApi return Ok(); } + /// + /// Write SetpointHMI (%) + /// + /// + /// + [Route("update"), HttpPut] + [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)] + public IHttpActionResult WriteSetpoints(Dictionary channelsLoad) + { + // scrive su CHp da ricetta oppure da override x parametri utente... + if (channelsLoad != null) + { + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"NC Not connected! | WriteSetpoints | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + // scrivo sul PLC + libraryError = ncAdapter.WriteRecipeWarmChSetpHMI(channelsLoad); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"WriteSetpoints error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + + // ritorno solo fatto! + return Ok(); + } + else + { + return NotFound(); + } + } + + /// + /// Write Termocam channels ENABLED + /// + /// + /// + [Route("updateTCamEnab"), HttpPut] + [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)] + public IHttpActionResult WriteTCamEnab(Dictionary channelsEnab) + { + // scrive su CHp da ricetta oppure da override x parametri utente... + if (channelsEnab != null) + { + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"NC Not connected! | WriteTCamEnab | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + // scrivo sul PLC + libraryError = ncAdapter.WriteRecipeWarmChTCamEnab(channelsEnab); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"WriteTCamEnab error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + // ritorno solo fatto! + return Ok(); + } + else + { + return NotFound(); + } + } + + /// + /// Write Termocam Temperature Setpoint (°C) + /// + /// + /// + [Route("updateTCamTemp"), HttpPut] + [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)] + public IHttpActionResult WriteTCamTempSet(Dictionary channelsTemp) + { + // scrive su CHp da ricetta oppure da override x parametri utente... + if (channelsTemp != null) + { + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"NC Not connected! | WriteTCamTempSet | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + // scrivo sul PLC + libraryError = ncAdapter.WriteRecipeWarmChTCamTempSet(channelsTemp); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"WriteTCamTempSet error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + + // ritorno solo fatto! + return Ok(); + } + else + { + return NotFound(); + } + } + /// + /// Esegue notifica HMI delle modifiche sulla ricetta/riscaldi + /// + /// + protected static CmsError notifyHmi() + { + CmsError libraryError = NO_ERROR; + // invio dati NUOVA ricetta (DOPO aver sistemato PLC) + DTORecipeStatus message = new DTORecipeStatus() + { + recipeName = NcAdapter.RecipeLiveData.RecipeName, + hasChanged = NcAdapter.RecipeLiveData.hasChanged, + forceSend = true + }; + MessageServices.Current.Publish(SEND_THERMO_RECIPE_CHANGED, null, message); + + // invio dati warmers aggiornati... + + // Get new data from PLC + libraryError = ncAdapter.ReadWarmers(false, out Dictionary currWarmers); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"Load error | ReadWarmers | {libraryError.errorCode} | {libraryError.exception} | {libraryError.localizationKey}"); + return libraryError; + } + // pubblico + MessageServices.Current.Publish(SEND_THERMO_WARMERS_DATA, null, currWarmers); + return libraryError; + } + /// /// Do actual recipe warmers SetpointHMI File-Save /// @@ -520,6 +565,7 @@ namespace Thermo.Active.Controllers.WebApi { ThermoActiveLogger.LogError($"Warmers | saveCurrentRecipeWarmersData exception | {exc}"); } + notifyHmi(); } #endregion Methods