Added method for Prod Info & Cycle data read

This commit is contained in:
Samuele Locatelli
2020-06-08 22:30:37 +02:00
parent 31519c303b
commit bdc0ce1aa5
6 changed files with 119 additions and 9 deletions
+88
View File
@@ -694,6 +694,94 @@ public static class ThreadsFunctions
ncAdapter.Dispose();
}
}
public static void ReadProdInfoData()
{
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.ReadProdInfoData(out ThermoModels.ProdInfoModel prodInfoData);
if (libraryError.IsError())
ManageLibraryError(libraryError);
MessageServices.Current.Publish(SEND_THERMO_PROD_INFO_DATA, null, prodInfoData);
}
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 ReadProdCycleData()
{
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())
{
#if false
// Get new data from PLC
libraryError = ncAdapter.ReadProdCycle(out ThermoModels.GaugeModel gaugeData);
if (libraryError.IsError())
ManageLibraryError(libraryError);
MessageServices.Current.Publish(SEND_THERMO_GAUGE_DATA, null, gaugeData);
#endif
}
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();
+5 -3
View File
@@ -14,19 +14,21 @@ namespace Thermo.Active.Core
ThreadsFunctions.ReadAlarms,
ThreadsFunctions.ReadPowerOnData,
ThreadsFunctions.StatThread,
ThreadsFunctions.ReadProcessesPPStatus,
//ThreadsFunctions.ReadProcessesPPStatus,
ThreadsFunctions.ReadEnabledFunctionality,
ThreadsFunctions.ReadExpiredMaintenances,
ThreadsFunctions.ReadAxesPositionsData,
//ThreadsFunctions.ReadAxesPositionsData,
ThreadsFunctions.ReadUserSoftKeysData,
//ThreadsFunctions.ReadHeadsData,
ThreadsFunctions.ReadAxesNamesData,
//ThreadsFunctions.ReadAxesNamesData,
//ThreadsFunctions.ReadActiveProgramData,
//ThreadsFunctions.ReadPartProgramQueueData,
ThreadsFunctions.ReadScadaData,
ThreadsFunctions.ReadM154Data, // levare?
// ThreadsFunctions.ReadNcSoftKeysData,
ThreadsFunctions.ReadGaugeData,
ThreadsFunctions.ReadProdInfoData,
ThreadsFunctions.ReadProdCycleData,
ThreadsFunctions.ReadRecipeData,
ThreadsFunctions.ReadWarmersData,
ThreadsFunctions.ReadModulesData
+2
View File
@@ -299,6 +299,8 @@ namespace Thermo.Active.Model
public const string SEND_THERMO_MODULE_DATA = "SEND_THERMO_MODULE_DATA";
public const string SEND_THERMO_WARMERS_DATA = "SEND_THERMO_WARMERS_DATA";
public const string SEND_THERMO_GAUGE_DATA = "SEND_THERMO_GAUGE_DATA";
public const string SEND_THERMO_PROD_INFO_DATA = "SEND_THERMO_PROD_INFO_DATA";
public const string SEND_THERMO_PROD_CYCLE_DATA = "SEND_THERMO_PROD_CYCLE_DATA";
public const string BROADCAST_DATA = "BROADCAST_DATA";
+14
View File
@@ -1063,6 +1063,20 @@ namespace Thermo.Active.NC
return cmsError;
}
public CmsError ReadProdInfoData(out ThermoModels.ProdInfoModel prodInfoData)
{
prodInfoData = new ThermoModels.ProdInfoModel();
CmsError cmsError = numericalControl.PLC_RProdInfo(ref prodInfoData);
return cmsError;
}
public CmsError ReadProdCycleData(out ThermoModels.ProdCycleModel prodCycleData)
{
prodCycleData = new ThermoModels.ProdCycleModel();
CmsError cmsError = numericalControl.PLC_RProdCycle(ref prodCycleData);
return cmsError;
}
/// <summary>
/// Vero metodo lettura ricetta da 2 aree memoria PLC
/// </summary>
+8 -4
View File
@@ -113,10 +113,14 @@ namespace Thermo.Active.Listeners
{
SignalRListener.SendThermoGaugeData(a);
}));
// FIXME TODO ADD ProdCycle
// FIXME TODO ADD ProdInfo
infos.Add(MessageServices.Current.Subscribe(SEND_THERMO_PROD_INFO_DATA, (a, b) =>
{
SignalRListener.SendThermoProdInfoData(a);
}));
infos.Add(MessageServices.Current.Subscribe(SEND_THERMO_PROD_CYCLE_DATA, (a, b) =>
{
SignalRListener.SendThermoProdCycleData(a);
}));
// Broadcast
infos.Add(MessageServices.Current.Subscribe(BROADCAST_DATA, (a, b) =>
@@ -359,7 +359,7 @@ namespace Thermo.Active.Listeners.SignalR
context.Clients.Group("ncData").gaugeData(currGauge);
}
}
public static void SendProdInfoData(object prodInfoData)
public static void SendThermoProdInfoData(object prodInfoData)
{
ProdInfoModel currProdInfo = prodInfoData as ProdInfoModel;
@@ -371,7 +371,7 @@ namespace Thermo.Active.Listeners.SignalR
context.Clients.Group("ncData").prodInfoData(currProdInfo);
}
}
public static void SendProdCycleData(object prodCycleData)
public static void SendThermoProdCycleData(object prodCycleData)
{
ProdCycleModel currProdCycle = prodCycleData as ProdCycleModel;