Ancora commenti su area redis x evitare crash ed avere report su PLC
This commit is contained in:
Vendored
+1
-1
@@ -15,7 +15,7 @@ pipeline {
|
||||
|
||||
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
|
||||
script {
|
||||
withEnv(['NEXT_BUILD_NUMBER=325']) {
|
||||
withEnv(['NEXT_BUILD_NUMBER=326']) {
|
||||
// env.versionNumber = VersionNumber(versionNumberString : '2.0.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
|
||||
env.versionNumber = VersionNumber(versionNumberString : '2.0.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
|
||||
env.APP_NAME = 'SCMA'
|
||||
|
||||
@@ -110,10 +110,17 @@ namespace OPC_UA_REDIS
|
||||
/// </summary>
|
||||
public void Begin()
|
||||
{
|
||||
mBegun = true;
|
||||
foreach (DataItemRed di in mDataItems)
|
||||
if (redisSrvOk)
|
||||
{
|
||||
di.Begin();
|
||||
mBegun = true;
|
||||
foreach (DataItemRed di in mDataItems)
|
||||
{
|
||||
di.Begin();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lg.Error("Errore: redis server NON disponibile (Begin)");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -195,12 +202,19 @@ namespace OPC_UA_REDIS
|
||||
}
|
||||
if (together.Count > 0)
|
||||
{
|
||||
// salvo su REDIS!!!
|
||||
foreach (DataItemRed di in together)
|
||||
if (redisSrvOk)
|
||||
{
|
||||
hashKey = machineHash(di.Name);
|
||||
hashVal = di.Value.ToString();
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
// salvo su REDIS!!!
|
||||
foreach (DataItemRed di in together)
|
||||
{
|
||||
hashKey = machineHash(di.Name);
|
||||
hashVal = di.Value.ToString();
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lg.Error("Attenzione! server REDIS non disponibile (SendChanged:toghether)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +231,7 @@ namespace OPC_UA_REDIS
|
||||
|
||||
// finito
|
||||
mBegun = false;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Salva hask KeyVal in REDIS
|
||||
@@ -250,11 +265,18 @@ namespace OPC_UA_REDIS
|
||||
|
||||
// ora il valore delle chaivi diventa unavailable...
|
||||
hashVal = availStatus.UNAVAILABLE.ToString();
|
||||
// percorro tutto l'albero nodi item ed allarmi e SCRIVO!!!!
|
||||
foreach (var item in itemNodes)
|
||||
if (redisSrvOk)
|
||||
{
|
||||
hashKey = machineHash(item.Key);
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
// percorro tutto l'albero nodi item ed allarmi e SCRIVO!!!!
|
||||
foreach (var item in itemNodes)
|
||||
{
|
||||
hashKey = machineHash(item.Key);
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lg.Error("Attenzione! server REDIS non disponibile (Stop)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,73 +284,65 @@ namespace OPC_UA_REDIS
|
||||
/// Avvio adapter (popolamento iniziale su redis...)
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
if (redisSrvOk)
|
||||
{ // var accessorie
|
||||
string hashKey = "";
|
||||
string hashVal = "";
|
||||
var list = new List<KeyValuePair<string, string>>();
|
||||
string nLevel = "";
|
||||
// Imposto CONF
|
||||
hashKey = redUtil.redHash("Adp:Vers");
|
||||
hashVal = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
hashKey = redUtil.redHash("Adp:Status");
|
||||
hashVal = "started";
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
hashKey = redUtil.redHash("Adp:Heartbeat");
|
||||
hashVal = DateTime.Now.ToString();
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
// allarmi CNC
|
||||
hashKey = confHash("CNC");
|
||||
foreach (var item in elencoAllarmi)
|
||||
{
|
||||
// var accessorie
|
||||
string hashKey = "";
|
||||
string hashVal = "";
|
||||
var list = new List<KeyValuePair<string, string>>();
|
||||
string nLevel = "";
|
||||
// Imposto CONF
|
||||
hashKey = redUtil.redHash("Adp:Vers");
|
||||
hashVal = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
hashKey = redUtil.redHash("Adp:Status");
|
||||
hashVal = "started";
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
hashKey = redUtil.redHash("Adp:Heartbeat");
|
||||
hashVal = DateTime.Now.ToString();
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
// allarmi CNC
|
||||
hashKey = confHash("CNC");
|
||||
foreach (var item in elencoAllarmi)
|
||||
// se è PLC aggiungo
|
||||
if (item.gruppo == "CNC")
|
||||
{
|
||||
// se è PLC aggiungo
|
||||
if (item.gruppo == "CNC")
|
||||
{
|
||||
nLevel = item.livello == "FAULT" ? "900" : "500";
|
||||
list.Add(new KeyValuePair<string, string>(item.codNum, nLevel + "|" + item.descrizione));
|
||||
}
|
||||
}
|
||||
redUtil.redSaveHashList(hashKey, list);
|
||||
// allarmi PLC
|
||||
hashKey = confHash("PLC");
|
||||
foreach (var item in elencoAllarmi)
|
||||
{
|
||||
// se è PLC aggiungo
|
||||
if (item.gruppo == "PLC")
|
||||
{
|
||||
nLevel = item.livello == "FAULT" ? "900" : "500";
|
||||
list.Add(new KeyValuePair<string, string>(item.codNum, nLevel + "|" + item.descrizione));
|
||||
}
|
||||
}
|
||||
redUtil.redSaveHashList(hashKey, list);
|
||||
|
||||
// DataModel --> salvo in redis!
|
||||
hashKey = confHash("DataModel");
|
||||
hashVal = DataModel;
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
|
||||
// imposto VETO
|
||||
hashKey = vetoHash("CNC");
|
||||
hashVal = "0";
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
hashKey = vetoHash("PLC");
|
||||
hashVal = "0";
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
|
||||
// Imposto DATI: percorro tutto l'albero nodi item ed allarmi e SCRIVO!!!!
|
||||
foreach (var item in itemNodes)
|
||||
{
|
||||
hashKey = machineHash(item.Key);
|
||||
hashVal = availStatus.UNAVAILABLE.ToString(); // item.Value.cObject.ToString();
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
nLevel = item.livello == "FAULT" ? "900" : "500";
|
||||
list.Add(new KeyValuePair<string, string>(item.codNum, nLevel + "|" + item.descrizione));
|
||||
}
|
||||
}
|
||||
else
|
||||
redUtil.redSaveHashList(hashKey, list);
|
||||
// allarmi PLC
|
||||
hashKey = confHash("PLC");
|
||||
foreach (var item in elencoAllarmi)
|
||||
{
|
||||
lg.Error("Attenzione! server REDIS non disponibile");
|
||||
// se è PLC aggiungo
|
||||
if (item.gruppo == "PLC")
|
||||
{
|
||||
nLevel = item.livello == "FAULT" ? "900" : "500";
|
||||
list.Add(new KeyValuePair<string, string>(item.codNum, nLevel + "|" + item.descrizione));
|
||||
}
|
||||
}
|
||||
redUtil.redSaveHashList(hashKey, list);
|
||||
|
||||
// DataModel --> salvo in redis!
|
||||
hashKey = confHash("DataModel");
|
||||
hashVal = DataModel;
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
|
||||
// imposto VETO
|
||||
hashKey = vetoHash("CNC");
|
||||
hashVal = "0";
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
hashKey = vetoHash("PLC");
|
||||
hashVal = "0";
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
|
||||
// Imposto DATI: percorro tutto l'albero nodi item ed allarmi e SCRIVO!!!!
|
||||
foreach (var item in itemNodes)
|
||||
{
|
||||
hashKey = machineHash(item.Key);
|
||||
hashVal = availStatus.UNAVAILABLE.ToString(); // item.Value.cObject.ToString();
|
||||
saveHashKeyVal(hashKey, hashVal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace OPC_UA_REDIS
|
||||
}
|
||||
else
|
||||
{
|
||||
lg.Error("Server REDIS non disponibile per setRSV");
|
||||
lg.Error("Server REDIS non disponibile (setRSV)");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -196,17 +196,24 @@ namespace OPC_UA_REDIS
|
||||
public bool setRSV(string chiave, string valore, int TTL_sec)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
if (srvConnected)
|
||||
{
|
||||
IDatabase cache = connRedis.GetDatabase();
|
||||
TimeSpan expT = new TimeSpan(0, 0, TTL_sec);
|
||||
// salvo con expyry...
|
||||
cache.StringSet(chiave, valore, expT);
|
||||
answ = true;
|
||||
try
|
||||
{
|
||||
IDatabase cache = connRedis.GetDatabase();
|
||||
TimeSpan expT = new TimeSpan(0, 0, TTL_sec);
|
||||
// salvo con expyry...
|
||||
cache.StringSet(chiave, valore, expT);
|
||||
answ = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lg.Info(string.Format("Errore in setRSV:{0}{1}", Environment.NewLine, exc));
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
else
|
||||
{
|
||||
lg.Info(string.Format("Errore in setRSV:{0}{1}", Environment.NewLine, exc));
|
||||
lg.Error("Server REDIS non disponibile (setRSV:TTL)");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -442,23 +449,30 @@ namespace OPC_UA_REDIS
|
||||
public bool redSaveHash(string hashKey, KeyValuePair<string, string>[] hashFields)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco se ci sia valore in redis...
|
||||
IDatabase cache = connRedis.GetDatabase();
|
||||
try
|
||||
if (srvConnected)
|
||||
{
|
||||
RedisKey chiave = hashKey;
|
||||
HashEntry[] valori = new HashEntry[hashFields.Length];
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, string> kvp in hashFields)
|
||||
// cerco se ci sia valore in redis...
|
||||
IDatabase cache = connRedis.GetDatabase();
|
||||
try
|
||||
{
|
||||
valori[i] = new HashEntry(kvp.Key, kvp.Value);
|
||||
i++;
|
||||
RedisKey chiave = hashKey;
|
||||
HashEntry[] valori = new HashEntry[hashFields.Length];
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, string> kvp in hashFields)
|
||||
{
|
||||
valori[i] = new HashEntry(kvp.Key, kvp.Value);
|
||||
i++;
|
||||
}
|
||||
cache.HashSet(chiave, valori);
|
||||
answ = true;
|
||||
}
|
||||
cache.HashSet(chiave, valori);
|
||||
answ = true;
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
else
|
||||
{
|
||||
lg.Error("Server REDIS non disponibile (redSaveHash)");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -470,23 +484,30 @@ namespace OPC_UA_REDIS
|
||||
public static bool redSaveHashList(string hashKey, List<KeyValuePair<string, string>> hashListKVP)
|
||||
{
|
||||
bool answ = false;
|
||||
// cerco se ci sia valore in redis...
|
||||
IDatabase cache = connRedis.GetDatabase();
|
||||
try
|
||||
if (srvConnected)
|
||||
{
|
||||
RedisKey chiave = hashKey;
|
||||
HashEntry[] valori = new HashEntry[hashListKVP.Count];
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, string> kvp in hashListKVP)
|
||||
// cerco se ci sia valore in redis...
|
||||
IDatabase cache = connRedis.GetDatabase();
|
||||
try
|
||||
{
|
||||
valori[i] = new HashEntry(kvp.Key, kvp.Value);
|
||||
i++;
|
||||
RedisKey chiave = hashKey;
|
||||
HashEntry[] valori = new HashEntry[hashListKVP.Count];
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, string> kvp in hashListKVP)
|
||||
{
|
||||
valori[i] = new HashEntry(kvp.Key, kvp.Value);
|
||||
i++;
|
||||
}
|
||||
cache.HashSet(chiave, valori);
|
||||
answ = true;
|
||||
}
|
||||
cache.HashSet(chiave, valori);
|
||||
answ = true;
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
else
|
||||
{
|
||||
lg.Error("Server REDIS non disponibile (redSaveHashList)");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -33,14 +33,7 @@ namespace SCMA.AdapterCom
|
||||
/// </summary>
|
||||
public override void sendChanged()
|
||||
{
|
||||
if (mAdapter.redisSrvOk)
|
||||
{
|
||||
mAdapter.SendChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
lg.Error("Errore: redis server NON disponibile in sendChanged");
|
||||
}
|
||||
mAdapter.SendChanged();
|
||||
}
|
||||
/// <summary>
|
||||
/// Wrapper metodo imposta tutto a UNAVAILABLE
|
||||
|
||||
Reference in New Issue
Block a user