diff --git a/Step.Core/ThreadsFunctions.cs b/Step.Core/ThreadsFunctions.cs index b7788957..b0ec927f 100644 --- a/Step.Core/ThreadsFunctions.cs +++ b/Step.Core/ThreadsFunctions.cs @@ -720,21 +720,21 @@ public static class ThreadsFunctions public static void MonitorPanelPCResources() { - float SumRec, SumSen; + float sumRec, sumSen; Stopwatch sw = new Stopwatch(); - DTONetworkMonitor Monitor = new DTONetworkMonitor(); - int CardId = ServerConfig.ServerStartupConfig.NetworkCardId - 1; + DTONetworkMonitorModel Monitor = new DTONetworkMonitorModel(); + int cardId = ServerConfig.ServerStartupConfig.NetworkCardId - 1; PerformanceCounterCategory performanceCounterCategory = new PerformanceCounterCategory("Network Interface"); - - if(CardId<0 || CardId > performanceCounterCategory.GetInstanceNames().Length ) + + if (cardId < 0 || cardId > performanceCounterCategory.GetInstanceNames().Length) { Monitor.Name = "No card to monitor"; MessageServices.Current.Publish(NETWORK_USAGE, null, Monitor); return; } - Monitor.Name = performanceCounterCategory.GetInstanceNames()[0]; + Monitor.Name = performanceCounterCategory.GetInstanceNames()[cardId]; PerformanceCounter PC_Bandwith = new PerformanceCounter("Network Interface", "Current Bandwidth", Monitor.Name); @@ -749,14 +749,14 @@ public static class ThreadsFunctions { sw.Restart(); - SumRec = 0; - SumSen = 0; + sumRec = 0; + sumSen = 0; for (int index = 0; index < 50; index++) { - SumRec += PC_RecievedBytes.NextValue(); - SumSen += PC_SentBytes.NextValue(); + sumRec += PC_RecievedBytes.NextValue(); + sumSen += PC_SentBytes.NextValue(); } - Monitor.Value = Math.Round(((8 * (SumSen + SumRec)) / (Monitor.Bandwidth * 50) * 100), 2) ; + Monitor.Value = Math.Round(((8 * (sumSen + sumRec)) / (Monitor.Bandwidth * 50) * 100), 2) ; MessageServices.Current.Publish(NETWORK_USAGE, null, Monitor); sw.Stop(); diff --git a/Step.Core/ThreadsHandler.cs b/Step.Core/ThreadsHandler.cs index 6ce2fe20..e375c416 100644 --- a/Step.Core/ThreadsHandler.cs +++ b/Step.Core/ThreadsHandler.cs @@ -31,14 +31,16 @@ namespace Step.Core private volatile static List RunningThreadsList = new List(); internal volatile static Dictionary RunningThreadStatus = new Dictionary(); + private static Thread MonitorNetworkResources; + public static void Start() { ThreadsFunctions.RestoreConnection(); // Start Thread Network monitor Action Monitor = new Action(ThreadsFunctions.MonitorPanelPCResources); - Thread t = new Thread(() => Monitor()); - t.Start(); + MonitorNetworkResources = new Thread(() => Monitor()); + MonitorNetworkResources.Start(); } public static void StartWorkers() @@ -82,6 +84,9 @@ namespace Step.Core RunningThreadStatus.Clear(); RunningThreadStatus.Add("TryNcConnection", "---"); } + // Close network monitor + MonitorNetworkResources.Abort(); + MessageServices.Current.Publish(SEND_THREADS_STATUS, null, RunningThreadStatus); } diff --git a/Step.Database/Controllers/AlarmsController.cs b/Step.Database/Controllers/AlarmsController.cs index 87a0b57b..e594ba71 100644 --- a/Step.Database/Controllers/AlarmsController.cs +++ b/Step.Database/Controllers/AlarmsController.cs @@ -28,7 +28,7 @@ namespace Step.Database.Controllers dbCtx.Dispose(); } - public List GetPaginatedWithFilter(string title, List types, int page, int pageSize, DateTime startDate, DateTime endDate, List userIds, Dictionary plcMessages) + public List GetPaginatedWithFilter(string title, List sources, int page, int pageSize, DateTime startDate, DateTime endDate, List userIds, Dictionary plcMessages) { bool ifNoUser = false; var index = userIds.IndexOf(-1); @@ -55,7 +55,7 @@ namespace Step.Database.Controllers .Include("Users") .Where(x => x.TimeStamp >= startDate && x.TimeStamp <= endDate // Filter by date - && types.Contains(x.Type) // Type + && sources.Contains(x.Source) // Check source && ( (ifNoUser && x.Users.Count() == 0) || x.Users.Any(y => userIds.Any(z => z == y.UserId))) // Check user && ((x.Source == ALARM_SOURCE.NC && ncAlarmDescIds.Contains(x.AlarmDescriptionId.Value)) // Check if message is contained in NC messages diff --git a/Step.Model/DTOModels/AlarmModels/DTOAlarmHistoricModel.cs b/Step.Model/DTOModels/AlarmModels/DTOAlarmHistoricModel.cs index a7cbeca7..53e1c9a5 100644 --- a/Step.Model/DTOModels/AlarmModels/DTOAlarmHistoricModel.cs +++ b/Step.Model/DTOModels/AlarmModels/DTOAlarmHistoricModel.cs @@ -65,7 +65,7 @@ namespace Step.Model.DTOModels.AlarmModels public string Title { get; set; } [Required] - public List Type { get; set; } + public List Sources { get; set; } [Required] public DateTime? StartDate { get; set; } diff --git a/Step.Model/DTOModels/DTONetworkMonitor.cs b/Step.Model/DTOModels/DTONetworkMonitor.cs index 75cab397..b776f1e1 100644 --- a/Step.Model/DTOModels/DTONetworkMonitor.cs +++ b/Step.Model/DTOModels/DTONetworkMonitor.cs @@ -6,10 +6,10 @@ using System.Threading.Tasks; namespace Step.Model.DTOModels { - public class DTONetworkMonitor + public class DTONetworkMonitorModel { - public String Name; - public Double Bandwidth; - public Double Value; + public string Name { get; set; } + public double Bandwidth { get; set; } + public double Value { get; set; } } } diff --git a/Step.Model/DatabaseModels/NcMagazinePositionModel.cs b/Step.Model/DatabaseModels/NcMagazinePositionModel.cs index 8c041503..d5e77bc4 100644 --- a/Step.Model/DatabaseModels/NcMagazinePositionModel.cs +++ b/Step.Model/DatabaseModels/NcMagazinePositionModel.cs @@ -13,7 +13,7 @@ namespace Step.Model.DatabaseModels [Key, Column("position_id", Order = 1)] public int PositionId { get; set; } - + [Column("type")] public byte Type { get; set; } diff --git a/Step.UI/ServerControlWindow.cs b/Step.UI/ServerControlWindow.cs index d543ead3..50dce856 100644 --- a/Step.UI/ServerControlWindow.cs +++ b/Step.UI/ServerControlWindow.cs @@ -154,7 +154,7 @@ namespace Step.UI }), MessageServices.Current.Subscribe(NETWORK_USAGE, (a, b) => { - DTONetworkMonitor NICMonitor = (DTONetworkMonitor)a; + DTONetworkMonitorModel NICMonitor = (DTONetworkMonitorModel)a; if (!IsDisposed) Invoke((MethodInvoker)delegate () { diff --git a/Step/Controllers/WebApi/ApiAlarmController.cs b/Step/Controllers/WebApi/ApiAlarmController.cs index 7339ad19..735d3c59 100644 --- a/Step/Controllers/WebApi/ApiAlarmController.cs +++ b/Step/Controllers/WebApi/ApiAlarmController.cs @@ -34,7 +34,7 @@ namespace Step.Controllers.WebApi using (AlarmsController alarm = new AlarmsController()) { - var alarms = alarm.GetPaginatedWithFilter(filter.Title, filter.Type, filter.Page, filter.PageSize, filter.StartDate.Value, filter.EndDate, filter.UserIds, plcMessages); + var alarms = alarm.GetPaginatedWithFilter(filter.Title, filter.Sources, filter.Page, filter.PageSize, filter.StartDate.Value, filter.EndDate, filter.UserIds, plcMessages); return Ok(alarms); } diff --git a/Step/wwwroot/assets/styles/base/card.less b/Step/wwwroot/assets/styles/base/card.less index fc2a43a8..e977d24b 100644 --- a/Step/wwwroot/assets/styles/base/card.less +++ b/Step/wwwroot/assets/styles/base/card.less @@ -1339,6 +1339,7 @@ width: 100%; display: flex; flex-flow: column; + font-family: monospace; .row{ width: 464px; height: 32px; @@ -1348,7 +1349,7 @@ line-height: 1.78px; text-align: justify; overflow: hidden; - white-space: nowrap; + white-space: pre; label{ font-size: 18px; margin-left: 36px; diff --git a/Step/wwwroot/assets/styles/style.css b/Step/wwwroot/assets/styles/style.css index 2b1d657c..41d8e74a 100644 --- a/Step/wwwroot/assets/styles/style.css +++ b/Step/wwwroot/assets/styles/style.css @@ -7213,6 +7213,7 @@ footer .container button.big:before { width: 100%; display: flex; flex-flow: column; + font-family: monospace; } .card-job-production .card-job-production-body .card-job-production-body-bottom .content-box .row { width: 464px; @@ -7223,7 +7224,7 @@ footer .container button.big:before { line-height: 1.78px; text-align: justify; overflow: hidden; - white-space: nowrap; + white-space: pre; } .card-job-production .card-job-production-body .card-job-production-body-bottom .content-box .row label { font-size: 18px;