Merge branch 'release/disconnectOnErrorSiemens'
This commit is contained in:
Binary file not shown.
@@ -62,10 +62,20 @@ namespace IOB_WIN_NEXT
|
||||
protected int B_previous;
|
||||
|
||||
/// <summary>
|
||||
/// NUm errori check alive
|
||||
/// Num errori check alive
|
||||
/// </summary>
|
||||
protected int currAliveErrors = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Variabile numero errori vari (in lettura) --> se supera soglia maxErroriCheck --> disconnette
|
||||
/// </summary>
|
||||
protected int numErroriCheck = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Soglia massima errori priam di disconnesisone automatica
|
||||
/// </summary>
|
||||
protected int maxErroriCheck = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario valori impostati x produzione
|
||||
/// </summary>
|
||||
@@ -81,6 +91,11 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
protected int currSendErrors = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Periodo wathdog di default (2 sec se non specificato)
|
||||
/// </summary>
|
||||
protected int watchDogPeriod = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Array dei contatori x segnali blinking
|
||||
/// </summary>
|
||||
@@ -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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -53,10 +53,6 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
protected DateTime lastCurrent = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Variabile numero errori controllo --> se supera soglia 20 --> disconnette
|
||||
/// </summary>
|
||||
protected int numErroriCheck = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 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");
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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++;
|
||||
|
||||
Reference in New Issue
Block a user