diff --git a/Client.Config/Config.xml b/Client.Config/Config.xml index 6da2ec9f..9430d784 100644 --- a/Client.Config/Config.xml +++ b/Client.Config/Config.xml @@ -3,7 +3,7 @@ #FF00FF GPU - true + false false true diff --git a/Client.Utils/Constants.cs b/Client.Utils/Constants.cs index 0833303b..3d266e0c 100644 --- a/Client.Utils/Constants.cs +++ b/Client.Utils/Constants.cs @@ -60,7 +60,8 @@ namespace Client.Utils public const int HMI_WINDOW_POS_Y_OSAI = 176; public const string HMI_WINDOW_TITLE_FANUC = "CNC Screen Display Function"; public const string HMI_WINDOW_TITLE_SIEMENS = "SINUMERIK Operate - Window Mode"; - + public const string HMI_WINDOW_TITLE_SIEMENS_CMS_CONTROL = "Sinumerik HMI"; + //KEYBOARD Constants public const int KEYB_HEIGHT = 377; diff --git a/Client/View/NcWindow.cs b/Client/View/NcWindow.cs index 250c4b70..0b8e00c6 100644 --- a/Client/View/NcWindow.cs +++ b/Client/View/NcWindow.cs @@ -851,7 +851,7 @@ namespace CMS_Client.View switch (Config.VendorHmiConfig.Type) { case 1: return (Title.Contains(HMI_WINDOW_TITLE_FANUC) && Title.Contains(Config.VendorHmiConfig.IpAddress)); - case 2: return (Title.Contains(HMI_WINDOW_TITLE_SIEMENS)); + case 2: return (Title.Contains(HMI_WINDOW_TITLE_SIEMENS) || Title.Contains(HMI_WINDOW_TITLE_SIEMENS_CMS_CONTROL)); case 3: return true; } return true; diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index b5c3803c..825447b2 100644 Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ diff --git a/Step.Core/ThreadsFunctions.cs b/Step.Core/ThreadsFunctions.cs index 6844a7d6..bbae70cc 100644 --- a/Step.Core/ThreadsFunctions.cs +++ b/Step.Core/ThreadsFunctions.cs @@ -60,7 +60,7 @@ public static class ThreadsFunctions ReadAlarmsTimes++; // Wait - Thread.Sleep(200); + Thread.Sleep(CalcSleepTime(200, (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -103,7 +103,7 @@ public static class ThreadsFunctions ReadPowerOnTimes++; // Wait - Thread.Sleep(400); + Thread.Sleep(CalcSleepTime(400, (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -160,7 +160,7 @@ public static class ThreadsFunctions ReadProcPPTimes++; // Wait - Thread.Sleep(200); + Thread.Sleep(CalcSleepTime(200, (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -205,7 +205,7 @@ public static class ThreadsFunctions ReadFunctionTimes++; // Wait - Thread.Sleep(200); + Thread.Sleep(CalcSleepTime(200, (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -295,7 +295,7 @@ public static class ThreadsFunctions ReadUserSoftKeysTimes++; // Wait - Thread.Sleep(200); + Thread.Sleep(CalcSleepTime(200, (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -304,51 +304,6 @@ public static class ThreadsFunctions } } - //public static void ReadNcSoftKeysData() - //{ - // NcHandler ncHandler = new NcHandler(); - // Stopwatch sw = new Stopwatch(); - - // try - // { - // // Try connection - // CmsError libraryError = ncHandler.Connect(); - // if (libraryError.errorCode != 0) - // ManageLibraryError(libraryError); - - // while (true) - // { - // sw.Restart(); - - // if (ncHandler.numericalControl.NC_IsConnected()) - // { - // // Get softkey data from config and PLC - // libraryError = ncHandler.GetNcSoftKeys(out List ncSoftKeys); - // if (libraryError.errorCode != 0) - // ManageLibraryError(libraryError); - // else - // // Send through signalR - // MessageServices.Current.Publish(SEND_NC_SOFTKEYS_DATA, null, ncSoftKeys); - // } - // else - // TryNcConnection(); - - // sw.Stop(); - - // // Update thread timer - // ReadUserSoftKeysTimer += sw.ElapsedMilliseconds; - // ReadUserSoftKeysTimes++; - - // // Wait - // Thread.Sleep(200); - // } - // } - // catch (ThreadAbortException) - // { - // ncHandler.Dispose(); - // } - //} - public static void ReadHeadsData() { NcHandler ncHandler = new NcHandler(); @@ -385,7 +340,7 @@ public static class ThreadsFunctions ReadHeadsTimes++; // Wait - Thread.Sleep(500); + Thread.Sleep(CalcSleepTime(500, (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -430,7 +385,7 @@ public static class ThreadsFunctions ReadAxesNamesTimes++; // Wait - Thread.Sleep(800); + Thread.Sleep(CalcSleepTime(800, (int)sw.ElapsedMilliseconds)); } } catch (ThreadAbortException) @@ -598,12 +553,6 @@ public static class ThreadsFunctions ReadAxesNamesTimer = 0; ReadAxesNamesTimes = 0; } - //if (ThreadsHandler.RunningThreadStatus.ContainsKey("ReadNcSoftKeysData") && ReadNcSoftKeysTimes != 0) - //{ - // ThreadsHandler.RunningThreadStatus["ReadNcSoftKeysData"] = (ReadNcSoftKeysTimer / ReadNcSoftKeysTimes) + " mS"; - // ReadNcSoftKeysTimer = 0; - // ReadNcSoftKeysTimes = 0; - //} MessageServices.Current.Publish(SEND_THREADS_STATUS, null, ThreadsHandler.RunningThreadStatus); @@ -629,5 +578,66 @@ public static class ThreadsFunctions ReadAxesNamesTimes = 0; } + private static int CalcSleepTime(int maxSleep, int execTime) + { + int sleep = 0; + // Check if the execution time is greater than the half of the max sleep time + if ( maxSleep - execTime < maxSleep / 2 ) + { + sleep = maxSleep; + } + else + { + sleep = maxSleep - execTime; + } + + return sleep; + } #endregion SupportFunctions -} \ No newline at end of file +} + + +//public static void ReadNcSoftKeysData() +//{ +// NcHandler ncHandler = new NcHandler(); +// Stopwatch sw = new Stopwatch(); + +// try +// { +// // Try connection +// CmsError libraryError = ncHandler.Connect(); +// if (libraryError.errorCode != 0) +// ManageLibraryError(libraryError); + +// while (true) +// { +// sw.Restart(); + +// if (ncHandler.numericalControl.NC_IsConnected()) +// { +// // Get softkey data from config and PLC +// libraryError = ncHandler.GetNcSoftKeys(out List ncSoftKeys); +// if (libraryError.errorCode != 0) +// ManageLibraryError(libraryError); +// else +// // Send through signalR +// MessageServices.Current.Publish(SEND_NC_SOFTKEYS_DATA, null, ncSoftKeys); +// } +// else +// TryNcConnection(); + +// sw.Stop(); + +// // Update thread timer +// ReadUserSoftKeysTimer += sw.ElapsedMilliseconds; +// ReadUserSoftKeysTimes++; + +// // Wait +// Thread.Sleep(200); +// } +// } +// catch (ThreadAbortException) +// { +// ncHandler.Dispose(); +// } +//} \ No newline at end of file diff --git a/Step.Core/ThreadsSiemensHmi.cs b/Step.Core/ThreadsSiemensHmi.cs index 8ceef799..8b75a737 100644 --- a/Step.Core/ThreadsSiemensHmi.cs +++ b/Step.Core/ThreadsSiemensHmi.cs @@ -50,14 +50,13 @@ namespace Step.Core // Wait until the process is started TriedTimes = 1; - while ((processes[0].MainWindowHandle == IntPtr.Zero || !processes[0].MainWindowTitle.Contains("SINUMERIK Operate - Window Mode")) && TriedTimes < TimesToTryKill) + while ((processes[0].MainWindowHandle == IntPtr.Zero || (!processes[0].MainWindowTitle.Contains("Sinumerik HMI") && !processes[0].MainWindowTitle.Contains("SINUMERIK Operate - Window Mode"))) && TriedTimes < TimesToTryKill) { processes = Process.GetProcessesByName(ProcessName); if (processes[0].MainWindowHandle == IntPtr.Zero) - { Thread.Sleep(WaitingMs); - TriedTimes++; - } + + TriedTimes++; } // Kill the process if needed