Added magazine action SignalR thread
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Step.Core;
|
||||
using Step.Model.DTOModels;
|
||||
using Step.Model.DTOModels.ToolModels;
|
||||
using Step.NC;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -24,7 +25,7 @@ public static class ThreadsFunctions
|
||||
|
||||
private static Thread ConnThread;
|
||||
|
||||
#region Nc Threads
|
||||
#region Nc functions threads
|
||||
|
||||
public static void ReadAlarms()
|
||||
{
|
||||
@@ -394,7 +395,51 @@ public static class ThreadsFunctions
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Nc Threads
|
||||
public static void ReadMagazinesStatus()
|
||||
{
|
||||
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 config and PLC
|
||||
libraryError = ncHandler.GetMagazineStatus(out DTOMagazineActionModel magazineStatus);
|
||||
if (libraryError.errorCode != 0)
|
||||
ManageLibraryError(libraryError);
|
||||
else
|
||||
// Send through signalR
|
||||
MessageServices.Current.Publish(SEND_MAGAZINES_STATUS, null, magazineStatus);
|
||||
}
|
||||
else
|
||||
TryNcConnection();
|
||||
|
||||
sw.Stop();
|
||||
|
||||
//Update thread timer
|
||||
ReadAxesNamesTimer += sw.ElapsedMilliseconds;
|
||||
ReadAxesNamesTimes++;
|
||||
|
||||
// Wait
|
||||
Thread.Sleep(CalcSleepTime(200, (int)sw.ElapsedMilliseconds));
|
||||
}
|
||||
}
|
||||
catch (ThreadAbortException)
|
||||
{
|
||||
ncHandler.Dispose();
|
||||
}
|
||||
}
|
||||
#endregion Nc threads
|
||||
|
||||
#region SupportFunctions
|
||||
|
||||
@@ -582,7 +627,7 @@ public static class ThreadsFunctions
|
||||
{
|
||||
int sleep = 0;
|
||||
// Check if the execution time is greater than the half of the max sleep time
|
||||
if ( maxSleep - execTime < maxSleep / 2 )
|
||||
if (maxSleep - execTime < maxSleep / 2)
|
||||
{
|
||||
sleep = maxSleep;
|
||||
}
|
||||
@@ -593,51 +638,6 @@ public static class ThreadsFunctions
|
||||
|
||||
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();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user