Fix refresh gauge

This commit is contained in:
Samuele Locatelli
2023-10-27 11:57:46 +02:00
parent 1e8757a2e4
commit a99b514548
5 changed files with 79 additions and 70 deletions
+67 -56
View File
@@ -4,9 +4,6 @@ using Microsoft.JSInterop;
using MP.Data.DatabaseModels;
using MP.Data.Services;
using NLog;
using NLog.Fluent;
using static MP_TAB_SERV.Pages.User;
using static Org.BouncyCastle.Math.EC.ECCurve;
namespace MP_TAB_SERV.Components
{
@@ -14,9 +11,13 @@ namespace MP_TAB_SERV.Components
{
#region Public Properties
public string currIpv4 { get; set; } = "";
[Parameter]
public bool FullMode { get; set; } = true;
public int Height { get; set; } = 0;
[Parameter]
public int keepAliveMin { get; set; } = 5;
@@ -26,60 +27,10 @@ namespace MP_TAB_SERV.Components
[Parameter]
public bool showCard { get; set; }
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
public int Width { get; set; } = 0;
#endregion Public Properties
protected List<CircleGaugeMulti.CircSegm> innerCircleVals = new List<CircleGaugeMulti.CircSegm>();
protected List<CircleGaugeMulti.CircSegm> outerCircleVals = new List<CircleGaugeMulti.CircSegm>();
protected int currVal1 = 1000;
protected int currMaxVal = 1000;
protected int maxVal = 1000;
public int Height { get; set; } = 0;
public int Width { get; set; } = 0;
public string currIpv4 { get; set; } = "";
public class WindowDimension
{
public int Width { get; set; }
public int Height { get; set; }
}
protected async Task getWDim()
{
var dimension = await JSRuntime.InvokeAsync<WindowDimension>("getWindowDimensions");
Height = dimension.Height;
Width = dimension.Width;
}
protected async Task setGaugeVals()
{
await Task.Delay(1);
if (RecMSE != null)
{
innerCircleVals.Clear();
outerCircleVals.Clear();
currMaxVal = int.Parse(RecMSE.NumPezzi.ToString()!);
innerCircleVals.Add(new CircleGaugeMulti.CircSegm() { Color = "#FFC107", Value = RecMSE.PezziProd });
if (RecMSE.PezziConf > 0)
{
innerCircleVals.Add(new CircleGaugeMulti.CircSegm() { Color = "#198754", Value = RecMSE.PezziConf });
}
if (RecMSE.extraVal > 0)
{
outerCircleVals.Add(new CircleGaugeMulti.CircSegm() { Color = "#1367FD", Value = RecMSE.extraVal });
}
}
}
#region Public Methods
/// <summary>
@@ -147,12 +98,34 @@ namespace MP_TAB_SERV.Components
#endregion Public Methods
#region Public Classes
public class WindowDimension
{
#region Public Properties
public int Height { get; set; }
public int Width { get; set; }
#endregion Public Properties
}
#endregion Public Classes
#region Protected Fields
protected string baseCss = "sem";
protected int currMaxVal = 1000;
protected List<CircleGaugeMulti.CircSegm> innerCircleVals = new List<CircleGaugeMulti.CircSegm>();
protected int kaFactor = 60 / 2;
protected int maxVal = 1000;
protected List<CircleGaugeMulti.CircSegm> outerCircleVals = new List<CircleGaugeMulti.CircSegm>();
#endregion Protected Fields
#region Protected Properties
@@ -175,6 +148,9 @@ namespace MP_TAB_SERV.Components
}
}
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MessageService MServ { get; set; } = null!;
@@ -185,6 +161,13 @@ namespace MP_TAB_SERV.Components
#region Protected Methods
protected async Task getWDim()
{
var dimension = await JSRuntime.InvokeAsync<WindowDimension>("getWindowDimensions");
Height = dimension.Height;
Width = dimension.Width;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{//await Task.Delay(500);
if (firstRender)
@@ -197,20 +180,47 @@ namespace MP_TAB_SERV.Components
//return base.OnAfterRenderAsync(firstRender);
}
protected override async void OnInitialized()
protected override void OnInitialized()
{
isLoading = true;
// se configurata uso cartella virtuale... altrimenti cartella processo
imgBasePath = Environment.CurrentDirectory; // @"C:\Steamware\macchine";
await setGaugeVals();
}
protected override async Task OnParametersSetAsync()
{
isLoading = RecMSE == null;
await setGaugeVals();
await Task.Delay(1);
}
protected async Task setGaugeVals()
{
await Task.Delay(1);
Log.Info("MBlock 01");
if (RecMSE != null)
{
Log.Info("MBlock 02");
innerCircleVals.Clear();
outerCircleVals.Clear();
currMaxVal = int.Parse(RecMSE.NumPezzi.ToString()!);
innerCircleVals.Add(new CircleGaugeMulti.CircSegm() { Color = "#FFC107", Value = RecMSE.PezziProd });
if (RecMSE.PezziConf > 0)
{
innerCircleVals.Add(new CircleGaugeMulti.CircSegm() { Color = "#198754", Value = RecMSE.PezziConf });
}
if (RecMSE.extraVal > 0)
{
outerCircleVals.Add(new CircleGaugeMulti.CircSegm() { Color = "#1367FD", Value = RecMSE.extraVal });
}
Log.Info("MBlock 03");
}
else
{
Log.Info("MBlock NO DATA");
}
}
protected async Task ShowDetail()
{
// salvo idxMacch
@@ -223,6 +233,7 @@ namespace MP_TAB_SERV.Components
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private string imgBasePath = "";
private bool isLoading = false;
+2 -2
View File
@@ -78,9 +78,9 @@ else
</div>
</div>
<div class="col-12 col-lg-6 text-nowrap text-success">
TC: @($"{item.Tcassegnato:N2}")
TC: @($"{item.Tcassegnato:N2}") (min)
<div class="text-secondary textCondens">
@TCMinSec(item.Tcassegnato) (ore:min:sec)
@TCMinSec(item.Tcassegnato)
</div>
</div>
</div>
+8 -1
View File
@@ -93,7 +93,14 @@ namespace MP_TAB_SERV.Components
if (fatto)
{
TimeSpan ts = TimeSpan.FromMinutes(TC);
TC_MinSec = $"{ts.Hours}:{ts.Minutes}:{ts.Seconds:00}";
if (ts.TotalHours > 1)
{
TC_MinSec = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00} (h:m:s)";
}
else
{
TC_MinSec = $"{ts.Minutes:00}:{ts.Seconds:00} (m:s)";
}
}
}
return TC_MinSec;
+1 -10
View File
@@ -20,12 +20,6 @@ namespace MP_TAB_SERV.Pages
#region Protected Methods
protected override async Task OnInitializedAsync()
{
//await ReloadData();
await Task.Delay(1);
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await ReloadData();
}
@@ -57,15 +51,12 @@ namespace MP_TAB_SERV.Pages
{
try
{
Log.Trace("ProdPlan 01");
if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null)
if (string.IsNullOrEmpty(IdxMacc))
{
Log.Trace("ProdPlan 02");
IdxMacc = await MsgServ.IdxMaccGet();
// recupero MSE macchina....
if (!string.IsNullOrEmpty(IdxMacc))
{
Log.Trace("ProdPlan 03");
CurrMSE = await MsgServ.GetMachineMse(IdxMacc);
}
}
+1 -1
View File
@@ -263,7 +263,7 @@ namespace MP.Data.Services
/// <returns></returns>
public async Task<MappaStatoExpl?> GetMachineMse(string idxMacchina)
{
MappaStatoExpl answ = null;// new MappaStatoExpl();
MappaStatoExpl answ = null;
string rawData = await localStorage.GetItemAsync<string>(machineMse(idxMacchina));
if (rawData != "")
{