Merge remote-tracking branch 'CMS/develop' into develop
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static Thermo.Active.Model.Constants;
|
||||
|
||||
namespace Thermo.Active.Model.DTOModels.ThProd
|
||||
{
|
||||
public class DTOThermoPanelProd
|
||||
{
|
||||
public short NumTarget { get; set; } = 0;
|
||||
public short NumDone { get; set; } = 0;
|
||||
public DateTime InizioProd { get; set; } = DateTime.Now;
|
||||
public double StimaDurata { get; set; } = 0;
|
||||
public double TempAct { get; set; } = 0;
|
||||
public double TempSetpoint { get; set; } = 0;
|
||||
public string NomeRicetta { get; set; } = "";
|
||||
public double LastCadenza { get; set; } = 0;
|
||||
public double LastTCiclo { get; set; } = 0;
|
||||
public Dictionary<int, double> TS_Cadenza { get; set; } = new Dictionary<int, double>();
|
||||
public Dictionary<int, double> TS_TCiclo { get; set; } = new Dictionary<int, double>();
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is DTOThermoPanelProd item))
|
||||
return false;
|
||||
|
||||
if (NumTarget != item.NumTarget)
|
||||
return false;
|
||||
if (NumDone != item.NumDone)
|
||||
return false;
|
||||
if (InizioProd != item.InizioProd)
|
||||
return false;
|
||||
if (StimaDurata != item.StimaDurata)
|
||||
return false;
|
||||
if (TempAct != item.TempAct)
|
||||
return false;
|
||||
if (TempSetpoint != item.TempSetpoint)
|
||||
return false;
|
||||
if (NomeRicetta != item.NomeRicetta)
|
||||
return false;
|
||||
if (LastCadenza != item.LastCadenza)
|
||||
return false;
|
||||
if (LastTCiclo != item.LastTCiclo)
|
||||
return false;
|
||||
if (!Enumerable.SequenceEqual(TS_Cadenza,item.TS_Cadenza))
|
||||
return false;
|
||||
if (!Enumerable.SequenceEqual(TS_TCiclo, item.TS_TCiclo))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -107,6 +107,7 @@
|
||||
<Compile Include="DTOModels\DTOAxisNameModel.cs" />
|
||||
<Compile Include="DTOModels\DTOClientConfigurationModel.cs" />
|
||||
<Compile Include="DTOModels\ThModules\DTOModulesBlock.cs" />
|
||||
<Compile Include="DTOModels\ThProd\DTOThermoPanelProd.cs" />
|
||||
<Compile Include="DTOModels\ThProd\DTOThermoProd.cs" />
|
||||
<Compile Include="DTOModels\ThRecipe\LiveData.cs" />
|
||||
<Compile Include="DTOModels\ThWarmers\DTOWarmers.cs" />
|
||||
@@ -169,9 +170,7 @@
|
||||
<Name>CMS_CORE_Library</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="DTOModels\Recipe\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
|
||||
@@ -1252,6 +1252,97 @@ namespace Thermo.Active.NC
|
||||
return libraryError;
|
||||
}
|
||||
|
||||
public CmsError ReadProdPanel(out DTOThermoPanelProd currentProdPanel)
|
||||
{
|
||||
// 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
|
||||
currentProdPanel.InizioProd = lottoStart;
|
||||
// dati ricetta da live
|
||||
currentProdPanel.NomeRicetta = NcFileAdapter.RecipeLiveData.RecipeName;
|
||||
// parto dai dati di lastProdInfoData...
|
||||
if (lastProdInfoData != null)
|
||||
{
|
||||
currentProdPanel.NumDone = lastProdInfoData.NumDone;
|
||||
currentProdPanel.NumTarget = lastProdInfoData.NumTarget;
|
||||
currentProdPanel.LastTCiclo = lastProdInfoData.TimeCycleGross;
|
||||
if (lastProdInfoData.TimeCycleGross > 0)
|
||||
{
|
||||
currentProdPanel.LastCadenza = (double)3600 / lastProdInfoData.TimeCycleGross;
|
||||
}
|
||||
// stima durata da pz fatti...
|
||||
currentProdPanel.StimaDurata = (currentProdPanel.NumTarget - currentProdPanel.NumDone) * currentProdPanel.LastTCiclo;
|
||||
}
|
||||
|
||||
// dai parametri sistemo i setpoints
|
||||
if (lastRecipe != null)
|
||||
{
|
||||
if (lastRecipe.ContainsKey("pyrometer_pyrometer_setpoint"))
|
||||
{
|
||||
currentProdPanel.TempAct = lastRecipe["pyrometer_pyrometer_setpoint"].ValueAct;
|
||||
currentProdPanel.TempSetpoint = lastRecipe["pyrometer_pyrometer_setpoint"].SetpointPLC;
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lettura dati ProdInfo
|
||||
/// </summary>
|
||||
/// <param name="prodInfoData"></param>
|
||||
/// <returns></returns>
|
||||
public CmsError ReadProdInfoData(out ThermoModels.ProdInfoModel prodInfoData)
|
||||
{
|
||||
prodInfoData = new ThermoModels.ProdInfoModel();
|
||||
@@ -1338,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,
|
||||
@@ -1382,6 +1474,11 @@ namespace Thermo.Active.NC
|
||||
|
||||
return libraryError;
|
||||
}
|
||||
/// <summary>
|
||||
/// Get cycle prod data
|
||||
/// </summary>
|
||||
/// <param name="prodCycleData"></param>
|
||||
/// <returns></returns>
|
||||
public CmsError ReadProdCycleData(out ThermoModels.ProdCycleModel prodCycleData)
|
||||
{
|
||||
prodCycleData = new ThermoModels.ProdCycleModel();
|
||||
@@ -1628,8 +1725,6 @@ namespace Thermo.Active.NC
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public CmsError ReadNcScada(ScadaSchemaModel scadaSchema, out DTOScadaModel scadaValue)
|
||||
{
|
||||
//ReadScadaDataSiemens(scadaSchema, out scadaValue);
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
/// Request production current data
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Route("get"), HttpPut]
|
||||
[Route("get"), HttpGet]
|
||||
public IHttpActionResult GetProd()
|
||||
{
|
||||
// Try connection
|
||||
@@ -157,7 +157,7 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
/// Request gauges current data
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Route("gauges"), HttpPut]
|
||||
[Route("gauges"), HttpGet]
|
||||
public IHttpActionResult GetGauges()
|
||||
{
|
||||
// Try connection
|
||||
@@ -168,7 +168,7 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
return BadRequest(libraryError.localizationKey);
|
||||
}
|
||||
|
||||
// scrivo sul PLC il comando strobe richiesta AUTO!
|
||||
// leggo dati gauges
|
||||
libraryError = ncAdapter.ReadGaugeData(out Dictionary<string, DTOThermoProd> currentLiveProd);
|
||||
if (libraryError.IsError())
|
||||
{
|
||||
@@ -183,7 +183,7 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
/// Request production data from indexStart record for numRecord items (DESCENDING)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Route("history"), HttpPut]
|
||||
[Route("history"), HttpGet]
|
||||
public IHttpActionResult GetHistory(int indexStart, int numRecord)
|
||||
{
|
||||
// Try connection
|
||||
@@ -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())
|
||||
{
|
||||
@@ -205,5 +205,31 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
// ritorno solo fatto!
|
||||
return Ok(prodInfoDataList);
|
||||
}
|
||||
/// <summary>
|
||||
/// Request Prod Panel data
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Route("prodPanel"), HttpGet]
|
||||
public IHttpActionResult GetProdPanel()
|
||||
{
|
||||
// Try connection
|
||||
CmsError libraryError = ncAdapter.Connect();
|
||||
if (libraryError.IsError())
|
||||
{
|
||||
ThermoActiveLogger.LogError($"NC Not connected! | GetProdPanel | {libraryError.exception}");
|
||||
return BadRequest(libraryError.localizationKey);
|
||||
}
|
||||
|
||||
// recupero dati produzione
|
||||
libraryError = ncAdapter.ReadProdPanel(out DTOThermoPanelProd currentProdPanel);
|
||||
if (libraryError.IsError())
|
||||
{
|
||||
ThermoActiveLogger.LogError($"GetProdPanel error | {libraryError.exception}");
|
||||
return BadRequest(libraryError.localizationKey);
|
||||
}
|
||||
|
||||
// ritorno solo fatto!
|
||||
return Ok(currentProdPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.9.29")]
|
||||
[assembly: AssemblyVersion("0.9.31")]
|
||||
|
||||
Reference in New Issue
Block a user