diff --git a/MP.MONO.UI/Components/MaintOverview.razor b/MP.MONO.UI/Components/MaintOverview.razor
index 6b093c5..c4c499b 100644
--- a/MP.MONO.UI/Components/MaintOverview.razor
+++ b/MP.MONO.UI/Components/MaintOverview.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
{
- - Maintainance Details
- - Calendar
-
+ - Maintainance Details
+ - Calendar
+
}
-@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/MaintOverview.razor.cs b/MP.MONO.UI/Components/MaintOverview.razor.cs
new file mode 100644
index 0000000..320252b
--- /dev/null
+++ b/MP.MONO.UI/Components/MaintOverview.razor.cs
@@ -0,0 +1,58 @@
+using MP.MONO.Core.DTO;
+using MP.MONO.Data;
+using Newtonsoft.Json;
+
+namespace MP.MONO.UI.Components
+{
+ public partial class MaintOverview
+ {
+ #region Protected Fields
+
+ protected bool dataLoaded = false;
+
+ #endregion Protected Fields
+
+ #region Private Properties
+
+ private List? ListRecords { get; set; } = null;
+
+ #endregion Private Properties
+
+ #region Private Methods
+
+ private void MaintPipe_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.maintPipe.EA_NewMessage += MaintPipe_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 f2b1296..361e17f 100644
--- a/MP.MONO.UI/Data/CurrentDataService.cs
+++ b/MP.MONO.UI/Data/CurrentDataService.cs
@@ -58,6 +58,7 @@ namespace MP.MONO.UI.Data
public MessagePipe statusPipe { get; set; } = null!;
public MessagePipe productionPipe { get; set; } = null!;
public MessagePipe machStatsPipe { get; set; } = null!;
+ public MessagePipe maintPipe { get; set; } = null!;
#region Public Constructors
@@ -75,6 +76,7 @@ namespace MP.MONO.UI.Data
statusPipe = new MessagePipe(redisConn, "status");
productionPipe = new MessagePipe(redisConn, "production");
machStatsPipe = new MessagePipe(redisConn, "machstats");
+ maintPipe = new MessagePipe(redisConn, "maintenance");
// conf cache
this.distributedCache = distributedCache;
diff --git a/MachineSim/MachineSim.csproj b/MachineSim/MachineSim.csproj
index 82a98b7..1f612d7 100644
--- a/MachineSim/MachineSim.csproj
+++ b/MachineSim/MachineSim.csproj
@@ -24,6 +24,9 @@
Always
+
+ Always
+
Always
diff --git a/MachineSim/Program.cs b/MachineSim/Program.cs
index fa2d9fd..7b42843 100644
--- a/MachineSim/Program.cs
+++ b/MachineSim/Program.cs
@@ -167,7 +167,7 @@ void simMaint()
do
{
// recupero uno stato simulato
- var newVal = currSimGen.getProdStats();
+ var newVal = currSimGen.getMaint();
string rawData = JsonConvert.SerializeObject(newVal);
saveAndSendMessage(mHash("Machine:Maintenance:Current"), rawData, "maintenance", rawData);
diff --git a/MachineSim/SimMaint.json b/MachineSim/SimMaint.json
new file mode 100644
index 0000000..16a56cc
--- /dev/null
+++ b/MachineSim/SimMaint.json
@@ -0,0 +1,26 @@
+[
+ {
+ "Order": 0,
+ "Type": "CALENDAR",
+ "Title": "Filter life (hour)",
+ "Value": "5000",
+ "ValueNum": 5000,
+ "MinVal": 1000,
+ "MaxVal": 10000,
+ "SimMean": 1,
+ "SimStd": 1,
+ "DisplFormat": "N0"
+ },
+ {
+ "Order": 0,
+ "Type": "CALENDAR",
+ "Title": "Lubro refill (hour)",
+ "Value": "100",
+ "ValueNum": 100,
+ "MinVal": 0,
+ "MaxVal": 1000,
+ "SimMean": -1,
+ "SimStd": 1,
+ "DisplFormat": "N0"
+ },
+]
\ No newline at end of file
diff --git a/MachineSim/Simulator.cs b/MachineSim/Simulator.cs
index 0932610..7454617 100644
--- a/MachineSim/Simulator.cs
+++ b/MachineSim/Simulator.cs
@@ -14,6 +14,7 @@ namespace MachineSim
protected string basePath = "";
protected List currSimMachStat = new List();
+ protected List currSimMaint = new List();
protected List currSimPar = new List();
protected string paramFileName = "SimParams.json";
@@ -48,10 +49,12 @@ namespace MachineSim
private void setupConfig()
{
- // setup conf parametri
+ // setup conf Parametri
setupConf("SimParams.json", ref currSimPar);
- // setup conf machStat
+ // setup conf MachStat
setupConf("SimMachStat.json", ref currSimMachStat);
+ // setup conf Maintenance
+ setupConf("SimMaint.json", ref currSimMaint);
}
#endregion Private Methods
@@ -97,60 +100,6 @@ namespace MachineSim
{
item.Value = $"{item.ValueNum.ToString(item.DisplFormat)}";
}
-
- // !!!FIXME TODO... รจ fake...
-
-#if false
- var currVal = rand.NextDouble();
- DisplayDataDTO displ01 = new DisplayDataDTO()
- {
- Order = 0,
- Title = "OEE",
- ValueNum = currVal,
- IsNumeric = true,
- Value = currVal.ToString("P1"),
- Type = "OEE-75-90"
- };
- answ.Add(displ01);
-
- currVal = rand.NextDouble();
- DisplayDataDTO displ02 = new DisplayDataDTO()
- {
- Order = 0,
- Title = "Avail",
- ValueNum = currVal,
- IsNumeric = true,
- Value = currVal.ToString("P1"),
- Type = "AVAIL-50-80"
- };
- answ.Add(displ02);
-
- currVal = rand.NextDouble();
- DisplayDataDTO displ03 = new DisplayDataDTO()
- {
- Order = 0,
- Title = "Order fulfill",
- ValueNum = currVal,
- IsNumeric = true,
- Value = currVal.ToString("P1"),
- Type = "ORDER"
- };
- answ.Add(displ03);
-
- double minTCiclo = stdCycle * rand.NextDouble();
- TimeSpan durTCycle = TimeSpan.FromMinutes(minTCiclo);
- DisplayDataDTO displ04 = new DisplayDataDTO()
- {
- Order = 0,
- Title = "Cycle time",
- ValueNum = 0,
- IsNumeric = false,
- Value = $"{durTCycle.Hours:00}:{durTCycle.Minutes:00}:{durTCycle.Seconds:00}",
- Type = "TCycle"
- };
- answ.Add(displ04);
-#endif
-
return answ;
}
@@ -197,6 +146,32 @@ namespace MachineSim
return answ;
}
+ public List getMaint()
+ {
+ List answ = new List();
+
+ // genero a partire dall'elenco configurato da simulare...
+ answ = currSimMaint.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
///