Fix siemens hmi managing
Added siemens library
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<Client>
|
||||
<TranspColor>#FF00FF</TranspColor>
|
||||
<RenderingMethod>GPU</RenderingMethod> <!-- GPU/CPU -->
|
||||
<ShowVirtualKeyboard>true</ShowVirtualKeyboard>
|
||||
<ShowVirtualKeyboard>false</ShowVirtualKeyboard>
|
||||
<RunningOnSecondaryScreen>false</RunningOnSecondaryScreen>
|
||||
<DeveloperMode>true</DeveloperMode>
|
||||
</Client>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Binary file not shown.
@@ -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<DTONcSoftKeyModel> 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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//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<DTONcSoftKeyModel> 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();
|
||||
// }
|
||||
//}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user