diff --git a/Thermo.Active.Config/ServerConfig.cs b/Thermo.Active.Config/ServerConfig.cs index 3146aa0b..d4517ec8 100644 --- a/Thermo.Active.Config/ServerConfig.cs +++ b/Thermo.Active.Config/ServerConfig.cs @@ -13,6 +13,7 @@ namespace Thermo.Active.Config public static List ExtSoftwaresConfig; public static Dictionary AdditionalParametersConfig; public static Dictionary UnitMeasuresConfig; + public static Dictionary ThreadSamplingConfig; public static SoftwareProdConfigModel SoftwareProdConfig; public static MachineModel MachineConfig; public static List MaintenancesConfig; diff --git a/Thermo.Active.Config/ServerConfigController.cs b/Thermo.Active.Config/ServerConfigController.cs index 68b0ce0a..2c348c6d 100644 --- a/Thermo.Active.Config/ServerConfigController.cs +++ b/Thermo.Active.Config/ServerConfigController.cs @@ -385,6 +385,13 @@ namespace Thermo.Active.Config .Elements("unitOfMeasure") .Select(x => new KeyValuePair(Convert.ToInt32(x.Attribute("id").Value), x.Attribute("value").Value)) .ToDictionary(x => x.Key, x => x.Value); + + // carico conf periodi thread... + ThreadSamplingConfig = xmlConfigFile + .Descendants("sampling") + .Elements("thread") + .Select(x => new KeyValuePair(x.Attribute("name").Value, Convert.ToInt32(x.Attribute("value").Value))) + .ToDictionary(x => x.Key, x => x.Value); } private static void ReadAreaConfig() diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index 64a4898c..cb717319 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -38,6 +38,20 @@ public static class ThreadsFunctions private static ConcurrentDictionary Counter = new ConcurrentDictionary(); private static Thread ConnThread; + /// + /// restituisce il periodo di campionamento SE configurato, altrimenti 1000 ms + /// + /// + /// + private static int samplMsec(string threadName) + { + int answ = 500; + if (ThreadSamplingConfig.ContainsKey(threadName)) + { + answ = ThreadSamplingConfig[threadName]; + } + return answ; + } #region Functions @@ -526,7 +540,7 @@ public static class ThreadsFunctions UpdateStat(MethodBase.GetCurrentMethod().Name, sw.ElapsedMilliseconds); // Wait - Thread.Sleep(CalcSleepTime(200, (int)sw.ElapsedMilliseconds)); + Thread.Sleep(CalcSleepTime(samplMsec("axis"), (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -613,7 +627,7 @@ public static class ThreadsFunctions //Update thread timer UpdateStat(MethodBase.GetCurrentMethod().Name, sw.ElapsedMilliseconds); // Wait - Thread.Sleep(CalcSleepTime(500, (int)sw.ElapsedMilliseconds)); + Thread.Sleep(CalcSleepTime(samplMsec("gauges"), (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -697,7 +711,7 @@ public static class ThreadsFunctions //Update thread timer UpdateStat(MethodBase.GetCurrentMethod().Name, sw.ElapsedMilliseconds); // Wait - Thread.Sleep(CalcSleepTime(500, (int)sw.ElapsedMilliseconds)); + Thread.Sleep(CalcSleepTime(samplMsec("prodInfo"), (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -739,7 +753,7 @@ public static class ThreadsFunctions //Update thread timer UpdateStat(MethodBase.GetCurrentMethod().Name, sw.ElapsedMilliseconds); // Wait - Thread.Sleep(CalcSleepTime(1000, (int)sw.ElapsedMilliseconds)); + Thread.Sleep(CalcSleepTime(samplMsec("prodCycle"), (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -925,7 +939,7 @@ public static class ThreadsFunctions // Update thread timer UpdateStat(MethodBase.GetCurrentMethod().Name, sw.ElapsedMilliseconds); // Wait - Thread.Sleep(CalcSleepTime(500, (int)sw.ElapsedMilliseconds)); + Thread.Sleep(CalcSleepTime(samplMsec("modules"), (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -933,7 +947,6 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } - public static void ReadMComandsData() { NcAdapter ncAdapter = new NcAdapter(); @@ -980,7 +993,6 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } - public static void ReadM154Data() { NcAdapter ncAdapter = new NcAdapter(); @@ -1155,8 +1167,6 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } - - public static void SetupCmsConnect() { NcAdapter ncAdapter = new NcAdapter();