aggiunta history plot
This commit is contained in:
@@ -1,41 +1,55 @@
|
||||
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>();
|
||||
|
||||
protected Dictionary<string, List<chartJsData.chartJsTSerie>> plotData = new Dictionary<string, List<chartJsData.chartJsTSerie>>();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected DataLogFilter _SelFilter { get; set; } = new DataLogFilter();
|
||||
protected string _selTool { get; set; } = "";
|
||||
|
||||
protected List<chartJsData.chartJsTSerie> LevelVal
|
||||
{
|
||||
get
|
||||
{
|
||||
List<chartJsData.chartJsTSerie> answ = new List<chartJsData.chartJsTSerie>();
|
||||
if (plotData.ContainsKey(SelectedTool))
|
||||
{
|
||||
answ = plotData[SelectedTool];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
protected string? MaxVal
|
||||
{
|
||||
get
|
||||
@@ -66,148 +80,77 @@ namespace MP.MONO.UI.Components
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public int maxRecord { get; set; } = 120;
|
||||
|
||||
public string ToolId
|
||||
{
|
||||
get => _selTool.Replace(" ", "_");
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public double sampleSecMin { get; set; } = 1;
|
||||
|
||||
[Parameter]
|
||||
public string SelectedTool
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selTool;
|
||||
}
|
||||
set
|
||||
{
|
||||
// controllo se è variato
|
||||
if (_selTool != value)
|
||||
{
|
||||
// salvo
|
||||
_selTool = value;
|
||||
// cerco se ho in dictionary...
|
||||
if (!plotData.ContainsKey(value))
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
// creo un oggetto della lunghezza desiderata...
|
||||
var emptyData = new List<chartJsData.chartJsTSerie>();
|
||||
for (int i = -maxRecord; i < 0; i++)
|
||||
{
|
||||
emptyData.Add(new chartJsData.chartJsTSerie() { x = adesso.AddSeconds(i), y = 0 });
|
||||
}
|
||||
plotData.Add(value, emptyData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
//private int inputValue = 123;
|
||||
private void ToolsPipe_EA_NewMessage(object? sender, EventArgs e)
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
if (lastRec.AddSeconds(sampleSecMin) < adesso)
|
||||
{
|
||||
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
||||
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
||||
{
|
||||
try
|
||||
{
|
||||
var ListRecords = JsonConvert.DeserializeObject<List<DisplayDataDTO>>(currArgs.newMessage);
|
||||
// prendo SOLO il dato della TS richiesta
|
||||
if (ListRecords != null)
|
||||
{
|
||||
// accodo in blocco tutti i valori...
|
||||
foreach (var item in ListRecords)
|
||||
{
|
||||
// cerco se ci sono min/max del valore indicato...
|
||||
if (!listMinVal.ContainsKey(item.Title))
|
||||
{
|
||||
listMinVal.Add(item.Title, $"{item.MinVal:N0}");
|
||||
}
|
||||
if (!listMaxVal.ContainsKey(item.Title))
|
||||
{
|
||||
listMaxVal.Add(item.Title, $"{item.MaxVal:N0}");
|
||||
}
|
||||
// verifico dictionary se mancasse...
|
||||
if (!plotData.ContainsKey(item.Title))
|
||||
{
|
||||
//plotData.Add(item.Title, new List<chartJsData.chartJsTSerie>());
|
||||
// creo un oggetto della lunghezza desiderata...
|
||||
var emptyData = new List<chartJsData.chartJsTSerie>();
|
||||
for (int i = -maxRecord; i < 0; i++)
|
||||
{
|
||||
emptyData.Add(new chartJsData.chartJsTSerie() { x = adesso.AddSeconds(i), y = 0 });
|
||||
}
|
||||
plotData.Add(item.Title, emptyData);
|
||||
}
|
||||
// ora accodo il valore
|
||||
if (plotData.ContainsKey(item.Title))
|
||||
{
|
||||
plotData[item.Title].Add(new chartJsData.chartJsTSerie() { x = adesso, y = item.ValueNum });
|
||||
// verifico limite visualizzazione
|
||||
if (plotData[item.Title].Count > maxRecord)
|
||||
{
|
||||
plotData[item.Title].RemoveRange(0, plotData[item.Title].Count - maxRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
lastRec = adesso;
|
||||
}
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected List<string> getFillColors(string alpha)
|
||||
{
|
||||
List<string> answ = new List<string>();
|
||||
answ.Add($"rgba(108, 164, 254, {alpha})");
|
||||
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, 82, 254, {alpha})");
|
||||
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, 118, 158, {alpha})");
|
||||
answ.Add($"rgba(108, 158, 118, {alpha})");
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
//await ReloadData();
|
||||
await ReloadData();
|
||||
await Task.Delay(1);
|
||||
MMDataService.toolsPipe.EA_NewMessage += ToolsPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
@using MP.MONO.UI.Components
|
||||
@using MP.MONO.Core.DTO
|
||||
@using MP.MONO.UI.Data
|
||||
@using Microsoft.Extensions.Configuration;
|
||||
|
||||
@inject IConfiguration Configuration;
|
||||
|
||||
@inject CurrentDataService MMDataService
|
||||
|
||||
@if (!string.IsNullOrEmpty(@SelectedTool))
|
||||
{
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<div class="px-1 border border-info rounded">
|
||||
<i class="fa-solid fa-tower-broadcast"></i> <b>@SelectedTool</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex">
|
||||
<div class="px-1 flex-fill">
|
||||
@if (LevelVal == null || LevelVal.Count == 0)
|
||||
{
|
||||
<LoadingDataSmall></LoadingDataSmall>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MP.MONO.UI.Components.Chart.Line ChartId="@ToolId" AspRatio="4" DataTS="@LevelVal" lineColor="@getLineColors("0.75")" backColor="@getFillColors("0.25")" pointColor="@getPointColors("1")" lTens="0" MinValue="@MinVal" MaxValue="@MaxVal"></MP.MONO.UI.Components.Chart.Line>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.MONO.Core.DTO;
|
||||
using MP.MONO.Data;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MP.MONO.UI.Components
|
||||
{
|
||||
public partial class ToolsPlotRT
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected DateTime lastRec = DateTime.Now.AddMinutes(-1);
|
||||
|
||||
protected Dictionary<string, string> listMaxVal = new Dictionary<string, string>();
|
||||
|
||||
protected Dictionary<string, string> listMinVal = new Dictionary<string, string>();
|
||||
|
||||
protected Dictionary<string, List<chartJsData.chartJsTSerie>> plotData = new Dictionary<string, List<chartJsData.chartJsTSerie>>();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected string _selTool { get; set; } = "";
|
||||
|
||||
protected List<chartJsData.chartJsTSerie> LevelVal
|
||||
{
|
||||
get
|
||||
{
|
||||
List<chartJsData.chartJsTSerie> answ = new List<chartJsData.chartJsTSerie>();
|
||||
if (plotData.ContainsKey(SelectedTool))
|
||||
{
|
||||
answ = plotData[SelectedTool];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
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 Public Properties
|
||||
|
||||
[Parameter]
|
||||
public int maxRecord { get; set; } = 120;
|
||||
|
||||
public string ToolId
|
||||
{
|
||||
get => _selTool.Replace(" ", "_");
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public double sampleSecMin { get; set; } = 1;
|
||||
|
||||
[Parameter]
|
||||
public string SelectedTool
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selTool;
|
||||
}
|
||||
set
|
||||
{
|
||||
// controllo se è variato
|
||||
if (_selTool != value)
|
||||
{
|
||||
// salvo
|
||||
_selTool = value;
|
||||
// cerco se ho in dictionary...
|
||||
if (!plotData.ContainsKey(value))
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
// creo un oggetto della lunghezza desiderata...
|
||||
var emptyData = new List<chartJsData.chartJsTSerie>();
|
||||
for (int i = -maxRecord; i < 0; i++)
|
||||
{
|
||||
emptyData.Add(new chartJsData.chartJsTSerie() { x = adesso.AddSeconds(i), y = 0 });
|
||||
}
|
||||
plotData.Add(value, emptyData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
//private int inputValue = 123;
|
||||
private void ToolsPipe_EA_NewMessage(object? sender, EventArgs e)
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
if (lastRec.AddSeconds(sampleSecMin) < adesso)
|
||||
{
|
||||
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
||||
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
||||
{
|
||||
try
|
||||
{
|
||||
var ListRecords = JsonConvert.DeserializeObject<List<DisplayDataDTO>>(currArgs.newMessage);
|
||||
// prendo SOLO il dato della TS richiesta
|
||||
if (ListRecords != null)
|
||||
{
|
||||
// accodo in blocco tutti i valori...
|
||||
foreach (var item in ListRecords)
|
||||
{
|
||||
// cerco se ci sono min/max del valore indicato...
|
||||
if (!listMinVal.ContainsKey(item.Title))
|
||||
{
|
||||
listMinVal.Add(item.Title, $"{item.MinVal:N0}");
|
||||
}
|
||||
if (!listMaxVal.ContainsKey(item.Title))
|
||||
{
|
||||
listMaxVal.Add(item.Title, $"{item.MaxVal:N0}");
|
||||
}
|
||||
// verifico dictionary se mancasse...
|
||||
if (!plotData.ContainsKey(item.Title))
|
||||
{
|
||||
//plotData.Add(item.Title, new List<chartJsData.chartJsTSerie>());
|
||||
// creo un oggetto della lunghezza desiderata...
|
||||
var emptyData = new List<chartJsData.chartJsTSerie>();
|
||||
for (int i = -maxRecord; i < 0; i++)
|
||||
{
|
||||
emptyData.Add(new chartJsData.chartJsTSerie() { x = adesso.AddSeconds(i), y = 0 });
|
||||
}
|
||||
plotData.Add(item.Title, emptyData);
|
||||
}
|
||||
// ora accodo il valore
|
||||
if (plotData.ContainsKey(item.Title))
|
||||
{
|
||||
plotData[item.Title].Add(new chartJsData.chartJsTSerie() { x = adesso, y = item.ValueNum });
|
||||
// verifico limite visualizzazione
|
||||
if (plotData[item.Title].Count > maxRecord)
|
||||
{
|
||||
plotData[item.Title].RemoveRange(0, plotData[item.Title].Count - maxRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
lastRec = adesso;
|
||||
}
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected List<string> getFillColors(string alpha)
|
||||
{
|
||||
List<string> answ = new List<string>();
|
||||
answ.Add($"rgba(108, 164, 254, {alpha})");
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected List<string> getLineColors(string alpha)
|
||||
{
|
||||
List<string> answ = new List<string>();
|
||||
answ.Add($"rgba(54, 82, 254, {alpha})");
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected List<string> getPointColors(string alpha)
|
||||
{
|
||||
List<string> answ = new List<string>();
|
||||
answ.Add($"rgba(108, 118, 158, {alpha})");
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
//await ReloadData();
|
||||
await Task.Delay(1);
|
||||
MMDataService.toolsPipe.EA_NewMessage += ToolsPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@
|
||||
public class DataLogFilter
|
||||
{
|
||||
|
||||
public DateTime DtStart { get; set; } = DateTime.Today.AddDays(-1);
|
||||
public DateTime DtEnd { get; set; } = DateTime.Today.AddDays(1);
|
||||
public DateTime DtStart { get; set; } = DateTime.Today.AddDays(-3);
|
||||
public DateTime DtEnd { get; set; } = DateTime.Today.AddDays(3);
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Platforms>AnyCPU;x86;x64</Platforms>
|
||||
<Version>1.2.2210.314</Version>
|
||||
<Version>1.2.2210.315</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -2,23 +2,51 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<h3>Tools</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-3">
|
||||
<ToolsOverview SelVal="@selTools" EC_AddValue="toolAdded" EC_RemValue="toolRemoved"></ToolsOverview>
|
||||
<h3>Tools</h3>
|
||||
|
||||
</div>
|
||||
<div class="row col-9">
|
||||
@foreach (var item in selTools)
|
||||
{
|
||||
<div class="@pcss">
|
||||
<ToolsPlot SelectedTool="@item" maxRecord="@maxRecord" sampleSecMin="@sampleSecMin"></ToolsPlot>
|
||||
</div>
|
||||
<div class="col-9 d-flex justify-content-between">
|
||||
<div class="px-0">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-text">
|
||||
<div class="form-check form-check-sm form-switch py-1" title="Parameter View Mode (RealTime / LogData)">
|
||||
<input class="form-check-input" type="checkbox" id="mySwitch" name="setupAlarms" value="@isRT" checked @onclick="() => toggleRT()">
|
||||
<label class="form-check-label" for="mySwitch">@currMode</label>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-3">
|
||||
<ToolsOverview SelVal="@selTools" EC_AddValue="toolAdded" EC_RemValue="toolRemoved"></ToolsOverview>
|
||||
</div>
|
||||
<div class="row col-9">
|
||||
@if (isRT)
|
||||
{
|
||||
|
||||
@foreach (var item in selTools)
|
||||
{
|
||||
<div class="@pcss">
|
||||
<ToolsPlotRT SelectedTool="@item" maxRecord="@maxRecord" sampleSecMin="@sampleSecMin"></ToolsPlotRT>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@foreach (var item in selTools)
|
||||
{
|
||||
<div class="@pcss">
|
||||
<ToolsPlot SelectedTool="@item"></ToolsPlot>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>MAPO-MONO</i>
|
||||
<h4>Version: 1.2.2210.314</h4>
|
||||
<h4>Version: 1.2.2210.315</h4>
|
||||
<br /> Release Note:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.2.2210.314
|
||||
1.2.2210.315
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.2.2210.314</version>
|
||||
<version>1.2.2210.315</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.UI/stable/LAST/MP.Mon.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.UI/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user