Added 8 bit status

Added update tool status & life thread/signalR
This commit is contained in:
Lucio Maranta
2018-07-25 17:47:33 +02:00
parent 9a961a8a7b
commit 746ff140c5
17 changed files with 326 additions and 184 deletions
+17 -5
View File
@@ -23,6 +23,7 @@ public static class ThreadsFunctions
private static long ReadUserSoftKeysTimer = 0, ReadUserSoftKeysTimes = 0;
private static long ReadAxesNamesTimer = 0, ReadAxesNamesTimes = 0;
private static long ReadHeadsTimer = 0, ReadHeadsTimes = 0;
private static long ReadToolDataTimer = 0, ReadToolDataTimes = 0;
private static Thread ConnThread;
@@ -499,23 +500,28 @@ public static class ThreadsFunctions
if (ncHandler.numericalControl.NC_IsConnected())
{
// Get new data from PLC
libraryError = ncHandler.GetNcAlarms(out DTOAlarmsModel alarms);
libraryError = ncHandler.GetUpdatedToolsData(out Dictionary<int, byte> updatedStatus, out Dictionary<int, uint> updatedLives);
if (libraryError.errorCode != 0)
ManageLibraryError(libraryError);
else
// Send through signalR
MessageServices.Current.Publish(UPDATE_TOOLS_DATA, null, alarms);
MessageServices.Current.Publish(UPDATE_TOOLS_DATA, null,
new DTONewToolDataModel
{
UpdatedStatus = updatedStatus,
UpdatedLives = updatedLives
});
}
else
TryNcConnection();
sw.Stop();
//Update thread timer
ReadAlarmsTimer += sw.ElapsedMilliseconds;
ReadAlarmsTimes++;
ReadToolDataTimer += sw.ElapsedMilliseconds;
ReadToolDataTimes++;
// Wait
Thread.Sleep(CalcSleepTime(200, (int)sw.ElapsedMilliseconds));
Thread.Sleep(CalcSleepTime(1000, (int)sw.ElapsedMilliseconds));
}
}
catch (ThreadAbortException)
@@ -682,6 +688,12 @@ public static class ThreadsFunctions
ReadAxesNamesTimer = 0;
ReadAxesNamesTimes = 0;
}
if (ThreadsHandler.RunningThreadStatus.ContainsKey("UpdateToolsData") && ReadAxesNamesTimer != 0)
{
ThreadsHandler.RunningThreadStatus["UpdateToolsData"] = (ReadToolDataTimer / ReadToolDataTimes) + " mS";
ReadToolDataTimer = 0;
ReadToolDataTimes = 0;
}
MessageServices.Current.Publish(SEND_THREADS_STATUS, null, ThreadsHandler.RunningThreadStatus);