Merge branch 'feature/add/risk' into develop

This commit is contained in:
Samuele Locatelli
2020-06-12 19:17:41 +02:00
10 changed files with 288 additions and 70 deletions
@@ -3,18 +3,28 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Thermo.Active.Model.Constants;
namespace Thermo.Active.Model.DTOModels.Recipe
{
public class DTOModulesBlock
{
public int Id { get; set; } = 0;
public double SetpointHMI { get; set; } = 0;
public double SetpointPLC { get; set; } = 0;
//public RPRange Range { get; set; }
//public RPStatus Status { get; set; }
public string UnitMeasure { get; set; }
public double ValueAct { get; set; }
public string LocalizedLabel { get; set; } = "";
public TACT_MBLOCK_TYPE Type { get; set; } = TACT_MBLOCK_TYPE.ND;
public TACT_MBLOCK_SECTION Section { get; set; } = TACT_MBLOCK_SECTION.ND;
public int IdParam { get; set; } = 0;
public bool ShowDelay { get; set; } = false;
public int Priority { get; set; } = 0;
public int ActualDelay { get; set; } = 0;
public int ActualDuration { get; set; } = 0;
public int EstimatedDelay { get; set; } = 0;
public int EstimatedDuration { get; set; } = 0;
public List<short> PrecedingId { get; set; } = new List<short>();
public bool Visible { get; set; } = false;
public bool Running { get; set; } = false;
public bool HasError { get; set; } = false;
public override bool Equals(object obj)
{
@@ -23,17 +33,33 @@ namespace Thermo.Active.Model.DTOModels.Recipe
if (Id!= item.Id)
return false;
if (SetpointHMI != item.SetpointHMI)
if (LocalizedLabel != item.LocalizedLabel)
return false;
if (SetpointPLC != item.SetpointPLC)
if (Type != item.Type)
return false;
//if (!Range.Equals(item.Range))
// return false;
//if (!Status.Equals(item.Status))
// return false;
if (UnitMeasure != item.UnitMeasure)
if (Section != item.Section)
return false;
if (ValueAct != item.ValueAct)
if (IdParam != item.IdParam)
return false;
if (ShowDelay != item.ShowDelay)
return false;
if (Priority != item.Priority)
return false;
if (ActualDelay != item.ActualDelay)
return false;
if (ActualDuration != item.ActualDuration)
return false;
if (EstimatedDelay != item.EstimatedDelay)
return false;
if (EstimatedDuration != item.EstimatedDuration)
return false;
if (PrecedingId != item.PrecedingId)
return false;
if (Visible != item.Visible)
return false;
if (Running != item.Running)
return false;
if (HasError != item.HasError)
return false;
return true;
+57 -17
View File
@@ -2042,22 +2042,62 @@ namespace Thermo.Active.NC
CmsError cmsError = NO_ERROR;
currModules = new Dictionary<int, DTOModulesBlock>();
// FIXME TODO
#if false
DTORecipeParam currParam = new DTORecipeParam();
RPRange currRange = new RPRange();
RPStatus currStatus = new RPStatus();
// gestione errore
cmsError = ReadRecipeData(false, true, out currModules);
cmsError = ReadModBlock(out currModules);
if (cmsError.IsError())
return cmsError;
#endif
return cmsError;
// restituisco cod errore se trovato
return cmsError;
}
public CmsError ReadModBlock(out Dictionary<int, DTOModulesBlock> currModules)
{
CmsError cmsError = NO_ERROR;
currModules = new Dictionary<int, DTOModulesBlock>();
DTOModulesBlock currVal = new DTOModulesBlock();
// read and return warmers data
if (NcConfig.NcVendor == NC_VENDOR.S7NET)
{
Dictionary<int, ThermoModels.ModuleBlock> currModBlock = new Dictionary<int, ThermoModels.ModuleBlock>();
cmsError = numericalControl.PLC_RModulesBlockList(false, ref currModBlock);
foreach (var item in ModBlockConfig)
{
try
{
ThermoModels.ModuleBlock currModule = currModBlock[item.Id];
currVal = new DTOModulesBlock()
{
Id = item.Id,
LocalizedLabel = item.LocalizedLabels["ITA"], // FIXME TODO check come gestire traduzione!!!
Type = item.Type,
Section = item.Section,
IdParam = item.IdParam,
ShowDelay = item.ShowDelay,
Priority = item.Priority,
ActualDelay = currModule.ActualDelay,
ActualDuration= currModule.ActualDuration,
EstimatedDelay = currModule.EstimatedDelay,
EstimatedDuration = currModule.EstimatedDuration,
PrecedingId = currModule.PrecedingId,
Visible = currModule.Visible,
Running = currModule.Running,
HasError = currModule.HasError
};
currModules.Add(item.Id, currVal);
}
catch(Exception exc)
{
// FIXME TODO...
}
}
}
return cmsError;
}
/// <summary>
/// GEt all warmers data by channel
/// </summary>
@@ -2157,15 +2197,15 @@ namespace Thermo.Active.NC
protected double getDimRatio(DTORecipeParam singlePar)
{
double ratio = 1;
if (singlePar!=null)
if (singlePar != null)
{
try
{
if (singlePar.Range.Max > 0)
ratio = singlePar.SetpointPLC / singlePar.Range.Max;
}
catch
{ }
try
{
if (singlePar.Range.Max > 0)
ratio = singlePar.SetpointPLC / singlePar.Range.Max;
}
catch
{ }
}
return ratio;
}
+1 -1
View File
@@ -6,7 +6,7 @@ using System.Windows.Forms;
using Thermo.Active.Model;
using TeamDev.SDK.MVVM;
using static Thermo.Active.Model.Constants;
using static Thermo.Active.Utils.StepLogger;
using static Thermo.Active.Utils.ThermoActiveLogger;
namespace Thermo.Active.Utils
{
@@ -69,7 +69,7 @@
<Compile Include="ExceptionManager.cs" />
<Compile Include="LanguageController.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StepLogger.cs" />
<Compile Include="ThermoActiveLogger.cs" />
<Compile Include="SupportFunctions.cs" />
</ItemGroup>
<ItemGroup>
@@ -4,7 +4,7 @@ using static Thermo.Active.Model.Constants;
namespace Thermo.Active.Utils
{
public static class StepLogger
public static class ThermoActiveLogger
{
private static Logger Log = LogManager.GetCurrentClassLogger();
@@ -13,6 +13,7 @@ using static CMS_CORE_Library.Models.DataStructures;
using static Thermo.Active.Config.ServerConfig;
using static Thermo.Active.Model.Constants;
using Thermo.Active.Model.DTOModels.Recipe;
using Thermo.Active.Utils;
namespace Thermo.Active.Controllers.WebApi
{
@@ -27,11 +28,17 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | GetCurrentModules | {libraryError.exception}");
return InternalServerError();
}
CmsError cmsError = ncAdapter.ReadModulesBlock(out Dictionary<int, DTOModulesBlock> currModules);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"GetRecipeOverview error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
return Ok(currModules);
}
@@ -14,6 +14,7 @@ using static Thermo.Active.Config.ServerConfig;
using static Thermo.Active.Model.Constants;
using Thermo.Active.Model.DTOModels.Recipe;
using Thermo.Active.Config;
using Thermo.Active.Utils;
namespace Thermo.Active.Controllers.WebApi
{
@@ -28,11 +29,17 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | GetOverview | {libraryError.exception}");
return InternalServerError();
}
CmsError cmsError = ncAdapter.GetRecipeOverview(out Dictionary<string, RecipeCatStatus> currOverview);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"GetRecipeOverview error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
return Ok(currOverview);
}
@@ -45,11 +52,17 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | GetCurrentParameters | {libraryError.exception}");
return InternalServerError();
}
CmsError cmsError = ncAdapter.ReadFullRecipe(out Dictionary<string, DTORecipeParam> currRecipe);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"GetRecipeOverview error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
return Ok(currRecipe);
}
@@ -67,15 +80,20 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | WriteParameters | {libraryError.exception}");
return InternalServerError();
}
// read recipe!
CmsError cmsError = ncAdapter.ReadFullRecipe(out Dictionary<string, DTORecipeParam> prevRecipe);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"GetRecipeOverview error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
Dictionary<string, DTORecipeParam> updtRecipe = new Dictionary<string, DTORecipeParam>();
foreach (var item in parametersList)
{
if (prevRecipe.ContainsKey(item.Key))
@@ -88,6 +106,7 @@ namespace Thermo.Active.Controllers.WebApi
}
else
{
ThermoActiveLogger.LogError($"WriteParameters error | key not found: {item.Key}");
return NotFound();
}
}
@@ -102,12 +121,14 @@ namespace Thermo.Active.Controllers.WebApi
else
{
// non pronto!
ThermoActiveLogger.LogError($"RecipeLiveData null | WriteParameters");
return InternalServerError();
}
}
else
{
return NotFound();
ThermoActiveLogger.LogError($"RecipeLiveData null | Empty Parameters");
return BadRequest();
}
}
@@ -125,17 +146,26 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | Recipe ConfirmEdit | {libraryError.exception}");
return InternalServerError();
}
// scrivo sul PLC il comando conferma!
CmsError cmsError = ncAdapter.ConfirmRecipeData(true);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"ConfirmEdit error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
// recupero i dati LIVE dei parametri HMI della ricetta...
cmsError = ncAdapter.ReadFullRecipe(out Dictionary<string, DTORecipeParam> currRecipe);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"ConfirmEdit error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
// rileggo la ricetta
var currParams = new Dictionary<string, double>();
@@ -144,7 +174,7 @@ namespace Thermo.Active.Controllers.WebApi
currParams.Add(item.Key, item.Value.SetpointHMI);
}
saveCurrentRecipeParams(currParams);
SaveCurrentRecipeParams(currParams);
// ritorno solo fatto!
return Ok();
@@ -153,6 +183,7 @@ namespace Thermo.Active.Controllers.WebApi
else
{
// non pronto!
ThermoActiveLogger.LogError($"RecipeLiveData null | Empty");
return InternalServerError();
}
}
@@ -171,17 +202,26 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | Recipe CancelEdit | {libraryError.exception}");
return InternalServerError();
}
// scrivo sul PLC il comando annula!
CmsError cmsError = ncAdapter.ConfirmRecipeData(false);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"ConfirmEdit error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
// recupero i dati LIVE dei parametri HMI della ricetta...
cmsError = ncAdapter.ReadFullRecipe(out Dictionary<string, DTORecipeParam> currRecipe);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"ConfirmEdit error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
var currParams = new Dictionary<string, double>();
foreach (var item in currRecipe)
@@ -190,7 +230,7 @@ namespace Thermo.Active.Controllers.WebApi
}
// ora salvo ANCHE i dati live...
saveCurrentRecipeParams(currParams);
SaveCurrentRecipeParams(currParams);
// ritorno solo fatto!
return Ok();
@@ -199,6 +239,7 @@ namespace Thermo.Active.Controllers.WebApi
else
{
// non pronto!
ThermoActiveLogger.LogError($"RecipeLiveData null | Empty");
return InternalServerError();
}
}
@@ -215,18 +256,26 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | Load | {libraryError.exception}");
return InternalServerError();
}
// chiamo metodo di lettura...
//CmsError cmsError = ServerConfigController.LoadRecipe(newName);
bool fatto = ServerConfigController.LoadRecipe(newName);
if (!fatto)
{
ThermoActiveLogger.LogError($"LoadRecipe error");
return NotFound();
}
CmsError cmsError = writeCurrentRecipeToPlc();
CmsError cmsError = WriteCurrentRecipeToPlc();
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"ConfirmEdit error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
// ritorno solo fatto!
return Ok();
@@ -246,11 +295,17 @@ namespace Thermo.Active.Controllers.WebApi
bool fatto = ServerConfigController.LoadTemplate();
if (!fatto)
{
ThermoActiveLogger.LogError($"LoadRecipe error");
return NotFound();
}
CmsError cmsError = writeCurrentRecipeToPlc();
CmsError cmsError = WriteCurrentRecipeToPlc();
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"ConfirmEdit error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
}
// ritorno solo fatto!
@@ -279,7 +334,7 @@ namespace Thermo.Active.Controllers.WebApi
}
// ora salvo ANCHE i dati live...
saveCurrentRecipeParams(currParams);
SaveCurrentRecipeParams(currParams);
// ritorno solo fatto!
return Ok();
@@ -297,7 +352,10 @@ namespace Thermo.Active.Controllers.WebApi
// recupero i dati LIVE dei parametri HMI della ricetta...
CmsError cmsError = ncAdapter.ReadFullRecipe(out Dictionary<string, DTORecipeParam> currRecipe);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"SaveAs error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
var currParams = new Dictionary<string, double>();
foreach (var item in currRecipe)
@@ -326,13 +384,19 @@ namespace Thermo.Active.Controllers.WebApi
// recupero i dati LIVE dei parametri HMI della ricetta...
CmsError cmsError = ncAdapter.ReadFullRecipe(out Dictionary<string, DTORecipeParam> currRecipe);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"SaveTemplate error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
// recupero i dati LIVE dei carichi load dei cahnnels di riscaldo...
cmsError = ncAdapter.ReadWarmers(out Dictionary<int, DTOWarmers> currWarmers);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"ReadWarmers error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
// uso i valopri HMI...
var currParams = new Dictionary<string, double>();
@@ -366,7 +430,7 @@ namespace Thermo.Active.Controllers.WebApi
/// Do actual recipe parameters FileSave
/// </summary>
/// <param name="currParams"></param>
private static void saveCurrentRecipeParams(Dictionary<string, double> currParams)
private static void SaveCurrentRecipeParams(Dictionary<string, double> currParams)
{
try
{
@@ -375,11 +439,13 @@ namespace Thermo.Active.Controllers.WebApi
// e salvo su disco
ServerConfigController.SaveRecipeCurrent();
}
catch
{ }
catch(Exception exc)
{
ThermoActiveLogger.LogError($"Recipe | SaveCurrentRecipeParams exception | {exc}");
}
}
protected static CmsError writeCurrentRecipeToPlc()
protected static CmsError WriteCurrentRecipeToPlc()
{
CmsError checkError = NO_ERROR;
@@ -388,13 +454,19 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
{
ThermoActiveLogger.LogError($"NC Not connected! | Load | {libraryError.exception}");
return libraryError;
}
// copy data to PLC
checkError = ncAdapter.ReadFullRecipe(out Dictionary<string, DTORecipeParam> prevRecipe);
if (checkError.IsError())
{
ThermoActiveLogger.LogError($"WriteCurrentRecipeToPlc | ReadFullRecipe error | {checkError.exception}");
return checkError;
}
// save parameters to PLC!!!
Dictionary<string, DTORecipeParam> updtRecipe = new Dictionary<string, DTORecipeParam>();
@@ -410,12 +482,18 @@ namespace Thermo.Active.Controllers.WebApi
}
else
{
ThermoActiveLogger.LogError($"prevRecipe not found | key: {item.Key}");
return NOT_FOUND_ERROR;
}
}
// write to PLC
checkError = ncAdapter.WriteRecipeParams(updtRecipe);
if (checkError.IsError())
{
ThermoActiveLogger.LogError($"WriteCurrentRecipeToPlc | WriteRecipeParams error | {checkError.exception}");
return checkError;
}
// process ch load setup...
@@ -427,11 +505,19 @@ namespace Thermo.Active.Controllers.WebApi
// write to PLC
checkError = ncAdapter.WriteRecipeWarmChSetpHMI(newRisk);
if (checkError.IsError())
{
ThermoActiveLogger.LogError($"WriteCurrentRecipeToPlc | WriteRecipeWarmChSetpHMI error | {checkError.exception}");
return checkError;
}
// enable recipe! scrivo sul PLC il comando conferma!
CmsError cmsError = ncAdapter.ConfirmRecipeData(true);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"ReadWarmers error | {cmsError.exception}");
return checkError;
}
}
return checkError;
}
@@ -42,7 +42,7 @@ namespace Thermo.Active.Controllers.WebApi
var context = GlobalHost.ConnectionManager.GetHubContext<NcHub>();
context.Clients.All.logout(new { id = userId.Value });
StepLogger.LogMessage("Logout: " + userId.Value + "Date:" + DateTime.Now, ERROR_LEVEL.INFO);
ThermoActiveLogger.LogMessage("Logout: " + userId.Value + "Date:" + DateTime.Now, ERROR_LEVEL.INFO);
return Ok();
}
@@ -14,6 +14,7 @@ using static Thermo.Active.Config.ServerConfig;
using static Thermo.Active.Model.Constants;
using Thermo.Active.Model.DTOModels.Recipe;
using Thermo.Active.Config;
using Thermo.Active.Utils;
namespace Thermo.Active.Controllers.WebApi
{
@@ -28,11 +29,17 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | GetCurrentWarmersChannels | {libraryError.exception}");
return InternalServerError();
}
CmsError cmsError = ncAdapter.ReadWarmers(out Dictionary<int, DTOWarmers> currWarmers);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"GetRecipeOverview error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
return Ok(currWarmers);
}
@@ -45,11 +52,17 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | GetCurrentWarmersResistances | {libraryError.exception}");
return InternalServerError();
}
CmsError cmsError = ncAdapter.GetWarmersResistances(out Dictionary<int, Model.ConfigModels.RiskResistModel> currWarmers);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"GetCurrentWarmersResistances error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
return Ok(currWarmers);
}
@@ -63,12 +76,18 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | GetCurrentAreaPerc | {libraryError.exception}");
return InternalServerError();
}
// recupera aree % X / Y
CmsError cmsError = ncAdapter.GetWarmMaterialArea(out Dictionary<string,double> currAreaPerc);
CmsError cmsError = ncAdapter.GetWarmMaterialArea(out Dictionary<string, double> currAreaPerc);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"GetCurrentAreaPerc error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
return Ok(currAreaPerc);
}
@@ -86,10 +105,17 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | WriteSetpoints | {libraryError.exception}");
return InternalServerError();
}
// scrivo sul PLC
ncAdapter.WriteRecipeWarmChSetpHMI(channelsLoad);
CmsError cmsError = ncAdapter.WriteRecipeWarmChSetpHMI(channelsLoad);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"WriteSetpoints error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
// ritorno solo fatto!
return Ok();
@@ -113,17 +139,26 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | Warmers ConfirmEdit | {libraryError.exception}");
return InternalServerError();
}
// scrivo sul PLC il comando conferma!
CmsError cmsError = ncAdapter.ConfirmRecipeData(true);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"Warmers ConfirmEdit error | ConfirmRecipeData | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
// recupero i dati LIVE dei parametri HMI dei riscaldi...
cmsError = ncAdapter.ReadWarmers(out Dictionary<int, DTOWarmers> currWarmers);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"Warmers ConfirmEdit error | ReadWarmers | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
// rileggo la ricetta
var currParams = new Dictionary<int, int>();
@@ -151,17 +186,26 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | Recipe CancelEdit | {libraryError.exception}");
return InternalServerError();
}
// scrivo sul PLC il comando annula!
CmsError cmsError = ncAdapter.ConfirmRecipeData(false);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"Warmers CancelEdit error | ConfirmRecipeData | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
// recupero i dati LIVE dei parametri HMI dei riscaldi...
cmsError = ncAdapter.ReadWarmers(out Dictionary<int, DTOWarmers> currWarmers);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"Warmers ConfirmEdit error | ReadWarmers | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
// rileggo la ricetta
var currParams = new Dictionary<int, int>();
@@ -187,10 +231,18 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | SetConfig | {libraryError.exception}");
return InternalServerError();
}
// scrivo sul PLC
ncAdapter.WriteRecipeWarmConfig();
CmsError cmsError = ncAdapter.WriteRecipeWarmConfig();
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"Warmers SetConfig error | WriteRecipeWarmConfig | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
// ritorno solo fatto!
return Ok();
@@ -204,10 +256,17 @@ namespace Thermo.Active.Controllers.WebApi
/// <param name="chSetpoints"></param>
private static void saveCurrentRecipeWarmers(Dictionary<int, int> chSetpoints)
{
// ora salvo ANCHE i dati live...
RecipeLiveData.ChannelSetpoints = chSetpoints;
// e salvo su disco
ServerConfigController.SaveRecipeCurrent();
try
{
// ora salvo ANCHE i dati live...
RecipeLiveData.ChannelSetpoints = chSetpoints;
// e salvo su disco
ServerConfigController.SaveRecipeCurrent();
}
catch (Exception exc)
{
ThermoActiveLogger.LogError($"Warmers | SaveCurrentRecipeParams exception | {exc}");
}
}
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ using System.Windows.Forms;
using TeamDev.SDK.MVVM;
using static Thermo.Active.Config.ServerConfig;
using static Thermo.Active.Model.Constants;
using static Thermo.Active.Utils.StepLogger;
using static Thermo.Active.Utils.ThermoActiveLogger;
using static Thermo.Active.Utils.ExceptionManager;
namespace Thermo.Active