diff --git a/MP.MONO.Data/Constants.cs b/MP.MONO.Core/Constants.cs similarity index 98% rename from MP.MONO.Data/Constants.cs rename to MP.MONO.Core/Constants.cs index 858aedc..a5fe10d 100644 --- a/MP.MONO.Data/Constants.cs +++ b/MP.MONO.Core/Constants.cs @@ -5,7 +5,7 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; -namespace MP.MONO.Data +namespace MP.MONO.Core { //// //// This is here so CodeMaid doesn't reorganize this document diff --git a/MP.MONO.UI/Components/AlarmsOverview.razor.cs b/MP.MONO.UI/Components/AlarmsOverview.razor.cs index 8de322c..087f656 100644 --- a/MP.MONO.UI/Components/AlarmsOverview.razor.cs +++ b/MP.MONO.UI/Components/AlarmsOverview.razor.cs @@ -58,9 +58,14 @@ namespace MP.MONO.UI.Components protected async Task ReloadData() { - //await Task.Delay(10); - //ListRecords = await MMDataService.MachineDisplay(); - await Task.Delay(500); + var alarmList = await MMDataService.getAlarms(); + ListRecords = alarmList.Select(x => new DisplayDataDTO() + { + IsNumeric = false, + Title = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}", + Value = x, + Order = ListRecords == null ? 0 : ListRecords.Count + }).ToList(); } } } \ No newline at end of file diff --git a/MP.MONO.UI/Data/CurrentDataService.cs b/MP.MONO.UI/Data/CurrentDataService.cs index ccf7817..10abf3b 100644 --- a/MP.MONO.UI/Data/CurrentDataService.cs +++ b/MP.MONO.UI/Data/CurrentDataService.cs @@ -1,3 +1,4 @@ +using MP.MONO.Core; using MP.MONO.Core.CONF; using MP.MONO.Core.DTO; using MP.MONO.Data; @@ -77,13 +78,21 @@ namespace MP.MONO.UI.Data #region Public Properties public MessagePipe actLogPipe { get; set; } = null!; + public MessagePipe alarmPipe { get; set; } = null!; + public MessagePipe machEvPipe { get; set; } = null!; + public MessagePipe machStatsPipe { get; set; } = null!; + public MessagePipe maintPipe { get; set; } = null!; + public MessagePipe parametersPipe { get; set; } = null!; + public MessagePipe productionPipe { get; set; } = null!; + public MessagePipe statusPipe { get; set; } = null!; + public MessagePipe toolsPipe { get; set; } = null!; #endregion Public Properties @@ -112,6 +121,22 @@ namespace MP.MONO.UI.Data return await Task.FromResult(dbResult); } + public async Task> getAlarms() + { + List? dbResult = new List(); + string cacheKey = Constants.ALARM_CURR_KEY; + string rawData = await redisDb.StringGetAsync(cacheKey); + if (!string.IsNullOrEmpty(rawData)) + { + dbResult = JsonConvert.DeserializeObject>(rawData); + } + if (dbResult == null) + { + dbResult = new List(); + } + return await Task.FromResult(dbResult); + } + public async Task> getEventHist() { List? dbResult = new List(); diff --git a/MP.MONO.UI/appsettings.json b/MP.MONO.UI/appsettings.json index e40715e..6a7c459 100644 --- a/MP.MONO.UI/appsettings.json +++ b/MP.MONO.UI/appsettings.json @@ -7,7 +7,7 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "Redis": "localhost:6379", + "Redis": "nkcredis.steamware.net:6379,DefaultDatabase=7,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,password=nkc.password", "AuthConnection": "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;", "DefaultConnection": "Server=localhost;port=3306;database=MAPO.MONO;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;", "AdminConnection": "Server=localhost;port=3306;database=MAPO.MONO;user=root;pwd=Egalware_24068!;sslmode=None;", diff --git a/MachineSim/MachineSim.csproj b/MachineSim/MachineSim.csproj index 515763c..45f684c 100644 --- a/MachineSim/MachineSim.csproj +++ b/MachineSim/MachineSim.csproj @@ -17,7 +17,6 @@ - diff --git a/MachineSim/Program.cs b/MachineSim/Program.cs index 5323c4b..7723fb1 100644 --- a/MachineSim/Program.cs +++ b/MachineSim/Program.cs @@ -1,14 +1,12 @@ // See https://aka.ms/new-console-template for more information using MachineSim; +using MP.MONO.Core; using MP.MONO.Core.CONF; -using MP.MONO.Core.DTO; -using MP.MONO.Data; -using MP.MONO.Data.Controllers; using Newtonsoft.Json; using StackExchange.Redis; string lineSep = "------------------------------------------------------"; -string redisConf = "127.0.0.1:6379"; +string redisConf = "nkcredis.steamware.net:6379,DefaultDatabase=7,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,password=nkc.password"; Random rand = new Random(); List? statusList = new List(); @@ -26,7 +24,6 @@ ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(redisConf); ISubscriber sub = redis.GetSubscriber(); IDatabase? redisDb = redis.GetDatabase(); - // imposto parametri simulatore string confPath = Path.Combine(Directory.GetCurrentDirectory(), "conf"); // salvo configurazioni in redis diff --git a/MachineSim/SimDisplayDataDTO.cs b/MachineSim/SimDisplayDataDTO.cs index 14d57a6..9d7eba2 100644 --- a/MachineSim/SimDisplayDataDTO.cs +++ b/MachineSim/SimDisplayDataDTO.cs @@ -1,14 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MachineSim +namespace MachineSim { - public class SimDisplayDataDTO: MP.MONO.Core.DTO.DisplayDataDTO + public class SimDisplayDataDTO : MP.MONO.Core.DTO.DisplayDataDTO { + #region Public Properties + public double SimMean { get; set; } = 0; public double SimStd { get; set; } = 1; + + #endregion Public Properties } -} +} \ No newline at end of file diff --git a/MachineSim/Simulator.cs b/MachineSim/Simulator.cs index 6c167e2..a8dee91 100644 --- a/MachineSim/Simulator.cs +++ b/MachineSim/Simulator.cs @@ -1,5 +1,4 @@ using MathNet.Numerics.Distributions; -using MP.MONO.Core; using MP.MONO.Core.DTO; using Newtonsoft.Json; @@ -25,9 +24,6 @@ namespace MachineSim #region Public Constructors - protected int numMode { get; set; } = 1; - protected int numStatus { get; set; } = 1; - public Simulator(string _basePath, int nMode, int nStatus) { basePath = _basePath; @@ -38,6 +34,13 @@ namespace MachineSim #endregion Public Constructors + #region Protected Properties + + protected int numMode { get; set; } = 1; + protected int numStatus { get; set; } = 1; + + #endregion Protected Properties + #region Private Methods private void setupConf(string paramFileName, ref List localObj)