Added axes names and selected axis

This commit is contained in:
Lucio Maranta
2018-03-20 17:02:59 +01:00
parent e9110db28b
commit 696aa24341
11 changed files with 241 additions and 62 deletions
+121 -48
View File
@@ -19,7 +19,8 @@ public static class ThreadsFunctions
private static long ReadFunctionTimer = 0, ReadFunctionTimes = 0;
private static long ReadMaintenanceTimer = 0, ReadMaintenanceTimes = 0;
private static long ReadUserSoftKeysTimer = 0, ReadUserSoftKeysTimes = 0;
private static long ReadNcSoftKeysTimer = 0, ReadNcSoftKeysTimes = 0;
private static long ReadAxesNamesTimer = 0, ReadAxesNamesTimes = 0;
private static long ReadHeadsTimer = 0, ReadHeadsTimes = 0;
private static Thread ConnThread;
@@ -135,8 +136,19 @@ public static class ThreadsFunctions
if (libraryError.errorCode != 0)
ManageLibraryError(libraryError);
else
// Send through signalR
MessageServices.Current.Publish(SEND_PROCESSES_DATA, null, processesPPData);
{
// Get softkey data from config and PLC
libraryError = ncHandler.GetNcSoftKeys(out List<DTONcSoftKeyModel> ncSoftKeys);
if (libraryError.errorCode != 0)
ManageLibraryError(libraryError);
else
{
// Send processes through signalR
MessageServices.Current.Publish(SEND_PROCESSES_DATA, null, processesPPData);
// Send ncSoftKeys through signalR
MessageServices.Current.Publish(SEND_NC_SOFTKEYS_DATA, null, ncSoftKeys);
}
}
}
else
TryNcConnection();
@@ -292,50 +304,50 @@ public static class ThreadsFunctions
}
}
public static void ReadNcSoftKeysData()
{
NcHandler ncHandler = new NcHandler();
Stopwatch sw = new Stopwatch();
//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);
// try
// {
// // Try connection
// CmsError libraryError = ncHandler.Connect();
// if (libraryError.errorCode != 0)
// ManageLibraryError(libraryError);
while (true)
{
sw.Restart();
// 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();
// 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();
// sw.Stop();
// Update thread timer
ReadUserSoftKeysTimer += sw.ElapsedMilliseconds;
ReadUserSoftKeysTimes++;
// // Update thread timer
// ReadUserSoftKeysTimer += sw.ElapsedMilliseconds;
// ReadUserSoftKeysTimes++;
// Wait
Thread.Sleep(200);
}
}
catch (ThreadAbortException)
{
ncHandler.Dispose();
}
}
// // Wait
// Thread.Sleep(200);
// }
// }
// catch (ThreadAbortException)
// {
// ncHandler.Dispose();
// }
//}
public static void ReadHeadsData()
{
@@ -367,10 +379,10 @@ public static class ThreadsFunctions
TryNcConnection();
sw.Stop();
//Update thread timer
ReadNcSoftKeysTimer += sw.ElapsedMilliseconds;
ReadNcSoftKeysTimes++;
ReadHeadsTimer += sw.ElapsedMilliseconds;
ReadHeadsTimes++;
// Wait
Thread.Sleep(500);
@@ -382,6 +394,51 @@ public static class ThreadsFunctions
}
}
public static void ReadAxesNamesData()
{
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.ReadAxisData(out List<DTOAxisNameModel> axes);
if (libraryError.errorCode != 0)
ManageLibraryError(libraryError);
else
// Send through signalR
MessageServices.Current.Publish(SEND_AXIS_NAMES_DATA, null, axes);
}
else
TryNcConnection();
sw.Stop();
//Update thread timer
ReadAxesNamesTimer += sw.ElapsedMilliseconds;
ReadAxesNamesTimes++;
// Wait
Thread.Sleep(800);
}
}
catch (ThreadAbortException)
{
ncHandler.Dispose();
}
}
#endregion Nc Threads
#region SupportFunctions
@@ -529,12 +586,24 @@ public static class ThreadsFunctions
ReadUserSoftKeysTimer = 0;
ReadUserSoftKeysTimes = 0;
}
if (ThreadsHandler.RunningThreadStatus.ContainsKey("ReadNcSoftKeysData") && ReadNcSoftKeysTimes != 0)
if (ThreadsHandler.RunningThreadStatus.ContainsKey("ReadHeadsData") && ReadHeadsTimes != 0)
{
ThreadsHandler.RunningThreadStatus["ReadNcSoftKeysData"] = (ReadNcSoftKeysTimer / ReadNcSoftKeysTimes) + " mS";
ReadNcSoftKeysTimer = 0;
ReadNcSoftKeysTimes = 0;
ThreadsHandler.RunningThreadStatus["ReadHeadsData"] = (ReadHeadsTimer / ReadHeadsTimes) + " mS";
ReadHeadsTimer = 0;
ReadHeadsTimes = 0;
}
if (ThreadsHandler.RunningThreadStatus.ContainsKey("ReadAxesNamesData") && ReadAxesNamesTimer != 0)
{
ThreadsHandler.RunningThreadStatus["ReadAxesNamesData"] = (ReadAxesNamesTimer / ReadAxesNamesTimes) + " mS";
ReadAxesNamesTimer = 0;
ReadAxesNamesTimes = 0;
}
//if (ThreadsHandler.RunningThreadStatus.ContainsKey("ReadNcSoftKeysData") && ReadNcSoftKeysTimes != 0)
//{
// ThreadsHandler.RunningThreadStatus["ReadNcSoftKeysData"] = (ReadNcSoftKeysTimer / ReadNcSoftKeysTimes) + " mS";
// ReadNcSoftKeysTimer = 0;
// ReadNcSoftKeysTimes = 0;
//}
MessageServices.Current.Publish(SEND_THREADS_STATUS, null, ThreadsHandler.RunningThreadStatus);
@@ -554,6 +623,10 @@ public static class ThreadsFunctions
ReadFunctionTimes = 0;
ReadMaintenanceTimer = 0;
ReadMaintenanceTimes = 0;
ReadHeadsTimer = 0;
ReadHeadsTimes = 0;
ReadAxesNamesTimer = 0;
ReadAxesNamesTimes = 0;
}
#endregion SupportFunctions