Continuo split componenti chart

This commit is contained in:
zaccaria.majid
2022-09-28 17:29:45 +02:00
parent 613c4edba8
commit f6722af1cc
11 changed files with 370 additions and 240 deletions
+18
View File
@@ -0,0 +1,18 @@
<div class="d-flex justify-content-between">
<div class="d-flex justify-content-between">
<h7 class="py-1">Choose mode:</h7>
<div class="form-switch mx-3 py-1 d-flex justify-content-between">
<input class="form-check-input py-1" type="checkbox" role="switch" id="toggleRec" title="Show Alarms log or Alarm rec" @onclick="() => toggleRec()">
<label for="toggleRec">@currMode</label>
</div>
</div>
<div class="col-6 d-flex justify-content-between">
<div class="input-group mb-3">
<label class="input-group-text" title="Choose Date/Time where to start analizing">Start</label>
<input @bind=dtStart id="DtRef" class="form-control" type="datetime-local" title="Choose Date/Time where to start analizing">
<label class="input-group-text" title="Choose Date/Time where to finish analizing">End</label>
<input @bind=dtEnd id="DtRef" class="form-control" type="datetime-local" title="Choose Date/Time where to finish analizing">
</div>
</div>
</div>
+111
View File
@@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using MP.MONO.UI;
using MP.MONO.UI.Shared;
using MP.MONO.UI.Components;
using MP.MONO.UI.Data;
namespace MP.MONO.UI.Components
{
public partial class ChartFilter
{
#region Public Properties
[Parameter]
public EventCallback<selectChartParams> FilterChanged { get; set; }
[Parameter]
public selectChartParams SelFilter { get; set; } = null!;
#endregion Public Properties
#region Public Methods
/// <summary>
/// Inizializzazione con periodo e arrotondamento
/// </summary>
/// <param name="minRound"></param>
/// <returns></returns>
public static DateTime RoundDatetime(int minRound)
{
TimeSpan DayElapsed = DateTime.Now.Subtract(DateTime.Today);
int minDay = (int)Math.Ceiling((double)(DayElapsed.TotalMinutes / minRound)) * minRound;
DateTime endRounded = DateTime.Today.AddMinutes(minDay);
return endRounded;
}
#endregion Public Methods
#region Protected Properties
protected override async Task OnInitializedAsync()
{
SelFilter = new selectChartParams();
await FilterChanged.InvokeAsync(SelFilter);
setDtMinMax();
}
protected void setDtMinMax()
{
// copio il filtro
var currFilt = SelFilter;
currFilt.CurrPage = 0;
currFilt.dtMax = RoundDatetime(5);
currFilt.dtMin = RoundDatetime(5).AddHours(-2);
SelFilter = currFilt;
}
protected async Task toggleRec()
{
setFreqDur = !setFreqDur;
await Task.Delay(1);
}
protected bool setFreqDur
{
get => SelFilter.setFreqDur;
set => SelFilter.setFreqDur = value;
}
private DateTime? dtStart
{
get => SelFilter.dtMin;
set
{
if (SelFilter.dtMax != value)
{
SelFilter.dtMin = value;
reportChange();
}
}
}
protected DateTime _dtEnd = DateTime.Now;
private DateTime? dtEnd
{
get => SelFilter.dtMax;
set
{
if (SelFilter.dtMax != value)
{
SelFilter.dtMax = value;
reportChange();
}
}
}
protected string currMode
{
get => setFreqDur ? "Alarm frequency" : "Alarm duration";
}
private void reportChange()
{
FilterChanged.InvokeAsync(SelFilter);
}
#endregion Protected Properties
}
}
+51 -48
View File
@@ -8,24 +8,41 @@ namespace MP.MONO.UI.Components
{
protected List<AlarmFreqDTO>? ListRecordsFreq { get; set; } = null;
private int totalCount { get; set; } = 0;
private int _totalCount { get; set; } = 0;
private int totalCount
{
get => _totalCount;
set
{
if (_totalCount != value)
{
_totalCount = value;
TotRecordChanged.InvokeAsync(value);
}
}
}
[Parameter]
public EventCallback<bool> PagerResetReq { get; set; }
[Parameter]
public selectChartParams selFilter { get; set; } = null!;
[Parameter]
public EventCallback<int> TotRecordChanged { get; set; }
protected List<AlarmFreqDTO>? SearchRecordsFreq { get; set; } = null;
[Parameter]
public int _numRecord { get; set; } = 0;
[Parameter]
public int _currPage { get; set; } = 0;
public int totalVar { get; set; } = 0;
public int totalVar { get; set; } = 0;
private int numRecord
{
get => _numRecord;
get => selFilter.MaxRecord;
set
{
if (_numRecord != value)
if (selFilter.MaxRecord != value)
{
_numRecord = value;
selFilter.MaxRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
@@ -34,58 +51,36 @@ namespace MP.MONO.UI.Components
public int currPage
{
get => _currPage;
get => selFilter.CurrPage;
set
{
if (_currPage != value)
if (selFilter.CurrPage != value)
{
_currPage = value;
if (_currPage != value)
{
_currPage = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
selFilter.CurrPage = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
//[Inject]
//protected MessageService MessageService { get; set; } = null!;
protected DateTime _dtStart = DateTime.Now.AddHours(-24);
protected DateTime dtStart
protected DateTime? dtStart
{
get => _dtStart;
set
{
_dtStart = value;
var pUpd = Task.Run(async () =>
{
await ReloadData();
});
pUpd.Wait();
}
get => selFilter.dtMin;
set => selFilter.dtMin = value;
}
protected DateTime _dtEnd = DateTime.Now;
protected DateTime dtEnd
protected DateTime? dtEnd
{
get => _dtEnd;
set
{
_dtEnd = value;
var pUpd = Task.Run(async () =>
{
await ReloadData();
});
pUpd.Wait();
}
get => selFilter.dtMax;
set => selFilter.dtMax = value;
}
private bool isLoading { get; set; } = false;
private async Task ReloadData()
{
DateTime dtMax = dtStart == null ? DateTime.Now : (DateTime)dtStart;
DateTime dtMin = dtEnd == null ? DateTime.Now.AddDays(-2) : (DateTime)dtEnd;
isLoading = true;
SearchRecordsFreq = CurrentDataService.dbController.AlarmRecGetParetoFreq(1, dtStart, dtEnd);
SearchRecordsFreq = CurrentDataService.dbController.AlarmRecGetParetoFreq(1, dtMin, dtMax);
ListRecordsFreq = SearchRecordsFreq.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
totalCount = SearchRecordsFreq.Count;
totalVar = SearchRecordsFreq.Sum(x => x.EventCount);
@@ -93,10 +88,18 @@ namespace MP.MONO.UI.Components
await Task.Delay(1);
isLoading = false;
}
public static DateTime RoundDatetime(int minRound)
{
TimeSpan DayElapsed = DateTime.Now.Subtract(DateTime.Today);
int minDay = (int)Math.Ceiling((double)(DayElapsed.TotalMinutes / minRound)) * minRound;
DateTime endRounded = DateTime.Today.AddMinutes(minDay);
return endRounded;
}
protected override async Task OnInitializedAsync()
{
SearchRecordsFreq = CurrentDataService.dbController.AlarmRecGetParetoFreq(1, dtStart, dtEnd);
DateTime dtMax = dtStart == null ? DateTime.Now : (DateTime)dtStart;
DateTime dtMin = dtEnd == null ? DateTime.Now.AddDays(-2) : (DateTime)dtEnd;
SearchRecordsFreq = CurrentDataService.dbController.AlarmRecGetParetoFreq(1, dtMin, dtMax);
ListRecordsFreq = SearchRecordsFreq.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await ReloadData();
@@ -159,6 +162,6 @@ namespace MP.MONO.UI.Components
return ans;
}
}
}
+48
View File
@@ -0,0 +1,48 @@
namespace MP.MONO.UI.Data
{
public class selectChartParams
{
#region Public Constructors
public selectChartParams()
{ }
#endregion Public Constructors
#region Public Properties
public int CurrPage { get; set; } = 1;
public DateTime? dtMax { get; set; } = null;
public DateTime? dtMin { get; set; } = null;
public int MaxRecord { get; set; } = 100;
public bool setFreqDur { get; set; } = true;
#endregion Public Properties
#region Public Methods
public override bool Equals(object obj)
{
if (!(obj is selectChartParams item))
return false;
if (MaxRecord != item.MaxRecord)
return false;
if (CurrPage != item.CurrPage)
return false;
if (setFreqDur != item.setFreqDur)
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.2.2209.2717</Version>
<Version>1.2.2209.2816</Version>
</PropertyGroup>
<ItemGroup>
+2 -2
View File
@@ -7,7 +7,7 @@
@inject CurrentDataService MMDataService
<div class="card">
<div class="card mb-5">
<div class="card-header">
<div class="row">
<div class="col-12 col-md-6 col-lg-3">
@@ -83,7 +83,7 @@
@*<div class="py-1" style="border-left: 3px solid black;
height: 30px;"></div>*@
<div ></div>
<h7 class="py-1">Choose modality:</h7>
<h7 class="py-1">Choose mode:</h7>
<div class="form-switch mx-2 py-1 col-6 d-flex justify-content-between">
<input class="form-check-input col-2 py-1" type="checkbox" role="switch" id="toggleRec" title="Show Alarms log or Alarm rec" @onclick="() => toggleRec()">
<label class="col-12" for="toggleRec">@currMode</label>
+58 -62
View File
@@ -3,36 +3,32 @@
@using MP.MONO.UI.Components
<div class="card">
<div class="card-header table-primary p-1 d-flex justify-content-between">
<div>
<div class="card mb-5">
<div class=" col-12 card-header table-primary p-1 d-flex justify-content-between">
<div class="col-2">
<h5>Alarm analysis</h5>
</div>
<div class="px-2 col-4 d-flex justify-content-between">
<h7 class="py-1">Choose modality:</h7>
<div class="form-switch mx-3 py-1 col-7 d-flex justify-content-between">
<input class="form-check-input col-2 py-1" type="checkbox" role="switch" id="toggleRec" title="Show Alarms log or Alarm rec" @onclick="() => toggleRec()">
<label class="col-12" for="toggleRec">@currMode</label>
</div>
</div>
<div class ="col-10">
<ChartFilter FilterChanged="updateFilter"></ChartFilter>
</div>
@*<div class="px-2 col-4 d-flex justify-content-between">
<h7 class="py-1">Choose mode:</h7>
<div class="form-switch mx-3 py-1 col-7 d-flex justify-content-between">
<input class="form-check-input col-2 py-1" type="checkbox" role="switch" id="toggleRec" title="Show Alarms log or Alarm rec" @onclick="() => toggleRec()">
<label class="col-12" for="toggleRec">@currMode</label>
</div>
</div>
<div class="col-6 d-flex justify-content-between">
<div class="input-group mb-3">
<label class="input-group-text" title="Choose Date/Time where to start analizing">Start</label>
<input @bind=dtStart id ="DtRef" class="form-control" type="datetime-local" title="Choose Date/Time where to start analizing">
<input @bind=dtStart id="DtRef" class="form-control" type="datetime-local" title="Choose Date/Time where to start analizing">
<label class="input-group-text" title="Choose Date/Time where to finish analizing">End</label>
<input @bind=dtEnd id="DtRef" class="form-control" type="datetime-local" title="Choose Date/Time where to finish analizing">
</div>
</div>
</div>*@
</div>
<div class="card-body py-0 px-1">
@if (ShowCharts == true)
{
@*<ChartAlarms RawData="SearchRecords"></ChartAlarms>*@
}@*
@if (currRecord != null)
{
<DetailOee currRecord="@currRecord"></DetailOee>
}*@
@if ((ListRecordsFreq == null && setFreqDur) || (ListRecordsDur == null && !setFreqDur))
{
<LoadingData></LoadingData>
@@ -45,49 +41,49 @@
{
@if (setFreqDur)
{
<ListFreqAlarms _numRecord="numRecord" _currPage="currPage"></ListFreqAlarms>
@*<div class="row">
<div class="col-12">
<table class="table table-sm table-striped">
<thead>
<tr>
<th>Alarm Description</th>
<th>Alarm Event Count</th>
<th>Event Frequency</th>
<th>Event Frequency Chart</th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecordsFreq)
{
<ListFreqAlarms selFilter="@currFilter" TotRecordChanged="@updateTotal"></ListFreqAlarms>
@*<div class="row">
<div class="col-12">
<table class="table table-sm table-striped">
<thead>
<tr>
<td>
<div>@record.AlarmDescription</div>
</td>
<td>
<div>@record.EventCount</div>
</td>
<td>
<div>
@if (totalVar != 0)
{
<span class="text-success">@calcPercFreq((double)record.EventCount)</span>
}
</div>
</td>
<td>
<div class="progress">
<div class="progress-bar @styleColourPBarFreq((double)record.EventCount/totalVar)" role="progressbar" style="@valFreq((double)record.EventCount)" aria-valuemin="0" aria-valuemax="100">@record.EventCount</div>
</div>
</td>
<th>Alarm Description</th>
<th>Alarm Event Count</th>
<th>Event Frequency</th>
<th>Event Frequency Chart</th>
</tr>
}
</tbody>
</table>
</div>
</div>*@
</thead>
<tbody>
@foreach (var record in ListRecordsFreq)
{
<tr>
<td>
<div>@record.AlarmDescription</div>
</td>
<td>
<div>@record.EventCount</div>
</td>
<td>
<div>
@if (totalVar != 0)
{
<span class="text-success">@calcPercFreq((double)record.EventCount)</span>
}
</div>
</td>
<td>
<div class="progress">
<div class="progress-bar @styleColourPBarFreq((double)record.EventCount/totalVar)" role="progressbar" style="@valFreq((double)record.EventCount)" aria-valuemin="0" aria-valuemax="100">@record.EventCount</div>
</div>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>*@
}
else
{
@@ -124,7 +120,7 @@
<td>
<div class="progress">
<div class="progress-bar @styleColourPBarDur((double)item.Duration/totalVar)" role="progressbar" style="@valDur((double)item.Duration)" aria-valuemin="0" aria-valuemax="100">@Math.Round(item.Duration,2)</div>
</div>
</div>
</td>
</tr>
}
+78 -124
View File
@@ -1,26 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using MP.MONO.UI;
using MP.MONO.UI.Shared;
using MP.MONO.UI.Components;
using MP.MONO.Data.DbModels;
using MP.MONO.UI.Data;
using MP.MONO.Data.DTO;
using System.Diagnostics.Tracing;
using System.Security.Cryptography.X509Certificates;
using System.DirectoryServices.Protocols;
using System.Security;
using MP.MONO.UI.Data;
namespace MP.MONO.UI.Pages
{
@@ -35,6 +14,7 @@ namespace MP.MONO.UI.Pages
private List<AlarmFreqDTO>? SearchRecordsFreq = null;
private List<AlarmDurationDTO>? SearchRecordsDur = null;
private selectChartParams currFilter { get; set; } = new selectChartParams();
#endregion Private Fields
@@ -43,8 +23,6 @@ namespace MP.MONO.UI.Pages
private int _currPage { get; set; } = 1;
private int _numRecord { get; set; } = 10;
protected double totalVar = 0;
protected string percEvents = "";
private int currPage
{
@@ -59,59 +37,12 @@ namespace MP.MONO.UI.Pages
}
}
}
//protected int _numHourPrev = 24;
//protected int numHourPrev
//{
// get => _numHourPrev;
// set
// {
// _numHourPrev = value;
// var pUpd = Task.Run(async () =>
// {
// await ReloadData();
// });
// pUpd.Wait();
// }
//}
protected string currMode
{
get => setFreqDur ? "Alarm frequency" : "Alarm duration";
}
public bool setFreqDur { get; set; } = true;
protected async Task toggleRec()
{
setFreqDur = !setFreqDur;
await Task.Delay(1);
await ReloadData();
}
protected DateTime _dtStart = DateTime.Now.AddHours(-24);
protected DateTime dtStart
{
get => _dtStart;
set
{
_dtStart = value;
var pUpd = Task.Run(async () =>
{
await ReloadData();
});
pUpd.Wait();
}
}
protected DateTime _dtEnd = DateTime.Now;
protected DateTime dtEnd
{
get => _dtEnd;
set
{
_dtEnd = value;
var pUpd = Task.Run(async () =>
{
await ReloadData();
});
pUpd.Wait();
}
}
private bool isLoading { get; set; } = false;
@@ -129,32 +60,60 @@ namespace MP.MONO.UI.Pages
}
}
private bool ShowCharts { get; set; } = true;
#endregion Private Properties
#region Protected Properties
protected async Task toggleRec()
{
setFreqDur = !setFreqDur;
await Task.Delay(1);
await ReloadData();
}
protected DateTime _dtStart = DateTime.Now.AddHours(-24);
protected DateTime dtStart
{
get => _dtStart;
set
{
_dtStart = value;
var pUpd = Task.Run(async () =>
{
await ReloadData();
});
pUpd.Wait();
}
}
protected DateTime _dtEnd = DateTime.Now;
protected DateTime dtEnd
{
get => _dtEnd;
set
{
_dtEnd = value;
var pUpd = Task.Run(async () =>
{
await ReloadData();
});
pUpd.Wait();
}
}
protected int totalCount { get; set; } = 0;
//{
// get
// {
// int answ = 0;
// if (SearchRecordsFreq != null && setFreqDur)
// {
// answ = SearchRecordsFreq.Count;
// }
// else
// {
// //answ = SearchRecordsDur.Count;
// }
// return answ;
// }
//}
protected string currMode
{
get => setFreqDur ? "Alarm frequency" : "Alarm duration";
}
protected double totalVar = 0;
protected string percEvents = "";
#endregion Protected Properties
#region Private Methods isLoading = false;
//}
private async Task ReloadData()
@@ -184,7 +143,7 @@ namespace MP.MONO.UI.Pages
isLoading = false;
}
#endregion Private Methods
#endregion Private Methods isLoading = false;
#region Protected Methods
@@ -209,13 +168,15 @@ namespace MP.MONO.UI.Pages
else
{
SearchRecordsDur = CurrentDataService.dbController.AlarmRecGetParetoDur(1, dtStart, dtEnd);
ListRecordsDur= SearchRecordsDur.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
ListRecordsDur = SearchRecordsDur.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
//calcolaSoglieDur();
}
await ReloadData();
}
private double sogliaGreen = 0;
private double sogliaRed = 1;
private void calcolaSoglieFreq()
{
int numRecord = totalCount;
@@ -230,6 +191,7 @@ namespace MP.MONO.UI.Pages
sogliaRed = (double)lastRecord.EventCount / totalVar;
}
}
private void calcolaSoglieDur()
{
int numRecord = totalCount;
@@ -249,12 +211,14 @@ namespace MP.MONO.UI.Pages
{
currRecord = null;
}
protected string calcPercFreq(double numEvent)
{
string ans = $"{numEvent / totalVar:P2}";
return ans;
}
protected string calcPercDur(double duration)
{
string ans = $"{duration / totalVar:P2}";
@@ -308,9 +272,9 @@ namespace MP.MONO.UI.Pages
ans = "bg-warning";
}
return ans;
}
protected string styleColourPBarDur(double duration)
{
string ans = "";
@@ -331,29 +295,21 @@ namespace MP.MONO.UI.Pages
ans = "bg-warning";
}
return ans;
}
protected void Select(AlarmFreqDTO selRecord)
{
// applico filtro da selezione
currRecord = selRecord;
}
protected async Task ToggleChart(bool doShow)
{
ShowCharts = !ShowCharts;
if (ShowCharts)
{
await ReloadData();
}
}
protected async Task UpdateData()
{
currRecord = null;
await ReloadData();
}
protected override async Task OnParametersSetAsync()
{
isLoading = true;
@@ -364,28 +320,26 @@ namespace MP.MONO.UI.Pages
#endregion Protected Methods
#region Public Methods
public string checkSelect(DateTime DtStart, double EventCount, int IdxMacchina)
protected void updateTotal(int newTotCount)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.MachineId == IdxMacchina && currRecord.EventCount == EventCount) ? "table-info" : "";
}
catch
{ }
}
return answ;
totalCount = newTotCount;
}
public async void OnSeachUpdated()
private async Task updateFilter(selectChartParams newParams)
{
await InvokeAsync(() =>
isLoading = true;
await Task.Delay(1);
currPage = 1;
if (newParams.CurrPage == 0)
{
Task task = UpdateData();
StateHasChanged();
});
newParams.CurrPage = 1;
}
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
newParams.dtMax = dtEnd;
newParams.dtMin = dtStart;
currFilter = newParams;
isLoading = false;
}
#endregion Public Methods
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.2.2209.2717</h4>
<h4>Version: 1.2.2209.2816</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.2.2209.2717
1.2.2209.2816
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.2.2209.2717</version>
<version>1.2.2209.2816</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>