Adapter.OPC:
-parametrizzato trim WhiteSpace alalrmi
This commit is contained in:
@@ -130,5 +130,65 @@
|
||||
"MaxVal": 0,
|
||||
"DisplFormat": "",
|
||||
"IsNumeric": false
|
||||
},
|
||||
{
|
||||
"Order": 12,
|
||||
"ExtCode": "ns=1;s=3_12_ALARM PLC 11",
|
||||
"Type": "ALARM",
|
||||
"Title": "ALARM PLC 11",
|
||||
"Value": "",
|
||||
"ValueNum": 0,
|
||||
"MinVal": 0,
|
||||
"MaxVal": 0,
|
||||
"DisplFormat": "",
|
||||
"IsNumeric": false
|
||||
},
|
||||
{
|
||||
"Order": 13,
|
||||
"ExtCode": "ns=1;s=3_13_ALARM PLC 12",
|
||||
"Type": "ALARM",
|
||||
"Title": "ALARM PLC 12",
|
||||
"Value": "",
|
||||
"ValueNum": 0,
|
||||
"MinVal": 0,
|
||||
"MaxVal": 0,
|
||||
"DisplFormat": "",
|
||||
"IsNumeric": false
|
||||
},
|
||||
{
|
||||
"Order": 14,
|
||||
"ExtCode": "ns=1;s=3_14_ALARM PLC 13",
|
||||
"Type": "ALARM",
|
||||
"Title": "ALARM PLC 13",
|
||||
"Value": "",
|
||||
"ValueNum": 0,
|
||||
"MinVal": 0,
|
||||
"MaxVal": 0,
|
||||
"DisplFormat": "",
|
||||
"IsNumeric": false
|
||||
},
|
||||
{
|
||||
"Order": 15,
|
||||
"ExtCode": "ns=1;s=3_15_ALARM PLC 14",
|
||||
"Type": "ALARM",
|
||||
"Title": "ALARM PLC 14",
|
||||
"Value": "",
|
||||
"ValueNum": 0,
|
||||
"MinVal": 0,
|
||||
"MaxVal": 0,
|
||||
"DisplFormat": "",
|
||||
"IsNumeric": false
|
||||
},
|
||||
{
|
||||
"Order": 16,
|
||||
"ExtCode": "ns=1;s=3_16_ALARM PLC 15",
|
||||
"Type": "ALARM",
|
||||
"Title": "ALARM PLC 15",
|
||||
"Value": "",
|
||||
"ValueNum": 0,
|
||||
"MinVal": 0,
|
||||
"MaxVal": 0,
|
||||
"DisplFormat": "",
|
||||
"IsNumeric": false
|
||||
}
|
||||
]
|
||||
@@ -47,7 +47,10 @@ namespace MP.MONO.ADAPTER.OPC
|
||||
msVetoRedCache = config.GetValue<int>("OptPar:VetoSendCache");
|
||||
MinWait = config.GetValue<int>("OptPar:MinWait");
|
||||
MaxWait = config.GetValue<int>("OptPar:MaxWait");
|
||||
logInfo($"VetoSendCache: {msVetoRedCache}s | MinWait: {MinWait} | MaxWait: {MaxWait}");
|
||||
AlarmCleanPre = config.GetValue<string>("OptPar:AlarmCleanPre");
|
||||
AlarmCleanPost= config.GetValue<string>("OptPar:AlarmCleanPost");
|
||||
AlarmTrimWSpace = config.GetValue<bool>("OptPar:AlarmTrimWSpace");
|
||||
logInfo($"VetoSendCache: {msVetoRedCache}s | MinWait: {MinWait} | MaxWait: {MaxWait} | AlarmCleanPre: {AlarmCleanPre} | AlarmCleanPost: {AlarmCleanPost}");
|
||||
|
||||
// gestione data filtering...
|
||||
if (!string.IsNullOrEmpty(config.GetValue<string>("ENABLE_DATA_FILTER")))
|
||||
@@ -803,13 +806,30 @@ namespace MP.MONO.ADAPTER.OPC
|
||||
// Allarmi
|
||||
if (AlarmsKList.Contains(uuid))
|
||||
{
|
||||
// allarmi: effettuo PRE processing x filtrare pre/post { }
|
||||
if (!string.IsNullOrEmpty(AlarmCleanPre))
|
||||
{
|
||||
rawDataVal = rawDataVal.Replace(AlarmCleanPre, "");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(AlarmCleanPost))
|
||||
{
|
||||
rawDataVal = rawDataVal.Replace(AlarmCleanPost, "");
|
||||
}
|
||||
if (AlarmTrimWSpace && string.IsNullOrWhiteSpace(rawDataVal))
|
||||
{
|
||||
rawDataVal = rawDataVal.Trim();
|
||||
}
|
||||
// aggiorno nella lista dei valori quello cambiato...
|
||||
var currItem = AlarmsStatus.FirstOrDefault(x => x.ExtCode == uuid);
|
||||
currItem.Value = rawDataVal;
|
||||
// salvo in redis!
|
||||
redisDb.StringSet(Constants.ALARMS_ADAP_CONF_KEY, JsonConvert.SerializeObject(AlarmsStatus));
|
||||
// genero elenco allarmi attivi
|
||||
List<string> adpActiveAlarm = AlarmsStatus.Select(x => x.Value).Where(x => !string.IsNullOrEmpty(x)).OrderBy(x => x).ToList();
|
||||
List<string> adpActiveAlarm = AlarmsStatus
|
||||
.Select(x => x.Value)
|
||||
.Where(x => !string.IsNullOrEmpty(x))
|
||||
.OrderBy(x => x)
|
||||
.ToList();
|
||||
|
||||
logTrace($"R&S | AlarmsKList | {uuid} | {currItem.Value}");
|
||||
var payloadAlarms = JsonConvert.SerializeObject(adpActiveAlarm);
|
||||
@@ -936,6 +956,20 @@ namespace MP.MONO.ADAPTER.OPC
|
||||
/// </summary>
|
||||
private List<string> AlarmsKList { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Char x bonifica stringa allarmi - PRE
|
||||
/// </summary>
|
||||
private string AlarmCleanPre = "";
|
||||
/// <summary>
|
||||
/// Char x bonifica stringa allarmi - POST
|
||||
/// </summary>
|
||||
private string AlarmCleanPost = "";
|
||||
|
||||
/// <summary>
|
||||
/// Indica se forzare trim dei whitespace da allarmi
|
||||
/// </summary>
|
||||
private bool AlarmTrimWSpace = false;
|
||||
|
||||
/// <summary>
|
||||
/// Elenco oggetti DisplayDTO da gestire come Allarmi
|
||||
/// </summary>
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
//"AlarmRegexp": "^{.*}",
|
||||
"AlarmCleanPre": "{",
|
||||
"AlarmCleanPost": "}",
|
||||
"AlarmTrimWSpace": true,
|
||||
"CleanupRegexpPre": "",
|
||||
//"CleanupRegexpPre": "[^a-zA-Z0-9 %/,.\\-\\+\\r\\n]",
|
||||
"CleanupRegexpPost": "[^a-zA-Z0-9 %\\{\\},.\\-\\+]",
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace MP.MONO.Core
|
||||
{
|
||||
currConf = JsonConvert.DeserializeObject<List<DisplayDataDTO>>(rawData);
|
||||
// salvo in redis!
|
||||
redisDb.StringSetAsync(Constants.ALARMS_ADAP_CONF_KEY, JsonConvert.SerializeObject(currConf));
|
||||
redisDb.StringSet(Constants.ALARMS_ADAP_CONF_KEY, JsonConvert.SerializeObject(currConf));
|
||||
}
|
||||
}
|
||||
if (currConf == null)
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
}
|
||||
},
|
||||
"OptPar": {
|
||||
"AlarmCleanPre": "{",
|
||||
"AlarmCleanPost": "}",
|
||||
"AlarmCleanPre": "",
|
||||
"AlarmCleanPost": "",
|
||||
"AlarmIgnoreEmpty": true,
|
||||
"AlarmMode": "RawList",
|
||||
"AlarmRegexp": "^{[\\d\\w\\:\\ \\.\\/\\(\\)]*}",
|
||||
|
||||
Reference in New Issue
Block a user