Update metodi cancel/confirm x ricetta...
This commit is contained in:
@@ -672,7 +672,7 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
libraryError = ncAdapter.ReadWarmers(false, out Dictionary<int, DTOWarmers> 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
|
||||
|
||||
@@ -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
|
||||
|
||||
/// <summary>
|
||||
@@ -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<int, DTOWarmers> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current channels status
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[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<int, DTOWarmers> currWarmers);
|
||||
if (libraryError.IsError())
|
||||
{
|
||||
ThermoActiveLogger.LogError($"GetCurrentWarmersChannels error | {libraryError.exception}");
|
||||
return BadRequest(libraryError.localizationKey);
|
||||
}
|
||||
|
||||
return Ok(currWarmers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current status related to ThermoCamera
|
||||
/// </summary>
|
||||
@@ -222,6 +213,30 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
return Ok(currTCamData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current channels status
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[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<int, DTOWarmers> currWarmers);
|
||||
if (libraryError.IsError())
|
||||
{
|
||||
ThermoActiveLogger.LogError($"GetCurrentWarmersChannels error | {libraryError.exception}");
|
||||
return BadRequest(libraryError.localizationKey);
|
||||
}
|
||||
|
||||
return Ok(currWarmers);
|
||||
}
|
||||
/// <summary>
|
||||
/// Resistance setup info
|
||||
/// </summary>
|
||||
@@ -276,113 +291,6 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write SetpointHMI (%)
|
||||
/// </summary>
|
||||
/// <param name="channelsLoad"></param>
|
||||
/// <returns></returns>
|
||||
[Route("update"), HttpPut]
|
||||
[WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)]
|
||||
public IHttpActionResult WriteSetpoints(Dictionary<int, int> 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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write Termocam Temperature Setpoint (°C)
|
||||
/// </summary>
|
||||
/// <param name="channelsTemp"></param>
|
||||
/// <returns></returns>
|
||||
[Route("updateTCamTemp"), HttpPut]
|
||||
[WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)]
|
||||
public IHttpActionResult WriteTCamTempSet(Dictionary<int, double> 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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write Termocam channels ENABLED
|
||||
/// </summary>
|
||||
/// <param name="channelsEnab"></param>
|
||||
/// <returns></returns>
|
||||
[Route("updateTCamEnab"), HttpPut]
|
||||
[WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)]
|
||||
public IHttpActionResult WriteTCamEnab(Dictionary<int, bool> 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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set/Unset ThermoCam mode
|
||||
/// </summary>
|
||||
@@ -411,6 +319,7 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
// ritorno solo fatto!
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set ThermoCam On/Off
|
||||
/// </summary>
|
||||
@@ -501,6 +410,142 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write SetpointHMI (%)
|
||||
/// </summary>
|
||||
/// <param name="channelsLoad"></param>
|
||||
/// <returns></returns>
|
||||
[Route("update"), HttpPut]
|
||||
[WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)]
|
||||
public IHttpActionResult WriteSetpoints(Dictionary<int, int> 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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write Termocam channels ENABLED
|
||||
/// </summary>
|
||||
/// <param name="channelsEnab"></param>
|
||||
/// <returns></returns>
|
||||
[Route("updateTCamEnab"), HttpPut]
|
||||
[WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)]
|
||||
public IHttpActionResult WriteTCamEnab(Dictionary<int, bool> 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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write Termocam Temperature Setpoint (°C)
|
||||
/// </summary>
|
||||
/// <param name="channelsTemp"></param>
|
||||
/// <returns></returns>
|
||||
[Route("updateTCamTemp"), HttpPut]
|
||||
[WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)]
|
||||
public IHttpActionResult WriteTCamTempSet(Dictionary<int, double> 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();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Esegue notifica HMI delle modifiche sulla ricetta/riscaldi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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<int, DTOWarmers> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Do actual recipe warmers SetpointHMI File-Save
|
||||
/// </summary>
|
||||
@@ -520,6 +565,7 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
{
|
||||
ThermoActiveLogger.LogError($"Warmers | saveCurrentRecipeWarmersData exception | {exc}");
|
||||
}
|
||||
notifyHmi();
|
||||
}
|
||||
|
||||
#endregion Methods
|
||||
|
||||
Reference in New Issue
Block a user