From d66ec9016c3b932f9d4bcf0eb9224cbbef2d8a94 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Thu, 22 Sep 2022 16:19:58 +0200 Subject: [PATCH] fix grafici alarm log e rec + inizio charts --- MP.MONO.UI/Components/Chart/BarPlot.razor | 134 +++++++++++++++ MP.MONO.UI/Components/ChartController.razor | 35 ++++ .../Components/ChartController.razor.cs | 153 ++++++++++++++++++ MP.MONO.UI/Conf/lic.file | 2 +- MP.MONO.UI/MP.MONO.UI.csproj | 2 +- MP.MONO.UI/Pages/Alarms.razor | 61 ++++--- MP.MONO.UI/Pages/Alarms.razor.cs | 10 +- MP.MONO.UI/Resources/ChangeLog.html | 2 +- MP.MONO.UI/Resources/VersNum.txt | 2 +- MP.MONO.UI/Resources/manifest.xml | 2 +- MP.MONO.UI/temp/InfoData.json | 66 ++++---- 11 files changed, 403 insertions(+), 66 deletions(-) create mode 100644 MP.MONO.UI/Components/Chart/BarPlot.razor create mode 100644 MP.MONO.UI/Components/ChartController.razor create mode 100644 MP.MONO.UI/Components/ChartController.razor.cs diff --git a/MP.MONO.UI/Components/Chart/BarPlot.razor b/MP.MONO.UI/Components/Chart/BarPlot.razor new file mode 100644 index 0000000..9596bab --- /dev/null +++ b/MP.MONO.UI/Components/Chart/BarPlot.razor @@ -0,0 +1,134 @@ +@using MP.MONO.UI.Data +@inject IJSRuntime JSRuntime + + + +@code { + [Parameter] + public string Id { get; set; } = "MyHist"; + + [Parameter] + public string Legenda { get; set; } = "Legenda"; + + [Parameter] + public bool Horizontal { get; set; } = false; + + [Parameter] + public List Data { get; set; } = new List(); + + [Parameter] + public List Labels { get; set; } = new List(); + + [Parameter] + public double AspRatio { get; set; } = 0; + + [Parameter] + public List lineColor { get; set; } = new List(); + + [Parameter] + public List backColor { get; set; } = new List(); + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + await renderChart(); + } + + + /// + /// Inizializzazione rendering componente + /// + /// partendo da qui: + /// https://www.williamleme.com/posts/2020/003-chartjs-blazor/ + /// https://www.puresourcecode.com/dotnet/blazor/using-chart-js-with-blazor/ + /// https://www.tutorialsteacher.com/csharp/csharp-anonymous-type + /// + /// + /// + protected async Task renderChart() + { + // creazione di un oggetto anonymous type con tutte le opzioni da passare a chart.js, tipo verticale + var config = new + { + type = "bar", + options = new + { + responsive = true, + scales = new + { + yAxes = new + { + suggestedMin = 0, + display = true, + ticks = new + { + beginAtZero = true, + maxTicksLimit = 10 + } + } + }, + Animation = false, + AspectRatio = AspRatio == 0 ? "auto" : $"{AspRatio}" + }, + data = new + { + datasets = new[] { + new { + data = Data, + borderColor = lineColor, + backgroundColor = backColor, + borderWidth = 1, + label = Legenda + } + }, + labels = Labels + } + }; + // creazione di un oggetto anonymous type con tutte le opzioni da passare a chart.js, tipo verticale + var configHor = new + { + type = "bar", + options = new + { + indexAxis = "y", + responsive = true, + scales = new + { + yAxes = new + { + suggestedMin = 0, + display = true, + ticks = new + { + beginAtZero = true, + maxTicksLimit = 10 + } + } + }, + Animation = false, + AspectRatio = AspRatio == 0 ? "auto" : $"{AspRatio}" + }, + data = new + { + datasets = new[] { + new { + data = Data, + borderColor = lineColor, + backgroundColor = backColor, + borderWidth = 1, + label = Legenda + } + }, + labels = Labels + } + }; + if (Horizontal) + { + await JSRuntime.InvokeVoidAsync("setup", Id, configHor); + } + else + { + await JSRuntime.InvokeVoidAsync("setup", Id, config); + } + } +} + diff --git a/MP.MONO.UI/Components/ChartController.razor b/MP.MONO.UI/Components/ChartController.razor new file mode 100644 index 0000000..096385f --- /dev/null +++ b/MP.MONO.UI/Components/ChartController.razor @@ -0,0 +1,35 @@ +@*@using MP.MONO.UI.Components.Chart + +
+ @if (RawData == null || RawData.Count == 0) + { +
+
No Chart Data
+
+ } + else + { +
+
    + @foreach (var item in @ParetoData) + { +
  • + @item.label + @item.value +
  • + } +
+
+
+
+
+ +
+
+ +
+
+
+ } +
+*@ \ No newline at end of file diff --git a/MP.MONO.UI/Components/ChartController.razor.cs b/MP.MONO.UI/Components/ChartController.razor.cs new file mode 100644 index 0000000..ec321b0 --- /dev/null +++ b/MP.MONO.UI/Components/ChartController.razor.cs @@ -0,0 +1,153 @@ +//using Microsoft.AspNetCore.Components; +//using MP.MONO.Data; + +//namespace MP.MONO.UI.Components +//{ +// public partial class ChartController +// { +// #region Protected Fields + +// protected const string EsitoKO = "Esito: Non Passato"; + +// protected const string EsitoOK = "Esito: OK"; + +// #endregion Protected Fields + +// #region Private Properties + +// private List DatiPareto +// { +// get => ParetoData.Select(x => x.).ToList(); +// } + +// private List DatiPlot +// { +// get => TSData; +// } + +// private List LabelPareto +// { +// get => ParetoData.Select(x => x.label).ToList(); +// } + +// private List LabelPlot +// { +// get => TSData.Select(r => $"{r.x:yyyy-MM-dd}").ToList(); +// } + +// #endregion Private Properties + +// #region Protected Properties + + +// protected List _rawData { get; set; } = new List(); + +// /// +// /// Genera colori sfondo 33% rosso / arancione / giallo +// /// +// /// +// /// +// protected List bgColors +// { +// get => semaphColors(ParetoData.Count, "0.3"); +// } + +// /// +// /// Genera colori sfondo 33% rosso / arancione / giallo +// /// +// /// +// /// +// protected List lineColor +// { +// get => solidColors("1"); +// } + +// /// +// /// Genera colori sfondo 33% rosso / arancione / giallo +// /// +// /// +// /// +// protected List lineColors +// { +// get => semaphColors(ParetoData.Count, "1"); +// } + +// protected List ParetoData { get; set; } = new List(); + +// protected List TSData { get; set; } = new List(); + +// #endregion Protected Properties + +// #region Public Properties + +// [Parameter] +// public List RawData +// { +// get => _rawData; +// set +// { +// // salvo valori +// _rawData = value; +// if (value != null) +// { +// // ricalcolo charting data +// recalcData(); +// } +// } +// } + +// #endregion Public Properties + +// #region Private Methods + +// private void recalcData() +// { +// if (RawData != null) +// { +// ParetoData = RawData +// .GroupBy(p => p.EsitoOk) +// .Select(y => new ChartKV() { label = y.First().EsitoOk ? EsitoOK : EsitoKO, value = y.Count() }) +// .OrderByDescending(x => x.value) +// .ToList(); + +// TSData = RawData +// .GroupBy(x => x.DataOra.Date) +// .Select(r => new chartJsData.chartJsTSerie() { x = r.First().DataOra.Date, y = r.Count() }) +// .OrderBy(o => o.x) +// .ToList(); +// } +// } + +// #endregion Private Methods + +// #region Protected Methods + +// /// Genera colori sfondo 33% rosso / arancione / giallo +// /// +// /// +// /// +// protected List semaphColors(int numRecords, string alpha) +// { +// List answ = new List(); + +// // aggiungo verde/rosso +// answ.Add($"rgba(54, 254, 82, {alpha})"); +// answ.Add($"rgba(254, 82, 65, {alpha})"); +// return answ; +// } + +// /// +// /// Genera colori sfondo 33% rosso / arancione / giallo +// /// +// /// +// /// +// protected List solidColors(string alpha) +// { +// List answ = new List(); +// answ.Add($"rgba(54, 162, 235, {alpha})"); +// return answ; +// } + +// #endregion Protected Methods +// } +//} \ No newline at end of file diff --git a/MP.MONO.UI/Conf/lic.file b/MP.MONO.UI/Conf/lic.file index 9540e9d..69f59a3 100644 --- a/MP.MONO.UI/Conf/lic.file +++ b/MP.MONO.UI/Conf/lic.file @@ -1 +1 @@ -31e9cc1c2e8f30a1b4098cb157d712f11f3f2e60fb74169a354c3fa646d6d0e28518b4e3139f844b25824fbcc4340051fc507d22c1c2d2786d3786c777c31cc3 \ No newline at end of file +467e4b24bc3fe9d237169aa274ae589b64f072fb1cd91f4d79aaee76c64afbfced7fb51536b62cf612dedfb304202a1e653778b7cc8c758f83bb058984460301 \ 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 fb01ee2..fd44af2 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.2212 + 1.2.2209.2215 diff --git a/MP.MONO.UI/Pages/Alarms.razor b/MP.MONO.UI/Pages/Alarms.razor index 53f738f..332bdd8 100644 --- a/MP.MONO.UI/Pages/Alarms.razor +++ b/MP.MONO.UI/Pages/Alarms.razor @@ -100,7 +100,7 @@ - @if (setRec) + @if (setLogRec) {
@@ -170,34 +170,49 @@ DateTime start - DateTime end - Machine ID -
Alarm id
-
Alarm id rec
+
Error
+
Status
Duration
@foreach (var record in ListRecordsREC) { - - - @record.DtStart.ToString("yyyy.MM.dd HH:mm:ss") - - -
@record.DtEnd.ToString("yyyy.MM.dd HH:mm:ss")
- - @record.MachineId - -
@record.AlarmRecId
- - -
@record.AlarmId
- - -
@record.Duration
- - + @if (record.DtEnd == record.DtStart) + { + + + @record.DtStart.ToString("yyyy.MM.dd HH:mm:ss") + + +
@record.AlarmListNav.FullValue
+ + +
Fixing...
+ + + +
@TimeSpan.FromMinutes(@record.Duration)
+ + + } + else + { + + + @record.DtStart.ToString("yyyy.MM.dd HH:mm:ss") + + +
@record.AlarmListNav.FullValue
+ + +
FIXED
+ + +
@TimeSpan.FromMinutes(@record.Duration)
+ + + } } diff --git a/MP.MONO.UI/Pages/Alarms.razor.cs b/MP.MONO.UI/Pages/Alarms.razor.cs index 15f10dd..d19ed13 100644 --- a/MP.MONO.UI/Pages/Alarms.razor.cs +++ b/MP.MONO.UI/Pages/Alarms.razor.cs @@ -15,11 +15,11 @@ namespace MP.MONO.UI.Pages #region Protected Properties public bool liveUpdate { get; set; } = true; - public bool setRec { get; set; } = true; + public bool setLogRec { get; set; } = true; public string lastUpdate { get; set; } = "-"; protected string currMode { - get => setRec ? "Alarm Log" : "Alarm Rec"; + get => setLogRec ? "Alarm Log" : "Alarm Rec"; } public void Dispose() @@ -107,7 +107,7 @@ namespace MP.MONO.UI.Pages protected override async Task OnInitializedAsync() { //StartTimer(); - if (!setRec) + if (setLogRec) { SearchRecords = await MMDataService.AlarmLogGetFilt(MachineId, 0, MaxRecord); ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); @@ -129,7 +129,7 @@ namespace MP.MONO.UI.Pages { //ListRecords = null; //ListRecordsREC = null; - if (!setRec) + if (setLogRec) { SearchRecords = await MMDataService.AlarmLogGetFilt(MachineId, 0, MaxRecord); ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); @@ -196,7 +196,7 @@ namespace MP.MONO.UI.Pages } protected async Task toggleRec() { - setRec = !setRec; + setLogRec = !setLogRec; await Task.Delay(1); await ReloadData(true); } diff --git a/MP.MONO.UI/Resources/ChangeLog.html b/MP.MONO.UI/Resources/ChangeLog.html index 3ce4f6b..2733d5e 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.2212

+

Version: 1.2.2209.2215


Release Note:
  • diff --git a/MP.MONO.UI/Resources/VersNum.txt b/MP.MONO.UI/Resources/VersNum.txt index 5989629..8960e4d 100644 --- a/MP.MONO.UI/Resources/VersNum.txt +++ b/MP.MONO.UI/Resources/VersNum.txt @@ -1 +1 @@ -1.2.2209.2212 +1.2.2209.2215 diff --git a/MP.MONO.UI/Resources/manifest.xml b/MP.MONO.UI/Resources/manifest.xml index e5d9a4a..2be2e4f 100644 --- a/MP.MONO.UI/Resources/manifest.xml +++ b/MP.MONO.UI/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.2.2209.2212 + 1.2.2209.2215 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 diff --git a/MP.MONO.UI/temp/InfoData.json b/MP.MONO.UI/temp/InfoData.json index 7a26333..962a618 100644 --- a/MP.MONO.UI/temp/InfoData.json +++ b/MP.MONO.UI/temp/InfoData.json @@ -2,55 +2,55 @@ "AdapterType": "Ethernet 802.3", "AddressWidth": "64", "Architecture": "9", - "BiosVersion": "ALASKA - 1072009", - "BuildNumber": "19044", - "Caption": "Microsoft Windows 10 Pro N", - "ConfiguredClockSpeed": "3600", + "BiosVersion": "_ASUS_ - 1072009", + "BuildNumber": "19043", + "Caption": "Microsoft Windows 10 Pro", + "ConfiguredClockSpeed": "2400", "ConfiguredVoltage": "1200", "CpuVersion": "Modello 1, Stepping 0", - "CurrentClockSpeed": "3501", - "CurrentVoltage": "11", + "CurrentClockSpeed": "2200", + "CurrentVoltage": "12", "DataWidth": "64", - "Description": "AMD64 Family 23 Model 113 Stepping 0", - "DeviceLocator": "DIMM 1", + "Description": "AMD64 Family 23 Model 17 Stepping 0", + "DeviceLocator": "ChannelA-DIMM0", "ExtClock": "100", "Family": "107", - "FormFactor": "8", - "GUID": "{E76995C4-F180-406E-B9C3-E491C65A8FCF}", - "L2CacheSize": "8192", - "L3CacheSize": "65536", + "FormFactor": "12", + "GUID": "{7F313732-DBA3-46E5-9FA7-BEF235B0682E}", + "L2CacheSize": "2048", + "L3CacheSize": "4096", "Level": "23", - "LoadPercentage": "48", - "MACAddress": "0C:9D:92:B8:FD:E8", - "Manufacturer": "American Megatrends International, LLC.", + "LoadPercentage": "23", + "MACAddress": "4C:ED:FB:D9:78:83", + "Manufacturer": "American Megatrends Inc.", "MaxNumberOfProcesses": "4294967295", "MaxProcessMemorySize": "137438953344", "MaxVoltage": "1200", "MinVoltage": "1200", - "Name": "ASUS XG-C100C 10G PCI-E Network Adapter", - "NumberOfCores": "16", - "NumberOfLogicalProcessors": "32", + "Name": "Realtek PCIe GbE Family Controller", + "NumberOfCores": "4", + "NumberOfLogicalProcessors": "8", "OSArchitecture": "64 bit", - "PartNumber": "CMK64GX4M2D3600C18", + "PartNumber": "8ATF1G64HZ-2G3E1 ", "PhysicalAdapter": "True", - "ProcessorId": "178BFBFF00870F10", + "ProcessorId": "178BFBFF00810F10", "ProcessorType": "3", - "ProductName": "ASUS XG-C100C 10G PCI-E Network Adapter", - "ReleaseDate": "20210521000000.000000+000", - "Revision": "28928", + "ProductName": "Realtek PCIe GbE Family Controller", + "ReleaseDate": "20190521000000.000000+000", + "Revision": "4352", "Role": "CPU", - "SerialNumber": "00332-00332-17209-AA940", - "ServiceName": "aqnic650", - "SMBIOSBIOSVersion": "F33", + "SerialNumber": "00330-80951-85780-AA242", + "ServiceName": "rt640x64", + "SMBIOSBIOSVersion": "X505ZA.311", "SMBIOSMajorVersion": "3", "SMBIOSMemoryType": "26", - "SMBIOSMinorVersion": "3", - "SocketDesignation": "AM4", - "SoftwareElementID": "F33", + "SMBIOSMinorVersion": "1", + "SocketDesignation": "FP5", + "SoftwareElementID": "X505ZA.311", "SoftwareElementState": "3", - "Speed": "3600", + "Speed": "2400", "SystemBiosMajorVersion": "5", - "SystemBiosMinorVersion": "17", - "SystemName": "WRKST-R9-SAM", - "Version": "10.0.19044" + "SystemBiosMinorVersion": "13", + "SystemName": "EGALW-NB-004", + "Version": "10.0.19043" } \ No newline at end of file