diff --git a/MP.MONO.UI/Components/ActivityOverview.razor b/MP.MONO.UI/Components/ActivityOverview.razor
index 8406972..022f42b 100644
--- a/MP.MONO.UI/Components/ActivityOverview.razor
+++ b/MP.MONO.UI/Components/ActivityOverview.razor
@@ -4,7 +4,7 @@
@inject CurrentDataService MMDataService
-@if (@dataLoaded && ListRecords != null)
+@if (ListRecords != null && ListRecords.Count > 0)
{
@foreach (var item in ListRecords)
@@ -24,26 +24,9 @@
else
{
- - Activity Log
- - User Actions Log
-
+ - Activity Log
+ - User Actions Log
+
}
-@code {
- protected bool dataLoaded = false;
- private List? ListRecords { get; set; } = null;
- protected override async Task OnInitializedAsync()
- {
- await ReloadData();
- }
-
- protected async Task ReloadData()
- {
- //await Task.Delay(10);
- //ListRecords = await MMDataService.MachineDisplay();
- await Task.Delay(500);
- dataLoaded = true;
- }
-
-}
diff --git a/MP.MONO.UI/Components/ActivityOverview.razor.cs b/MP.MONO.UI/Components/ActivityOverview.razor.cs
new file mode 100644
index 0000000..90ce71b
--- /dev/null
+++ b/MP.MONO.UI/Components/ActivityOverview.razor.cs
@@ -0,0 +1,52 @@
+using MP.MONO.Core.DTO;
+using MP.MONO.Data;
+using Newtonsoft.Json;
+
+namespace MP.MONO.UI.Components
+{
+ public partial class ActivityOverview
+ {
+ #region Private Properties
+
+ private List? ListRecords { get; set; } = null;
+
+ #endregion Private Properties
+
+ #region Private Methods
+
+ private void ActLogPipe_EA_NewMessage(object? sender, EventArgs e)
+ {
+ PubSubEventArgs currArgs = (PubSubEventArgs)e;
+ if (!string.IsNullOrEmpty(currArgs.newMessage))
+ {
+ try
+ {
+ ListRecords = JsonConvert.DeserializeObject>(currArgs.newMessage);
+ }
+ catch
+ { }
+ }
+ InvokeAsync(() =>
+ {
+ StateHasChanged();
+ });
+ }
+
+ #endregion Private Methods
+
+ #region Protected Methods
+
+ protected override async Task OnInitializedAsync()
+ {
+ await ReloadData();
+ MMDataService.actLogPipe.EA_NewMessage += ActLogPipe_EA_NewMessage;
+ }
+
+ protected async Task ReloadData()
+ {
+ ListRecords = new List();
+ }
+
+ #endregion Protected Methods
+ }
+}
\ No newline at end of file
diff --git a/MP.MONO.UI/Components/EventsOverview.razor b/MP.MONO.UI/Components/EventsOverview.razor
index 8768d1f..1683cb0 100644
--- a/MP.MONO.UI/Components/EventsOverview.razor
+++ b/MP.MONO.UI/Components/EventsOverview.razor
@@ -4,7 +4,7 @@
@inject CurrentDataService MMDataService
-@if (@dataLoaded && ListRecords != null)
+@if (ListRecords != null && ListRecords.Count > 0)
{
@foreach (var item in ListRecords)
@@ -24,26 +24,9 @@
else
{
- - Events Log
- - Machine Events
-
+ - Events Log
+ - Machine Events
+
}
-@code {
- protected bool dataLoaded = false;
- private List? ListRecords { get; set; } = null;
- protected override async Task OnInitializedAsync()
- {
- await ReloadData();
- }
-
- protected async Task ReloadData()
- {
- //await Task.Delay(10);
- //ListRecords = await MMDataService.MachineDisplay();
- await Task.Delay(500);
- dataLoaded = true;
- }
-
-}
diff --git a/MP.MONO.UI/Components/EventsOverview.razor.cs b/MP.MONO.UI/Components/EventsOverview.razor.cs
new file mode 100644
index 0000000..87af891
--- /dev/null
+++ b/MP.MONO.UI/Components/EventsOverview.razor.cs
@@ -0,0 +1,52 @@
+using MP.MONO.Core.DTO;
+using MP.MONO.Data;
+using Newtonsoft.Json;
+
+namespace MP.MONO.UI.Components
+{
+ public partial class EventsOverview
+ {
+ #region Private Properties
+
+ private List? ListRecords { get; set; } = null;
+
+ #endregion Private Properties
+
+ #region Private Methods
+
+ private void MachEvPipe_EA_NewMessage(object? sender, EventArgs e)
+ {
+ PubSubEventArgs currArgs = (PubSubEventArgs)e;
+ if (!string.IsNullOrEmpty(currArgs.newMessage))
+ {
+ try
+ {
+ ListRecords = JsonConvert.DeserializeObject>(currArgs.newMessage);
+ }
+ catch
+ { }
+ }
+ InvokeAsync(() =>
+ {
+ StateHasChanged();
+ });
+ }
+
+ #endregion Private Methods
+
+ #region Protected Methods
+
+ protected override async Task OnInitializedAsync()
+ {
+ await ReloadData();
+ MMDataService.machEvPipe.EA_NewMessage += MachEvPipe_EA_NewMessage;
+ }
+
+ protected async Task ReloadData()
+ {
+ ListRecords = new List();
+ }
+
+ #endregion Protected Methods
+ }
+}
\ No newline at end of file
diff --git a/MP.MONO.UI/Data/CurrentDataService.cs b/MP.MONO.UI/Data/CurrentDataService.cs
index 1e424c9..759e52a 100644
--- a/MP.MONO.UI/Data/CurrentDataService.cs
+++ b/MP.MONO.UI/Data/CurrentDataService.cs
@@ -57,6 +57,8 @@ namespace MP.MONO.UI.Data
machStatsPipe = new MessagePipe(redisConn, "machstats");
maintPipe = new MessagePipe(redisConn, "maintenance");
toolsPipe = new MessagePipe(redisConn, "tools");
+ machEvPipe = new MessagePipe(redisConn, "events");
+ actLogPipe = new MessagePipe(redisConn, "activitylog");
// conf DB
string connStr = _configuration.GetConnectionString("MP.MONO.Data");
@@ -82,6 +84,8 @@ namespace MP.MONO.UI.Data
public MessagePipe productionPipe { get; set; } = null!;
public MessagePipe statusPipe { get; set; } = null!;
public MessagePipe toolsPipe { get; set; } = null!;
+ public MessagePipe machEvPipe { get; set; } = null!;
+ public MessagePipe actLogPipe { get; set; } = null!;
#endregion Public Properties
diff --git a/MachineSim/MachineSim.csproj b/MachineSim/MachineSim.csproj
index 327309a..c4d5316 100644
--- a/MachineSim/MachineSim.csproj
+++ b/MachineSim/MachineSim.csproj
@@ -21,9 +21,15 @@
+
+ Always
+
Always
+
+ Always
+
Always
diff --git a/MachineSim/Program.cs b/MachineSim/Program.cs
index 1178c63..85a05de 100644
--- a/MachineSim/Program.cs
+++ b/MachineSim/Program.cs
@@ -177,7 +177,6 @@ void simMaint()
void simTools()
{
- // FIXME TODO !!!
int minPeriod = 3000;
int maxPeriod = 5000;
@@ -195,14 +194,13 @@ void simTools()
void simEvents()
{
- // FIXME TODO !!!
- int minPeriod = 3000;
- int maxPeriod = 5000;
+ int minPeriod = 4000;
+ int maxPeriod = 8000;
do
{
// recupero uno stato simulato
- var newVal = currSimGen.getProdStats();
+ var newVal = currSimGen.getEvents();
string rawData = JsonConvert.SerializeObject(newVal);
saveAndSendMessage(mHash("Machine:Events:Current"), rawData, "events", rawData);
@@ -213,14 +211,13 @@ void simEvents()
void simActivityLog()
{
- // FIXME TODO !!!
- int minPeriod = 3000;
- int maxPeriod = 5000;
+ int minPeriod = 5000;
+ int maxPeriod = 10000;
do
{
// recupero uno stato simulato
- var newVal = currSimGen.getProdStats();
+ var newVal = currSimGen.getActLog();
string rawData = JsonConvert.SerializeObject(newVal);
saveAndSendMessage(mHash("Machine:ActivityLog:Current"), rawData, "activitylog", rawData);
diff --git a/MachineSim/SimActLog.json b/MachineSim/SimActLog.json
new file mode 100644
index 0000000..e739067
--- /dev/null
+++ b/MachineSim/SimActLog.json
@@ -0,0 +1,26 @@
+[
+ {
+ "Order": 0,
+ "Type": "ACTLOG",
+ "Title": "User Act 01",
+ "Value": "1000",
+ "ValueNum": 1000,
+ "MinVal": 0,
+ "MaxVal": 2000,
+ "SimMean": -1,
+ "SimStd": 1,
+ "DisplFormat": "N0"
+ },
+ {
+ "Order": 2,
+ "Type": "ACTLOG",
+ "Title": "User Act 02",
+ "Value": "700",
+ "ValueNum": 700,
+ "MinVal": 0,
+ "MaxVal": 2000,
+ "SimMean": -1,
+ "SimStd": 1,
+ "DisplFormat": "N0"
+ }
+]
\ No newline at end of file
diff --git a/MachineSim/SimEvHist.json b/MachineSim/SimEvHist.json
new file mode 100644
index 0000000..241d2ba
--- /dev/null
+++ b/MachineSim/SimEvHist.json
@@ -0,0 +1,38 @@
+[
+ {
+ "Order": 0,
+ "Type": "EVENT",
+ "Title": "Event 01",
+ "Value": "1000",
+ "ValueNum": 1000,
+ "MinVal": 0,
+ "MaxVal": 2000,
+ "SimMean": -1,
+ "SimStd": 1,
+ "DisplFormat": "N1"
+ },
+ {
+ "Order": 1,
+ "Type": "EVENT",
+ "Title": "Event 02",
+ "Value": "800",
+ "ValueNum": 800,
+ "MinVal": 0,
+ "MaxVal": 2000,
+ "SimMean": -1,
+ "SimStd": 1,
+ "DisplFormat": "N1"
+ },
+ {
+ "Order": 2,
+ "Type": "EVENT",
+ "Title": "Event 03",
+ "Value": "700",
+ "ValueNum": 700,
+ "MinVal": 0,
+ "MaxVal": 2000,
+ "SimMean": -1,
+ "SimStd": 1,
+ "DisplFormat": "N1"
+ }
+]
\ No newline at end of file
diff --git a/MachineSim/Simulator.cs b/MachineSim/Simulator.cs
index 908ee22..4efe7c5 100644
--- a/MachineSim/Simulator.cs
+++ b/MachineSim/Simulator.cs
@@ -17,6 +17,8 @@ namespace MachineSim
protected List currSimMaint = new List();
protected List currSimPar = new List();
protected List currSimTools = new List();
+ protected List currSimEvHist = new List();
+ protected List currSimActLog = new List();
protected Random rand = new Random();
@@ -57,6 +59,10 @@ namespace MachineSim
setupConf("SimMaint.json", ref currSimMaint);
// setup conf Tools
setupConf("SimTools.json", ref currSimTools);
+ // setup conf Event History
+ setupConf("SimEvHist.json", ref currSimEvHist);
+ // setup conf Activity Log
+ setupConf("SimActLog.json", ref currSimActLog);
}
#endregion Private Methods
@@ -200,6 +206,58 @@ namespace MachineSim
return answ;
}
+ public List getEvents()
+ {
+ List answ = new List();
+
+ // genero a partire dall'elenco configurato da simulare...
+ answ = currSimEvHist.Select(i => new DisplayDataDTO()
+ {
+ IsNumeric = i.IsNumeric,
+ MaxVal = i.MaxVal,
+ MinVal = i.MinVal,
+ Order = i.Order,
+ Title = i.Title,
+ Type = i.Type,
+ ValueNum = simNext(i.ValueNum, i.MinVal, i.MaxVal, i.SimMean, i.SimStd),
+ DisplFormat = i.DisplFormat
+ //Value = $"{getNext(i.ValueNum, i.MinVal, i.MaxVal, i.SimMean, i.SimStd):N3}",
+ }).ToList();
+
+ foreach (var item in answ)
+ {
+ item.Value = $"{item.ValueNum.ToString(item.DisplFormat)}";
+ }
+
+ return answ;
+ }
+
+ public List getActLog()
+ {
+ List answ = new List();
+
+ // genero a partire dall'elenco configurato da simulare...
+ answ = currSimActLog.Select(i => new DisplayDataDTO()
+ {
+ IsNumeric = i.IsNumeric,
+ MaxVal = i.MaxVal,
+ MinVal = i.MinVal,
+ Order = i.Order,
+ Title = i.Title,
+ Type = i.Type,
+ ValueNum = simNext(i.ValueNum, i.MinVal, i.MaxVal, i.SimMean, i.SimStd),
+ DisplFormat = i.DisplFormat
+ //Value = $"{getNext(i.ValueNum, i.MinVal, i.MaxVal, i.SimMean, i.SimStd):N3}",
+ }).ToList();
+
+ foreach (var item in answ)
+ {
+ item.Value = $"{item.ValueNum.ToString(item.DisplFormat)}";
+ }
+
+ return answ;
+ }
+
///
/// Restituisce stato Macchina simulato come DTO
///