diff --git a/IOB-UT-NEXT/DataQueue.cs b/IOB-UT-NEXT/DataQueue.cs index 66ae460f..4b8ecd32 100644 --- a/IOB-UT-NEXT/DataQueue.cs +++ b/IOB-UT-NEXT/DataQueue.cs @@ -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 { diff --git a/IOB-WIN-FORM/AdapterForm.cs b/IOB-WIN-FORM/AdapterForm.cs index 8813d534..c9837d98 100644 --- a/IOB-WIN-FORM/AdapterForm.cs +++ b/IOB-WIN-FORM/AdapterForm.cs @@ -39,6 +39,81 @@ namespace IOB_WIN_FORM #endregion Public Fields + #region Protected Fields + + protected static string baseUrl = @"https://liman.egalware.com/MP/IO/"; + + /// + /// Data-Ora prima apertura FORM... + /// + protected DateTime firstStart; + + /// + /// Oggetto ultimo inviato stato IOB x REDIS + /// + protected IobWinStatus lastIobStatus = new IobWinStatus() { lastUpdate = DateTime.Now.AddHours(-1), lastDataOut = DateTime.Now.AddHours(-1) }; + + /// + /// Oggetto ultimo inviato stato MP-IO x REDIS + /// + protected ServerMpStatus lastSrvStatus = new ServerMpStatus(); + + /// + /// ultimo tentativo riavvio... + /// + protected DateTime lastStartTry; + + /// + /// Generatore numeri random + /// + protected Random rndGen = new Random(); + + /// + /// Contatore campionamento memoria + /// + protected int sampleMemCount; + + /// + /// Indica se inviare avvio adapter con FluxLog + /// + protected bool sendStartFLog = false; + + /// + /// Temnpo attesa std in MS + /// + protected int waitRecMSec = 30000; + + #endregion Protected Fields + + #region Private Fields + + /// + /// Contatore chiamate timers x debug timing + /// + private Dictionary TimersCycleCount = new Dictionary(); + + /// + /// Contatore durata exec x debug timing + /// + private Dictionary TimersCycleElaps = new Dictionary(); + + /// + /// Dizionario scadenza timers interni x esecuzione dei vari task a differente frequenza di chiamata + /// + private Dictionary TimersVeto = new Dictionary(); + + /// + /// Dizionario dei valori bloccati x evitare log eccessivo + /// + private Dictionary vetoLogError = new Dictionary(); + + /// + /// Periodo di veto log in minuti + /// + private int vetoPeriodMin = 15; + + #endregion Private Fields + #region Public Constructors /// @@ -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 + + /// + /// Valore protected comunicazione PLC + /// + protected bool _commPlcActive { get; set; } = false; + + /// + /// Valore protetto stato comunicazione + /// + protected int _commSrvActive { get; set; } = 0; + + /// + /// Valore protected semaforo IN + /// + protected Semaforo _sIN { get; set; } = Semaforo.ND; + + /// + /// Valore protected semaforo OUT + /// + protected Semaforo _sOUT { get; set; } = Semaforo.ND; + + /// + /// Codice IOB della macchina cui connettersi (x scegliere corretto file di conf...) + /// + protected string CurrIOB { get; set; } + + protected int delayShowLogMs { get; set; } = utils.CRI("delayShowLogMs"); + + /// + /// Dictionary dei divieti del datamonitor + /// + protected Dictionary dMonDisplVetoVeto { get; set; } = new Dictionary(); + + /// + /// array degli oggetti datamonitor da mostrare + /// + protected Dictionary> dMonValues { get; set; } = new Dictionary>(); + + /// + /// Veto a NUOVE scritture in COUNTER... + /// + protected DateTime logCounterVeto { get; set; } = DateTime.Now; + + /// + /// Lista String da mostrare quale TaskLog corrente... + /// + protected List logTaskString { get; set; } = new List(); + + /// + /// Lista String da mostrare quale WatchLog corrente... + /// + protected ConcurrentQueue logWatchString { get; set; } = new ConcurrentQueue(); + + /// + /// Veto a NUOVE scritture in logWatch... + /// + 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; + } + } + + /// + /// URL per salvare i file dell'IOB (SENZA IOB) + /// + protected string urlUploadFile + { + get => $"http://{IOBConfFull.MapoMes.IpAddr}{IOBConfFull.MapoMes.BaseAppUrl}IOB/uploadFile/"; + } + + /// + /// URL per salvare i file dell'IOB su CLOUD (SENZA IOB) + /// + protected string urlUploadFileCloud + { + get => $"{baseUrl}IOB/uploadFile/"; + } + + #endregion Protected Properties + #region Public Methods /// @@ -948,161 +1138,6 @@ namespace IOB_WIN_FORM #endregion Public Methods - #region Protected Fields - - protected static string baseUrl = @"https://liman.egalware.com/MP/IO/"; - - /// - /// Data-Ora prima apertura FORM... - /// - protected DateTime firstStart; - - /// - /// Oggetto ultimo inviato stato IOB x REDIS - /// - protected IobWinStatus lastIobStatus = new IobWinStatus() { lastUpdate = DateTime.Now.AddHours(-1), lastDataOut = DateTime.Now.AddHours(-1) }; - - /// - /// Oggetto ultimo inviato stato MP-IO x REDIS - /// - protected ServerMpStatus lastSrvStatus = new ServerMpStatus(); - - /// - /// ultimo tentativo riavvio... - /// - protected DateTime lastStartTry; - - /// - /// Generatore numeri random - /// - protected Random rndGen = new Random(); - - /// - /// Contatore campionamento memoria - /// - protected int sampleMemCount; - - /// - /// Indica se inviare avvio adapter con FluxLog - /// - protected bool sendStartFLog = false; - - /// - /// Temnpo attesa std in MS - /// - protected int waitRecMSec = 30000; - - #endregion Protected Fields - - #region Protected Properties - - /// - /// Valore protected comunicazione PLC - /// - protected bool _commPlcActive { get; set; } = false; - - /// - /// Valore protetto stato comunicazione - /// - protected int _commSrvActive { get; set; } = 0; - - /// - /// Valore protected semaforo IN - /// - protected Semaforo _sIN { get; set; } = Semaforo.ND; - - /// - /// Valore protected semaforo OUT - /// - protected Semaforo _sOUT { get; set; } = Semaforo.ND; - - /// - /// Codice IOB della macchina cui connettersi (x scegliere corretto file di conf...) - /// - protected string CurrIOB { get; set; } - - protected int delayShowLogMs { get; set; } = utils.CRI("delayShowLogMs"); - - /// - /// Dictionary dei divieti del datamonitor - /// - protected Dictionary dMonDisplVetoVeto { get; set; } = new Dictionary(); - - /// - /// array degli oggetti datamonitor da mostrare - /// - protected Dictionary> dMonValues { get; set; } = new Dictionary>(); - - /// - /// Veto a NUOVE scritture in COUNTER... - /// - protected DateTime logCounterVeto { get; set; } = DateTime.Now; - - /// - /// Lista String da mostrare quale TaskLog corrente... - /// - protected List logTaskString { get; set; } = new List(); - - /// - /// Lista String da mostrare quale WatchLog corrente... - /// - protected ConcurrentQueue logWatchString { get; set; } = new ConcurrentQueue(); - - /// - /// Veto a NUOVE scritture in logWatch... - /// - 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; - } - } - - /// - /// URL per salvare i file dell'IOB (SENZA IOB) - /// - protected string urlUploadFile - { - get => $"http://{IOBConfFull.MapoMes.IpAddr}{IOBConfFull.MapoMes.BaseAppUrl}IOB/uploadFile/"; - } - - /// - /// URL per salvare i file dell'IOB su CLOUD (SENZA IOB) - /// - 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); + } + /// /// impostazione valori defaults /// @@ -1269,41 +1310,6 @@ namespace IOB_WIN_FORM #endregion Protected Methods - #region Private Fields - - /// - /// Contatore chiamate timers x debug timing - /// - private Dictionary TimersCycleCount = new Dictionary(); - - /// - /// Contatore durata exec x debug timing - /// - private Dictionary TimersCycleElaps = new Dictionary(); - - /// - /// Dizionario scadenza timers interni x esecuzione dei vari task a differente frequenza di chiamata - /// - private Dictionary TimersVeto = new Dictionary(); - - /// - /// Dizionario dei valori bloccati x evitare log eccessivo - /// - private Dictionary vetoLogError = new Dictionary(); - - /// - /// Periodo di veto log in minuti - /// - 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) { } diff --git a/IOB-WIN-FORM/Iob/Generic.Protected.cs b/IOB-WIN-FORM/Iob/Generic.Protected.cs index d1e028fd..4a6c5310 100644 --- a/IOB-WIN-FORM/Iob/Generic.Protected.cs +++ b/IOB-WIN-FORM/Iob/Generic.Protected.cs @@ -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); diff --git a/IOB-WIN-FORM/MainForm.cs b/IOB-WIN-FORM/MainForm.cs index dfb891cf..c527ac6a 100644 --- a/IOB-WIN-FORM/MainForm.cs +++ b/IOB-WIN-FORM/MainForm.cs @@ -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); } diff --git a/IOB-WIN-SIEMENS/IobSiemens/Siemens.cs b/IOB-WIN-SIEMENS/IobSiemens/Siemens.cs index 7072cfa2..57699ec4 100644 --- a/IOB-WIN-SIEMENS/IobSiemens/Siemens.cs +++ b/IOB-WIN-SIEMENS/IobSiemens/Siemens.cs @@ -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