Update metodi preliminari signal-r

This commit is contained in:
Samuele Locatelli
2020-05-19 16:23:10 +02:00
parent 63b09c1dfb
commit 95484c7ee7
11 changed files with 226 additions and 39 deletions
+52 -4
View File
@@ -377,6 +377,7 @@ public static class ThreadsFunctions
}
}
#if false
public static void ReadHeadsData()
{
NcAdapter ncAdapter = new NcAdapter();
@@ -419,7 +420,8 @@ public static class ThreadsFunctions
{
ncAdapter.Dispose();
}
}
}
#endif
public static void ReadAxesNamesData()
{
@@ -509,6 +511,7 @@ public static class ThreadsFunctions
}
}
#if false
public static void ReadActiveProgramData()
{
NcFileAdapter ncAdapter = new NcFileAdapter();
@@ -552,8 +555,10 @@ public static class ThreadsFunctions
{
ncAdapter.Dispose();
}
}
}
#endif
#if false
public static void ReadPartProgramQueueData()
{
NcFileAdapter ncAdapter = new NcFileAdapter();
@@ -599,7 +604,8 @@ public static class ThreadsFunctions
{
ncAdapter.Dispose();
}
}
}
#endif
public static void ReadScadaData()
{
@@ -645,7 +651,49 @@ public static class ThreadsFunctions
ncAdapter.Dispose();
}
}
public static void ReadGaugeData()
{
NcAdapter ncAdapter = new NcAdapter();
Stopwatch sw = new Stopwatch();
try
{
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
ManageLibraryError(libraryError);
while (true)
{
sw.Restart();
// Check if client is connected
if (ncAdapter.numericalControl.NC_IsConnected())
{
// Get new data from PLC
libraryError = ncAdapter.ReadGaugeData(out ThermoModels.GaugeModel gaugeData);
if (libraryError.IsError())
ManageLibraryError(libraryError);
MessageServices.Current.Publish(SEND_THERMO_GAUGE_DATA, null, gaugeData);
}
else
RestoreConnection();
sw.Stop();
//Update thread timer
UpdateStat(MethodBase.GetCurrentMethod().Name, sw.ElapsedMilliseconds);
// Wait
Thread.Sleep(CalcSleepTime(500, (int)sw.ElapsedMilliseconds));
}
}
catch (ThreadAbortException)
{
ncAdapter.Dispose();
}
}
public static void ReadRecipeData()
{
NcAdapter ncAdapter = new NcAdapter();
@@ -687,7 +735,7 @@ public static class ThreadsFunctions
// Update thread timer
UpdateStat(MethodBase.GetCurrentMethod().Name, sw.ElapsedMilliseconds);
// Wait
Thread.Sleep(CalcSleepTime(500, (int)sw.ElapsedMilliseconds));
Thread.Sleep(CalcSleepTime(250, (int)sw.ElapsedMilliseconds));
}
}
catch (ThreadAbortException)