diff --git a/Step.Config/Config/serverConfig.xml b/Step.Config/Config/serverConfig.xml index aef05b1c..562bbb4b 100644 --- a/Step.Config/Config/serverConfig.xml +++ b/Step.Config/Config/serverConfig.xml @@ -12,7 +12,6 @@ 9000 * - 1 en true localhost diff --git a/Step.Config/Config/serverConfigValidator.xsd b/Step.Config/Config/serverConfigValidator.xsd index 6987c1e6..c90ea360 100644 --- a/Step.Config/Config/serverConfigValidator.xsd +++ b/Step.Config/Config/serverConfigValidator.xsd @@ -22,7 +22,6 @@ - diff --git a/Step.Config/ServerConfigController.cs b/Step.Config/ServerConfigController.cs index 1604d244..3141c076 100644 --- a/Step.Config/ServerConfigController.cs +++ b/Step.Config/ServerConfigController.cs @@ -192,6 +192,7 @@ namespace Step.Config Id = i++, Buttons = x.Buttons.Select(y => { y.Id = i++; return y; }).ToArray(), Images = x.Images.Select(y => { y.Id = i++; return y; }).ToArray(), + Labels = x.Labels.Select(y => { y.Id = i++; return y; }).ToArray(), ProgressBars = x.ProgressBars.Select(y => { y.Id = i++; return y; }).ToArray(), Inputs = x.Inputs.Select(y => { y.Id = i++; return y; }).ToArray() }) @@ -237,7 +238,6 @@ namespace Step.Config Language = CultureInfo.CreateSpecificCulture(x.Element("language").Value), ServerAddress = x.Element("serverAddress").Value, ServerPort = Convert.ToInt32(x.Element("serverPort").Value), - NetworkCardId = Convert.ToInt32(x.Element("networkCardId").Value), EnableDirectoryBrowsing = Convert.ToBoolean(x.Element("enableDirectoryBrowsing").Value), DatabaseAddress = x.Element("databaseAddress").Value, AutoOpenCmsClient = Convert.ToBoolean(x.Element("autoOpenCmsClient").Value) diff --git a/Step.Core/ThreadsFunctions.cs b/Step.Core/ThreadsFunctions.cs index 039fb02c..4960d4ff 100644 --- a/Step.Core/ThreadsFunctions.cs +++ b/Step.Core/ThreadsFunctions.cs @@ -720,57 +720,6 @@ public static class ThreadsFunctions } } - public static void MonitorPanelPCResources() - { - float sumRec, sumSen; - Stopwatch sw = new Stopwatch(); - DTONetworkMonitorModel Monitor = new DTONetworkMonitorModel(); - int cardId = ServerConfig.ServerStartupConfig.NetworkCardId - 1; - - PerformanceCounterCategory performanceCounterCategory = new PerformanceCounterCategory("Network Interface"); - - 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()[cardId]; - - PerformanceCounter PC_Bandwith = new PerformanceCounter("Network Interface", "Current Bandwidth", Monitor.Name); - PerformanceCounter PC_RecievedBytes = new PerformanceCounter("Network Interface", "Bytes Received/sec", Monitor.Name); - PerformanceCounter PC_SentBytes = new PerformanceCounter("Network Interface", "Bytes Sent/sec", Monitor.Name); - - Monitor.Bandwidth = PC_Bandwith.NextValue(); - - try - { - while (true) - { - sw.Restart(); - - sumRec = 0; - sumSen = 0; - for (int index = 0; index < 50; index++) - { - sumRec += PC_RecievedBytes.NextValue(); - sumSen += PC_SentBytes.NextValue(); - } - Monitor.Value = Math.Round(((8 * (sumSen + sumRec)) / (Monitor.Bandwidth * 50) * 100), 2); - MessageServices.Current.Publish(NETWORK_USAGE, null, Monitor); - sw.Stop(); - - // Wait - Thread.Sleep(CalcSleepTime(2000, (int)sw.ElapsedMilliseconds)); - } - } - catch (ThreadAbortException) - { - ExceptionManager.Manage(ERROR_LEVEL.FATAL, "Fatal error in Network Performance monitor Thread"); - } - } - public static void ReadScadaData() { NcHandler ncHandler = new NcHandler(); @@ -1004,4 +953,55 @@ public static class ThreadsFunctions } #endregion SupportFunctions -} \ No newline at end of file +} + +//public static void MonitorPanelPCResources() +//{ +// float sumRec, sumSen; +// Stopwatch sw = new Stopwatch(); +// DTONetworkMonitorModel Monitor = new DTONetworkMonitorModel(); +// int cardId = ServerConfig.ServerStartupConfig.NetworkCardId - 1; + +// PerformanceCounterCategory performanceCounterCategory = new PerformanceCounterCategory("Network Interface"); + +// 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()[cardId]; + +// PerformanceCounter PC_Bandwith = new PerformanceCounter("Network Interface", "Current Bandwidth", Monitor.Name); +// PerformanceCounter PC_RecievedBytes = new PerformanceCounter("Network Interface", "Bytes Received/sec", Monitor.Name); +// PerformanceCounter PC_SentBytes = new PerformanceCounter("Network Interface", "Bytes Sent/sec", Monitor.Name); + +// Monitor.Bandwidth = PC_Bandwith.NextValue(); + +// try +// { +// while (true) +// { +// sw.Restart(); + +// sumRec = 0; +// sumSen = 0; +// for (int index = 0; index < 50; index++) +// { +// sumRec += PC_RecievedBytes.NextValue(); +// sumSen += PC_SentBytes.NextValue(); +// } +// Monitor.Value = Math.Round(((8 * (sumSen + sumRec)) / (Monitor.Bandwidth * 50) * 100), 2); +// MessageServices.Current.Publish(NETWORK_USAGE, null, Monitor); +// sw.Stop(); + +// // Wait +// Thread.Sleep(CalcSleepTime(2000, (int)sw.ElapsedMilliseconds)); +// } +// } +// catch (ThreadAbortException) +// { +// ExceptionManager.Manage(ERROR_LEVEL.FATAL, "Fatal error in Network Performance monitor Thread"); +// } +//} \ No newline at end of file diff --git a/Step.Core/ThreadsHandler.cs b/Step.Core/ThreadsHandler.cs index ac274f21..b37ed8c9 100644 --- a/Step.Core/ThreadsHandler.cs +++ b/Step.Core/ThreadsHandler.cs @@ -32,16 +32,9 @@ 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); - MonitorNetworkResources = new Thread(() => Monitor()); - MonitorNetworkResources.Start(); } public static void StartWorkers() @@ -85,8 +78,6 @@ 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.Model/ConfigModels/ServerConfigModel.cs b/Step.Model/ConfigModels/ServerConfigModel.cs index d4d29253..20b825aa 100644 --- a/Step.Model/ConfigModels/ServerConfigModel.cs +++ b/Step.Model/ConfigModels/ServerConfigModel.cs @@ -11,8 +11,7 @@ namespace Step.Model.ConfigModels { public CultureInfo Language { get; set; } public int ServerPort { get; set; } - public string ServerAddress { get; set; } - public int NetworkCardId { get; set; } + public string ServerAddress { get; set; } public bool EnableDirectoryBrowsing { get; set; } public string DatabaseAddress { get; set; } public bool AutoOpenCmsClient { get; set; } diff --git a/Step.Model/Constants.cs b/Step.Model/Constants.cs index f41f2b84..546e323d 100644 --- a/Step.Model/Constants.cs +++ b/Step.Model/Constants.cs @@ -196,7 +196,6 @@ namespace Step.Model public const string NC_MAGAZINE_IS_ACTIVE = "UPDATE_NC_MAGAZINE_STATUS"; public const string SEND_QUEUE_DATA = "SEND_QUEUE_DATA"; public const string SEND_M155_DATA = "SEND_M155_DATA"; - public const string NETWORK_USAGE = "NETWORK_USAGE"; public const string SEND_SCADA_DATA = "SEND_SCADA_DATA"; public const string BROADCAST_DATA = "BROADCAST_DATA"; diff --git a/Step.Model/DTOModels/Scada/ScadaSchemaModel.cs b/Step.Model/DTOModels/Scada/ScadaSchemaModel.cs index 5905ddfb..0277299a 100644 --- a/Step.Model/DTOModels/Scada/ScadaSchemaModel.cs +++ b/Step.Model/DTOModels/Scada/ScadaSchemaModel.cs @@ -32,6 +32,9 @@ namespace Step.Model.DTOModels.Scada [XmlArrayItem("image", typeof(ScadaSchemaImageModel))] public ScadaSchemaImageModel[] Images { get; set; } + [XmlArray("labels")] + [XmlArrayItem("label", typeof(ScadaSchemaLabelModel))] + public ScadaSchemaLabelModel[] Labels { get; set; } [XmlArray("progressBars")] [XmlArrayItem("progressBar", typeof(ScadaSchemaProgressBarModel))] diff --git a/Step.UI/ServerControlWindow.Designer.cs b/Step.UI/ServerControlWindow.Designer.cs index d53df862..b5343c9b 100644 --- a/Step.UI/ServerControlWindow.Designer.cs +++ b/Step.UI/ServerControlWindow.Designer.cs @@ -46,17 +46,9 @@ namespace Step.UI this.TXTType = new System.Windows.Forms.Label(); this.CHNcConnected = new MetroFramework.Controls.MetroCheckBox(); this.label1 = new System.Windows.Forms.Label(); - this.labelNetworkName = new System.Windows.Forms.Label(); - this.metroPanel1 = new MetroFramework.Controls.MetroPanel(); - this.label3 = new System.Windows.Forms.Label(); - this.labelNetworkSpeed = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.labelNetworkBand = new System.Windows.Forms.Label(); this.NotifyIconMenu.SuspendLayout(); this.metroTabControl1.SuspendLayout(); this.ThreadsInfo.SuspendLayout(); - this.metroPanel1.SuspendLayout(); this.SuspendLayout(); // // StepNotifyIcon @@ -86,7 +78,7 @@ namespace Step.UI // openUiButton // this.openUiButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.openUiButton.Location = new System.Drawing.Point(11, 477); + this.openUiButton.Location = new System.Drawing.Point(11, 371); this.openUiButton.Name = "openUiButton"; this.openUiButton.Size = new System.Drawing.Size(151, 42); this.openUiButton.TabIndex = 1; @@ -159,7 +151,7 @@ namespace Step.UI // stopServerButton // this.stopServerButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.stopServerButton.Location = new System.Drawing.Point(188, 477); + this.stopServerButton.Location = new System.Drawing.Point(188, 371); this.stopServerButton.Name = "stopServerButton"; this.stopServerButton.Size = new System.Drawing.Size(151, 42); this.stopServerButton.TabIndex = 3; @@ -187,7 +179,7 @@ namespace Step.UI this.TXTstatus.Enabled = false; this.TXTstatus.Lines = new string[] { "..."}; - this.TXTstatus.Location = new System.Drawing.Point(-1, 535); + this.TXTstatus.Location = new System.Drawing.Point(-1, 419); this.TXTstatus.MaxLength = 32767; this.TXTstatus.Name = "TXTstatus"; this.TXTstatus.PasswordChar = '\0'; @@ -234,90 +226,11 @@ namespace Step.UI this.label1.TabIndex = 54; this.label1.Text = "Vendor:"; // - // labelNetworkName - // - this.labelNetworkName.Location = new System.Drawing.Point(82, 12); - this.labelNetworkName.Name = "labelNetworkName"; - this.labelNetworkName.Size = new System.Drawing.Size(242, 22); - this.labelNetworkName.TabIndex = 55; - this.labelNetworkName.Text = "---"; - this.labelNetworkName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // metroPanel1 - // - this.metroPanel1.AccessibleName = ""; - this.metroPanel1.Controls.Add(this.label4); - this.metroPanel1.Controls.Add(this.labelNetworkBand); - this.metroPanel1.Controls.Add(this.label3); - this.metroPanel1.Controls.Add(this.labelNetworkSpeed); - this.metroPanel1.Controls.Add(this.label2); - this.metroPanel1.Controls.Add(this.labelNetworkName); - this.metroPanel1.HorizontalScrollbarBarColor = true; - this.metroPanel1.HorizontalScrollbarHighlightOnWheel = false; - this.metroPanel1.HorizontalScrollbarSize = 10; - this.metroPanel1.Location = new System.Drawing.Point(8, 371); - this.metroPanel1.Name = "metroPanel1"; - this.metroPanel1.Size = new System.Drawing.Size(331, 100); - this.metroPanel1.TabIndex = 56; - this.metroPanel1.Tag = ""; - this.metroPanel1.VerticalScrollbarBarColor = true; - this.metroPanel1.VerticalScrollbarHighlightOnWheel = false; - this.metroPanel1.VerticalScrollbarSize = 10; - // - // label3 - // - this.label3.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; - this.label3.Location = new System.Drawing.Point(3, 34); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(73, 22); - this.label3.TabIndex = 58; - this.label3.Text = "Load: "; - this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // labelNetworkSpeed - // - this.labelNetworkSpeed.Location = new System.Drawing.Point(82, 34); - this.labelNetworkSpeed.Name = "labelNetworkSpeed"; - this.labelNetworkSpeed.Size = new System.Drawing.Size(242, 22); - this.labelNetworkSpeed.TabIndex = 57; - this.labelNetworkSpeed.Text = "0.0%"; - this.labelNetworkSpeed.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // label2 - // - this.label2.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; - this.label2.Location = new System.Drawing.Point(3, 12); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(73, 22); - this.label2.TabIndex = 56; - this.label2.Text = "NIC Name: "; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // label4 - // - this.label4.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; - this.label4.Location = new System.Drawing.Point(3, 56); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(73, 22); - this.label4.TabIndex = 60; - this.label4.Text = "Bandwidth: "; - this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // labelNetworkBand - // - this.labelNetworkBand.Location = new System.Drawing.Point(82, 56); - this.labelNetworkBand.Name = "labelNetworkBand"; - this.labelNetworkBand.Size = new System.Drawing.Size(242, 22); - this.labelNetworkBand.TabIndex = 59; - this.labelNetworkBand.Text = "0 Mb/s"; - this.labelNetworkBand.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // // ServerControlWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(350, 565); - this.Controls.Add(this.metroPanel1); + this.ClientSize = new System.Drawing.Size(350, 449); this.Controls.Add(this.label1); this.Controls.Add(this.TXTType); this.Controls.Add(this.CHNcConnected); @@ -338,7 +251,6 @@ namespace Step.UI this.NotifyIconMenu.ResumeLayout(false); this.metroTabControl1.ResumeLayout(false); this.ThreadsInfo.ResumeLayout(false); - this.metroPanel1.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -359,12 +271,5 @@ namespace Step.UI private Label TXTType; private MetroFramework.Controls.MetroCheckBox CHNcConnected; private Label label1; - private Label labelNetworkName; - private MetroFramework.Controls.MetroPanel metroPanel1; - private Label label3; - private Label labelNetworkSpeed; - private Label label2; - private Label label4; - private Label labelNetworkBand; } } \ No newline at end of file diff --git a/Step.UI/ServerControlWindow.cs b/Step.UI/ServerControlWindow.cs index 50dce856..2255bba2 100644 --- a/Step.UI/ServerControlWindow.cs +++ b/Step.UI/ServerControlWindow.cs @@ -151,24 +151,6 @@ namespace Step.UI //ShowMessage on UI TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + message.Message; }); - }), - MessageServices.Current.Subscribe(NETWORK_USAGE, (a, b) => - { - DTONetworkMonitorModel NICMonitor = (DTONetworkMonitorModel)a; - if (!IsDisposed) - Invoke((MethodInvoker)delegate () - { - labelNetworkSpeed.Text = NICMonitor.Value + " %"; - labelNetworkName.Text = NICMonitor.Name; - - if(NICMonitor.Bandwidth >= Math.Pow(10,9)) - labelNetworkBand.Text = (NICMonitor.Bandwidth * Math.Pow(10,-9)).ToString() + " Gb/s"; - else - labelNetworkBand.Text = (NICMonitor.Bandwidth * Math.Pow(10,-6)).ToString() + " Mb/s"; - - if(NICMonitor.Value > 95.0) - StepNotifyIcon.ShowBalloonTip(30000, "Network Card Warning", "Network Card - Bandwith Overload", ToolTipIcon.Error); - }); }), // NC status handler MessageServices.Current.Subscribe(SEND_NC_STATUS, (a, b) =>