Merge branch 'release/AddFrerModbus_03'
This commit is contained in:
+42
-5
@@ -8,6 +8,15 @@ namespace IOB_UT_NEXT
|
||||
{
|
||||
public class RedisIobCache
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Hash REDIS x dati IOB
|
||||
/// </summary>
|
||||
public string redIobTrackKey = "";
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -17,7 +26,7 @@ namespace IOB_UT_NEXT
|
||||
/// <param name="codIob"></param>
|
||||
public RedisIobCache()
|
||||
{
|
||||
initHashKeys();
|
||||
initMemKeys();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -34,7 +43,7 @@ namespace IOB_UT_NEXT
|
||||
// init dati di base...
|
||||
currCodIob = codIob;
|
||||
currIobType = tipoIob;
|
||||
initHashKeys();
|
||||
initMemKeys();
|
||||
// init oggetti gestiti
|
||||
ServerMpStatus newSrvStatus = new ServerMpStatus()
|
||||
{
|
||||
@@ -688,6 +697,33 @@ namespace IOB_UT_NEXT
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Incremento conteggio di un valore dentro una hash
|
||||
/// </summary>
|
||||
/// <param name="hashKey">chiave</param>
|
||||
/// <param name="hashField">valore con conteggio da tracciare</param>
|
||||
/// <param name="hashExpire">scadenza preimpostata hash datetime, se null NON scade</param>
|
||||
/// <returns></returns>
|
||||
public bool redIncrHashCount(string hashKey, string hashField, DateTime? hashExpire)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco se ci sia valore in redis...
|
||||
try
|
||||
{
|
||||
RedisKey chiave = hashKey;
|
||||
cache.HashIncrement(chiave, hashField, 1);
|
||||
if (hashExpire != null)
|
||||
{
|
||||
cache.KeyExpire(chiave, hashExpire);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Logging.Instance.Error($"redIncrHashCount {exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica se ci siano valori nella KEY indicata...
|
||||
/// </summary>
|
||||
@@ -818,7 +854,7 @@ namespace IOB_UT_NEXT
|
||||
/// <param name="hashKey">chiave</param>
|
||||
/// <param name="hashFields">valori</param>
|
||||
/// <param name="expireSeconds">
|
||||
/// scadenza preimpostata hash (secondi) | defaoult = -1 (non scade)
|
||||
/// scadenza preimpostata hash (secondi) | default = -1 (non scade)
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public bool redSaveHash(string hashKey, KeyValuePair<string, string>[] hashFields, double expireSeconds = -1)
|
||||
@@ -877,7 +913,7 @@ namespace IOB_UT_NEXT
|
||||
/// <param name="hashKey">chiave</param>
|
||||
/// <param name="hashFields">valori</param>
|
||||
/// <param name="expireSeconds">
|
||||
/// scadenza preimpostata hash (secondi) | defaoult = -1 (non scade)
|
||||
/// scadenza preimpostata hash (secondi) | default = -1 (non scade)
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public bool redSaveHashDict(string hashKey, Dictionary<string, string> hashFields, double expireSeconds = -1)
|
||||
@@ -1283,11 +1319,12 @@ namespace IOB_UT_NEXT
|
||||
return y.Key.CompareTo(x.Key);
|
||||
}
|
||||
|
||||
private void initHashKeys()
|
||||
private void initMemKeys()
|
||||
{
|
||||
// init dati di base...
|
||||
redServKey = redHash($"MP");
|
||||
redIobKey = redHash($"IOB:{currCodIob}");
|
||||
redIobTrackKey = redHash($"IOB:Track:{currCodIob}");
|
||||
redIobChannel = $"IobChannel_{currCodIob}";
|
||||
}
|
||||
|
||||
|
||||
@@ -1866,7 +1866,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
lgInfo($"CSV: saved PODL file {csvName} at {filePath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return answ;
|
||||
}
|
||||
@@ -3080,7 +3080,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (IOBConfFull != null)
|
||||
{
|
||||
#if false
|
||||
bool hasPzCount = enablePzCountByApp && !disablePzCountByIob;
|
||||
bool hasPzCount = enablePzCountByApp && !disablePzCountByIob;
|
||||
#endif
|
||||
// creo obj dati necessari...
|
||||
currDict.Add("IobName", IOBConfFull.General.CodIOB);
|
||||
@@ -3116,6 +3116,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
// salvo comunque in fluxLog...
|
||||
accodaFLog($"{paramName}|{paramValue}", qEncodeFLog(paramName, paramValue));
|
||||
// traccio valore DynData x analisi
|
||||
trackDynData(paramName, paramValue);
|
||||
if (checkServerAlive)
|
||||
{
|
||||
string url2call = $"{urlSetOptVal}pName={paramName}&pValue={paramValue}";
|
||||
@@ -3480,7 +3482,6 @@ namespace IOB_WIN_FORM.Iob
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// recupero le folder specifiche x IN/OUT ricette filtrando direttamente l'area di memoria...
|
||||
sCond = "path";
|
||||
var dirList = memMap.OptKVP
|
||||
@@ -3507,6 +3508,23 @@ namespace IOB_WIN_FORM.Iob
|
||||
return origData.Replace(".", "").Replace(" ", "_");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Traccia in redis un dynData x analisi frequenza e campionamento valori FluxLog ...
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
protected void trackDynData(string key, string value)
|
||||
{
|
||||
// attenzione: x ora cablato 3 gg e 1 mese le registrazioni
|
||||
DateTime oggi = DateTime.Today;
|
||||
string rKey = $"{redisMan.redIobTrackKey}:FL:Day:{oggi:yyMMdd}";
|
||||
// traccio con scadenza 1 mese da oggi pareto chiamate giornaliere
|
||||
redisMan.redIncrHashCount(rKey, key, oggi.AddMonths(1));
|
||||
// traccio con scadenza 3 gg da oggi pareto chaimate x tipo
|
||||
rKey = $"{redisMan.redIobTrackKey}:FL:Det:{oggi:yyMMdd}:{key}";
|
||||
redisMan.redIncrHashCount(rKey, value, oggi.AddDays(3));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata MP-IO per cheidere all'utente se vuole effettuare chiusura ODL
|
||||
/// corrente della macchina
|
||||
@@ -4529,6 +4547,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog("PROG", currPrgName));
|
||||
// traccio valore DynData x analisi
|
||||
trackDynData("PROG", currPrgName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4569,6 +4589,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
sVal = string.Format("[SYSINFO]{0}|{1}", item.Key, item.Value);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog(item.Key, item.Value));
|
||||
// traccio valore DynData x analisi
|
||||
trackDynData(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4877,6 +4899,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (!disableWdst)
|
||||
{
|
||||
accodaFLog(sVal, qEncodeFLog("WDST", wdStatus));
|
||||
// traccio valore DynData x analisi
|
||||
trackDynData("WDST", wdStatus);
|
||||
}
|
||||
lastWatchDog = DateTime.Now;
|
||||
sendOnMachineOff = true;
|
||||
|
||||
@@ -2114,6 +2114,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
sVal = string.Format("[CNC_ALARM]{0}|{1}", item.Key, item.Value);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog(item.Key, item.Value));
|
||||
// traccio valore DynData x analisi
|
||||
trackDynData(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2130,6 +2132,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
sVal = $"{item.Key} | {item.Value}";
|
||||
accodaFLog(sVal, qEncodeFLog(item.Key, item.Value));
|
||||
// traccio valore DynData x analisi
|
||||
trackDynData(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2197,6 +2201,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (connectionOk)
|
||||
{
|
||||
currDynData = getDynData();
|
||||
|
||||
bool hasDynDataVal = currDynData.Count > 0;
|
||||
var currAlarmData = getAlarmData();
|
||||
lgTrace($"currDynData: {currDynData.Count} rec | currAlarmData: {currAlarmData.Count} rec");
|
||||
@@ -2243,6 +2248,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
sVal = string.Format("[DYNDATA]{0}|{1}", item.Key, item.Value);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog(item.Key, item.Value));
|
||||
// traccio valore DynData x analisi
|
||||
trackDynData(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2269,6 +2276,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
sVal = string.Format("[DYNDATA]{0}|{1}", item.Key, item.Value);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog(item.Key, item.Value));
|
||||
// traccio valore DynData x analisi
|
||||
trackDynData(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2387,6 +2396,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
sVal = string.Format("[OVERRIDES]{0}|{1}", item.Key, item.Value);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog(item.Key, item.Value));
|
||||
// traccio valore DynData x analisi
|
||||
trackDynData(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,8 +217,8 @@ namespace IOB_WIN_MBUS.IobModbusTCP
|
||||
public override Dictionary<string, string> getDynData()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
int minWait = 50;
|
||||
int maxWait = 50;
|
||||
int minWait = 40;
|
||||
int maxWait = 60;
|
||||
int.TryParse(getOptPar("minWait"), out minWait);
|
||||
int.TryParse(getOptPar("maxWait"), out maxWait);
|
||||
// valore non presente in vers default... se gestito fare override
|
||||
@@ -760,6 +760,7 @@ namespace IOB_WIN_MBUS.IobModbusTCP
|
||||
string trad = string.Join(",", listVal);
|
||||
string sVal = $"Change {item.Key}: {locTStamp.ToString()} | Val: {item.Value} | trad: {trad}";
|
||||
accodaFLog(sVal, qEncodeFLog(item.Key, trad));
|
||||
trackDynData(item.Key, trad);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -814,6 +815,7 @@ namespace IOB_WIN_MBUS.IobModbusTCP
|
||||
OptVar2TranslInt[item.Key] = item.Value;
|
||||
sVal = $"Change {item.Key}: {locTStamp.ToString()} | Val: {item.Value}";
|
||||
accodaFLog(sVal, qEncodeFLog(item.Key, item.Value));
|
||||
trackDynData(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user