Added labels to scada,

Remove network card monitor
This commit is contained in:
Lucio Maranta
2019-01-21 09:29:03 +01:00
parent 6d25dcc55e
commit d9a22655b8
10 changed files with 61 additions and 184 deletions
+52 -52
View File
@@ -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
}
}
//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");
// }
//}