Merge branch 'feature/Osai_ToolTable' into develop
# Conflicts: # Libs/CMS_CORE_Library.dll # Step.Core/ThreadsFunctions.cs # Step.Core/ThreadsHandler.cs # Step.Database/DatabaseContext.cs # Step.Database/Migrations/201806220920193_InitMigration.Designer.cs # Step.Database/Migrations/201806220920193_InitMigration.cs # Step.Database/Migrations/201807120908403_InitMigration.Designer.cs # Step.Database/Migrations/201807120908403_InitMigration.cs # Step.Database/Migrations/201807120908403_InitMigration.resx # Step.Database/Migrations/201807251330036_InitMigration.Designer.cs # Step.Database/Migrations/201807251330036_InitMigration.cs # Step.Database/Step.Database.csproj # Step.Model/Constants.cs # Step.NC/NcHandler.cs # Step/Listeners/ListenersHandler.cs # Step/Step.csproj
This commit is contained in:
@@ -22,6 +22,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;
|
||||
|
||||
@@ -505,6 +506,7 @@ public static class ThreadsFunctions
|
||||
{
|
||||
// Get Data from config and PLC
|
||||
libraryError = ncHandler.GetActiveProgramInfo(out DTOActiveProgramDataModel active);
|
||||
|
||||
if (libraryError.errorCode != 0)
|
||||
ManageLibraryError(libraryError);
|
||||
else
|
||||
@@ -530,7 +532,53 @@ public static class ThreadsFunctions
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Nc threads
|
||||
public static void UpdateToolsData()
|
||||
{
|
||||
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();
|
||||
|
||||
// Check if client is connected
|
||||
if (ncHandler.numericalControl.NC_IsConnected())
|
||||
{
|
||||
// Get new data from PLC
|
||||
libraryError = ncHandler.GetUpdatedToolsData(out Dictionary<int, byte> updatedStatus, out Dictionary<int, uint> updatedLives);
|
||||
MessageServices.Current.Publish(UPDATE_TOOLS_DATA, null,
|
||||
new DTONewToolDataModel
|
||||
{
|
||||
UpdatedStatus = updatedStatus,
|
||||
UpdatedLives = updatedLives
|
||||
});
|
||||
}
|
||||
else
|
||||
TryNcConnection();
|
||||
sw.Stop();
|
||||
|
||||
//Update thread timer
|
||||
ReadToolDataTimer += sw.ElapsedMilliseconds;
|
||||
ReadToolDataTimes++;
|
||||
|
||||
// Wait
|
||||
Thread.Sleep(CalcSleepTime(1000, (int)sw.ElapsedMilliseconds));
|
||||
}
|
||||
}
|
||||
catch (ThreadAbortException)
|
||||
{
|
||||
ncHandler.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Nc functions threads
|
||||
|
||||
#region SupportFunctions
|
||||
|
||||
@@ -689,6 +737,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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user