Modifica conf pulizia dati in ingresso x server OSAI con caratteri in eccesso (da testare)

This commit is contained in:
Samuele Locatelli
2022-06-17 09:03:45 +02:00
parent cbf778217b
commit 4964854038
19 changed files with 52 additions and 142 deletions
+31 -9
View File
@@ -37,7 +37,6 @@ namespace MP.MONO.ADAPTER.OPC
connectionOk = false;
configPath = confPath;
confMan = config;
CleanupRegexp = confMan.GetValue<string>("CleanupRegexp");
if (confMan != null)
{
// carico dati endpoint
@@ -51,8 +50,17 @@ namespace MP.MONO.ADAPTER.OPC
var optPar = confMan.GetSection("OptPar");
if (optPar.Exists())
{
CleanupRegexp = optPar.GetValue<string>("CleanupRegexp");
FiltSplitChar = optPar.GetValue<string>("FiltSplitChar");
ForceSplit = optPar.GetValue<bool>("ForceSplit");
CleanupRegexpPre = optPar.GetValue<string>("CleanupRegexpPre");
if (optPar.GetValue<bool>("FiltCrLf"))
{
FiltSplitChar = new char[] { '\n', '\r' };
}
else
{
FiltSplitChar = optPar.GetValue<char[]>("FiltSplitChar");
}
CleanupRegexpPost = optPar.GetValue<string>("CleanupRegexpPost");
}
}
}
@@ -316,14 +324,24 @@ namespace MP.MONO.ADAPTER.OPC
internal EndpointData cIobConf { get; set; } = new EndpointData();
/// <summary>
/// Stringa regexp da usare x bonifica caratteri
/// Stringa regexp da usare x bonifica caratteri, PRE split
/// </summary>
internal string CleanupRegexp { get; set; } = "";
internal string CleanupRegexpPre { get; set; } = "";
/// <summary>
/// Stringa regexp da usare x bonifica caratteri, POST split
/// </summary>
internal string CleanupRegexpPost { get; set; } = "";
/// <summary>
/// Carattere x eventuale split/filt valori notificati
/// </summary>
internal string FiltSplitChar { get; set; } = "";
internal char[] FiltSplitChar { get; set; } = new char[1];
/// <summary>
/// Indica se forzare split caratteri letti
/// </summary>
internal bool ForceSplit { get; set; } = false;
internal string configPath { get; set; } = "";
@@ -453,11 +471,13 @@ namespace MP.MONO.ADAPTER.OPC
/// <returns></returns>
internal string stringCleanup(string rawData)
{
Regex rgx = new Regex(CleanupRegexp);
Regex rgxPre = new Regex(CleanupRegexpPre);
Regex rgxPost = new Regex(CleanupRegexpPost);
string currVal = "";
string temp = rgx.Replace(rawData, "");
// pulizia dati preliminare
string temp = rgxPre.Replace(rawData, "");
// se è abilitato filt/split...
if (!string.IsNullOrEmpty(FiltSplitChar))
if (ForceSplit)
{
var dataArray = temp.Split(FiltSplitChar);
if (dataArray.Length > 0)
@@ -469,6 +489,8 @@ namespace MP.MONO.ADAPTER.OPC
{
currVal = temp;
}
// pulizia dati finale
currVal = rgxPre.Replace(currVal, "");
return currVal;
}
-113
View File
@@ -906,114 +906,6 @@ namespace MP.MONO.ADAPTER.OPC
/// </summary>
private ISubscriber sub { get; set; }
//#region Public Methods
///// <summary>
///// Recupera uno specifico dataItem
///// </summary>
///// <param name="diKey"></param>
///// <returns></returns>
//public string getDataItemValue(string diKey)
//{
// string answ = "";
// if (string.IsNullOrEmpty(diKey))
// {
// logError($"Attenzione: richiesta chiave vuota in getDataItemValue{Environment.NewLine}StackTrace: {Environment.StackTrace}");
// }
// else
// {
// DateTime adesso = DateTime.Now;
// if (dataItemMem.Count == 0)
// {
// numErroriCheck++;
// if (vetoCheckStatus < adesso)
// {
// logError($"Errore in getDataItemValue per {diKey} | dataItemMem NON contiene valori");
// // imposto veto per vetoSeconds...
// vetoCheckStatus = adesso.AddSeconds(vetoSeconds * 2);
// }
// }
// else
// {
// if (!dataItemMem.ContainsKey(diKey))
// {
// if (vetoCheckStatus < adesso)
// {
// logError($"Errore in getDataItemValue per {diKey} | dataItemMem non contiene la chiave richiesta ma altri {dataItemMem.Count} valori");
// // imposto veto per vetoSeconds...
// vetoCheckStatus = adesso.AddSeconds(vetoSeconds * 2);
// }
// numErroriCheck++;
// }
// else
// {
// try
// {
// var currDataItem = dataItemMem[diKey];
// answ = currDataItem.value;
// }
// catch (Exception exc)
// {
// logError($"Errore in getDataItemValue per {diKey} | dataItemMem contiene {dataItemMem.Count} valori {Environment.NewLine}{exc}");
// if (dataItemMem != null)
// {
// logError($"dataItemMem contiene {dataItemMem.Count} valori");
// int maxNum = 5;
// foreach (var item in dataItemMem)
// {
// maxNum--;
// if (maxNum < 0)
// {
// break;
// }
// logInfo($"{item.Key} --> {item.Value.DisplayName} = {item.Value.value}");
// }
// }
// }
// }
// }
// // se supero soglia errori lettura --> disconnetto e resetto
// if (numErroriCheck > maxErroriCheck)
// {
// logInfo($"numErroriCheck: {numErroriCheck} --> richiesta disconnessione adapter con tryDisconnect");
// numErroriCheck = 0; tryDisconnect(); } }
// return answ;
//}
///// <summary>
///// Recupero dati dinamici...
///// </summary>
//public override Dictionary<string, string> getDynData()
//{
// Dictionary<string, string> outVal = new Dictionary<string, string>();
// return outVal;
//}
///// <summary>
///// Effettua vero processing contapezzi
///// </summary>
//public override void processContapezzi()
//{
// if (utils.CRB("enableContapezzi"))
// {
// // da ridefinire la gestione base del contapezzi OPC-UA...
// }
//}
///// <summary>
///// Effettua lettura semafori principale
///// <paramref name="currDispData">Parametri da aggiornare x display in form</paramref>
///// </summary>
//public override void readSemafori(ref newDisplayData currDispData)
//{
// base.readSemafori(ref currDispData);
// try
// {
// if (verboseLog)
// {
// logInfo("inizio read semafori");
// }
/// <summary>
/// Elenco chiavi dei parametri gestiti come Tool
@@ -1559,10 +1451,5 @@ namespace MP.MONO.ADAPTER.OPC
#endregion Private Methods
//#endregion Protected Methods
//#region Private Fields
//#endregion Private Fields
//#endregion Private Methods
}
}
+5 -4
View File
@@ -44,7 +44,6 @@
"FullUrl": "opc.tcp://localhost:62541/Quickstarts/ReferenceServer",
"PingMsTimeout": 1500
},
"CleanupRegexp": "[^a-zA-Z0-9 %,.\\-\\+]",
//"Endpoint": {
// "ConfFile": "Multiax.json",
// "FullUrl": "opc.tcp://192.168.0.2:4840",
@@ -53,9 +52,11 @@
// "PingMsTimeout": 1500
//},
"OptPar": {
"CleanupRegexp": "[^a-zA-Z0-9 %,.\\-\\+]",
"FiltSplitChar": " ",
"ForceStringSeparator": true
"ForceSplit": true,
"CleanupRegexpPre": "",
"CleanupRegexpPost": "[^a-zA-Z0-9 %,.\\-\\+]",
"FiltCrLf": true,
"FiltSplitChar": []
},
"ENABLE_DATA_FILTER": true,
"ENABLE_CLI_RESTART": true,
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.12206.1619</Version>
<Version>1.12206.1708</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.12206.1619</h4>
<h4>Version: 1.12206.1708</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.12206.1619
1.12206.1708
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.12206.1619</version>
<version>1.12206.1708</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.ANALYZER/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.ANALYZER/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.12206.1619</Version>
<Version>1.12206.1708</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.12206.1619</h4>
<h4>Version: 1.12206.1708</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.12206.1619
1.12206.1708
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.12206.1619</version>
<version>1.12206.1708</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.DECODER/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.DECODER/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.12206.1619</Version>
<Version>1.12206.1708</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.12206.1619</h4>
<h4>Version: 1.12206.1708</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.12206.1619
1.12206.1708
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.12206.1619</version>
<version>1.12206.1708</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.SIM/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.SIM/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.12206.1619</Version>
<Version>1.12206.1708</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.12206.1619</h4>
<h4>Version: 1.12206.1708</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.12206.1619
1.12206.1708
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.12206.1619</version>
<version>1.12206.1708</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.UI/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.UI/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>