156 lines
4.0 KiB
C#
156 lines
4.0 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.MONO.Core.DTO;
|
|
using MP.MONO.Data;
|
|
using MP.MONO.Data.DTO;
|
|
using MP.MONO.UI.Data;
|
|
using Newtonsoft.Json;
|
|
using static MP.MONO.Core.Enums;
|
|
|
|
namespace MP.MONO.UI.Components
|
|
{
|
|
public partial class ToolsPlot
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public int MachineId { get; set; } = 1;
|
|
|
|
public string ToolId
|
|
{
|
|
get => _selTool.Replace(" ", "_");
|
|
}
|
|
|
|
[Parameter]
|
|
public string SelectedTool
|
|
{
|
|
get => _selTool;
|
|
set => _selTool = value;
|
|
}
|
|
|
|
[Parameter]
|
|
public DataLogFilter SelFilter
|
|
{
|
|
get => _SelFilter;
|
|
set { _SelFilter = value; }
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected DateTime lastRec = DateTime.Now.AddMinutes(-1);
|
|
protected List<chartJsData.chartJsTSerie> LevelVal = new List<chartJsData.chartJsTSerie>();
|
|
protected Dictionary<string, string> listMaxVal = new Dictionary<string, string>();
|
|
protected Dictionary<string, string> listMinVal = new Dictionary<string, string>();
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected DataLogFilter _SelFilter { get; set; } = new DataLogFilter();
|
|
protected string _selTool { get; set; } = "";
|
|
|
|
protected string? MaxVal
|
|
{
|
|
get
|
|
{
|
|
string answ = "0";
|
|
if (listMaxVal != null && listMaxVal.Count > 0)
|
|
{
|
|
answ = listMaxVal[SelectedTool] ?? "0";
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
protected string? MinVal
|
|
{
|
|
get
|
|
{
|
|
string answ = "0";
|
|
if (listMinVal != null && listMinVal.Count > 0)
|
|
{
|
|
answ = listMinVal[SelectedTool] ?? "0";
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected List<string> getFillColors(string alpha)
|
|
{
|
|
List<string> answ = new List<string>();
|
|
answ.Add($"rgba(108, 214, 164, {alpha})");
|
|
return answ;
|
|
}
|
|
|
|
protected List<string> getLineColors(string alpha)
|
|
{
|
|
List<string> answ = new List<string>();
|
|
answ.Add($"rgba(54, 204, 82, {alpha})");
|
|
return answ;
|
|
}
|
|
|
|
protected List<string> getPointColors(string alpha)
|
|
{
|
|
List<string> answ = new List<string>();
|
|
answ.Add($"rgba(108, 158, 118, {alpha})");
|
|
return answ;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
isLoading = true;
|
|
await ReloadData();
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
protected async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
ListRecords = null;
|
|
await Task.Delay(1);
|
|
ListRecords = await MMDataService.DataLogDtoGetFilt(MachineId, DataLogType.Tools, SelectedTool, StartDate, EndDate);
|
|
await Task.Delay(1);
|
|
// converto in plotdata
|
|
LevelVal = ListRecords.Select(l => new chartJsData.chartJsTSerie() { x = l.DtRif, y = l.ValNum }).ToList();
|
|
await Task.Delay(1);
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private List<DataLogDTO>? ListRecords = null;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private DateTime EndDate
|
|
{
|
|
get => _SelFilter.DtEnd;
|
|
}
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private DateTime StartDate
|
|
{
|
|
get => _SelFilter.DtStart;
|
|
}
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |