Completata sositutiozne sampler con TabDataFeeder
This commit is contained in:
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
using global::Microsoft.AspNetCore.Components;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.Services;
|
||||
using NLog;
|
||||
|
||||
namespace MP_TAB3.Components
|
||||
{
|
||||
public partial class MseSampler : IDisposable
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<List<MappaStatoExpl>> E_Updated { get; set; }
|
||||
|
||||
/// <summary> Moltiplicatore campionamento:
|
||||
/// HF: se > 1 (mappa)
|
||||
/// LF: se < 1 (dettaglio) </summary>
|
||||
[Parameter]
|
||||
public double SampleMult { get; set; } = 1;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (aTimer != null)
|
||||
{
|
||||
disposeTimer();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int fastTimerMSec = 3000;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected IConfiguration config { get; set; } = null!;
|
||||
|
||||
protected int fastRefreshMs
|
||||
{
|
||||
get
|
||||
{
|
||||
// tempo variabile tra +/- 10% del target (SampleMult) della freq standard di update MSE
|
||||
int answ = ((int)(fastTimerMSec / SampleMult * rnd.Next(900, 1100))) / 1000;
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
[Inject]
|
||||
protected MessageService MServ { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected StatusData SDService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
numCall++;
|
||||
// se supero limite --> resetto
|
||||
if (numCall >= maxCall)
|
||||
{
|
||||
StartTimer();
|
||||
numCall = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aTimer.Interval = fastRefreshMs;
|
||||
await InvokeAsync(RefreshData);
|
||||
}
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante MseSampler.ElapsedTimer{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
SetupConf();
|
||||
StartTimer();
|
||||
}
|
||||
|
||||
protected void StartTimer()
|
||||
{
|
||||
if (aTimer != null)
|
||||
{
|
||||
disposeTimer();
|
||||
}
|
||||
aTimer = new System.Timers.Timer(fastRefreshMs);
|
||||
aTimer.Elapsed += ElapsedTimer;
|
||||
aTimer.Enabled = true;
|
||||
aTimer.Start();
|
||||
Log.Info("MseSampler Timer started!");
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private System.Timers.Timer aTimer = null!;
|
||||
|
||||
/// <summary>
|
||||
/// max chimate prima di fare dispose/GC
|
||||
/// </summary>
|
||||
private int maxCall = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Numero chiamate al sampler
|
||||
/// </summary>
|
||||
private int numCall = 0;
|
||||
|
||||
private Random rnd = new Random();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void disposeTimer()
|
||||
{
|
||||
aTimer.Elapsed -= ElapsedTimer;
|
||||
aTimer.Stop();
|
||||
aTimer.Dispose();
|
||||
GC.Collect();
|
||||
Log.Info("MseSampler Timer Disposed!");
|
||||
}
|
||||
|
||||
private async Task RefreshData()
|
||||
{
|
||||
List<MappaStatoExpl> ListMSE = await SDService.MseGetAll();
|
||||
await MServ.SaveMse(ListMSE);
|
||||
await E_Updated.InvokeAsync(ListMSE);
|
||||
}
|
||||
|
||||
private void SetupConf()
|
||||
{
|
||||
// sistemo i parametri opzionali...
|
||||
fastTimerMSec = config.GetValue<int>("OptConf:msRefresh");
|
||||
maxCall = config.GetValue<int>("OptConf:samplerMaxCall");
|
||||
Log.Trace($"MseSampler setupConf | Effettuato setup parametri | fastRefreshMSec: {fastTimerMSec} | maxCall: {maxCall}");
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,13 @@
|
||||
<RootNamespace>MP_TAB3</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Components\MseSampler.razor.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="compilerconfig.json" />
|
||||
<Content Remove="Components\MseSampler.razor" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@page "/alarms"
|
||||
|
||||
<MseSampler SampleMult="0.5" E_Updated="RefreshData"></MseSampler>
|
||||
@if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null)
|
||||
{
|
||||
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using global::Microsoft.AspNetCore.Components;
|
||||
using MP.Data;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MP_TAB3.Pages
|
||||
{
|
||||
@@ -12,7 +14,7 @@ namespace MP_TAB3.Pages
|
||||
{
|
||||
IdxMacc = "";
|
||||
CurrMSE = null;
|
||||
//GC.Collect();
|
||||
TDFeeder.dataPipe.EA_NewMessage -= DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
@@ -20,11 +22,15 @@ namespace MP_TAB3.Pages
|
||||
#region Protected Properties
|
||||
|
||||
protected MappaStatoExpl? CurrMSE { get; set; } = null;
|
||||
|
||||
protected string IdxMacc { get; set; } = "";
|
||||
|
||||
[Inject]
|
||||
protected MessageService MsgServ { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected TabDataFeeder TDFeeder { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
@@ -32,6 +38,7 @@ namespace MP_TAB3.Pages
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
TDFeeder.dataPipe.EA_NewMessage += DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
protected async Task RefreshData(List<MappaStatoExpl> newList)
|
||||
@@ -56,6 +63,35 @@ namespace MP_TAB3.Pages
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Ricevuto nuovi dati da mostrare!
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void DataPipe_EA_NewMessage(object? sender, EventArgs e)
|
||||
{
|
||||
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
||||
// conversione on-the-fly List<string> --> allarmi
|
||||
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<MappaStatoExpl>? dataList = JsonConvert.DeserializeObject<List<MappaStatoExpl>>(currArgs.newMessage);
|
||||
if (dataList != null)
|
||||
{
|
||||
InvokeAsync(() => RefreshData(dataList));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
if (string.IsNullOrEmpty(IdxMacc))
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@page "/controls"
|
||||
|
||||
<MseSampler SampleMult="0.5" E_Updated="RefreshData"></MseSampler>
|
||||
@if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null || IsLoading)
|
||||
{
|
||||
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using global::Microsoft.AspNetCore.Components;
|
||||
using MP.Data;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MP_TAB3.Pages
|
||||
{
|
||||
@@ -12,7 +14,7 @@ namespace MP_TAB3.Pages
|
||||
{
|
||||
IdxMacc = "";
|
||||
CurrMSE = null;
|
||||
//GC.Collect();
|
||||
TDFeeder.dataPipe.EA_NewMessage -= DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
@@ -20,11 +22,15 @@ namespace MP_TAB3.Pages
|
||||
#region Protected Properties
|
||||
|
||||
protected MappaStatoExpl? CurrMSE { get; set; } = null;
|
||||
|
||||
protected string IdxMacc { get; set; } = "";
|
||||
|
||||
[Inject]
|
||||
protected MessageService MsgServ { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected TabDataFeeder TDFeeder { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
@@ -39,6 +45,7 @@ namespace MP_TAB3.Pages
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
TDFeeder.dataPipe.EA_NewMessage += DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
protected async Task RefreshData(List<MappaStatoExpl> newList)
|
||||
@@ -69,12 +76,42 @@ namespace MP_TAB3.Pages
|
||||
#region Private Fields
|
||||
|
||||
private string IdxMaccSubSel = "";
|
||||
|
||||
private bool IsLoading = false;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Ricevuto nuovi dati da mostrare!
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void DataPipe_EA_NewMessage(object? sender, EventArgs e)
|
||||
{
|
||||
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
||||
// conversione on-the-fly List<string> --> allarmi
|
||||
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<MappaStatoExpl>? dataList = JsonConvert.DeserializeObject<List<MappaStatoExpl>>(currArgs.newMessage);
|
||||
if (dataList != null)
|
||||
{
|
||||
InvokeAsync(() => RefreshData(dataList));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
if (string.IsNullOrEmpty(IdxMacc))
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@page "/iob-info"
|
||||
|
||||
<MseSampler SampleMult="0.5" E_Updated="RefreshData"></MseSampler>
|
||||
@if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null)
|
||||
{
|
||||
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using global::Microsoft.AspNetCore.Components;
|
||||
using MP.Data;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MP_TAB3.Pages
|
||||
{
|
||||
@@ -12,7 +14,7 @@ namespace MP_TAB3.Pages
|
||||
{
|
||||
IdxMacc = "";
|
||||
CurrMSE = null;
|
||||
//GC.Collect();
|
||||
TDFeeder.dataPipe.EA_NewMessage -= DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
@@ -20,11 +22,15 @@ namespace MP_TAB3.Pages
|
||||
#region Protected Properties
|
||||
|
||||
protected MappaStatoExpl? CurrMSE { get; set; } = null;
|
||||
|
||||
protected string IdxMacc { get; set; } = "";
|
||||
|
||||
[Inject]
|
||||
protected MessageService MsgServ { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected TabDataFeeder TDFeeder { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
@@ -32,6 +38,7 @@ namespace MP_TAB3.Pages
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
TDFeeder.dataPipe.EA_NewMessage += DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
protected async Task RefreshData(List<MappaStatoExpl> newList)
|
||||
@@ -56,6 +63,35 @@ namespace MP_TAB3.Pages
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Ricevuto nuovi dati da mostrare!
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void DataPipe_EA_NewMessage(object? sender, EventArgs e)
|
||||
{
|
||||
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
||||
// conversione on-the-fly List<string> --> allarmi
|
||||
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<MappaStatoExpl>? dataList = JsonConvert.DeserializeObject<List<MappaStatoExpl>>(currArgs.newMessage);
|
||||
if (dataList != null)
|
||||
{
|
||||
InvokeAsync(() => RefreshData(dataList));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
if (string.IsNullOrEmpty(IdxMacc))
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@page "/notes"
|
||||
|
||||
<MseSampler SampleMult="0.5" E_Updated="RefreshData"></MseSampler>
|
||||
@if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null)
|
||||
{
|
||||
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using global::Microsoft.AspNetCore.Components;
|
||||
using MP.Data;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace MP_TAB3.Pages
|
||||
{
|
||||
@@ -12,7 +15,7 @@ namespace MP_TAB3.Pages
|
||||
{
|
||||
IdxMacc = "";
|
||||
CurrMSE = null;
|
||||
//GC.Collect();
|
||||
TDFeeder.dataPipe.EA_NewMessage -= DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
@@ -25,6 +28,9 @@ namespace MP_TAB3.Pages
|
||||
[Inject]
|
||||
protected MessageService MsgServ { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected TabDataFeeder TDFeeder { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
@@ -32,6 +38,7 @@ namespace MP_TAB3.Pages
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
TDFeeder.dataPipe.EA_NewMessage += DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
protected async Task RefreshData(List<MappaStatoExpl> newList)
|
||||
@@ -56,6 +63,35 @@ namespace MP_TAB3.Pages
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Ricevuto nuovi dati da mostrare!
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void DataPipe_EA_NewMessage(object? sender, EventArgs e)
|
||||
{
|
||||
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
||||
// conversione on-the-fly List<string> --> allarmi
|
||||
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<MappaStatoExpl>? dataList = JsonConvert.DeserializeObject<List<MappaStatoExpl>>(currArgs.newMessage);
|
||||
if (dataList != null)
|
||||
{
|
||||
InvokeAsync(() => RefreshData(dataList));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
if (string.IsNullOrEmpty(IdxMacc))
|
||||
|
||||
@@ -4,6 +4,7 @@ using MP.Data.DatabaseModels;
|
||||
using MP.Data.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace MP_TAB3.Pages
|
||||
{
|
||||
public partial class Parameters : IDisposable
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@page "/prod-plan"
|
||||
|
||||
<MseSampler SampleMult="0.5" E_Updated="RefreshData"></MseSampler>
|
||||
@if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null)
|
||||
{
|
||||
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using global::Microsoft.AspNetCore.Components;
|
||||
using MP.Data;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.Services;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
|
||||
namespace MP_TAB3.Pages
|
||||
@@ -13,7 +15,7 @@ namespace MP_TAB3.Pages
|
||||
{
|
||||
IdxMacc = "";
|
||||
CurrMSE = null;
|
||||
//GC.Collect();
|
||||
TDFeeder.dataPipe.EA_NewMessage -= DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
@@ -26,6 +28,9 @@ namespace MP_TAB3.Pages
|
||||
[Inject]
|
||||
protected MessageService MsgServ { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected TabDataFeeder TDFeeder { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
@@ -33,6 +38,7 @@ namespace MP_TAB3.Pages
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
TDFeeder.dataPipe.EA_NewMessage += DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
protected async Task RefreshData(List<MappaStatoExpl> newList)
|
||||
@@ -63,6 +69,35 @@ namespace MP_TAB3.Pages
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Ricevuto nuovi dati da mostrare!
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void DataPipe_EA_NewMessage(object? sender, EventArgs e)
|
||||
{
|
||||
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
||||
// conversione on-the-fly List<string> --> allarmi
|
||||
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<MappaStatoExpl>? dataList = JsonConvert.DeserializeObject<List<MappaStatoExpl>>(currArgs.newMessage);
|
||||
if (dataList != null)
|
||||
{
|
||||
InvokeAsync(() => RefreshData(dataList));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@page "/scrap"
|
||||
|
||||
<MseSampler SampleMult="0.25" E_Updated="RefreshData"></MseSampler>
|
||||
@if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null)
|
||||
{
|
||||
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using global::Microsoft.AspNetCore.Components;
|
||||
using MP.Data;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MP_TAB3.Pages
|
||||
{
|
||||
@@ -12,7 +14,7 @@ namespace MP_TAB3.Pages
|
||||
{
|
||||
IdxMacc = "";
|
||||
CurrMSE = null;
|
||||
//GC.Collect();
|
||||
TDFeeder.dataPipe.EA_NewMessage -= DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
@@ -20,11 +22,15 @@ namespace MP_TAB3.Pages
|
||||
#region Protected Properties
|
||||
|
||||
protected MappaStatoExpl? CurrMSE { get; set; } = null;
|
||||
|
||||
protected string IdxMacc { get; set; } = "";
|
||||
|
||||
[Inject]
|
||||
protected MessageService MsgServ { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected TabDataFeeder TDFeeder { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
@@ -32,6 +38,7 @@ namespace MP_TAB3.Pages
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
TDFeeder.dataPipe.EA_NewMessage += DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
protected async Task RefreshData(List<MappaStatoExpl> newList)
|
||||
@@ -67,6 +74,35 @@ namespace MP_TAB3.Pages
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Ricevuto nuovi dati da mostrare!
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void DataPipe_EA_NewMessage(object? sender, EventArgs e)
|
||||
{
|
||||
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
||||
// conversione on-the-fly List<string> --> allarmi
|
||||
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<MappaStatoExpl>? dataList = JsonConvert.DeserializeObject<List<MappaStatoExpl>>(currArgs.newMessage);
|
||||
if (dataList != null)
|
||||
{
|
||||
InvokeAsync(() => RefreshData(dataList));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
if (string.IsNullOrEmpty(IdxMacc))
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@page "/workshift"
|
||||
|
||||
<MseSampler SampleMult="0.5" E_Updated="RefreshData"></MseSampler>
|
||||
@if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null)
|
||||
{
|
||||
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using global::Microsoft.AspNetCore.Components;
|
||||
using MP.Data;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MP_TAB3.Pages
|
||||
{
|
||||
@@ -13,14 +15,17 @@ namespace MP_TAB3.Pages
|
||||
IdxMacc = "";
|
||||
CurrMSE = null;
|
||||
currTurni = new TurniMaccModel();
|
||||
//GC.Collect();
|
||||
TDFeeder.dataPipe.EA_NewMessage -= DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected MappaStatoExpl? CurrMSE { get; set; } = null;
|
||||
|
||||
protected TurniMaccModel currTurni { get; set; } = new TurniMaccModel();
|
||||
|
||||
protected string IdxMacc { get; set; } = "";
|
||||
|
||||
[Inject]
|
||||
@@ -68,6 +73,9 @@ namespace MP_TAB3.Pages
|
||||
[Inject]
|
||||
protected TabDataService TabServ { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected TabDataFeeder TDFeeder { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
@@ -80,6 +88,7 @@ namespace MP_TAB3.Pages
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
TDFeeder.dataPipe.EA_NewMessage += DataPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
protected async Task RefreshData(List<MappaStatoExpl> newList)
|
||||
@@ -104,6 +113,35 @@ namespace MP_TAB3.Pages
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Ricevuto nuovi dati da mostrare!
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void DataPipe_EA_NewMessage(object? sender, EventArgs e)
|
||||
{
|
||||
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
||||
// conversione on-the-fly List<string> --> allarmi
|
||||
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<MappaStatoExpl>? dataList = JsonConvert.DeserializeObject<List<MappaStatoExpl>>(currArgs.newMessage);
|
||||
if (dataList != null)
|
||||
{
|
||||
InvokeAsync(() => RefreshData(dataList));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
if (string.IsNullOrEmpty(IdxMacc))
|
||||
|
||||
Reference in New Issue
Block a user