diff --git a/Thermo.Active.Model/Constants.cs b/Thermo.Active.Model/Constants.cs index 38f717c7..82426a46 100644 --- a/Thermo.Active.Model/Constants.cs +++ b/Thermo.Active.Model/Constants.cs @@ -219,6 +219,8 @@ namespace Thermo.Active.Model public static readonly string CLIENT_PATH_86 = BASE_PATH + @"\Client\x86\" + CLIENT_EXE_NAME; public static string WEBSITE_DIRECTORY = BASE_PATH + "\\view"; #endif + + public const int numRecProdPanelGraph = 30; public const string CONFIG_DIRECTORY = "Config\\"; public const string RECIPE_DIRECTORY = "Recipes\\"; public const string RECIPE_TEMPLATE_PATH = CONFIG_DIRECTORY + RECIPE_DIRECTORY + "template.tpl"; diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index aff637b2..53e37114 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -1256,6 +1256,8 @@ namespace Thermo.Active.NC { // preparo oggetti OUT currentProdPanel = new DTOThermoPanelProd(); + Dictionary TS_Cad = new Dictionary(); + Dictionary TS_TC = new Dictionary(); CmsError libraryError = NO_ERROR; // inizio da ncAdapter.lottoStart @@ -1277,7 +1279,7 @@ namespace Thermo.Active.NC } // dai parametri sistemo i setpoints - if(lastRecipe!=null) + if (lastRecipe != null) { if (lastRecipe.ContainsKey("pyrometer_pyrometer_setpoint")) { @@ -1285,8 +1287,52 @@ namespace Thermo.Active.NC currentProdPanel.TempSetpoint = lastRecipe["pyrometer_pyrometer_setpoint"].SetpointPLC; } } - // dal DB recupero i dati dei TC storici... - + // dal DB recupero i dati dei TC storici... cablato a last 30 x ora... + if (currentProdPanel.NumDone > 0) + { + libraryError = GetHistProdInfoData(out List prodInfoDataList, currentProdPanel.NumDone, numRecProdPanelGraph); + // se ci sono dati --> creo le 2 TS! + if (prodInfoDataList != null) + { + foreach (var item in prodInfoDataList) + { + if (TS_TC.ContainsKey(item.NumDone)) + { + TS_TC[item.NumDone] = item.TimeCycleGross; + } + else + { + TS_TC.Add(item.NumDone, item.TimeCycleGross); + } + if (item.TimeCycleGross > 0) + { + if (TS_Cad.ContainsKey(item.NumDone)) + { + TS_Cad[item.NumDone] = 3600 / item.TimeCycleGross; + } + else + { + TS_Cad.Add(item.NumDone, 3600 / item.TimeCycleGross); + } + } + } + // accodo! + currentProdPanel.TS_Cadenza = TS_Cad; + currentProdPanel.TS_TCiclo = TS_TC; + } + // giĆ  che ci sono recupero prima record x prodStart... + libraryError = GetHistProdInfoData(out List prodInfoFirst, 1, 1); + // se ci sono dati --> fix start + if (prodInfoFirst != null) + { + try + { + currentProdPanel.InizioProd = prodInfoFirst.FirstOrDefault().DtEvent; + } + catch + { } + } + } return libraryError; @@ -1383,6 +1429,7 @@ namespace Thermo.Active.NC // converto! prodInfoDataList = results.Select(x => new ThermoModels.ProdInfoModel() { + DtEvent = x.DtEvent, NumTarget = x.NumTarget, NumDone = x.NumDone, TimeWarm = x.TimeWarm, diff --git a/Thermo.Active/Controllers/WebApi/ProdController.cs b/Thermo.Active/Controllers/WebApi/ProdController.cs index 89da31a0..2d6f1cf7 100644 --- a/Thermo.Active/Controllers/WebApi/ProdController.cs +++ b/Thermo.Active/Controllers/WebApi/ProdController.cs @@ -194,7 +194,7 @@ namespace Thermo.Active.Controllers.WebApi return BadRequest(libraryError.localizationKey); } - // scrivo sul PLC il comando strobe richiesta AUTO! + // recupero da DB i record richiesti libraryError = ncAdapter.GetHistProdInfoData(out List prodInfoDataList, indexStart, numRecord); if (libraryError.IsError()) {