Vari fix x errori + continuo fix x provare metodi backgroundWorkers

This commit is contained in:
Samuele E. Locatelli
2019-11-08 19:07:03 +01:00
parent bdfd0787c4
commit 2a6fb4292c
3 changed files with 57 additions and 31 deletions
+12
View File
@@ -14,3 +14,15 @@ dotnet_diagnostic.CA1806.severity = none
# CA1305: Specificare IFormatProvider
dotnet_diagnostic.CA1305.severity = none
# CA1031: Do not catch general exception types
dotnet_diagnostic.CA1031.severity = none
# CA1707: Gli identificatori non devono contenere caratteri di sottolineatura
dotnet_diagnostic.CA1707.severity = none
# CA1307: Specificare StringComparison
dotnet_diagnostic.CA1307.severity = none
# CA1063: Implement IDisposable Correctly
dotnet_diagnostic.CA1063.severity = none
+43 -29
View File
@@ -10,7 +10,7 @@ using System.Net.NetworkInformation;
namespace IOB_WIN
{
public class IobSiemens : IobGeneric
public class IobSiemens : IobGeneric, IDisposable
{
/* --------------------------------------------------------------------------------
* Controlli SIEMENS tramite libreria S7.net
@@ -348,35 +348,42 @@ namespace IOB_WIN
public IobSiemens(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
{
memMap = new plcMemMap();
// gestione invio ritardato contapezzi
pzCountDelay = utils.CRI("pzCountDelay");
lastPzCountSend = DateTime.Now;
lastWarnODL = DateTime.Now;
// inizializzo parametri...
parametri = new connParamS7()
if (IOBConf != null)
{
ipAdrr = "127.0.0.1",
tipoCpu = CpuType.S7200,
slot = 0,
rack = 0,
pingMsTimeout = IOBConf.pingMsTimeout,
memAddrRead = "DB1.DBB0",
memAddrWrite = "DB2.DBB0",
memSizeRead = 0,
memSizeWrite = 0
};
setParamPlc();
// gestione invio ritardato contapezzi
pzCountDelay = utils.CRI("pzCountDelay");
lastPzCountSend = DateTime.Now;
lastWarnODL = DateTime.Now;
// inizializzo parametri...
parametri = new connParamS7()
{
ipAdrr = "127.0.0.1",
tipoCpu = CpuType.S7200,
slot = 0,
rack = 0,
pingMsTimeout = IOBConf.pingMsTimeout,
memAddrRead = "DB1.DBB0",
memAddrWrite = "DB2.DBB0",
memSizeRead = 0,
memSizeWrite = 0
};
setParamPlc();
// salvo info su conf IOB...
string iobConfSer = "";
try
{
iobConfSer = JsonConvert.SerializeObject(IOBConf);
// salvo info su conf IOB...
string iobConfSer = "";
try
{
iobConfSer = JsonConvert.SerializeObject(IOBConf);
}
catch
{ }
// finito!
lgInfo($"Init IOB, con {iobConfSer}");
}
else
{
lgError("Impossibile avviare, IOBConf nullo/non valido!");
}
catch
{ }
// finito!
lgInfo($"Init IOB, con {iobConfSer}");
}
/// <summary>
@@ -505,7 +512,7 @@ namespace IOB_WIN
try
{
// verifico quale modalità sia richiesta: STD (6711) oppure BIT (Custom, con indicazione area)
if (cIobConf.optPar.Count > 0 && getOptPar("PZCOUNT_MODE") != "")
if (cIobConf.optPar.Count > 0 && !string.IsNullOrWhiteSpace(getOptPar("PZCOUNT_MODE")))
{
if (getOptPar("PZCOUNT_MODE").StartsWith("STD"))
{
@@ -672,7 +679,7 @@ namespace IOB_WIN
try
{
// verifico quale modalità sia richiesta: STD (6711) oppure BIT (Custom, con indicazione area)
if (cIobConf.optPar.Count > 0 && getOptPar("PZCOUNT_MODE") != "")
if (cIobConf.optPar.Count > 0 && !string.IsNullOrWhiteSpace(getOptPar("PZCOUNT_MODE")))
{
string memAddr = getOptPar("PZCOUNT_MODE");
if (memAddr.StartsWith("STD"))
@@ -952,6 +959,13 @@ namespace IOB_WIN
}
return outVal;
}
/// <summary>
/// Metodo dispose x il currPLC contenuto
/// </summary>
public void Dispose()
{
currPLC.Dispose();
}
#endregion
}
+2 -2
View File
@@ -181,7 +181,7 @@ namespace IOB_WIN
{
currODL = utils.callUrl(urlGetCurrODL);
// solo SE HO un ODL...
if (currODL == "" || currODL == "0")
if (string.IsNullOrWhiteSpace(currODL) || currODL == "0")
{
if (periodicLog)
{
@@ -207,7 +207,7 @@ namespace IOB_WIN
lastWarnODL = DateTime.Now;
}
}
if (currODL != null && currODL != "" && currODL != "0")
if (!string.IsNullOrWhiteSpace(currODL) && currODL != "0")
{
// ora processo il contapezzi...
// controllo se è passato intervallo minimo tra 2 controlli/elaborazioni x distanziare invio e ridurre letture