WIP
Read updated tool life and status
This commit is contained in:
@@ -480,6 +480,49 @@ public static class ThreadsFunctions
|
||||
ncHandler.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateToolsData()
|
||||
{
|
||||
NcHandler ncHandler = new NcHandler();
|
||||
Stopwatch sw = new Stopwatch();
|
||||
|
||||
try
|
||||
{
|
||||
CmsError libraryError = ncHandler.Connect();
|
||||
if (libraryError.errorCode != 0)
|
||||
ManageLibraryError(libraryError);
|
||||
|
||||
while (true)
|
||||
{
|
||||
sw.Restart();
|
||||
// Check if client is connected
|
||||
if (ncHandler.numericalControl.NC_IsConnected())
|
||||
{
|
||||
// Get new data from PLC
|
||||
libraryError = ncHandler.GetNcAlarms(out DTOAlarmsModel alarms);
|
||||
if (libraryError.errorCode != 0)
|
||||
ManageLibraryError(libraryError);
|
||||
else
|
||||
// Send through signalR
|
||||
MessageServices.Current.Publish(UPDATE_TOOLS_DATA, null, alarms);
|
||||
}
|
||||
else
|
||||
TryNcConnection();
|
||||
sw.Stop();
|
||||
|
||||
//Update thread timer
|
||||
ReadAlarmsTimer += sw.ElapsedMilliseconds;
|
||||
ReadAlarmsTimes++;
|
||||
|
||||
// Wait
|
||||
Thread.Sleep(CalcSleepTime(200, (int)sw.ElapsedMilliseconds));
|
||||
}
|
||||
}
|
||||
catch (ThreadAbortException)
|
||||
{
|
||||
ncHandler.Dispose();
|
||||
}
|
||||
}
|
||||
#endregion Nc threads
|
||||
|
||||
#region SupportFunctions
|
||||
|
||||
Reference in New Issue
Block a user