Read updated tool life and status
This commit is contained in:
Lucio Maranta
2018-07-24 17:27:11 +02:00
parent a0630adf43
commit 9a961a8a7b
5 changed files with 118 additions and 56 deletions
+43
View File
@@ -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