First softkey implementation
Added config and API Added Thread and signal
This commit is contained in:
@@ -18,7 +18,8 @@ public static class ThreadsFunctions
|
||||
private static long ReadProcPPTimer = 0, ReadProcPPTimes = 0;
|
||||
private static long ReadFunctionTimer = 0, ReadFunctionTimes = 0;
|
||||
private static long ReadMaintenanceTimer = 0, ReadMaintenanceTimes = 0;
|
||||
|
||||
private static long ReadSoftKeysTimer = 0, ReadSoftKeysTimes = 0;
|
||||
|
||||
private static Thread ConnThread;
|
||||
|
||||
#region Nc Threads
|
||||
@@ -242,6 +243,50 @@ public static class ThreadsFunctions
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReadSoftKeysData()
|
||||
{
|
||||
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 Data from database and PLC
|
||||
libraryError = ncHandler.GetSoftKeys(out List<DTOSoftKeyModel> softKeys);
|
||||
if (libraryError.errorCode != 0)
|
||||
ManageLibraryError(libraryError);
|
||||
else
|
||||
// Send through signalR
|
||||
MessageServices.Current.Publish(SEND_SOFT_KEYS_DATA, null, softKeys);
|
||||
}
|
||||
else
|
||||
TryNcConnection();
|
||||
|
||||
sw.Stop();
|
||||
//Send to the UI the time
|
||||
ReadSoftKeysTimer += sw.ElapsedMilliseconds;
|
||||
ReadSoftKeysTimes++;
|
||||
|
||||
// Wait
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
}
|
||||
catch (ThreadAbortException)
|
||||
{
|
||||
ncHandler.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Nc Threads
|
||||
|
||||
#region SupportFunctions
|
||||
@@ -383,7 +428,12 @@ public static class ThreadsFunctions
|
||||
ReadMaintenanceTimer = 0;
|
||||
ReadMaintenanceTimes = 0;
|
||||
}
|
||||
|
||||
if (ThreadsHandler.RunningThreadStatus.ContainsKey("ReadSoftKeysData") && ReadSoftKeysTimes != 0)
|
||||
{
|
||||
ThreadsHandler.RunningThreadStatus["ReadSoftKeysData"] = (ReadSoftKeysTimer / ReadSoftKeysTimes) + " mS";
|
||||
ReadSoftKeysTimer = 0;
|
||||
ReadSoftKeysTimes = 0;
|
||||
}
|
||||
|
||||
MessageServices.Current.Publish(SEND_THREADS_STATUS, null, ThreadsHandler.RunningThreadStatus);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user