Merge branch 'release/FixTimersOnClose_01'

This commit is contained in:
Samuele E. Locatelli
2025-12-01 10:45:15 +01:00
5 changed files with 208 additions and 206 deletions
-13
View File
@@ -50,10 +50,6 @@ namespace IOB_UT_NEXT
if (UseRedis)
{
Count = redisMan.redQueuePush(KeyName, item);
#if false
redisMan.redQueuePush(KeyName, item);
Count = (long)redisMan.redQueueCount(KeyName);
#endif
}
else
{
@@ -75,15 +71,6 @@ namespace IOB_UT_NEXT
answ = redisMan.redQueuePopAll(KeyName)
.Select(x => $"{x}")
.ToList();
#if false
Count = (int)redisMan.redQueueCount(KeyName);
// ciclo x prendere tutti...
while (Count > 0)
{
answ.Add(redisMan.redQueuePop(KeyName));
Count = (int)redisMan.redQueueCount(KeyName);
}
#endif
}
else
{
+204 -190
View File
@@ -39,6 +39,81 @@ namespace IOB_WIN_FORM
#endregion Public Fields
#region Protected Fields
protected static string baseUrl = @"https://liman.egalware.com/MP/IO/";
/// <summary>
/// Data-Ora prima apertura FORM...
/// </summary>
protected DateTime firstStart;
/// <summary>
/// Oggetto ultimo inviato stato IOB x REDIS
/// </summary>
protected IobWinStatus lastIobStatus = new IobWinStatus() { lastUpdate = DateTime.Now.AddHours(-1), lastDataOut = DateTime.Now.AddHours(-1) };
/// <summary>
/// Oggetto ultimo inviato stato MP-IO x REDIS
/// </summary>
protected ServerMpStatus lastSrvStatus = new ServerMpStatus();
/// <summary>
/// ultimo tentativo riavvio...
/// </summary>
protected DateTime lastStartTry;
/// <summary>
/// Generatore numeri random
/// </summary>
protected Random rndGen = new Random();
/// <summary>
/// Contatore campionamento memoria
/// </summary>
protected int sampleMemCount;
/// <summary>
/// Indica se inviare avvio adapter con FluxLog
/// </summary>
protected bool sendStartFLog = false;
/// <summary>
/// Temnpo attesa std in MS
/// </summary>
protected int waitRecMSec = 30000;
#endregion Protected Fields
#region Private Fields
/// <summary>
/// Contatore chiamate timers x debug timing
/// </summary>
private Dictionary<gatherCycle, int> TimersCycleCount = new Dictionary<gatherCycle, int>();
/// <summary>
/// Contatore durata exec x debug timing
/// </summary>
private Dictionary<gatherCycle, double> TimersCycleElaps = new Dictionary<gatherCycle, double>();
/// <summary>
/// Dizionario scadenza timers interni x esecuzione dei vari task a differente frequenza di chiamata
/// </summary>
private Dictionary<gatherCycle, DateTime> TimersVeto = new Dictionary<gatherCycle, DateTime>();
/// <summary>
/// Dizionario dei valori bloccati x evitare log eccessivo
/// </summary>
private Dictionary<string, DateTime> vetoLogError = new Dictionary<string, DateTime>();
/// <summary>
/// Periodo di veto log in minuti
/// </summary>
private int vetoPeriodMin = 15;
#endregion Private Fields
#region Public Constructors
/// <summary>
@@ -149,6 +224,12 @@ namespace IOB_WIN_FORM
#endregion Public Constructors
#region Private Delegates
private delegate void SafeCallDelegate(string text);
#endregion Private Delegates
#region Public Properties
public long alQueueLen
@@ -735,6 +816,115 @@ namespace IOB_WIN_FORM
#endregion Public Properties
#region Protected Properties
/// <summary>
/// Valore protected comunicazione PLC
/// </summary>
protected bool _commPlcActive { get; set; } = false;
/// <summary>
/// Valore protetto stato comunicazione
/// </summary>
protected int _commSrvActive { get; set; } = 0;
/// <summary>
/// Valore protected semaforo IN
/// </summary>
protected Semaforo _sIN { get; set; } = Semaforo.ND;
/// <summary>
/// Valore protected semaforo OUT
/// </summary>
protected Semaforo _sOUT { get; set; } = Semaforo.ND;
/// <summary>
/// Codice IOB della macchina cui connettersi (x scegliere corretto file di conf...)
/// </summary>
protected string CurrIOB { get; set; }
protected int delayShowLogMs { get; set; } = utils.CRI("delayShowLogMs");
/// <summary>
/// Dictionary dei divieti del datamonitor
/// </summary>
protected Dictionary<int, DateTime> dMonDisplVetoVeto { get; set; } = new Dictionary<int, DateTime>();
/// <summary>
/// array degli oggetti datamonitor da mostrare
/// </summary>
protected Dictionary<int, List<string>> dMonValues { get; set; } = new Dictionary<int, List<string>>();
/// <summary>
/// Veto a NUOVE scritture in COUNTER...
/// </summary>
protected DateTime logCounterVeto { get; set; } = DateTime.Now;
/// <summary>
/// Lista String da mostrare quale TaskLog corrente...
/// </summary>
protected List<string> logTaskString { get; set; } = new List<string>();
/// <summary>
/// Lista String da mostrare quale WatchLog corrente...
/// </summary>
protected ConcurrentQueue<string> logWatchString { get; set; } = new ConcurrentQueue<string>();
/// <summary>
/// Veto a NUOVE scritture in logWatch...
/// </summary>
protected DateTime logWatchWriteVeto { get; set; } = DateTime.Now;
protected long maxAlQueue { get; set; }
protected long maxEvQueue { get; set; }
protected long maxFlQueue { get; set; }
protected long maxMsQueue { get; set; }
protected long maxRwTrQueue { get; set; }
protected long maxUlQueue { get; set; }
protected long qAlLen { get; set; }
protected long qEvLen { get; set; }
protected long qFlLen { get; set; }
protected long qMsLen { get; set; }
protected long qRTrLen { get; set; }
protected long qUlLen { get; set; }
protected long totQueue
{
get
{
return qEvLen + qFlLen + qAlLen + qMsLen + qUlLen;
}
}
/// <summary>
/// URL per salvare i file dell'IOB (SENZA IOB)
/// </summary>
protected string urlUploadFile
{
get => $"http://{IOBConfFull.MapoMes.IpAddr}{IOBConfFull.MapoMes.BaseAppUrl}IOB/uploadFile/";
}
/// <summary>
/// URL per salvare i file dell'IOB su CLOUD (SENZA IOB)
/// </summary>
protected string urlUploadFileCloud
{
get => $"{baseUrl}IOB/uploadFile/";
}
#endregion Protected Properties
#region Public Methods
/// <summary>
@@ -948,161 +1138,6 @@ namespace IOB_WIN_FORM
#endregion Public Methods
#region Protected Fields
protected static string baseUrl = @"https://liman.egalware.com/MP/IO/";
/// <summary>
/// Data-Ora prima apertura FORM...
/// </summary>
protected DateTime firstStart;
/// <summary>
/// Oggetto ultimo inviato stato IOB x REDIS
/// </summary>
protected IobWinStatus lastIobStatus = new IobWinStatus() { lastUpdate = DateTime.Now.AddHours(-1), lastDataOut = DateTime.Now.AddHours(-1) };
/// <summary>
/// Oggetto ultimo inviato stato MP-IO x REDIS
/// </summary>
protected ServerMpStatus lastSrvStatus = new ServerMpStatus();
/// <summary>
/// ultimo tentativo riavvio...
/// </summary>
protected DateTime lastStartTry;
/// <summary>
/// Generatore numeri random
/// </summary>
protected Random rndGen = new Random();
/// <summary>
/// Contatore campionamento memoria
/// </summary>
protected int sampleMemCount;
/// <summary>
/// Indica se inviare avvio adapter con FluxLog
/// </summary>
protected bool sendStartFLog = false;
/// <summary>
/// Temnpo attesa std in MS
/// </summary>
protected int waitRecMSec = 30000;
#endregion Protected Fields
#region Protected Properties
/// <summary>
/// Valore protected comunicazione PLC
/// </summary>
protected bool _commPlcActive { get; set; } = false;
/// <summary>
/// Valore protetto stato comunicazione
/// </summary>
protected int _commSrvActive { get; set; } = 0;
/// <summary>
/// Valore protected semaforo IN
/// </summary>
protected Semaforo _sIN { get; set; } = Semaforo.ND;
/// <summary>
/// Valore protected semaforo OUT
/// </summary>
protected Semaforo _sOUT { get; set; } = Semaforo.ND;
/// <summary>
/// Codice IOB della macchina cui connettersi (x scegliere corretto file di conf...)
/// </summary>
protected string CurrIOB { get; set; }
protected int delayShowLogMs { get; set; } = utils.CRI("delayShowLogMs");
/// <summary>
/// Dictionary dei divieti del datamonitor
/// </summary>
protected Dictionary<int, DateTime> dMonDisplVetoVeto { get; set; } = new Dictionary<int, DateTime>();
/// <summary>
/// array degli oggetti datamonitor da mostrare
/// </summary>
protected Dictionary<int, List<string>> dMonValues { get; set; } = new Dictionary<int, List<string>>();
/// <summary>
/// Veto a NUOVE scritture in COUNTER...
/// </summary>
protected DateTime logCounterVeto { get; set; } = DateTime.Now;
/// <summary>
/// Lista String da mostrare quale TaskLog corrente...
/// </summary>
protected List<string> logTaskString { get; set; } = new List<string>();
/// <summary>
/// Lista String da mostrare quale WatchLog corrente...
/// </summary>
protected ConcurrentQueue<string> logWatchString { get; set; } = new ConcurrentQueue<string>();
/// <summary>
/// Veto a NUOVE scritture in logWatch...
/// </summary>
protected DateTime logWatchWriteVeto { get; set; } = DateTime.Now;
protected long maxAlQueue { get; set; }
protected long maxEvQueue { get; set; }
protected long maxFlQueue { get; set; }
protected long maxMsQueue { get; set; }
protected long maxRwTrQueue { get; set; }
protected long maxUlQueue { get; set; }
protected long qAlLen { get; set; }
protected long qEvLen { get; set; }
protected long qFlLen { get; set; }
protected long qMsLen { get; set; }
protected long qRTrLen { get; set; }
protected long qUlLen { get; set; }
protected long totQueue
{
get
{
return qEvLen + qFlLen + qAlLen + qMsLen + qUlLen;
}
}
/// <summary>
/// URL per salvare i file dell'IOB (SENZA IOB)
/// </summary>
protected string urlUploadFile
{
get => $"http://{IOBConfFull.MapoMes.IpAddr}{IOBConfFull.MapoMes.BaseAppUrl}IOB/uploadFile/";
}
/// <summary>
/// URL per salvare i file dell'IOB su CLOUD (SENZA IOB)
/// </summary>
protected string urlUploadFileCloud
{
get => $"{baseUrl}IOB/uploadFile/";
}
#endregion Protected Properties
#region Protected Methods
protected override void Dispose(bool disposing)
@@ -1227,6 +1262,12 @@ namespace IOB_WIN_FORM
ttForceSend.SetToolTip(this.chkForceDequeue, "Forza invio eventi allo stop");
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
CloseTimers();
base.OnFormClosing(e);
}
/// <summary>
/// impostazione valori defaults
/// </summary>
@@ -1269,41 +1310,6 @@ namespace IOB_WIN_FORM
#endregion Protected Methods
#region Private Fields
/// <summary>
/// Contatore chiamate timers x debug timing
/// </summary>
private Dictionary<gatherCycle, int> TimersCycleCount = new Dictionary<gatherCycle, int>();
/// <summary>
/// Contatore durata exec x debug timing
/// </summary>
private Dictionary<gatherCycle, double> TimersCycleElaps = new Dictionary<gatherCycle, double>();
/// <summary>
/// Dizionario scadenza timers interni x esecuzione dei vari task a differente frequenza di chiamata
/// </summary>
private Dictionary<gatherCycle, DateTime> TimersVeto = new Dictionary<gatherCycle, DateTime>();
/// <summary>
/// Dizionario dei valori bloccati x evitare log eccessivo
/// </summary>
private Dictionary<string, DateTime> vetoLogError = new Dictionary<string, DateTime>();
/// <summary>
/// Periodo di veto log in minuti
/// </summary>
private int vetoPeriodMin = 15;
#endregion Private Fields
#region Private Delegates
private delegate void SafeCallDelegate(string text);
#endregion Private Delegates
#region Private Methods
private void btnForceAutoOdl_Click(object sender, EventArgs e)
@@ -1450,6 +1456,14 @@ namespace IOB_WIN_FORM
fermaTutto(true, false, true, false);
}
private void CloseTimers()
{
displTimer?.Stop();
displTimer?.Dispose();
gather?.Stop();
gather?.Dispose();
}
private void displTimer_Tick(object sender, EventArgs e)
{
}
-1
View File
@@ -5352,7 +5352,6 @@ namespace IOB_WIN_FORM.Iob
QueueIN = new DataQueue(codIob, "QueueIN", useRedis, redisMan);
// no coda redis
QueueFLog = new DataQueue(codIob, "QueueFLog", false, redisMan);
//QueueFLog = new DataQueue(codIob, "QueueFLog", useRedis, redisMan);
QueueMessages = new DataQueue(codIob, "QueueMessages", false, redisMan);
QueueRawTransf = new DataQueue(codIob, "QueueRawTransf", false, redisMan);
QueueULog = new DataQueue(codIob, "QueueULog", false, redisMan);
+3
View File
@@ -14,6 +14,7 @@ using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Timers;
using System.Windows.Forms;
namespace IOB_WIN_FORM
@@ -496,6 +497,8 @@ namespace IOB_WIN_FORM
protected override void OnFormClosing(FormClosingEventArgs e)
{
MainTimer?.Stop();
MainTimer?.Dispose();
closeActiveChild();
base.OnFormClosing(e);
}
+1 -2
View File
@@ -20,8 +20,7 @@ namespace IOB_WIN_SIEMENS.IobSiemens
* - basasto su SIEMENS
* - S7 testato vers 300 e 1200
* - attenzione conf rack/slot x varie serie controlli
* - necessità apertura metodi pu/get
*
* - necessità apertura metodi put/get
* -------------------------------------------------------------------------------- */
#region Public Fields