From 3634d7e4ac36d32298bb8c6c5168c710bc175d2e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 19 May 2026 16:16:51 +0200 Subject: [PATCH] Update comportamento watchdog ping --- IOB-WIN-FORM/Iob/PingWatchDog.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/IOB-WIN-FORM/Iob/PingWatchDog.cs b/IOB-WIN-FORM/Iob/PingWatchDog.cs index 3fa4d2ae..56843e48 100644 --- a/IOB-WIN-FORM/Iob/PingWatchDog.cs +++ b/IOB-WIN-FORM/Iob/PingWatchDog.cs @@ -65,7 +65,7 @@ namespace IOB_WIN_FORM.Iob { readSemafori(ref currDispData); } - catch(Exception exc) + catch (Exception exc) { lgError($"Eccezione in processDisconnectedTask{Environment.NewLine}{exc}"); } @@ -144,7 +144,9 @@ namespace IOB_WIN_FORM.Iob } sw.Stop(); // fermo per una quota del tempo di attesa previsto - Task.Delay(vetoCheckSec - (int)sw.ElapsedMilliseconds + 20); + int nextWait = vetoCheckSec * 1000 - (int)sw.ElapsedMilliseconds + 20; + nextWait = nextWait < 0 ? 10 : nextWait; + Task.Delay(nextWait); } public override void startAdapter(bool resetQueue) @@ -168,8 +170,6 @@ namespace IOB_WIN_FORM.Iob lgDebug($"PING: tryConnect step 01 | connectionOk: {connectionOk}"); if (!connectionOk) { - //// resetto coda... - //QueuePing = new DataQueue("000", "QueuePing", false); // controllo che il ping sia stato tentato almeno pingTestSec fa... if (DateTime.Now.Subtract(lastPING).TotalSeconds > utils.CRI("pingTestSec")) { @@ -201,6 +201,7 @@ namespace IOB_WIN_FORM.Iob { // loggo no risposta ping ... lgError("PING KO"); + // 2026.05.19 aggiunta esecuzione disconnect queueInEnabCurr = true; processDisconnectedTask(); queueInEnabCurr = false; @@ -240,7 +241,7 @@ namespace IOB_WIN_FORM.Iob // controllo: se era spenta e risulta ping ok --> reset coda! if (B_input == 0 && pingOk) { - B_input = 1; + B_input = bInOn; QueuePing = new DataQueue(IOBConfFull.General.FilenameIOB, "QueuePing", false, redisMan); lgTrace($"QueuePing resetted on addTest"); }