gestione semafori x Reciper + Warmers
This commit is contained in:
@@ -1479,39 +1479,46 @@ public static class ThreadsFunctions
|
||||
// Check if client is connected
|
||||
if (ncAdapter.numericalControl.NC_IsConnected())
|
||||
{
|
||||
// Get new data from PLC
|
||||
libraryError = ncAdapter.ReadRecipeData(onlyRt, false, out Dictionary<string, DTORecipeParam> currRecipe);
|
||||
if (libraryError.IsError())
|
||||
ManageLibraryError(libraryError);
|
||||
|
||||
MessageServices.Current.Publish(SEND_THERMO_RECIPE_FULL, null, currRecipe);
|
||||
|
||||
// ora gestisco la overview!
|
||||
libraryError = ncAdapter.GetRecipeOverview(out Dictionary<RecipeSection, RecipeCatStatus> currOverview);
|
||||
if (libraryError.IsError())
|
||||
ManageLibraryError(libraryError);
|
||||
|
||||
MessageServices.Current.Publish(SEND_THERMO_RECIPE_OVERWIEW, null, currOverview);
|
||||
|
||||
// ora gestisco la lettura della overview di "modificata
|
||||
DTORecipeStatus message = new DTORecipeStatus()
|
||||
// controllo su redis che NON sia bloccata lettura ricetta..
|
||||
if (!RedisController.getRecipeReadSem)
|
||||
{
|
||||
recipeName = NcAdapter.RecipeLiveData.RecipeName,
|
||||
hasChanged = NcAdapter.RecipeLiveData.hasChanged
|
||||
};
|
||||
// Get new data from PLC
|
||||
libraryError = ncAdapter.ReadRecipeData(onlyRt, false, out Dictionary<string, DTORecipeParam> currRecipe);
|
||||
if (libraryError.IsError())
|
||||
ManageLibraryError(libraryError);
|
||||
|
||||
MessageServices.Current.Publish(SEND_THERMO_RECIPE_CHANGED, null, message);
|
||||
MessageServices.Current.Publish(SEND_THERMO_RECIPE_FULL, null, currRecipe);
|
||||
|
||||
// verifico se dal PLC è segnalato che i setpointHMI sono invalidati, nel qual caso INVIO
|
||||
bool setpointHmiInvalidated = false;
|
||||
libraryError = ncAdapter.checkSetpointInvalidated(out setpointHmiInvalidated);
|
||||
if (setpointHmiInvalidated)
|
||||
{
|
||||
// ora gestisco l'ack della richiesta
|
||||
libraryError = ncAdapter.doAckSetpointInvalidated();
|
||||
// ora gestisco la overview!
|
||||
libraryError = ncAdapter.GetRecipeOverview(out Dictionary<RecipeSection, RecipeCatStatus> currOverview);
|
||||
if (libraryError.IsError())
|
||||
ManageLibraryError(libraryError);
|
||||
|
||||
MessageServices.Current.Publish(SEND_THERMO_RECIPE_OVERWIEW, null, currOverview);
|
||||
|
||||
// ora gestisco la lettura della overview di "modificata
|
||||
DTORecipeStatus message = new DTORecipeStatus()
|
||||
{
|
||||
recipeName = NcAdapter.RecipeLiveData.RecipeName,
|
||||
hasChanged = NcAdapter.RecipeLiveData.hasChanged
|
||||
};
|
||||
|
||||
MessageServices.Current.Publish(SEND_THERMO_RECIPE_CHANGED, null, message);
|
||||
|
||||
// verifico se dal PLC è segnalato che i setpointHMI sono invalidati, nel qual caso INVIO
|
||||
bool setpointHmiInvalidated = false;
|
||||
libraryError = ncAdapter.checkSetpointInvalidated(out setpointHmiInvalidated);
|
||||
if (setpointHmiInvalidated)
|
||||
{
|
||||
// ora gestisco l'ack della richiesta
|
||||
libraryError = ncAdapter.doAckSetpointInvalidated();
|
||||
}
|
||||
// pubblico booleana dei setpointHMI invalidati
|
||||
MessageServices.Current.Publish(SEND_THERMO_RECIPE_SETPOINTHMI_CHANGED, null, setpointHmiInvalidated);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
// pubblico booleana dei setpointHMI invalidati
|
||||
MessageServices.Current.Publish(SEND_THERMO_RECIPE_SETPOINTHMI_CHANGED, null, setpointHmiInvalidated);
|
||||
}
|
||||
else
|
||||
RestoreConnection();
|
||||
@@ -1646,33 +1653,38 @@ public static class ThreadsFunctions
|
||||
bool useCache = false;
|
||||
while (true)
|
||||
{
|
||||
sw.Restart();
|
||||
|
||||
// Check if client is connected
|
||||
if (ncAdapter.numericalControl.NC_IsConnected())
|
||||
// controllo su redis che NON sia bloccata lettura ricetta..
|
||||
if (!RedisController.getWarmersReadSem)
|
||||
{
|
||||
if (cacheWarmers)
|
||||
sw.Restart();
|
||||
|
||||
// Check if client is connected
|
||||
if (ncAdapter.numericalControl.NC_IsConnected())
|
||||
{
|
||||
// every 10 reads all data...
|
||||
useCache = (readCount != 0);
|
||||
readCount++;
|
||||
// ciclo resettato ogni 20
|
||||
readCount = readCount % 20;
|
||||
if (cacheWarmers)
|
||||
{
|
||||
// every 10 reads all data...
|
||||
useCache = (readCount != 0);
|
||||
readCount++;
|
||||
// ciclo resettato ogni 20
|
||||
readCount = readCount % 20;
|
||||
}
|
||||
// Get new data from PLC
|
||||
libraryError = ncAdapter.ReadWarmers(useCache, out Dictionary<int, DTOWarmers> currWarmers);
|
||||
if (libraryError.IsError())
|
||||
ManageLibraryError(libraryError);
|
||||
// pubblico
|
||||
MessageServices.Current.Publish(SEND_THERMO_WARMERS_DATA, null, currWarmers);
|
||||
}
|
||||
// Get new data from PLC
|
||||
libraryError = ncAdapter.ReadWarmers(useCache, out Dictionary<int, DTOWarmers> currWarmers);
|
||||
if (libraryError.IsError())
|
||||
ManageLibraryError(libraryError);
|
||||
// pubblico
|
||||
MessageServices.Current.Publish(SEND_THERMO_WARMERS_DATA, null, currWarmers);
|
||||
else
|
||||
RestoreConnection();
|
||||
|
||||
sw.Stop();
|
||||
|
||||
// Update thread timer
|
||||
UpdateStat(MethodBase.GetCurrentMethod().Name, sw.ElapsedMilliseconds);
|
||||
}
|
||||
else
|
||||
RestoreConnection();
|
||||
|
||||
sw.Stop();
|
||||
|
||||
// Update thread timer
|
||||
UpdateStat(MethodBase.GetCurrentMethod().Name, sw.ElapsedMilliseconds);
|
||||
// Wait
|
||||
Thread.Sleep(CalcSleepTime(samplMsec("warmers"), (int)sw.ElapsedMilliseconds));
|
||||
}
|
||||
|
||||
@@ -3669,8 +3669,15 @@ namespace Thermo.Active.NC
|
||||
/// <returns></returns>
|
||||
public CmsError WriteRecipeParams(Dictionary<string, DTORecipeParam> updtRecipe, int nMaxParamWrite, int delayParamWrite)
|
||||
{
|
||||
|
||||
// registro in redis blocco x lettura ricetta...
|
||||
RedisController.setRecipeReadSem(true);
|
||||
|
||||
CmsError libraryError = WriteRecipeParametersToPLC(updtRecipe, nMaxParamWrite, delayParamWrite);
|
||||
|
||||
// tolgo blocco x lettura ricetta...
|
||||
RedisController.setRecipeReadSem(false);
|
||||
|
||||
return libraryError;
|
||||
}
|
||||
|
||||
@@ -3681,8 +3688,15 @@ namespace Thermo.Active.NC
|
||||
/// <returns></returns>
|
||||
public CmsError WriteRecipeWarmChSetpHMI(Dictionary<int, int> updtSetpHmi)
|
||||
{
|
||||
// registro in redis blocco x lettura warmers...
|
||||
RedisController.setWarmersReadSem(true);
|
||||
|
||||
CmsError libraryError = numericalControl.PLC_WWarmerChSetpHmi(updtSetpHmi);
|
||||
|
||||
// tolgo blocco x lettura warmers...
|
||||
RedisController.setWarmersReadSem(false);
|
||||
|
||||
|
||||
return libraryError;
|
||||
}
|
||||
|
||||
@@ -3693,8 +3707,14 @@ namespace Thermo.Active.NC
|
||||
/// <returns></returns>
|
||||
public CmsError WriteRecipeWarmChTCamEnab(Dictionary<int, bool> actualStates)
|
||||
{
|
||||
// registro in redis blocco x lettura warmers...
|
||||
RedisController.setWarmersReadSem(true);
|
||||
|
||||
CmsError libraryError = numericalControl.PLC_WWarmerChTCamEnab(actualStates);
|
||||
|
||||
// tolgo blocco x lettura warmers...
|
||||
RedisController.setWarmersReadSem(false);
|
||||
|
||||
return libraryError;
|
||||
}
|
||||
|
||||
@@ -3705,8 +3725,14 @@ namespace Thermo.Active.NC
|
||||
/// <returns></returns>
|
||||
public CmsError WriteRecipeWarmChTCamTempAct(Dictionary<int, double> actualTemp)
|
||||
{
|
||||
// registro in redis blocco x lettura warmers...
|
||||
RedisController.setWarmersReadSem(true);
|
||||
|
||||
CmsError libraryError = numericalControl.PLC_WWarmerChTCamTempAct(actualTemp);
|
||||
|
||||
// tolgo blocco x lettura warmers...
|
||||
RedisController.setWarmersReadSem(false);
|
||||
|
||||
return libraryError;
|
||||
}
|
||||
|
||||
@@ -3717,8 +3743,14 @@ namespace Thermo.Active.NC
|
||||
/// <returns></returns>
|
||||
public CmsError WriteRecipeWarmChTCamTempSet(Dictionary<int, double> referenceTemp)
|
||||
{
|
||||
// registro in redis blocco x lettura warmers...
|
||||
RedisController.setWarmersReadSem(true);
|
||||
|
||||
CmsError libraryError = numericalControl.PLC_WWarmerChTCamTempSet(referenceTemp);
|
||||
|
||||
// tolgo blocco x lettura warmers...
|
||||
RedisController.setWarmersReadSem(false);
|
||||
|
||||
return libraryError;
|
||||
}
|
||||
|
||||
@@ -3732,6 +3764,9 @@ namespace Thermo.Active.NC
|
||||
Dictionary<int, int> newData = new Dictionary<int, int>();
|
||||
CmsError libraryError = NO_ERROR;
|
||||
|
||||
// registro in redis blocco x lettura warmers...
|
||||
RedisController.setWarmersReadSem(true);
|
||||
|
||||
// scrivo l'abilitazione dei canali...
|
||||
foreach (var item in RiskBoardConfig)
|
||||
{
|
||||
@@ -3793,6 +3828,10 @@ namespace Thermo.Active.NC
|
||||
numericalControl.PLC_WWarmerChTCamEnab(resetTCamEnab);
|
||||
numericalControl.PLC_WWarmerChTCamTempAct(resetTCamTemp);
|
||||
numericalControl.PLC_WWarmerChTCamTempSet(resetTCamTemp);
|
||||
|
||||
// tolgo blocco x lettura warmers...
|
||||
RedisController.setWarmersReadSem(false);
|
||||
|
||||
// esce
|
||||
return libraryError;
|
||||
}
|
||||
|
||||
@@ -701,6 +701,7 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
}
|
||||
|
||||
|
||||
|
||||
// copy data to PLC
|
||||
checkError = ncAdapter.ReadFullRecipe(out Dictionary<string, DTORecipeParam> prevRecipe);
|
||||
if (checkError.IsError())
|
||||
|
||||
Reference in New Issue
Block a user