Update IO: salva e recupera counter x pz
This commit is contained in:
@@ -792,6 +792,68 @@ namespace MapoDb
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Processa registrazione di un counter x una data macchina IOB
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="counter">Dati live nel formato chiave1|valore1#chiave2|valore2#chiave3|valore3</param>
|
||||
/// <returns></returns>
|
||||
public static string saveCounter(string idxMacchina, string counter)
|
||||
{
|
||||
if (counter == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(counter));
|
||||
}
|
||||
// registro conteggio impiego chiamate REDIS
|
||||
if (memLayer.ML.CRB("IOB_RedEnab"))
|
||||
{
|
||||
// conto la richiesta nel contatore REDIS
|
||||
long nCall = memLayer.ML.setRCntI(mHash("COUNT:setCounter"));
|
||||
//... se == nCall2Log scrivo su log e resetto
|
||||
long nCall2Log = memLayer.ML.cdvi("nCall2Log");
|
||||
if (nCall >= nCall2Log)
|
||||
{
|
||||
// loggo
|
||||
logger.lg.scriviLog(string.Format("saveCounter: effettuate {0} call", nCall), tipoLog.INFO);
|
||||
// resetto!
|
||||
memLayer.ML.resetRCnt(mHash("COUNT:setCounter"));
|
||||
}
|
||||
}
|
||||
string answ = "";
|
||||
DateTime dataOraEvento = DateTime.Now;
|
||||
// inizio processing vero e proprio INPUT...
|
||||
if (idxMacchina != null && counter != null)
|
||||
{
|
||||
if (idxMacchina != "" && counter != "")
|
||||
{
|
||||
int newCounter = -1;
|
||||
int.TryParse(counter, out newCounter);
|
||||
// se il conteggio è >= 0 SALVO come nuovo conteggio...
|
||||
if (newCounter >= 0)
|
||||
{
|
||||
// salvo in Redis nell'area CURR_VAL TUTTI i valori live
|
||||
memLayer.ML.setRSV(pzCountHash(idxMacchina), counter);
|
||||
}
|
||||
// registro in risposta che è andato tutto bene...
|
||||
answ = "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
string errore = "Errore: parametri macchina/counter vuoti";
|
||||
logger.lg.scriviLog(errore, tipoLog.ERROR);
|
||||
answ = errore;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string errore = "Errore: mancano parametri macchina/counter";
|
||||
logger.lg.scriviLog(errore, tipoLog.ERROR);
|
||||
answ = errore;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#region definizioni hash x REDIS
|
||||
|
||||
/// <summary>
|
||||
@@ -822,6 +884,15 @@ namespace MapoDb
|
||||
return mHash(string.Format("StMac:{0}", idxMacchina));
|
||||
}
|
||||
/// <summary>
|
||||
/// Hash dati COUNTER x la macchina specificata
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public static string pzCountHash(string idxMacchina)
|
||||
{
|
||||
return mHash(string.Format("PzCount:{0}", idxMacchina));
|
||||
}
|
||||
/// <summary>
|
||||
/// Hash dati LIVE x la macchina specificata
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
@@ -1055,6 +1126,38 @@ namespace MapoDb
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce il contapezzi salvato per la macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public static int pzCounter(string idxMacchina)
|
||||
{
|
||||
int answ = -1;
|
||||
if (memLayer.ML.CRB("IOB_RedEnab"))
|
||||
{
|
||||
|
||||
// conto la richiesta nel contatore REDIS
|
||||
long nCall = memLayer.ML.setRCntI(mHash("COUNT:getCounter"));
|
||||
//... se == nCall2Log scrivo su log e resetto
|
||||
long nCall2Log = memLayer.ML.cdvi("nCall2Log");
|
||||
if (nCall >= nCall2Log)
|
||||
{
|
||||
// loggo
|
||||
logger.lg.scriviLog(string.Format("isMulti: effettuate {0} call", nCall), tipoLog.INFO);
|
||||
// resetto!
|
||||
memLayer.ML.resetRCnt(mHash("COUNT:getCounter"));
|
||||
}
|
||||
try
|
||||
{
|
||||
int.TryParse(memLayer.ML.getRSV(pzCountHash(idxMacchina)), out answ);
|
||||
//answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "Multi") == "1");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Restituisce il valore booleano se la macchina sia di tipo MULTI (con più state machine x INGRESSI)
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user