fix grafici alarm log e rec + inizio charts

This commit is contained in:
zaccaria.majid
2022-09-22 16:19:58 +02:00
parent 635196dc9a
commit d66ec9016c
11 changed files with 403 additions and 66 deletions
+134
View File
@@ -0,0 +1,134 @@
@using MP.MONO.UI.Data
@inject IJSRuntime JSRuntime
<canvas id="@Id"></canvas>
@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<double> Data { get; set; } = new List<double>();
[Parameter]
public List<string> Labels { get; set; } = new List<string>();
[Parameter]
public double AspRatio { get; set; } = 0;
[Parameter]
public List<string> lineColor { get; set; } = new List<string>();
[Parameter]
public List<string> backColor { get; set; } = new List<string>();
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await renderChart();
}
/// <summary>
/// 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
/// </summary>
/// <param name = "firstRender"></param>
/// <returns></returns>
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);
}
}
}
@@ -0,0 +1,35 @@
@*@using MP.MONO.UI.Components.Chart
<div class="row">
@if (RawData == null || RawData.Count == 0)
{
<div class="col-12">
<div class="alert alert-secondary text-center h4"><span class="oi oi-graph"></span> No Chart Data</div>
</div>
}
else
{
<div class="col-2" style="max-height: 10em; overflow:hidden; overflow-y: auto;">
<ul class="list-group list-group-sm small">
@foreach (var item in @ParetoData)
{
<li class="list-group-item p-1 d-flex justify-content-between align-items-center">
@item.label
<span class="badge badge-primary badge-pill">@item.value</span>
</li>
}
</ul>
</div>
<div class="col-10">
<div class="row">
<div class="col-2">
<PieChart Id="PieControlli" AspRatio="1" LegendPos="bottom" Data="@DatiPareto" Labels="@LabelPareto" lineColor="@lineColors" backColor="@bgColors" Title="Esito Controlli"></PieChart>
</div>
<div class="col-10">
<Line Id="NumControlli" AspRatio="6" DataTS="@DatiPlot" Labels="@LabelPlot" lineColor="@lineColor" backColor="@lineColor" lTens="0" Title="Num Controlli"></Line>
</div>
</div>
</div>
}
</div>
*@
@@ -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<double> DatiPareto
// {
// get => ParetoData.Select(x => x.).ToList();
// }
// private List<chartJsData.chartJsTSerie> DatiPlot
// {
// get => TSData;
// }
// private List<string> LabelPareto
// {
// get => ParetoData.Select(x => x.label).ToList();
// }
// private List<string> LabelPlot
// {
// get => TSData.Select(r => $"{r.x:yyyy-MM-dd}").ToList();
// }
// #endregion Private Properties
// #region Protected Properties
// protected List<ParetoAlarms> _rawData { get; set; } = new List<ParetoAlarms>();
// /// <summary>
// /// Genera colori sfondo 33% rosso / arancione / giallo
// /// </summary>
// /// <param name="numRecords"></param>
// /// <returns></returns>
// protected List<string> bgColors
// {
// get => semaphColors(ParetoData.Count, "0.3");
// }
// /// <summary>
// /// Genera colori sfondo 33% rosso / arancione / giallo
// /// </summary>
// /// <param name="numRecords"></param>
// /// <returns></returns>
// protected List<string> lineColor
// {
// get => solidColors("1");
// }
// /// <summary>
// /// Genera colori sfondo 33% rosso / arancione / giallo
// /// </summary>
// /// <param name="numRecords"></param>
// /// <returns></returns>
// protected List<string> lineColors
// {
// get => semaphColors(ParetoData.Count, "1");
// }
// protected List<ParetoAlarms> ParetoData { get; set; } = new List<ParetoAlarms>();
// protected List<chartJsData.chartJsTSerie> TSData { get; set; } = new List<chartJsData.chartJsTSerie>();
// #endregion Protected Properties
// #region Public Properties
// [Parameter]
// public List<ParetoAlarms> 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
// /// </summary>
// /// <param name="numRecords"></param>
// /// <returns></returns>
// protected List<string> semaphColors(int numRecords, string alpha)
// {
// List<string> answ = new List<string>();
// // aggiungo verde/rosso
// answ.Add($"rgba(54, 254, 82, {alpha})");
// answ.Add($"rgba(254, 82, 65, {alpha})");
// return answ;
// }
// /// <summary>
// /// Genera colori sfondo 33% rosso / arancione / giallo
// /// </summary>
// /// <param name="numRecords"></param>
// /// <returns></returns>
// protected List<string> solidColors(string alpha)
// {
// List<string> answ = new List<string>();
// answ.Add($"rgba(54, 162, 235, {alpha})");
// return answ;
// }
// #endregion Protected Methods
// }
//}
+1 -1
View File
@@ -1 +1 @@
31e9cc1c2e8f30a1b4098cb157d712f11f3f2e60fb74169a354c3fa646d6d0e28518b4e3139f844b25824fbcc4340051fc507d22c1c2d2786d3786c777c31cc3
467e4b24bc3fe9d237169aa274ae589b64f072fb1cd91f4d79aaee76c64afbfced7fb51536b62cf612dedfb304202a1e653778b7cc8c758f83bb058984460301
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.2.2209.2212</Version>
<Version>1.2.2209.2215</Version>
</PropertyGroup>
<ItemGroup>
+38 -23
View File
@@ -100,7 +100,7 @@
</div>
</div>
</div>
@if (setRec)
@if (setLogRec)
{
<div class="card-body">
@@ -170,34 +170,49 @@
<thead>
<tr>
<th>DateTime start</th>
<th>DateTime end</th>
<th>Machine ID</th>
<th><div class="float-end">Alarm id</div></th>
<th><div class="float-end">Alarm id rec</div></th>
<th><div class="">Error</div></th>
<th><div class="">Status</div></th>
<th><div class="float-end">Duration</div></th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecordsREC)
{
<tr>
<td class="text-nowrap">
@record.DtStart.ToString("yyyy.MM.dd HH:mm:ss")
</td>
<td>
<div class="float-end">@record.DtEnd.ToString("yyyy.MM.dd HH:mm:ss")</div>
</td>
<td align="center"><b>@record.MachineId</b></td>
<td>
<div class="float-end">@record.AlarmRecId</div>
</td>
<td>
<div class="float-end">@record.AlarmId</div>
</td>
<td>
<div class="float-end">@record.Duration</div>
</td>
</tr>
@if (record.DtEnd == record.DtStart)
{
<tr class="bg-danger">
<td class="text-nowrap">
@record.DtStart.ToString("yyyy.MM.dd HH:mm:ss")
</td>
<td>
<div class="">@record.AlarmListNav.FullValue</div>
</td>
<td>
<div class="">Fixing...</div>
</td>
<td>
<div class="float-end">@TimeSpan.FromMinutes(@record.Duration)</div>
</td>
</tr>
}
else
{
<tr>
<td class="text-nowrap">
@record.DtStart.ToString("yyyy.MM.dd HH:mm:ss")
</td>
<td>
<div class="text-success">@record.AlarmListNav.FullValue</div>
</td>
<td>
<div class="text-success">FIXED</div>
</td>
<td>
<div class="float-end">@TimeSpan.FromMinutes(@record.Duration)</div>
</td>
</tr>
}
}
</tbody>
</table>
+5 -5
View File
@@ -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);
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.2.2209.2212</h4>
<h4>Version: 1.2.2209.2215</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.2.2209.2212
1.2.2209.2215
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.2.2209.2212</version>
<version>1.2.2209.2215</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>
+33 -33
View File
@@ -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"
}