Completed review of WebAPI method for prodPanel

This commit is contained in:
Samuele Locatelli
2020-07-09 17:53:11 +02:00
parent d7ca3e0563
commit bf3084b376
3 changed files with 53 additions and 4 deletions
+2
View File
@@ -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";
+50 -3
View File
@@ -1256,6 +1256,8 @@ namespace Thermo.Active.NC
{
// preparo oggetti OUT
currentProdPanel = new DTOThermoPanelProd();
Dictionary<int, double> TS_Cad = new Dictionary<int, double>();
Dictionary<int, double> TS_TC = new Dictionary<int, double>();
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<ThermoModels.ProdInfoModel> 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<ThermoModels.ProdInfoModel> 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,
@@ -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<ThermoModels.ProdInfoModel> prodInfoDataList, indexStart, numRecord);
if (libraryError.IsError())
{