diff --git a/MP.MONO.UI/Components/ChartFilter.razor b/MP.MONO.UI/Components/ChartFilter.razor new file mode 100644 index 0000000..8e5a1db --- /dev/null +++ b/MP.MONO.UI/Components/ChartFilter.razor @@ -0,0 +1,18 @@ +
+
+ Choose mode: +
+ + +
+
+
+
+ + + + +
+
+
+ diff --git a/MP.MONO.UI/Components/ChartFilter.razor.cs b/MP.MONO.UI/Components/ChartFilter.razor.cs new file mode 100644 index 0000000..7edfd96 --- /dev/null +++ b/MP.MONO.UI/Components/ChartFilter.razor.cs @@ -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 FilterChanged { get; set; } + + [Parameter] + public selectChartParams SelFilter { get; set; } = null!; + + #endregion Public Properties + + #region Public Methods + + /// + /// Inizializzazione con periodo e arrotondamento + /// + /// + /// + 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 + } +} \ No newline at end of file diff --git a/MP.MONO.UI/Components/ListFreqAlarms.razor.cs b/MP.MONO.UI/Components/ListFreqAlarms.razor.cs index 4e4566d..c73fe40 100644 --- a/MP.MONO.UI/Components/ListFreqAlarms.razor.cs +++ b/MP.MONO.UI/Components/ListFreqAlarms.razor.cs @@ -8,24 +8,41 @@ namespace MP.MONO.UI.Components { protected List? 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 PagerResetReq { get; set; } + + [Parameter] + public selectChartParams selFilter { get; set; } = null!; + + [Parameter] + public EventCallback TotRecordChanged { get; set; } protected List? 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; } - + } } diff --git a/MP.MONO.UI/Data/selectChartParams.cs b/MP.MONO.UI/Data/selectChartParams.cs new file mode 100644 index 0000000..ceede38 --- /dev/null +++ b/MP.MONO.UI/Data/selectChartParams.cs @@ -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 + } +} \ No newline at end of file diff --git a/MP.MONO.UI/MP.MONO.UI.csproj b/MP.MONO.UI/MP.MONO.UI.csproj index 3bac4ed..4db067c 100644 --- a/MP.MONO.UI/MP.MONO.UI.csproj +++ b/MP.MONO.UI/MP.MONO.UI.csproj @@ -5,7 +5,7 @@ enable enable AnyCPU;x86;x64 - 1.2.2209.2717 + 1.2.2209.2816 diff --git a/MP.MONO.UI/Pages/Alarms.razor b/MP.MONO.UI/Pages/Alarms.razor index 676afe5..d4ea0f3 100644 --- a/MP.MONO.UI/Pages/Alarms.razor +++ b/MP.MONO.UI/Pages/Alarms.razor @@ -7,7 +7,7 @@ @inject CurrentDataService MMDataService -
+
@@ -83,7 +83,7 @@ @*
*@
- Choose modality: + Choose mode:
diff --git a/MP.MONO.UI/Pages/AlarmsAnalysis.razor b/MP.MONO.UI/Pages/AlarmsAnalysis.razor index 6e4922b..925f5a4 100644 --- a/MP.MONO.UI/Pages/AlarmsAnalysis.razor +++ b/MP.MONO.UI/Pages/AlarmsAnalysis.razor @@ -3,36 +3,32 @@ @using MP.MONO.UI.Components -
-
-
+
+
+
Alarm analysis
-
- Choose modality: -
- - -
-
+
+ +
+ @*
+ Choose mode: +
+ + +
+
- +
-
+
*@
- @if (ShowCharts == true) - { - @**@ - }@* - @if (currRecord != null) - { - - }*@ + @if ((ListRecordsFreq == null && setFreqDur) || (ListRecordsDur == null && !setFreqDur)) { @@ -45,49 +41,49 @@ { @if (setFreqDur) { - - - @*
-
- - - - - - - - - - - @foreach (var record in ListRecordsFreq) - { - + + + @*
+
+
Alarm DescriptionAlarm Event CountEvent FrequencyEvent Frequency Chart
+ - - - - + + + + - } - -
-
@record.AlarmDescription
-
-
@record.EventCount
-
-
- @if (totalVar != 0) - { - @calcPercFreq((double)record.EventCount) - } -
-
-
-
@record.EventCount
-
-
Alarm DescriptionAlarm Event CountEvent FrequencyEvent Frequency Chart
-
-
*@ + + + @foreach (var record in ListRecordsFreq) + { + + + +
@record.AlarmDescription
+ + +
@record.EventCount
+ + +
+ @if (totalVar != 0) + { + @calcPercFreq((double)record.EventCount) + } +
+ + +
+
@record.EventCount
+
+ + + } + + +
+
*@ } else { @@ -124,7 +120,7 @@
@Math.Round(item.Duration,2)
-
+
} diff --git a/MP.MONO.UI/Pages/AlarmsAnalysis.razor.cs b/MP.MONO.UI/Pages/AlarmsAnalysis.razor.cs index 8ea5829..da05e3f 100644 --- a/MP.MONO.UI/Pages/AlarmsAnalysis.razor.cs +++ b/MP.MONO.UI/Pages/AlarmsAnalysis.razor.cs @@ -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? SearchRecordsFreq = null; private List? 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 diff --git a/MP.MONO.UI/Resources/ChangeLog.html b/MP.MONO.UI/Resources/ChangeLog.html index 8e5e372..0fe269a 100644 --- a/MP.MONO.UI/Resources/ChangeLog.html +++ b/MP.MONO.UI/Resources/ChangeLog.html @@ -1,6 +1,6 @@ MAPO-MONO -

Version: 1.2.2209.2717

+

Version: 1.2.2209.2816


Release Note:
  • diff --git a/MP.MONO.UI/Resources/VersNum.txt b/MP.MONO.UI/Resources/VersNum.txt index 6e24454..d8aca12 100644 --- a/MP.MONO.UI/Resources/VersNum.txt +++ b/MP.MONO.UI/Resources/VersNum.txt @@ -1 +1 @@ -1.2.2209.2717 +1.2.2209.2816 diff --git a/MP.MONO.UI/Resources/manifest.xml b/MP.MONO.UI/Resources/manifest.xml index dc9ec0d..a8a5f0f 100644 --- a/MP.MONO.UI/Resources/manifest.xml +++ b/MP.MONO.UI/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.2.2209.2717 + 1.2.2209.2816 http://nexus.steamware.net/repository/SWS/MP.MONO.UI/stable/LAST/MP.Mon.zip http://nexus.steamware.net/repository/SWS/MP.MONO.UI/stable/LAST/ChangeLog.html false