diff --git a/CVCncLib/CVCncLib.dll b/CVCncLib/CVCncLib.dll index 0cf7b395..9551de0f 100644 Binary files a/CVCncLib/CVCncLib.dll and b/CVCncLib/CVCncLib.dll differ diff --git a/IOB-WIN-NEXT/IobGeneric.cs b/IOB-WIN-NEXT/IobGeneric.cs index ffd308d1..5f6ad9c3 100644 --- a/IOB-WIN-NEXT/IobGeneric.cs +++ b/IOB-WIN-NEXT/IobGeneric.cs @@ -62,10 +62,20 @@ namespace IOB_WIN_NEXT protected int B_previous; /// - /// NUm errori check alive + /// Num errori check alive /// protected int currAliveErrors = 0; + /// + /// Variabile numero errori vari (in lettura) --> se supera soglia maxErroriCheck --> disconnette + /// + protected int numErroriCheck = 0; + + /// + /// Soglia massima errori priam di disconnesisone automatica + /// + protected int maxErroriCheck = 100; + /// /// Dizionario valori impostati x produzione /// @@ -81,6 +91,11 @@ namespace IOB_WIN_NEXT /// protected int currSendErrors = 0; + /// + /// Periodo wathdog di default (2 sec se non specificato) + /// + protected int watchDogPeriod = 2; + /// /// Array dei contatori x segnali blinking /// @@ -1694,10 +1709,6 @@ namespace IOB_WIN_NEXT // mostro update... string newString = string.Format("{0:X}", B_input); currDispData.newInData = newString; -#if false - // salvo coda debug... - QueueDebug.Enqueue(B_input); -#endif } /// @@ -1781,6 +1792,22 @@ namespace IOB_WIN_NEXT int.TryParse(s_maxPingRetry, out numRetry); maxPingRetry = numRetry; } + + string s_maxErrCheck = getOptPar("MAX_ERR_CHECK"); + if (!string.IsNullOrEmpty(s_maxErrCheck)) + { + int numErr = 50; + int.TryParse(s_maxErrCheck, out numErr); + maxErroriCheck = numErr; + } + + string s_watchDogPer = getOptPar("WATCHDOG_PERIOD"); + if (!string.IsNullOrEmpty(s_watchDogPer)) + { + int numPer = 3; + int.TryParse(s_watchDogPer, out numPer); + watchDogPeriod = numPer; + } } /// diff --git a/IOB-WIN-NEXT/IobOpcUa.cs b/IOB-WIN-NEXT/IobOpcUa.cs index 97882859..a99eb267 100644 --- a/IOB-WIN-NEXT/IobOpcUa.cs +++ b/IOB-WIN-NEXT/IobOpcUa.cs @@ -53,10 +53,6 @@ namespace IOB_WIN_NEXT /// protected DateTime lastCurrent = DateTime.Now; - /// - /// Variabile numero errori controllo --> se supera soglia 20 --> disconnette - /// - protected int numErroriCheck = 0; /// /// Oggetto MAIN x connessione MTC @@ -930,7 +926,7 @@ namespace IOB_WIN_NEXT } } // se supero soglia errori lettura --> disconnetto e resetto - if (numErroriCheck > 100) + if (numErroriCheck > maxErroriCheck) { lgInfo($"numErroriCheck: {numErroriCheck} --> richiesta disconnessione adapter con tryDisconnect"); diff --git a/IOB-WIN-NEXT/IobSiemens.cs b/IOB-WIN-NEXT/IobSiemens.cs index 614bb0a6..3af6857a 100644 --- a/IOB-WIN-NEXT/IobSiemens.cs +++ b/IOB-WIN-NEXT/IobSiemens.cs @@ -176,7 +176,7 @@ namespace IOB_WIN_NEXT { lastMemWrite.Add(memAddrWrite, adesso.AddMinutes(-1)); } - // ora mi leggo valore ultimas crittura e confronto con adesso + // ora mi leggo valore ultima scrittura e confronto con adesso try { doWrite = (lastMemWrite[memAddrWrite].AddSeconds(vetoSeconds) < adesso); @@ -188,7 +188,8 @@ namespace IOB_WIN_NEXT // se encessario --> LOG! if (doWrite) { - lgInfo(logValue); + // 2022.03.16 portato a livello TRACE x evitare log troppo verboso + lgTrace(logValue); lastMemWrite[memAddrWrite] = adesso; } } @@ -1086,6 +1087,7 @@ namespace IOB_WIN_NEXT else { lgError($"Mismatch dimensione array memoria: indirizzo: {memAddrRead} | passato array di {Value.Length} byte, letti da S7 {memByteRead.Length} byte"); + numErroriCheck++; } string titolo = $"READ BLOCK MEM BYTE: {parametri.memAddrRead} --> {numByte} byte"; if (verboseLog) @@ -1117,6 +1119,14 @@ namespace IOB_WIN_NEXT TimingData.addResult(cIobConf.codIOB, string.Format("{0}|{1}", parametri.memAddrRead, numByte), sw.ElapsedTicks); } } + // se supero soglia errori lettura --> disconnetto e resetto + if (numErroriCheck > maxErroriCheck) + { + lgInfo($"numErroriCheck: {numErroriCheck} --> richiesta disconnessione adapter con tryDisconnect"); + numErroriCheck = 0; + tryDisconnect(); + } + return answ; } diff --git a/IOB-WIN-NEXT/IobSiemensIngenia.cs b/IOB-WIN-NEXT/IobSiemensIngenia.cs index 3a437ced..145bfd45 100644 --- a/IOB-WIN-NEXT/IobSiemensIngenia.cs +++ b/IOB-WIN-NEXT/IobSiemensIngenia.cs @@ -281,7 +281,7 @@ namespace IOB_WIN_NEXT { // scrivo 1 volta al secondo il contatore incrementale su area apposita DateTime adesso = DateTime.Now; - if (adesso.Subtract(lastPLCWatchDog).TotalSeconds > 1) + if (adesso.Subtract(lastPLCWatchDog).TotalSeconds > watchDogPeriod) { // incremento counterMes2Plc++; diff --git a/IOB-WIN-NEXT/IobSiemensLasco.cs b/IOB-WIN-NEXT/IobSiemensLasco.cs index cde6f297..90a71f2a 100644 --- a/IOB-WIN-NEXT/IobSiemensLasco.cs +++ b/IOB-WIN-NEXT/IobSiemensLasco.cs @@ -564,7 +564,7 @@ namespace IOB_WIN_NEXT // scrive nel primo byte, ultimo bit, il watchdog, mentre scrive nel primo 1 = setup, 0 = run // scrivo 1 volta al secondo il contatore incrementale su area apposita DateTime adesso = DateTime.Now; - if (adesso.Subtract(lastPLCWatchDog).TotalSeconds > 1) + if (adesso.Subtract(lastPLCWatchDog).TotalSeconds > watchDogPeriod) { // incremento counterMes2Plc++; diff --git a/IOB-WIN-NEXT/IobSiemensSaet.cs b/IOB-WIN-NEXT/IobSiemensSaet.cs index b5281266..90f6ead5 100644 --- a/IOB-WIN-NEXT/IobSiemensSaet.cs +++ b/IOB-WIN-NEXT/IobSiemensSaet.cs @@ -318,9 +318,9 @@ namespace IOB_WIN_NEXT public override void processWhatchDog() { - // scrivo 1 volta al secondo il contatore incrementale su area apposita + // scrivo 1 volta ogni n secondi il contatore incrementale su area apposita DateTime adesso = DateTime.Now; - if (adesso.Subtract(lastPLCWatchDog).TotalSeconds > 1) + if (adesso.Subtract(lastPLCWatchDog).TotalSeconds > watchDogPeriod) { // incremento counterMes2Plc++;