Merge remote-tracking branch 'CMS/develop' into develop

This commit is contained in:
=
2020-07-14 15:00:18 +02:00
5 changed files with 80 additions and 9 deletions
@@ -12,6 +12,10 @@ namespace Thermo.Active.Model.DTOModels.ThRecipe
/// </summary>
public string RecipeName = "current.json";
/// <summary>
/// User that made last save
/// </summary>
public string UserSave = "";
/// <summary>
/// Dictionary of all parameters and values
/// </summary>
public Dictionary<string, double> RecipeParameters;
@@ -23,6 +27,10 @@ namespace Thermo.Active.Model.DTOModels.ThRecipe
/// Recipe Overview
/// </summary>
public Dictionary<RecipeSection, RecipeCatStatus> RecipeOverview;
/// <summary>
/// Last TC observed (stats) in sec
/// </summary>
public double TC_last = 3600;
}
+16 -4
View File
@@ -48,6 +48,10 @@ namespace Thermo.Active.NC
/// Ultimo ciclo registrato(secondi)
/// </summary>
protected double lastCycle = 9999;
/// <summary>
/// Recipe Live data
/// </summary>
public static LiveData RecipeLiveData = new LiveData();
public NcAdapter() =>
// Choose NC
@@ -1227,7 +1231,6 @@ namespace Thermo.Active.NC
break;
}
// creo obj contenuto
currProdData = new DTOThermoProd()
{
@@ -1241,6 +1244,11 @@ namespace Thermo.Active.NC
MinVal = item.MinVal / item.ScaleFactor,
MaxVal = item.MaxVal / item.ScaleFactor
};
// fix: se + timeAdv uso come max ultimo TC rilevato...
if (item.Name == "timeAdv")
{
currProdData.MaxVal = (int)Math.Ceiling((double)lastProdInfoData.TimeCycleGross / 1000);
}
// aggiungo a dictionary!
if (currentLiveProd.ContainsKey(item.Name))
{
@@ -1303,6 +1311,8 @@ namespace Thermo.Active.NC
}
// stima durata da pz fatti...
currentProdPanel.StimaDurata = Math.Round((currentProdPanel.NumTarget - currentProdPanel.NumDone) * currentProdPanel.LastTCiclo, 2);
// se stima negativa (+ pezzi di quanti richiesti...) --> ZERO!
currentProdPanel.StimaDurata = currentProdPanel.StimaDurata < 0 ? 0 : currentProdPanel.StimaDurata;
}
// dai parametri sistemo i setpoints
if (lastRecipe != null)
@@ -1453,16 +1463,18 @@ namespace Thermo.Active.NC
lastProdEnd = DateTime.Now;
// calcolo ultimo ciclo...
var lastDuration = lastProdEnd.Subtract(lastProdStart).TotalSeconds;
// se il prec è > 3 cicli uso SOLO ultimo
if (lastCycle > 3 * lastDuration)
// se il valore SALVATO è > 3 * valore rilevato (ma NON inferiore a 1/3...) --> uso SOLO ultimo
if ((lastCycle > 3 * lastDuration) && (lastCycle / 3 < lastDuration))
{
lastCycle = lastDuration;
}
// altrimenti ewma 50%
// altrimenti EWMA 50%
else
{
lastCycle = 0.5 * lastCycle + 0.5 * lastDuration;
}
// salvo anche nei live data della ricetta...
RecipeLiveData.TC_last = lastCycle;
// manage strobe/ack!
libraryError = numericalControl.PLC_WAckPzProdEnd();
-4
View File
@@ -20,10 +20,6 @@ namespace Thermo.Active.NC
public class NcFileAdapter : NcAdapter
{
/// <summary>
/// Recipe Live data
/// </summary>
public static LiveData RecipeLiveData = new LiveData();
/// <summary>
/// Read file from local devices ad give back string content
@@ -9,6 +9,7 @@ using System.Security.Claims;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Windows.Media.Animation;
using Thermo.Active.Config;
using Thermo.Active.Database.Controllers;
using Thermo.Active.Model.DTOModels.ThRecipe;
@@ -456,6 +457,60 @@ namespace Thermo.Active.Controllers.WebApi
}
[Route("saveAll"), HttpPost]
public async Task<IHttpActionResult> SaveAll(string newName, double estimTimeSec)
{
bool imageUploaded = false;
if (!Request.Content.IsMimeMultipartContent())
{
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
List<FormItem> formItems = await MultipartHandler.ManageMultiPartFileAsync(Request);
foreach (FormItem item in formItems)
{
if (item.IsAFile)
{
if (item.ParameterName == "image" || item.MediaType.StartsWith("image/"))
{
string filePath = item.FileName;
imageUploaded = NcFileAdapter.SaveRecipeImage(item.FileName, item.Data);
}
}
}
if (!string.IsNullOrEmpty(newName))
{
// recupero i dati LIVE dei parametri HMI della ricetta...
CmsError libraryError = ncAdapter.ReadFullRecipe(out Dictionary<string, DTORecipeParam> currRecipe);
if (libraryError.IsError())
{
ThermoActiveLogger.LogError($"SaveAll error | {libraryError.exception}");
return BadRequest(libraryError.localizationKey);
}
var currParams = new Dictionary<string, double>();
foreach (var item in currRecipe)
{
currParams.Add(item.Key, item.Value.SetpointPLC);
}
// salvo parametri
NcFileAdapter.RecipeLiveData.RecipeParameters = currParams;
// ora salvo il dato del TC stimato se presente
if (estimTimeSec > 0)
{
NcFileAdapter.RecipeLiveData.TC_last = estimTimeSec;
}
// e salvo su disco
NcFileAdapter.SaveRecipe(newName, NcFileAdapter.RecipeLiveData);
}
return Ok();
}
/// <summary>
/// Do actual recipe parameters FileSave
/// </summary>
+1 -1
View File
@@ -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.36")]
[assembly: AssemblyVersion("0.9.38")]