Merge branch 'release/UpdateHistDataLog'

This commit is contained in:
Samuele Locatelli
2022-09-23 18:29:53 +02:00
44 changed files with 1021 additions and 314 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.2.2209.2212</Version>
<Version>1.2.2209.2318</Version>
</PropertyGroup>
<ItemGroup>
+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.2318</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.2.2209.2212
1.2.2209.2318
+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.2318</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.ANALYZER/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.ANALYZER/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+5
View File
@@ -55,6 +55,11 @@ namespace MP.MONO.Core
public static readonly string TOOLS_CURR_KEY = $"{BASE_HASH}:Current:Tools";
public static readonly string COUNT_CURR_KEY = $"{BASE_HASH}:Current:Counters";
// REDIS KEY Dati cache
public static readonly string DATA_LOG_KEY = $"{BASE_HASH}:Cache:DataLog";
public static readonly string DATA_LOG_DTO_KEY = $"{BASE_HASH}:Cache:DataLogDto";
// REDIS Channels messaggi (verso UI)
public static readonly string ACT_LOG_M_QUEUE = $"ActivityLog";
public static readonly string ALARM_M_QUEUE = $"Alarms";
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.2.2209.2212</Version>
<Version>1.2.2209.2318</Version>
</PropertyGroup>
<ItemGroup>
+35 -29
View File
@@ -38,6 +38,11 @@ Console.WriteLine("Running - press CTRL-C to stop");
Console.WriteLine(lineSep);
Console.WriteLine("");
Log.Info(lineSep);
Log.Info("Start DECODER with LUA integration!");
Log.Info($"vers.{Assembly.GetExecutingAssembly().GetName().Version}");
Log.Info(lineSep);
// init DB
// init info x DB
string dbServerAddr = config["DbConfig:Server"];
@@ -91,33 +96,23 @@ string AlarmCleanPost = "";
int DbSampleInt = 60;
setupConf();
/* --------------------------------
* Setup Gestione ALLARMI
* --------------------------------*/
// init classe gestione allarmi con LUA
AlarmsManager alarmsMan = new AlarmsManager();
// inizializzo gestione messagePipe da Redis x allarmi
MessagePipe alarmsSendPipe = new MessagePipe(redisConn, Constants.ALARM_M_QUEUE);
MessagePipe alarmsRecvPipe = new MessagePipe(redisConn, Constants.ALARM_RAW_QUEUE);
// datetime dell'inizio esecuzione task... x usare un semaforo di veto doppia esecuzione entro 30 sec
DateTime lastExecAlarms = DateTime.Now.AddHours(-1);
// registro gestione eventi
alarmsRecvPipe.EA_NewMessage += AlarmsValPipe_EA_NewMessage;
/* --------------------------------
* Setup Gestione Parametri
* --------------------------------*/
ParamsManager paramMan = new ParamsManager();
// inizializzo gestione messagePipe da Redis x allarmi
MessagePipe paramsSendPipe = new MessagePipe(redisConn, Constants.PARAMS_M_QUEUE);
MessagePipe paramsRecvPipe = new MessagePipe(redisConn, Constants.PARAMS_RAW_QUEUE);
// datetime dell'inizio esecuzione task... x usare un semaforo di veto doppia esecuzione entro 30 sec
DateTime lastExecParams = DateTime.Now.AddHours(-1);
DateTime lastLogDetail = DateTime.Now.AddHours(-1);
int numSendParam = 1;
int numSendMStatus = 1;
/* --------------------------------
* Setup Gestione Counters
* --------------------------------*/
CounterManager counterMan = new CounterManager();
// inizializzo gestione messagePipe da Redis x allarmi
MessagePipe counterSendPipe = new MessagePipe(redisConn, Constants.COUNT_M_QUEUE);
MessagePipe counterRecvPipe = new MessagePipe(redisConn, Constants.COUNT_RAW_QUEUE);
// datetime dell'inizio esecuzione task... x usare un semaforo di veto doppia esecuzione entro 30 sec
DateTime lastExecCounters = DateTime.Now.AddHours(-1);
// registro gestione eventi
paramsRecvPipe.EA_NewMessage += ParamsValPipe_EA_NewMessage;
counterRecvPipe.EA_NewMessage += CounterRecvPipe_EA_NewMessage;
/* --------------------------------
* Setup Gestione MachineStatus
@@ -132,16 +127,27 @@ DateTime lastExecStatus = DateTime.Now.AddHours(-1);
mpStatusRecvPipe.EA_NewMessage += MpStatusRecvPipe_EA_NewMessage;
/* --------------------------------
* Setup Gestione Counters
* Setup Gestione Parametri
* --------------------------------*/
CounterManager counterMan = new CounterManager();
ParamsManager paramMan = new ParamsManager();
// inizializzo gestione messagePipe da Redis x allarmi
MessagePipe counterSendPipe = new MessagePipe(redisConn, Constants.COUNT_M_QUEUE);
MessagePipe counterRecvPipe = new MessagePipe(redisConn, Constants.COUNT_RAW_QUEUE);
// datetime dell'inizio esecuzione task... x usare un semaforo di veto doppia esecuzione entro 30 sec
DateTime lastExecCounters = DateTime.Now.AddHours(-1);
MessagePipe paramsSendPipe = new MessagePipe(redisConn, Constants.PARAMS_M_QUEUE);
MessagePipe paramsRecvPipe = new MessagePipe(redisConn, Constants.PARAMS_RAW_QUEUE);
// registro gestione eventi
counterRecvPipe.EA_NewMessage += CounterRecvPipe_EA_NewMessage;
paramsRecvPipe.EA_NewMessage += ParamsValPipe_EA_NewMessage;
/* --------------------------------
* Setup Gestione ALLARMI
* --------------------------------*/
// init classe gestione allarmi con LUA
AlarmsManager alarmsMan = new AlarmsManager();
// inizializzo gestione messagePipe da Redis x allarmi
MessagePipe alarmsSendPipe = new MessagePipe(redisConn, Constants.ALARM_M_QUEUE);
MessagePipe alarmsRecvPipe = new MessagePipe(redisConn, Constants.ALARM_RAW_QUEUE);
// datetime dell'inizio esecuzione task... x usare un semaforo di veto doppia esecuzione entro 30 sec
DateTime lastExecAlarms = DateTime.Now.AddHours(-1);
// registro gestione eventi
alarmsRecvPipe.EA_NewMessage += AlarmsValPipe_EA_NewMessage;
/* --------------------------------
* Funzioni / metodi accessori
@@ -798,7 +804,7 @@ void MpStatusRecvPipe_EA_NewMessage(object? sender, EventArgs e)
// invio sulla message pipeline corretta TUTTI i parametri aggiornati serializzati
string updRawVal = JsonConvert.SerializeObject(machinePlate);
paramsSendPipe.saveAndSendMessage(Constants.STATUS_CURR_KEY, updRawVal);
mpStatusSendPipe.saveAndSendMessage(Constants.STATUS_CURR_KEY, updRawVal);
}
}
catch (Exception exc)
+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.2318</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.2.2209.2212
1.2.2209.2318
+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.2318</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.DECODER/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.DECODER/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+43 -2
View File
@@ -3,6 +3,7 @@ using MP.MONO.Core.DTO;
using MP.MONO.Data.DbModels;
using MP.MONO.Data.DTO;
using NLog;
using System.Diagnostics;
namespace MP.MONO.Data.Controllers
{
@@ -177,11 +178,16 @@ namespace MP.MONO.Data.Controllers
{
try
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
await localDbCtx
.DbSetAlarmLog
.AddRangeAsync(newItems);
.DbSetAlarmLog
.AddRangeAsync(newItems);
await localDbCtx.SaveChangesAsync();
fatto = true;
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"AlarmLogInsertMany| DB insert | {newItems.Count} rec | {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
@@ -390,11 +396,16 @@ namespace MP.MONO.Data.Controllers
{
try
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
await localDbCtx
.DbSetAlarmRec
.AddRangeAsync(newItems);
await localDbCtx.SaveChangesAsync();
fatto = true;
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"AlarmRecInsertMany| DB insert | {newItems.Count} rec | {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
@@ -434,6 +445,36 @@ namespace MP.MONO.Data.Controllers
return dbResult;
}
/// <summary>
/// Recupero DataLogDTO data condizione filtro
/// </summary>
/// <param name="machineId"></param>
/// <param name="fluxType"></param>
/// <param name="inizio"></param>
/// <param name="fine"></param>
/// <returns></returns>
public List<DataLogDTO> DataLogDtoGetFilt(int machineId, string fluxType, DateTime inizio, DateTime fine)
{
List<DataLogDTO> dbResult = new List<DataLogDTO>();
using (MapoMonoContext localDbCtx = new MapoMonoContext())
{
try
{
dbResult = localDbCtx
.DbSetDataLog
.Where(x => x.MachineId == machineId && x.FluxType == fluxType && x.DtRif >= inizio && x.DtRif <= fine)
.Select(r => new DataLogDTO() { DataLogId=r.DataLogId, DtRif=r.DtRif, ValNum=r.ValNum })
.OrderByDescending(x => x.DataLogId)
.ToList();
}
catch (Exception exc)
{
Log.Error($"Eccezione durante DataLogDtoGetFilt{Environment.NewLine}{exc}");
}
}
return dbResult;
}
/// <summary>
/// Inserimento di un SET di record DataLog (post aggregazione base VC)
/// </summary>
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace MP.MONO.Data.DTO
{
public class DataLogDTO
{
public int DataLogId { get; set; }
/// <summary>
/// DataOra evento registrato
/// </summary>
public DateTime DtRif { get; set; } = DateTime.Now;
/// <summary>
/// Valore formato numerico (0 se non numerico)
/// </summary>
public double ValNum { get; set; } = 0;
}
}
+22 -4
View File
@@ -1,5 +1,6 @@
using NLog;
using StackExchange.Redis;
using System.Diagnostics;
namespace MP.MONO.Data
{
@@ -46,6 +47,8 @@ namespace MP.MONO.Data
/// </summary>
private string _channel { get; set; } = "";
private Dictionary<string, int> numSent = new Dictionary<string, int>();
#endregion Private Properties
#region Private Methods
@@ -75,15 +78,30 @@ namespace MP.MONO.Data
public bool saveAndSendMessage(string memKey, string message)
{
bool answ = false;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
// invio notifica tramite il canale richiesto
answ = sendMessage(message);
if (redisDb != null)
{
redisDb.StringSetAsync(memKey, message);
if (enableLog)
{
Log.Info($"Redis Cache Key: {memKey}");
}
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
if (numSent.ContainsKey(memKey))
{
numSent[memKey]++;
}
else
{
numSent.Add(memKey, 1);
}
if (enableLog || numSent[memKey] > 30)
{
Log.Info($"saveAndSendMessage| mKey {memKey} x {numSent[memKey]} | {message.Length} size | {ts.TotalMilliseconds} ms");
numSent[memKey] = 0;
}
return answ;
}
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.2.2209.2212</Version>
<Version>1.2.2209.2318</Version>
</PropertyGroup>
<ItemGroup>
+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.2318</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.2.2209.2212
1.2.2209.2318
+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.2318</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.SIM/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.SIM/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -44,7 +44,7 @@
"SimPar": {
"MinSaveIntSec": 5,
"PercAllarmi": 10,
"MaxAddAllarmi": 5,
"MaxAddAllarmi": 4,
"MaxDurationAllarmi": 10
}
}
+1 -2
View File
@@ -1,2 +1 @@
<canvas id="@Id"></canvas>
<canvas id="@Id"></canvas>
+44 -56
View File
@@ -6,15 +6,6 @@ namespace MP.MONO.UI.Components.Chart
{
public partial class Line
{
#region Private Properties
private List<chartJsData.chartJsTSerie> _DataTS { get; set; } = null!;
[Inject]
private IJSRuntime JSRuntime { get; set; } = null!;
#endregion Private Properties
#region Public Properties
[Parameter]
@@ -23,6 +14,19 @@ namespace MP.MONO.UI.Components.Chart
[Parameter]
public List<string> backColor { get; set; } = new List<string>();
[Parameter]
public string ChartId
{
get
{
return Id;
}
set
{
Id = value;
}
}
[Parameter]
public List<chartJsData.chartJsTSerie> DataTS
{
@@ -39,21 +43,6 @@ namespace MP.MONO.UI.Components.Chart
}
}
protected string Id { get; set; } = "CurrId";
[Parameter]
public string ChartId
{
get
{
return Id;
}
set
{
Id = value;
}
}
[Parameter]
public List<string> Labels { get; set; } = new List<string>();
@@ -77,17 +66,21 @@ namespace MP.MONO.UI.Components.Chart
#endregion Public Properties
#region Protected Properties
protected string Id { get; set; } = "CurrId";
#endregion Protected Properties
#region Protected Methods
/// <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
/// 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>
/// <param name="firstRender"></param>
/// <returns></returns>
protected override async Task OnAfterRenderAsync(bool firstRender)
{
@@ -97,12 +90,10 @@ namespace MP.MONO.UI.Components.Chart
/// <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
/// 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>
/// <param name="firstRender"></param>
/// <returns></returns>
protected async Task renderChart()
{
@@ -122,46 +113,34 @@ namespace MP.MONO.UI.Components.Chart
ticks = new
{
maxTicksLimit = 10
}
,
},
suggestedMin = MinValue != MaxValue ? MinValue : "auto",
suggestedMax = MinValue != MaxValue ? MaxValue : "auto"
}
,
},
xAxes = new
{
type = "time",
distribution = "linear",
}
}
,
},
plugins = new
{
legend = new
{
display = false
}
,
}
,
},
},
Animation = false,
AspectRatio = AspRatio == 0 ? "auto" : $"{AspRatio}"
}
,
},
data = new
{
labels = Labels,
datasets = new[]{new
{
data = DataTS, pointBorderColor = backColor, borderColor = lineColor, backgroundColor = backColor, fill = true, PointRadius = 2, BorderWidth = 1, lineTension = lTens, stepped = false, label = Title
}
}
{
data = DataTS, pointBorderColor = backColor, borderColor = lineColor, backgroundColor = backColor, fill = true, PointRadius = 2, BorderWidth = 1, lineTension = lTens, stepped = false, label = Title
}
}
}
}
@@ -170,5 +149,14 @@ namespace MP.MONO.UI.Components.Chart
}
#endregion Protected Methods
#region Private Properties
private List<chartJsData.chartJsTSerie> _DataTS { get; set; } = null!;
[Inject]
private IJSRuntime JSRuntime { get; set; } = null!;
#endregion Private Properties
}
}
+34
View File
@@ -0,0 +1,34 @@
@using MP.MONO.UI.Components.ChartJS
<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 RawData)
{
<li class="list-group-item p-1 d-flex justify-content-between align-items-center">
@item.AlarmDescription
@if(totalEvents != 0)
{
<span class="badge bg-primary"></span>
}
</li>
}
</ul>
</div>*@
<div class="col-10">
<div class="row">
<div class="col-6">
<BarPlot Id="ParetoOee" AspRatio="3" Data="@DatiParetoOee" Labels="@LabelParetoOee" Legenda="Most frequent alarms" lineColor="@lineColors" backColor="@bgColors"></BarPlot>
</div>
</div>
</div>
}
</div>
+185
View File
@@ -0,0 +1,185 @@
using Microsoft.AspNetCore.Components;
using MP.MONO.Data;
using MP.MONO.UI.Data;
using System;
using System.Collections.Generic;
using System.Linq;
namespace MP.MONO.UI.Components
{
public partial class ChartAlarms
{
#region Private Properties
private List<double> DatiParetoOee
{
get => ParetoData.Select(x => x.value).ToList();
}
private List<chartJsData.chartJsTSerie> DatiTrs
{
get => TSData;
}
private List<string> LabelParetoOee
{
get => ParetoData.Select(x => x.label).ToList();
}
private List<string> LabelTrs
{
get => TSData.Select(r => $"{r.x:yyyy-MM-dd}").ToList();
}
#endregion Private Properties
#region Protected Properties
//protected SelectData _currFilter { get; set; } = new SelectData();
protected List<MP.MONO.Data.DTO.AlarmFreqDTO> _rawData { get; set; } = new List<MP.MONO.Data.DTO.AlarmFreqDTO>();
/// <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");
}
#if false
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> lineColor
{
get => solidColors("1");
}
#endif
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> lineColors
{
get => semaphColors(ParetoData.Count, "1");
}
//[Inject]
//protected MessageService MessageService { get; set; }
protected List<ChartKV> ParetoData { get; set; } = new List<ChartKV>();
//[Inject]
//protected MpStatsService StatService { get; set; }
protected List<chartJsData.chartJsTSerie> TSData { get; set; } = new List<chartJsData.chartJsTSerie>();
#endregion Protected Properties
#region Public Properties
[Parameter]
public List<MP.MONO.Data.DTO.AlarmFreqDTO> RawData
{
get => _rawData;
set
{
// salvo valori
_rawData = value;
if (value != null)
{
// ricalcolo charting data
recalcData();
}
}
}
#endregion Public Properties
#region Private Methods
private Dictionary<DateTime, double> calcTSData(DateTime inizio, List<double> yData)
{
Dictionary<DateTime, double> answ = new Dictionary<DateTime, double>();
// usando i dati ricevuti aggiunge variabile x = tempo crescente
int idx = 0;
foreach (var item in yData)
{
answ.Add(inizio.AddHours(idx), item);
idx++;
}
// restituisco!
return answ;
}
protected int totalEvents = 0;
private void recalcData()
{
if (RawData != null)
{
ParetoData = RawData
.GroupBy(x => x.AlarmId)
.Select(y => new ChartKV() { label = y.First().AlarmDescription.ToString(), value = Math.Round(y.Average(c => c.EventCount), 2) })
.OrderByDescending(x => x.value)
.ToList();
TSData = RawData
.GroupBy(x => x.AlarmId)
.Select(r => new chartJsData.chartJsTSerie() { x = DateTime.Now, y = Math.Round(r.Average(c => c.EventCount), 2) })
.OrderBy(o => o.x)
.ToList();
totalEvents = RawData.Sum(x => x.EventCount);
}
}
#endregion Private Methods
#region Protected Methods
/// <summary>
/// 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>();
// verde...
for (int i = 0; i < numRecords / 3; i++)
{
answ.Add($"rgba(255, 99, 132, {alpha}");
}
// arancione
for (int i = 0; i < numRecords / 3; i++)
{
answ.Add($"rgba(255, 206, 86, {alpha})");
}
while (answ.Count < numRecords)
{
answ.Add($"rgba(54, 235, 82, {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
@@ -26,7 +26,7 @@
<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>
<BarPlot Id="ParetoOee" AspRatio="3" Data="@Dat" Labels="s" Legenda="Pareto OEE Macchine" lineColor="@lineColors" backColor="@bgColors"></BarPlot>
</div>
</div>
</div>
@@ -83,6 +83,7 @@
labels = Labels
}
};
// creazione di un oggetto anonymous type con tutte le opzioni da passare a chart.js, tipo verticale
var configHor = new
{
@@ -131,4 +132,3 @@
}
}
}
+7 -2
View File
@@ -16,7 +16,8 @@
</div>
<div class="d-flex">
<div class="px-1 flex-fill">
@if (isLoading || LevelVal == null || LevelVal.Count == 0)
@if (isLoading)
@*@if (isLoading || LevelVal == null || LevelVal.Count == 0)*@
{
<LoadingDataSmall></LoadingDataSmall>
}
@@ -27,4 +28,8 @@
</div>
</div>
}
@*else
{
<LoadingData></LoadingData>
}
*@
+57 -76
View File
@@ -1,38 +1,51 @@
using Microsoft.AspNetCore.Components;
using MP.MONO.Data;
using MP.MONO.Data.DbModels;
using MP.MONO.Data.DTO;
using MP.MONO.UI.Data;
namespace MP.MONO.UI.Components
{
public partial class ParamPlot
{
#region Private Fields
#region Public Properties
private List<DataLogModel>? ListRecords = null;
[Parameter]
public int MachineId { get; set; } = 1;
#endregion Private Fields
public string ParamId
{
get => _selParam.Replace(" ", "_");
}
[Parameter]
public string SelectedParam
{
get => _selParam;
set => _selParam = 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>();
#endregion Protected Fields
#region Private Properties
private bool isLoading { get; set; } = false;
#endregion Private Properties
#region Protected Properties
protected DataLogFilter _SelFilter { get; set; } = new DataLogFilter();
protected string _selParam { get; set; } = "";
protected DateTime DateFrom { get; set; } = DateTime.Today.AddDays(-1);
protected DateTime DateTo { get; set; } = DateTime.Today.AddDays(1);
protected string? MaxVal
{
@@ -64,68 +77,6 @@ namespace MP.MONO.UI.Components
#endregion Protected Properties
#region Public Properties
[Parameter]
public DateTime EndDate
{
get
{
return DateTo;
}
set
{
DateTo = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
[Parameter]
public int MachineId { get; set; } = 1;
public string ParamId
{
get => _selParam.Replace(" ", "_");
}
[Parameter]
public string SelectedParam
{
get
{
return _selParam;
}
set
{
// controllo se è variato
if (_selParam != value)
{
// salvo
_selParam = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
[Parameter]
public DateTime StartDate
{
get
{
return DateFrom;
}
set
{
DateFrom = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
#endregion Public Properties
#region Protected Methods
protected List<string> getFillColors(string alpha)
@@ -155,12 +106,20 @@ namespace MP.MONO.UI.Components
await Task.Delay(1);
}
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.DataLogGetFilt(MachineId, SelectedParam, StartDate, EndDate);
ListRecords = await MMDataService.DataLogDtoGetFilt(MachineId, SelectedParam, 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);
@@ -168,5 +127,27 @@ namespace MP.MONO.UI.Components
}
#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
}
}
+1 -1
View File
@@ -1 +1 @@
467e4b24bc3fe9d237169aa274ae589b64f072fb1cd91f4d79aaee76c64afbfced7fb51536b62cf612dedfb304202a1e653778b7cc8c758f83bb058984460301
31e9cc1c2e8f30a1b4098cb157d712f11f3f2e60fb74169a354c3fa646d6d0e28518b4e3139f844b25824fbcc4340051fc507d22c1c2d2786d3786c777c31cc3
+59 -3
View File
@@ -193,13 +193,69 @@ namespace MP.MONO.UI.Data
public async Task<List<DataLogModel>> DataLogGetFilt(int machineId, string fluxType, DateTime inizio, DateTime fine)
{
string source = "DB";
List<DataLogModel> dbResult = new List<DataLogModel>();
string currKey = $"{Constants.DATA_LOG_KEY}:{machineId}:{fluxType.Replace(" ", "_")}:{inizio:yyyyMMdd}:{fine:yyyyMMdd}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
var dbResult = dbController.DataLogGetFilt(machineId, fluxType, inizio, fine);
string rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<DataLogModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<DataLogModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.DataLogGetFilt(machineId, fluxType, inizio, fine);
// salvo per 2 min...
rawData = JsonConvert.SerializeObject(dbResult);
await redisDb.StringSetAsync(currKey, rawData, TimeSpan.FromSeconds(120));
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Trace($"Effettuata lettura da DB ParamLogGetFilt: {ts.TotalMilliseconds} ms");
return await Task.FromResult(dbResult);
Log.Info($"DataLogGetFilt | {machineId} | {fluxType} | {inizio:yyyyMMdd}-{fine:yyyyMMdd} | {source} | {ts.TotalMilliseconds} ms | {rawData.Length / 1024} kb");
return dbResult;
}
public async Task<List<DataLogDTO>> DataLogDtoGetFilt(int machineId, string fluxType, DateTime inizio, DateTime fine)
{
string source = "DB";
List<DataLogDTO> dbResult = new List<DataLogDTO>();
string currKey = $"{Constants.DATA_LOG_DTO_KEY}:{machineId}:{fluxType.Replace(" ", "_")}:{inizio:yyyyMMdd}:{fine:yyyyMMdd}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<DataLogDTO>>(rawData);
if (tempResult == null)
{
dbResult = new List<DataLogDTO>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.DataLogDtoGetFilt(machineId, fluxType, inizio, fine);
// salvo per 2 min...
rawData = JsonConvert.SerializeObject(dbResult);
await redisDb.StringSetAsync(currKey, rawData, TimeSpan.FromSeconds(120));
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"DataLogDtoGetFilt | {machineId} | {fluxType} | {inizio:yyyyMMdd}-{fine:yyyyMMdd} | {source} | {ts.TotalMilliseconds} ms | {rawData.Length / 1024} kb");
return dbResult;
}
public void Dispose()
+28
View File
@@ -0,0 +1,28 @@
namespace MP.MONO.UI.Data
{
public class DataLogFilter
{
public DateTime DtStart { get; set; } = DateTime.Today.AddDays(-1);
public DateTime DtEnd { get; set; } = DateTime.Today.AddDays(1);
public override bool Equals(object obj)
{
if (!(obj is DataLogFilter item))
return false;
if (DtStart != item.DtStart)
return false;
if (DtEnd != item.DtEnd)
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}
+72
View File
@@ -0,0 +1,72 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.2.2209.2309</Version>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Components\ChartController.razor.cs" />
</ItemGroup>
<ItemGroup>
<Content Remove="compilerconfig.json" />
<Content Remove="Components\ChartController.razor" />
<Content Remove="Components\Chart\BarPlot.razor" />
</ItemGroup>
<ItemGroup>
<None Include="compilerconfig.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MP.MONO.Core\MP.MONO.Core.csproj" />
<ProjectReference Include="..\MP.MONO.Data\MP.MONO.Data.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.multiax.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.ufficio.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="Conf\lic.multiax.demo.file">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<None Update="Conf\lic.NB-SAM.file">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<None Update="Conf\lic.WKS-R9-SAM.file">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<None Update="Conf\lic.file">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="logs\.placeholder.file">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="temp\OUT.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\post-build.ps1 -ProjectDir $(ProjectDir) -ProjectPath $(ProjectPath)" />
<!--<Exec Command="powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\obfuscate.ps1 -CurrConfig $(ConfigurationName)" />-->
</Target>
</Project>
+66
View File
@@ -0,0 +1,66 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.2.2209.2309</Version>
</PropertyGroup>
<ItemGroup>
<Content Remove="compilerconfig.json" />
</ItemGroup>
<ItemGroup>
<None Include="compilerconfig.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MP.MONO.Core\MP.MONO.Core.csproj" />
<ProjectReference Include="..\MP.MONO.Data\MP.MONO.Data.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.multiax.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.ufficio.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="Conf\lic.multiax.demo.file">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<None Update="Conf\lic.NB-SAM.file">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<None Update="Conf\lic.WKS-R9-SAM.file">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<None Update="Conf\lic.file">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="logs\.placeholder.file">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="temp\OUT.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\post-build.ps1 -ProjectDir $(ProjectDir) -ProjectPath $(ProjectPath)" />
<!--<Exec Command="powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\obfuscate.ps1 -CurrConfig $(ConfigurationName)" />-->
</Target>
</Project>
+10 -1
View File
@@ -5,15 +5,24 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.2.2209.2216</Version>
<Version>1.2.2209.2318</Version>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Components\ChartController.razor.cs" />
</ItemGroup>
<ItemGroup>
<Content Remove="compilerconfig.json" />
<Content Remove="Components\ChartController.razor" />
<Content Remove="NLog.config" />
</ItemGroup>
<ItemGroup>
<None Include="compilerconfig.json" />
<None Include="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
+58
View File
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue" />
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<!--
add your targets here
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
-->
<!--
Write events to a file with the date in the filename.
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
<target xsi:type="File"
name="fileTarget"
fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} | ${uppercase:${level}} | ${logger:shortName=false} | ${message}"
archiveFileName="${basedir}/logs/${shortdate}.{###}.zip"
archiveNumbering="Sequence"
archiveAboveSize="1024000"
maxArchiveFiles="90"
enableArchiveFileCompression="true"
keepFileOpen="false"
/>
<target xsi:type="ColoredConsole"
name="consoleTarget"
layout="${longdate} | ${uppercase:${level}} | ${logger:shortName=true}| ${message}" />
</targets>
<rules>
<!-- add your logging rules here -->
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
<!--<logger name="Microsoft.*" maxlevel="Info" final="true" />-->
<!--<logger name="*" minlevel="Trace" writeTo="consoleTarget" />-->
<logger name="*" minlevel="Info" writeTo="fileTarget" />
</rules>
</nlog>
+1 -1
View File
@@ -178,7 +178,7 @@
<tbody>
@foreach (var record in ListRecordsREC)
{
@if (record.DtEnd == record.DtStart)
@if (record.DtEnd < record.DtStart)
{
<tr class="bg-danger">
<td class="text-nowrap">
+33 -36
View File
@@ -1,18 +1,26 @@
@page "/AlarmsAnalysis"
@*@page "/controlli/{IdxMacchina}"*@
@using MP.Stats.Components
@using MP.MONO.UI.Components
<div class="card">
<div class="card-header table-primary p-1">
@*
<SelectionFilter SelFilter="currFilter" filterChanged="DoFilter" filterReset="ResetFilter" chartVisible="ShowCharts" chartsToggle="ToggleChart" ChartEnabled="true"></SelectionFilter>*@
<div class="col-3">
<div class="input-group mb-3">
<label class="input-group-text">Choose time span:</label>
<input class="form-control" @bind-value="@numHourPrev" />
</div>
</div>
</div>
<div class="card-body py-0 px-1">
@if (ShowCharts == true)
{
<ChartControlli RawData="SearchRecords"></ChartControlli>
}
@*<ChartAlarms RawData="SearchRecords"></ChartAlarms>*@
}@*
@if (currRecord != null)
{
<DetailOee currRecord="@currRecord"></DetailOee>
}*@
@if (ListRecords == null)
{
<LoadingData></LoadingData>
@@ -25,51 +33,40 @@
{
<div class="row">
<div class="col-12">
<table class="table table-sm table-striped table-responsive-lg small">
<table class="table table-sm table-striped">
<thead>
<tr>
<th>DateTime start</th>
<th><div class="">Error</div></th>
<th><div class="">Status</div></th>
<th><div class="float-end">Duration</div></th>
<th>Alarm Description</th>
<th>Alarm Event Count</th>
<th>Event Frequence</th>
<th>Event Frequence Chart</th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecordsREC)
@foreach (var record in ListRecords)
{
<tr class="bg-danger">
<td class="text-nowrap">
@record.DtStart.ToString("yyyy.MM.dd HH:mm:ss")
<tr>
<td>
<div>@record.AlarmDescription</div>
</td>
<td>
<div class="">@record.AlarmListNav.FullValue</div>
<div>@record.EventCount</div>
</td>
<td>
<div class="">Fixing...</div>
<div>
@if (totalEvents != 0)
{
<span class="text-success">@calcPerc((double)record.EventCount)</span>
}
</div>
</td>
<td>
<div class="float-end">@TimeSpan.FromMinutes(@record.Duration)</div>
<div class="progress">
<div class="progress-bar @styleColourPBar((double)record.EventCount/totalEvents)" role="progressbar" aria-label="Danger example" style="@calcPercStyle((double)record.EventCount)" aria-valuenow="4.08" aria-valuemin="0" aria-valuemax="@val(record.EventCount)"></div>
</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>
</div>
@@ -77,7 +74,7 @@
}
</div>
<div class="card-footer py-1">
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" exportRequested="ExportCsv" fileName="@fileName" />
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
</div>
</div>
+118 -27
View File
@@ -16,6 +16,11 @@ 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;
namespace MP.MONO.UI.Pages
{
@@ -23,11 +28,11 @@ namespace MP.MONO.UI.Pages
{
#region Private Fields
private AlarmRecModel currRecord = null;
private AlarmFreqDTO currRecord = null;
private string fileName = "Controlli.csv";
private List<AlarmRecModel> ListRecords;
private List<AlarmRecModel> SearchRecords;
private List<AlarmFreqDTO> ListRecords;
private List<AlarmFreqDTO> SearchRecords;
#endregion Private Fields
@@ -36,6 +41,8 @@ namespace MP.MONO.UI.Pages
private int _currPage { get; set; } = 1;
private int _numRecord { get; set; } = 10;
protected int totalEvents = 0;
protected string percEvents = "";
private int currPage
{
@@ -45,11 +52,25 @@ namespace MP.MONO.UI.Pages
if (_currPage != value)
{
_currPage = value;
var pUpd = Task.Run(async () => await reloadData());
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
protected int _numHourPrev = 24;
protected int numHourPrev
{
get => _numHourPrev;
set
{
_numHourPrev = value;
var pUpd = Task.Run(async () =>
{
await ReloadData();
});
pUpd.Wait();
}
}
private bool isLoading { get; set; } = false;
@@ -61,18 +82,24 @@ namespace MP.MONO.UI.Pages
if (_numRecord != value)
{
_numRecord = value;
var pUpd = Task.Run(async () => await reloadData());
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool ShowCharts { get; set; } = false;
private bool ShowCharts { get; set; } = true;
#endregion Private Properties
#region Protected Properties
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[Inject]
protected NavigationManager NavManager { get; set; }
protected int totalCount
{
get
@@ -85,21 +112,20 @@ namespace MP.MONO.UI.Pages
return answ;
}
}
protected int machine { get; set; } = ListRecords.Select(x => x.MachineId).FirstOrDefault();
#endregion Protected Properties
#region Public Properties
#region Private Methods isLoading = false;
//}
#endregion Public Properties
#region Private Methods
private async Task reloadData()
private async Task ReloadData()
{
isLoading = true;
SearchRecords = await MP.MONO.UI.Data.CurrentDataService.dbController.AlarmRecGetParetoFreq();
DateTime adesso = DateTime.Now;
SearchRecords = CurrentDataService.dbController.AlarmRecGetParetoFreq(1, adesso.AddHours(-numHourPrev), adesso);
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
totalEvents = SearchRecords.Sum(x => x.EventCount);
calcolaSoglie();
isLoading = false;
}
@@ -120,53 +146,118 @@ namespace MP.MONO.UI.Pages
protected override async Task OnInitializedAsync()
{
numRecord = 10;
await reloadData();
SearchRecords = MP.MONO.UI.Data.CurrentDataService.dbController.AlarmRecGetParetoFreq(1, DateTime.Now.AddDays(-numHourPrev), DateTime.Now);
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await ReloadData();
}
private double sogliaGreen = 0;
private double sogliaRed = 1;
private void calcolaSoglie()
{
int numRecord = SearchRecords.Count;
var firstRecord = SearchRecords.Skip((int)(numRecord * 0.2)).FirstOrDefault();
var lastRecord = SearchRecords.Skip((int)(numRecord * 0.8)).FirstOrDefault();
if (firstRecord != null)
{
sogliaGreen = (double)firstRecord.EventCount / totalEvents;
}
if (lastRecord != null)
{
sogliaRed = (double)lastRecord.EventCount / totalEvents;
}
}
protected void ResetData()
{
currRecord = null;
}
protected string calcPerc(double numEvent)
{
string ans = $"{numEvent / totalEvents:P2}";
return ans;
}
protected string calcPercStyle(double numEvent)
{
string perc = $"{numEvent / totalEvents:P2}";
string percs = perc.Substring(0, perc.Length - 1);
string ans = $"width: {@Math.Round(double.Parse(percs), 0)}%";
return ans;
}
protected string val(int eventCount)
{
int max = SearchRecords.Max(a => a.EventCount);
string ans = $"{eventCount/max}";
return ans;
}
protected string styleColourPBar(double eventFreq)
{
string ans = "";
var source = ListRecords;
calcolaSoglie();
if (eventFreq >= sogliaGreen)
{
ans = "bg-danger";
}
else if (eventFreq <= sogliaRed)
{
ans = "bg-success";
}
else
{
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();
await ReloadData();
}
}
protected async Task UpdateData()
{
currRecord = null;
await reloadData();
await ReloadData();
}
#endregion Protected Methods
#region Public Methods
public string checkSelect(int IdxMacchina)
public string checkSelect(DateTime DtStart, double EventCount, int IdxMacchina)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.MachineId == IdxMacchina) ? "table-info" : "";
answ = (currRecord.MachineId == IdxMacchina && currRecord.EventCount == EventCount) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
public void Dispose()
{
//MessageService.EA_SearchUpdated -= OnSeachUpdated;
}
public async void OnSeachUpdated()
{
await InvokeAsync(() =>
+15 -10
View File
@@ -73,18 +73,23 @@
{
<div class="row">
@foreach (var item in selParams)
@if (isRT)
{
<div class="@pcss">
@if (isRT)
{
@foreach (var item in selParams)
{
<div class="@pcss">
<ParamPlotRT SelectedParam="@item" maxRecord="@maxRecord" sampleSecMin="@sampleSecMin"></ParamPlotRT>
}
else
{
<ParamPlot SelectedParam="@item" StartDate="@DateFrom" EndDate="@DateTo"></ParamPlot>
}
</div>
</div>
}
}
else
{
@foreach (var item in selParams)
{
<div class="@pcss">
<ParamPlot SelectedParam="@item" SelFilter="@SelFilter"></ParamPlot>
</div>
}
}
</div>
}
+15 -2
View File
@@ -1,3 +1,6 @@
using MP.MONO.UI.Data;
namespace MP.MONO.UI.Pages
{
public partial class Parameters
@@ -7,8 +10,18 @@ namespace MP.MONO.UI.Pages
private int maxRecord = 120;
private bool showParam = false;
private DateTime DateFrom = DateTime.Today.AddDays(-2);
private DateTime DateTo = DateTime.Today.AddDays(1);
private DateTime DateFrom
{
get => SelFilter.DtStart;
set => SelFilter.DtStart = value;
}
private DateTime DateTo
{
get => SelFilter.DtEnd;
set => SelFilter.DtEnd = value;
}
protected DataLogFilter SelFilter { get; set; } = new DataLogFilter();
#endregion Private Fields
+10 -6
View File
@@ -6,17 +6,21 @@
<div class="card">
<div class="card-header">
<h3>Test</h3>
<div class="d-flex justify-content-between">
<div>
<h3>Test</h3>
</div>
<div>
h prec:
<input @bind-value="@numHourPrev" />
</div>
</div>
</div>
<div class="card-body">
@if (ListRecords == null)
{
<LoadingData></LoadingData>
}
@*else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">No record found</div>
}*@
else
{
<table class="table table-sm table-striped table-responsive-lg small">
@@ -41,7 +45,7 @@
</td>
<td>
<div class="float-end">
@if (totalEvents!= 0)
@if (totalEvents != 0)
{
<span class="text-success">@($"{(double)record.EventCount/totalEvents:P2}")</span>
}
+24 -5
View File
@@ -20,18 +20,37 @@ namespace MP.MONO.UI.Pages
{
public partial class Test
{
protected int _numHourPrev = 24;
protected int numHourPrev
{
get => _numHourPrev;
set
{
_numHourPrev = value;
var pUpd = Task.Run(async () =>
{
await ReloadData();
});
pUpd.Wait();
}
}
protected int totalCount = 0;
protected int totalEvents = 0;
protected List<AlarmFreqDTO> ListRecords = new List<AlarmFreqDTO>();
protected override async Task OnInitializedAsync()
{
await Task.Delay(1);
DateTime adesso = DateTime.Now;
ListRecords = await MMDataService.AlarmRecGetParetoFreq(1, adesso.AddDays(-1), adesso);
totalCount = ListRecords.Count;
totalEvents = ListRecords.Sum(x => x.EventCount);
await ReloadData();
}
private async Task ReloadData()
{
await Task.Delay(1);
DateTime adesso = DateTime.Now;
ListRecords = await MMDataService.AlarmRecGetParetoFreq(1, adesso.AddHours(-numHourPrev), adesso);
totalCount = ListRecords.Count;
totalEvents = ListRecords.Sum(x => x.EventCount);
await Task.Delay(1);
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.2.2209.2216</h4>
<h4>Version: 1.2.2209.2318</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.2.2209.2216
1.2.2209.2318
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.2.2209.2216</version>
<version>1.2.2209.2318</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": "_ASUS_ - 1072009",
"BuildNumber": "19043",
"Caption": "Microsoft Windows 10 Pro",
"ConfiguredClockSpeed": "2400",
"BiosVersion": "ALASKA - 1072009",
"BuildNumber": "19044",
"Caption": "Microsoft Windows 10 Pro N",
"ConfiguredClockSpeed": "3600",
"ConfiguredVoltage": "1200",
"CpuVersion": "Modello 1, Stepping 0",
"CurrentClockSpeed": "2200",
"CurrentVoltage": "12",
"CurrentClockSpeed": "3501",
"CurrentVoltage": "11",
"DataWidth": "64",
"Description": "AMD64 Family 23 Model 17 Stepping 0",
"DeviceLocator": "ChannelA-DIMM0",
"Description": "AMD64 Family 23 Model 113 Stepping 0",
"DeviceLocator": "DIMM 1",
"ExtClock": "100",
"Family": "107",
"FormFactor": "12",
"GUID": "{7F313732-DBA3-46E5-9FA7-BEF235B0682E}",
"L2CacheSize": "2048",
"L3CacheSize": "4096",
"FormFactor": "8",
"GUID": "{E76995C4-F180-406E-B9C3-E491C65A8FCF}",
"L2CacheSize": "8192",
"L3CacheSize": "65536",
"Level": "23",
"LoadPercentage": "23",
"MACAddress": "4C:ED:FB:D9:78:83",
"Manufacturer": "American Megatrends Inc.",
"LoadPercentage": "14",
"MACAddress": "0C:9D:92:B8:FD:E8",
"Manufacturer": "American Megatrends International, LLC.",
"MaxNumberOfProcesses": "4294967295",
"MaxProcessMemorySize": "137438953344",
"MaxVoltage": "1200",
"MinVoltage": "1200",
"Name": "Realtek PCIe GbE Family Controller",
"NumberOfCores": "4",
"NumberOfLogicalProcessors": "8",
"Name": "ASUS XG-C100C 10G PCI-E Network Adapter",
"NumberOfCores": "16",
"NumberOfLogicalProcessors": "32",
"OSArchitecture": "64 bit",
"PartNumber": "8ATF1G64HZ-2G3E1 ",
"PartNumber": "CMK64GX4M2D3600C18",
"PhysicalAdapter": "True",
"ProcessorId": "178BFBFF00810F10",
"ProcessorId": "178BFBFF00870F10",
"ProcessorType": "3",
"ProductName": "Realtek PCIe GbE Family Controller",
"ReleaseDate": "20190521000000.000000+000",
"Revision": "4352",
"ProductName": "ASUS XG-C100C 10G PCI-E Network Adapter",
"ReleaseDate": "20210521000000.000000+000",
"Revision": "28928",
"Role": "CPU",
"SerialNumber": "00330-80951-85780-AA242",
"ServiceName": "rt640x64",
"SMBIOSBIOSVersion": "X505ZA.311",
"SerialNumber": "00332-00332-17209-AA940",
"ServiceName": "aqnic650",
"SMBIOSBIOSVersion": "F33",
"SMBIOSMajorVersion": "3",
"SMBIOSMemoryType": "26",
"SMBIOSMinorVersion": "1",
"SocketDesignation": "FP5",
"SoftwareElementID": "X505ZA.311",
"SMBIOSMinorVersion": "3",
"SocketDesignation": "AM4",
"SoftwareElementID": "F33",
"SoftwareElementState": "3",
"Speed": "2400",
"Speed": "3600",
"SystemBiosMajorVersion": "5",
"SystemBiosMinorVersion": "13",
"SystemName": "EGALW-NB-004",
"Version": "10.0.19043"
"SystemBiosMinorVersion": "17",
"SystemName": "WRKST-R9-SAM",
"Version": "10.0.19044"
}