diff --git a/IOB-UT-NEXT/DataQueue.cs b/IOB-UT-NEXT/DataQueue.cs
index 1dfed082..37b69eea 100644
--- a/IOB-UT-NEXT/DataQueue.cs
+++ b/IOB-UT-NEXT/DataQueue.cs
@@ -1,4 +1,5 @@
using StackExchange.Redis;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
@@ -8,7 +9,7 @@ namespace IOB_UT_NEXT
///
/// Classe gestione code, a seconda della conf come LIST redis o come concurrent queue in memoria
///
- public class DataQueue
+ public class DataQueue : IDisposable
{
#region Public Fields
@@ -23,14 +24,23 @@ namespace IOB_UT_NEXT
UseRedis = useRedis;
CodIOB = codIOB;
QueueName = qName;
- redisMan = redisCacheMan;
- KeyName = redisMan.redHash($"IOB:QUEUE:{CodIOB}:{QueueName}");
+ if (UseRedis)
+ {
+ redisMan = redisCacheMan;
+ KeyName = redisMan.redHash($"IOB:QUEUE:{CodIOB}:{QueueName}");
+ }
}
#endregion Public Constructors
#region Public Methods
+ public void Dispose()
+ {
+ redisMan = null;
+ KeyName = "";
+ }
+
///
/// Accodamento elemento
///
@@ -42,7 +52,7 @@ namespace IOB_UT_NEXT
Count = redisMan.redQueuePush(KeyName, item);
#if false
redisMan.redQueuePush(KeyName, item);
- Count = (long)redisMan.redQueueCount(KeyName);
+ Count = (long)redisMan.redQueueCount(KeyName);
#endif
}
else
@@ -62,7 +72,7 @@ namespace IOB_UT_NEXT
if (UseRedis)
{
// recupero in blocco...
- answ = redisMan.redQueuePopAll(KeyName)
+ answ = redisMan.redQueuePopAll(KeyName)
.Select(x => $"{x}")
.ToList();
#if false
@@ -72,7 +82,7 @@ namespace IOB_UT_NEXT
{
answ.Add(redisMan.redQueuePop(KeyName));
Count = (int)redisMan.redQueueCount(KeyName);
- }
+ }
#endif
}
else
@@ -120,20 +130,16 @@ namespace IOB_UT_NEXT
private string QueueName = "NA";
+ ///
+ /// Oggetto connessione REDIS
+ ///
+ private RedisIobCache redisMan;
+
///
/// Indica se usare redis come datastore vs memoria
///
private bool UseRedis = false;
#endregion Private Fields
-
- #region Private Properties
-
- ///
- /// Oggetto connessione REDIS
- ///
- private RedisIobCache redisMan; // { get; set; } = new RedisIobCache();
-
- #endregion Private Properties
}
}
\ No newline at end of file
diff --git a/IOB-UT-NEXT/RedisMan.cs b/IOB-UT-NEXT/RedisMan.cs
index d7d9b1ad..beef51d8 100644
--- a/IOB-UT-NEXT/RedisMan.cs
+++ b/IOB-UT-NEXT/RedisMan.cs
@@ -1129,31 +1129,6 @@ namespace IOB_UT_NEXT
return answ;
}
- ///
- /// Restituisce info dei server connessi...
- ///
- ///
- public IServer[] redServInfo()
- {
- IServer[] answ = new IServer[1];
- try
- {
- answ = new IServer[connRedisAdmin.GetEndPoints().Length];
- int i = 0;
- foreach (var ep in connRedisAdmin.GetEndPoints())
- {
- var server = connRedisAdmin.GetServer(ep);
- answ[i] = server;
- i++;
- }
- }
- catch (Exception exc)
- {
- Logging.Instance.Error($"redServInfo {exc}");
- }
- return answ;
- }
-
///
/// Conteggio elementi in QUEUE (LIFO)
///
@@ -1469,36 +1444,6 @@ namespace IOB_UT_NEXT
///
private Dictionary LastKeySave = new Dictionary();
-#if false
- ///
- /// Connessione lazy a redis...
- ///
- private Lazy lazyConnection = new Lazy(() =>
- {
- string RedisConn = baseUtils.CRS("RedisConn");
- if (string.IsNullOrEmpty(RedisConn))
- {
- RedisConn = "localhost,abortConnect=false,ssl=false";
- }
-
- return ConnectionMultiplexer.Connect(RedisConn);
- });
-
- ///
- /// Connessione lazy a redis...
- ///
- private Lazy lazyConnectionAdmin = new Lazy(() =>
- {
- string RedisConnAdmin = baseUtils.CRS("RedisConnAdmin");
- if (string.IsNullOrEmpty(RedisConnAdmin))
- {
- RedisConnAdmin = "localhost,abortConnect=false,ssl=false,allowAdmin=true";
- }
-
- return ConnectionMultiplexer.Connect(RedisConnAdmin);
- });
-#endif
-
#endregion Private Fields
#region Private Properties
@@ -1517,27 +1462,6 @@ namespace IOB_UT_NEXT
/// Oggetto statico connessione redis
///
private ConnectionMultiplexer connRedis { get; set; }
-#if false
- {
- get
- {
- return lazyConnection.Value;
- }
- }
-#endif
-
- ///
- /// Oggetto statico connessione redis
- ///
- private ConnectionMultiplexer connRedisAdmin { get; set; }
-#if false
- {
- get
- {
- return lazyConnectionAdmin.Value;
- }
-}
-#endif
#endregion Private Properties
@@ -1587,46 +1511,8 @@ namespace IOB_UT_NEXT
}
connRedis = ConnectionMultiplexer.Connect(RedisConn);
Logging.Instance.Info($"Apertura di un Redis Multiplexer");
-
- // initi obj admin
- string RedisConnAdmin = baseUtils.CRS("RedisConnAdmin");
- if (string.IsNullOrEmpty(RedisConnAdmin))
- {
- RedisConnAdmin = "localhost,abortConnect=false,ssl=false,allowAdmin=true";
- }
- connRedisAdmin = ConnectionMultiplexer.Connect(RedisConnAdmin);
- Logging.Instance.Info($"Apertura di un Redis Multiplexer Admin");
}
#endregion Private Methods
-
-#if false
- ///
- /// Incremento conteggio di un valore dentro una hash
- ///
- /// chiave
- /// valore con conteggio da tracciare
- /// scadenza preimpostata hash datetime, se null NON scade
- ///
- public bool redIncrHashCount(string hashKey, string hashField, DateTime? hashExpire)
- {
- bool answ = false;
- // cerco se ci sia valore in redis...
- try
- {
- RedisKey chiave = hashKey;
- cache.HashIncrement(chiave, hashField, 1);
- if (hashExpire != null)
- {
- cache.KeyExpire(chiave, hashExpire);
- }
- }
- catch (Exception exc)
- {
- Logging.Instance.Error($"redIncrHashCount {exc}");
- }
- return answ;
- }
-#endif
}
}
\ No newline at end of file
diff --git a/IOB-WIN-FORM/AdapterForm.cs b/IOB-WIN-FORM/AdapterForm.cs
index e36ab976..ffc3a5f7 100644
--- a/IOB-WIN-FORM/AdapterForm.cs
+++ b/IOB-WIN-FORM/AdapterForm.cs
@@ -1,6 +1,7 @@
using IOB_UT_NEXT;
using IOB_UT_NEXT.Config;
using MapoSDK;
+using Newtonsoft.Json;
using NLog;
using System;
using System.Collections.Concurrent;
@@ -10,6 +11,8 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
+using System.Security.Policy;
+using System.Text;
using System.Threading;
using System.Windows.Forms;
@@ -95,10 +98,12 @@ namespace IOB_WIN_FORM
if (File.Exists(defConfFilePathYaml))
{
loadYamlFile(defConfFilePathYaml);
+ sendConfFile(defConfFilePathYaml);
}
else
{
loadIniFile(defConfFilePath);
+ sendConfFile(defConfFilePath);
}
lgInfo("INI LOADED");
}
@@ -165,6 +170,89 @@ namespace IOB_WIN_FORM
displayTaskAndLog("Main Form OK", true);
}
+ ///
+ /// Invio per backup contenuto file conf
+ ///
+ ///
+ private void sendConfFile(string confFilePath)
+ {
+ string answ = "";
+ fileEmbed objFiles = new fileEmbed();
+ try
+ {
+ if (File.Exists(confFilePath))
+ {
+ string fileContent = System.IO.File.ReadAllText($"{confFilePath}");
+ smallFile currFile = new smallFile()
+ {
+ fileName = confFilePath,
+ content = fileContent.Replace("\r\n", Environment.NewLine)
+ };
+ objFiles.fileList.Add(currFile);
+ // serializzo
+ string rawData = JsonConvert.SerializeObject(objFiles);
+ // mod 2022.12.30: verifico se diverso da copia redis ultimo MD5 del set
+ // salvato, nel caso NON invio...
+ bool needSend = false;
+ using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
+ {
+ var hash = md5.ComputeHash(Encoding.ASCII.GetBytes(rawData));
+ string newMD5 = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
+ string redKey = redisMan.redHash($"IOB:ConfFileMD5:{CurrIOB}");
+ var rawVal = redisMan.getRSV(redKey);
+ // verifico uguaglianza MD5...
+ if (string.IsNullOrEmpty(rawVal) || !newMD5.Equals(rawVal))
+ {
+ needSend = true;
+ int CacheConfToCloudDuratHour = utils.CRI("CacheConfToCloudDuratHour");
+ // calcolo attesa con errore random -/+ 10%
+ int ttlSec = 60 * 60 * CacheConfToCloudDuratHour * rndGen.Next(900, 1100) / 1000;
+ redisMan.setRSV(redKey, newMD5, ttlSec);
+ }
+ }
+ // invio solo se necessario
+ if (needSend)
+ {
+ if (utils.CRB("ConfToCloud"))
+ {
+ // invio su cloud...
+ answ = utils.callUrlAsync($"{urlUploadFileCloud}{CurrIOB}", rawData);
+ }
+ else
+ {
+ // provo invio locale
+ answ = utils.callUrl($"{urlUploadFile}{CurrIOB}", rawData);
+ // se va male invio cloud...
+ if (answ.ToUpper() != "OK")
+ {
+ answ = utils.callUrlAsync($"{urlUploadFileCloud}{CurrIOB}", rawData);
+ }
+ }
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ lgError($"Eccezione in upload IOB conf files{Environment.NewLine}{exc}");
+ }
+ }
+
+ ///
+ /// URL per salvare i file dell'IOB su CLOUD (SENZA IOB)
+ ///
+ protected string urlUploadFileCloud
+ {
+ get => $"{baseUrl}IOB/uploadFile/";
+ }
+ ///
+ /// URL per salvare i file dell'IOB (SENZA IOB)
+ ///
+ protected string urlUploadFile
+ {
+ get => $"http://{IOBConfFull.MapoMes.IpAddr}{IOBConfFull.MapoMes.BaseAppUrl}IOB/uploadFile/";
+ }
+ protected static string baseUrl = @"https://liman.egalware.com/MP/IO/";
+
#endregion Public Constructors
#region Public Properties
@@ -1267,644 +1355,644 @@ namespace IOB_WIN_FORM
private delegate void SafeCallDelegate(string text);
- #endregion Private Delegates
+ #endregion Private Delegates
- #region Private Methods
+ #region Private Methods
- private void btnForceAutoOdl_Click(object sender, EventArgs e)
+ private void btnForceAutoOdl_Click(object sender, EventArgs e)
+ {
+ iobObj.forceResetOdl();
+ }
+
+ private void BtnOpenLog_Click(object sender, EventArgs e)
+ {
+ try
{
- iobObj.forceResetOdl();
+ string logPath = $"{System.AppDomain.CurrentDomain.BaseDirectory}logs\\{CurrIOB}\\{DateTime.Today:yyyy-MM-dd}.log";
+ Process.Start(logPath);
}
-
- private void BtnOpenLog_Click(object sender, EventArgs e)
+ catch (Exception exc)
{
+ lgError($"Eccezione in show log (MAIN):{Environment.NewLine}{exc}");
+ }
+ }
+
+ private void BtnSendPLC_Click(object sender, EventArgs e)
+ {
+ // invia a MES il parametro selezionato (es ART / ODL / PRG NAME, come task2exe..)
+ Dictionary forcedTask = new Dictionary();
+ // guardo i parametri...
+ if (!string.IsNullOrEmpty(txtValue.Text))
+ {
+ forcedTask.Add(cmbParamValues.SelectedValue.ToString(), txtValue.Text);
+ }
+ // chiedo esecuzione task!
+ iobObj.processTask(forcedTask);
+ chkEdit.Checked = false;
+ toggleEditMes2Plc();
+ }
+
+ private void checkAssignSize()
+ {
+ int valSize = 0;
+ int.TryParse(txtMReadSize.Text, out valSize);
+ // verifico sia valida con lenght array...
+ int maxSize = iobObj.RawInput.Length - iobObj.RawDataInputStart;
+ valSize = valSize > maxSize ? maxSize : valSize;
+ // riporto
+ iobObj.RawDataInputSize = valSize;
+ }
+
+ private void checkAssignStart()
+ {
+ int valStart = 0;
+ int.TryParse(txtMReadStart.Text, out valStart);
+ // verifico sia valida con start/lenght array...
+ int maxStart = iobObj.RawInput.Length - 1;
+ valStart = valStart > maxStart ? maxStart : valStart;
+ // riporto
+ iobObj.RawDataInputStart = valStart;
+ }
+
+ private void checkEditMes2Plc()
+ {
+ cmbParamValues.Enabled = enableEditMes2Plc;
+ txtValue.Enabled = enableEditMes2Plc;
+ if (enableEditMes2Plc)
+ {
+ // aggiorno (se possibile) i parametri selezionabili...
+ fixComboParameters();
+ }
+ }
+
+ ///
+ /// Verifica scadenza task
+ ///
+ ///
+ private void checkScad()
+ {
+ DateTime adesso = DateTime.Now;
+ bool sendDone = false;
+ // ciclo su tutti i timers enum superiori a VHF
+ var priorities = (gatherCycle[])Enum.GetValues(typeof(gatherCycle));
+ // prendo solo > VHF e ordino discendenti x dare priorità ai più rari...
+ var ordered = priorities.Where(x => x > gatherCycle.VHF).OrderByDescending(x => x);
+ foreach (gatherCycle item in ordered)
+ {
+ if (TimersVeto.ContainsKey(item))
+ {
+ if (TimersVeto[item] <= adesso)
+ {
+ // se non ho già processato a questo giro...
+ if (!sendDone)
+ {
+ TimersCycleCount[item]++;
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+ // se scaduto processo!
+ iobObj.getAndSend(item);
+ sendDone = true;
+ sw.Stop();
+ TimersCycleElaps[item] += sw.Elapsed.TotalMilliseconds;
+ // metto nuova scadenza perturbata 10%
+ TimersVeto[item] = adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0.1));
+ }
+ // log + reset se ho contato ALMENO 100 exec o il tempo totale supera 1000msec
+ int limMs = 10000;
+ if (TimersCycleCount[item] >= 100 || (TimersCycleElaps.ContainsKey(item) && TimersCycleElaps[item] > limMs))
+ {
+ var nCount = TimersCycleCount[item];
+ nCount = nCount > 0 ? nCount : 1;
+ lgDebug($"checkScad | {item} | {TimersCycleElaps[item] / nCount:F1}ms x {nCount}");
+ TimersCycleCount[item] = 0;
+ TimersCycleElaps[item] = 0;
+ }
+ }
+ }
+ else
+ {
+ TimersVeto.Add(item, adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0)));
+ TimersCycleCount.Add(item, 0);
+ }
+ }
+ }
+
+ private void checkSampleMem()
+ {
+ // decremento contatore...
+ sampleMemCount--;
+ if (sampleMemCount <= 0)
+ {
+ sampleMemCount = utils.CRI("sampleMemCount");
+ // avvio fase raccolta dati e invio con adapter
+ iobObj.saveMemDump(dumpType.SAMPLE);
+ }
+ }
+
+ private void ChkEdit_CheckedChanged(object sender, EventArgs e)
+ {
+ toggleEditMes2Plc();
+ }
+
+ ///
+ /// Chiusura adapter
+ ///
+ private void closeAdapter()
+ {
+ lgDebug("closeAdapter | true | false | true | false");
+ fermaTutto(true, false, true, false);
+ }
+
+ private void displTimer_Tick(object sender, EventArgs e)
+ {
+ }
+
+ ///
+ /// Ferma tutti i componenti adapter + update buttons
+ ///
+ ///
+ /// indica se fermare il timer (gather) principale (solo se non si chiude)
+ ///
+ /// indica se tentare di riconnettersi
+ /// indica se sia richiesto di SVUOTARE le code delle info
+ /// indica se si debba aggiornare la form (no se si sta chiudendo...)
+ private void fermaTutto(bool stopTimer, bool tryRestart, bool forceDequeue, bool updateForm)
+ {
+ try
+ {
+ iobObj.stopAdapter(tryRestart, forceDequeue);
+
+ stop.Enabled = false;
+ start.Enabled = true;
+ restart.Enabled = false;
+
+ if (stopTimer)
+ {
+ gather.Enabled = false;
+ }
+
+ newDisplayData currDispData = new newDisplayData();
+ currDispData.semIn = Semaforo.SS;
+ currDispData.semOut = Semaforo.SS;
+ if (updateForm)
+ {
+ updateFormDisplay(currDispData);
+ }
+ }
+ catch (Exception exc)
+ {
+ lgError($"Errore in chiusura:{Environment.NewLine}{exc}");
+ }
+ }
+
+ private void fixComboParameters()
+ {
+ if (iobObj != null)
+ {
+ if (iobObj.memMap != null)
+ {
+ if (iobObj.memMap.mMapWrite != null)
+ {
+ if (iobObj.memMap.mMapWrite.Count > 0)
+ {
+ var oldParams = cmbParamValues.DataSource;
+ List parametri = new List();
+ foreach (var item in iobObj.memMap.mMapWrite)
+ {
+ parametri.Add(item.Key);
+ }
+ // salvo selezione
+ int oldIdx = cmbParamValues.SelectedIndex;
+ // riassegno e ri-seleziono
+ cmbParamValues.DataSource = parametri;
+ cmbParamValues.SelectedIndex = oldIdx >= 0 ? oldIdx : 0;
+ }
+ }
+ }
+ }
+ }
+
+ ///
+ /// Dizionario scadenza timers interni x esecuzione dei vari task a differente frequenza di chiamata
+ ///
+ private Dictionary TimersVeto = new Dictionary();
+ ///
+ /// Contatore chiamate timers x debug timing
+ ///
+ private Dictionary TimersCycleCount = new Dictionary();
+ ///
+ /// Contatore durata exec x debug timing
+ ///
+ private Dictionary TimersCycleElaps = new Dictionary();
+
+ ///
+ /// Evento principale scadenza del timer interno MsUI da cui scaturire le varie esecuzioni
+ ///
+ ///
+ ///
+ private void gather_Tick(object sender, EventArgs e)
+ {
+ bool doLog = false;
+ if (iobObj != null)
+ {
+ // fermo il timer...
+ gather.Stop();
+ // procedo!
+ if (iobObj.periodicLog)
+ {
+ doLog = true;
+ }
try
{
- string logPath = $"{System.AppDomain.CurrentDomain.BaseDirectory}logs\\{CurrIOB}\\{DateTime.Today:yyyy-MM-dd}.log";
- Process.Start(logPath);
- }
- catch (Exception exc)
- {
- lgError($"Eccezione in show log (MAIN):{Environment.NewLine}{exc}");
- }
- }
-
- private void BtnSendPLC_Click(object sender, EventArgs e)
- {
- // invia a MES il parametro selezionato (es ART / ODL / PRG NAME, come task2exe..)
- Dictionary forcedTask = new Dictionary();
- // guardo i parametri...
- if (!string.IsNullOrEmpty(txtValue.Text))
- {
- forcedTask.Add(cmbParamValues.SelectedValue.ToString(), txtValue.Text);
- }
- // chiedo esecuzione task!
- iobObj.processTask(forcedTask);
- chkEdit.Checked = false;
- toggleEditMes2Plc();
- }
-
- private void checkAssignSize()
- {
- int valSize = 0;
- int.TryParse(txtMReadSize.Text, out valSize);
- // verifico sia valida con lenght array...
- int maxSize = iobObj.RawInput.Length - iobObj.RawDataInputStart;
- valSize = valSize > maxSize ? maxSize : valSize;
- // riporto
- iobObj.RawDataInputSize = valSize;
- }
-
- private void checkAssignStart()
- {
- int valStart = 0;
- int.TryParse(txtMReadStart.Text, out valStart);
- // verifico sia valida con start/lenght array...
- int maxStart = iobObj.RawInput.Length - 1;
- valStart = valStart > maxStart ? maxStart : valStart;
- // riporto
- iobObj.RawDataInputStart = valStart;
- }
-
- private void checkEditMes2Plc()
- {
- cmbParamValues.Enabled = enableEditMes2Plc;
- txtValue.Enabled = enableEditMes2Plc;
- if (enableEditMes2Plc)
- {
- // aggiorno (se possibile) i parametri selezionabili...
- fixComboParameters();
- }
- }
-
- ///
- /// Verifica scadenza task
- ///
- ///
- private void checkScad()
- {
- DateTime adesso = DateTime.Now;
- bool sendDone = false;
- // ciclo su tutti i timers enum superiori a VHF
- var priorities = (gatherCycle[])Enum.GetValues(typeof(gatherCycle));
- // prendo solo > VHF e ordino discendenti x dare priorità ai più rari...
- var ordered = priorities.Where(x => x > gatherCycle.VHF).OrderByDescending(x => x);
- foreach (gatherCycle item in ordered)
- {
- if (TimersVeto.ContainsKey(item))
+ refreshFormData();
+ // check esecuzione SendTask (MsVHF) COMUNQUE...
+ iobObj.getAndSend(gatherCycle.VHF);
+ // eseguo cicli attivi SOLO se adapter è in EFFETTIVO running...
+ if (iobObj.adpRunning)
{
- if (TimersVeto[item] <= adesso)
+ if (iobObj.connectionOk)
{
- // se non ho già processato a questo giro...
- if (!sendDone)
+ // se richiesto faccio memory DUMP INIZIALE!
+ if (iobObj.doStartMemDump)
{
- TimersCycleCount[item]++;
- Stopwatch sw = new Stopwatch();
- sw.Start();
- // se scaduto processo!
- iobObj.getAndSend(item);
- sendDone = true;
- sw.Stop();
- TimersCycleElaps[item] += sw.Elapsed.TotalMilliseconds;
- // metto nuova scadenza perturbata 10%
- TimersVeto[item] = adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0.1));
+ lgInfo("Inizio dump memoria");
+ iobObj.saveMemDump(dumpType.STARTUP);
+ // fatto! non ripeto...
+ iobObj.doStartMemDump = false;
+ lgInfo("Finito dump memoria");
}
- // log + reset se ho contato ALMENO 100 exec o il tempo totale supera 1000msec
- int limMs = 10000;
- if (TimersCycleCount[item] >= 100 || (TimersCycleElaps.ContainsKey(item) && TimersCycleElaps[item] > limMs))
+ // controllo se sia abilitato sampleDump della meoria (periodico)
+ if (iobObj.doSampleMemory)
{
- var nCount = TimersCycleCount[item];
- nCount = nCount > 0 ? nCount : 1;
- lgDebug($"checkScad | {item} | {TimersCycleElaps[item] / nCount:F1}ms x {nCount}");
- TimersCycleCount[item] = 0;
- TimersCycleElaps[item] = 0;
+ checkSampleMem();
+ }
+ // controllo TUTTE le scadenze...
+ checkScad();
+ if (utils.CRI("waitEndCycle") > 0)
+ {
+ Thread.Sleep(utils.CRI("waitEndCycle"));
+ }
+ }
+ else
+ {
+ // qui attende meno...
+ DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec / 2);
+ if (iobObj.adpTryRestart && (DateTime.Now > dtVeto))
+ {
+ if (doLog)
+ {
+ lgInfo($"Retry Time Elapsed ({waitRecMSec / 2} ms)--> tryConnect");
+ }
+ lastStartTry = DateTime.Now;
+ iobObj.tryConnect();
}
}
}
else
{
- TimersVeto.Add(item, adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0)));
- TimersCycleCount.Add(item, 0);
- }
- }
- }
-
- private void checkSampleMem()
- {
- // decremento contatore...
- sampleMemCount--;
- if (sampleMemCount <= 0)
- {
- sampleMemCount = utils.CRI("sampleMemCount");
- // avvio fase raccolta dati e invio con adapter
- iobObj.saveMemDump(dumpType.SAMPLE);
- }
- }
-
- private void ChkEdit_CheckedChanged(object sender, EventArgs e)
- {
- toggleEditMes2Plc();
- }
-
- ///
- /// Chiusura adapter
- ///
- private void closeAdapter()
- {
- lgDebug("closeAdapter | true | false | true | false");
- fermaTutto(true, false, true, false);
- }
-
- private void displTimer_Tick(object sender, EventArgs e)
- {
- }
-
- ///
- /// Ferma tutti i componenti adapter + update buttons
- ///
- ///
- /// indica se fermare il timer (gather) principale (solo se non si chiude)
- ///
- /// indica se tentare di riconnettersi
- /// indica se sia richiesto di SVUOTARE le code delle info
- /// indica se si debba aggiornare la form (no se si sta chiudendo...)
- private void fermaTutto(bool stopTimer, bool tryRestart, bool forceDequeue, bool updateForm)
- {
- try
- {
- iobObj.stopAdapter(tryRestart, forceDequeue);
-
- stop.Enabled = false;
- start.Enabled = true;
- restart.Enabled = false;
-
- if (stopTimer)
- {
- gather.Enabled = false;
- }
-
- newDisplayData currDispData = new newDisplayData();
- currDispData.semIn = Semaforo.SS;
- currDispData.semOut = Semaforo.SS;
- if (updateForm)
- {
- updateFormDisplay(currDispData);
+ if (doLog)
+ {
+ lgInfo("Adapter stopped");
+ }
+ // verifico SE debba tentare il riavvio, ovvero NON running ma adpTryRestart
+ // e non ho riprovato x oltre waitRecMSec
+ DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec);
+ if (iobObj.adpTryRestart && (DateTime.Now > dtVeto))
+ {
+ lastStartTry = DateTime.Now;
+ avviaAdapter(chkForceDequeue.Checked);
+ }
}
}
catch (Exception exc)
{
- lgError($"Errore in chiusura:{Environment.NewLine}{exc}");
+ lgError(string.Format("Eccezione in fase di gatherTick: {0}{1}", Environment.NewLine, exc));
+ }
+
+ // riavvio il timer...
+ gather.Start();
+ }
+ }
+
+ ///
+ /// Init oggetti datamonitor
+ ///
+ private void initDatamonitor()
+ {
+ for (int i = 0; i < 4; i++)
+ {
+ dMonDisplVetoVeto.Add(i, DateTime.Now);
+ dMonValues.Add(i, new List());
+ }
+ }
+
+ ///
+ /// Carica file ini della configurazione richiesta
+ ///
+ ///
+ private void loadIniFile(string iniConfFile)
+ {
+ // out di cosa faccio...
+ displayTaskAndLog($"[STARTUP] Loading ConfFile: {iniConfFile}");
+ var appVers = Assembly.GetExecutingAssembly().GetName().Version;
+ string path = fileMover.GetExecutingDirectoryName(); // Directory.GetCurrentDirectory();
+ string fileName = Path.GetFileName(iniConfFile).Replace(".ini", ".iob");
+ string dirPath = Path.Combine(path, "DATA", "CONF_RUN");
+ // verifica directory
+ baseUtils.checkDir(dirPath);
+ string fullPath = Path.Combine(dirPath, fileName);
+ // preparazione file conf con nuovo formato e salvataggio...
+ IOBConfFull = IobConfTree.LoadFromINI(iniConfFile);
+ if (IOBConfFull.General.FileName.EndsWith("ini"))
+ {
+ IOBConfFull.General.FileName = IOBConfFull.General.FileName.Replace("ini", "yaml");
+ }
+ // salvo anche yaml...
+ IOBConfFull.SaveYaml(fullPath.Replace("iob", "yaml"));
+
+ // carico IOB
+ loadIobType();
+ // invio file di conf!
+ IOBConfFull.SendConfYaml(iobObj.urlSaveConfYaml);
+
+ // avvio macchina con adapter specificato...
+ if (utils.CRB("autoStartOnLoad"))
+ {
+ displayTaskAndLog("Auto Starting...", true);
+ // avvio!
+ avviaAdapter(chkForceDequeue.Checked);
+ displayTaskAndLog("Auto Started!", true);
+ }
+ }
+
+ ///
+ /// Carica file yaml della configurazione richiesta
+ ///
+ ///
+ private void loadYamlFile(string yamlConfFile)
+ {
+ // out di cosa faccio...
+ displayTaskAndLog($"[STARTUP] Loading yamlConfFile: {yamlConfFile}");
+ // leggo file
+ IniFile fIni = new IniFile(yamlConfFile);
+
+ // carivo vettore parametri opzionai
+ Dictionary optParRead = new Dictionary();
+ string[] optParRows = fIni.ReadSection("OPTPAR");
+ if (optParRows.Length > 0)
+ {
+ try
+ {
+ string[] kvp;
+ foreach (var item in optParRows)
+ {
+ kvp = item.Split('=');
+ optParRead.Add(kvp[0], kvp[1]);
+ }
+ lgDebug($"Caricati {optParRead.Count} parametri opzionali da OPTPAR");
+ }
+ catch (Exception exc)
+ {
+ lgError(string.Format("EXCEPTION in fase di lettura OPTPAR: {0}{1}", Environment.NewLine, exc));
}
}
+ var appVers = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
- private void fixComboParameters()
+ loadIobType();
+ // avvio macchina con adapter specificato...
+ if (utils.CRB("autoStartOnLoad"))
{
- if (iobObj != null)
- {
- if (iobObj.memMap != null)
- {
- if (iobObj.memMap.mMapWrite != null)
- {
- if (iobObj.memMap.mMapWrite.Count > 0)
- {
- var oldParams = cmbParamValues.DataSource;
- List parametri = new List();
- foreach (var item in iobObj.memMap.mMapWrite)
- {
- parametri.Add(item.Key);
- }
- // salvo selezione
- int oldIdx = cmbParamValues.SelectedIndex;
- // riassegno e ri-seleziono
- cmbParamValues.DataSource = parametri;
- cmbParamValues.SelectedIndex = oldIdx >= 0 ? oldIdx : 0;
- }
- }
- }
- }
+ displayTaskAndLog("Auto Starting...", true);
+ // avvio!
+ avviaAdapter(chkForceDequeue.Checked);
+ displayTaskAndLog("Auto Started!", true);
}
+ }
- ///
- /// Dizionario scadenza timers interni x esecuzione dei vari task a differente frequenza di chiamata
- ///
- private Dictionary TimersVeto = new Dictionary();
- ///
- /// Contatore chiamate timers x debug timing
- ///
- private Dictionary TimersCycleCount = new Dictionary();
- ///
- /// Contatore durata exec x debug timing
- ///
- private Dictionary TimersCycleElaps = new Dictionary();
- ///
- /// Evento principale scadenza del timer interno MsUI da cui scaturire le varie esecuzioni
- ///
- ///
- ///
- private void gather_Tick(object sender, EventArgs e)
+ ///
+ /// Verifica se il log di un dato errore sia permesso
+ ///
+ /// ID del valore log da loggare/verificare
+ ///
+ private bool logValuePermit(string logKey)
+ {
+ bool doLog = false;
+ if (vetoLogError.ContainsKey(logKey))
{
- bool doLog = false;
- if (iobObj != null)
- {
- // fermo il timer...
- gather.Stop();
- // procedo!
- if (iobObj.periodicLog)
- {
- doLog = true;
- }
- try
- {
- refreshFormData();
- // check esecuzione SendTask (MsVHF) COMUNQUE...
- iobObj.getAndSend(gatherCycle.VHF);
- // eseguo cicli attivi SOLO se adapter è in EFFETTIVO running...
- if (iobObj.adpRunning)
- {
- if (iobObj.connectionOk)
- {
- // se richiesto faccio memory DUMP INIZIALE!
- if (iobObj.doStartMemDump)
- {
- lgInfo("Inizio dump memoria");
- iobObj.saveMemDump(dumpType.STARTUP);
- // fatto! non ripeto...
- iobObj.doStartMemDump = false;
- lgInfo("Finito dump memoria");
- }
- // controllo se sia abilitato sampleDump della meoria (periodico)
- if (iobObj.doSampleMemory)
- {
- checkSampleMem();
- }
- // controllo TUTTE le scadenze...
- checkScad();
- if (utils.CRI("waitEndCycle") > 0)
- {
- Thread.Sleep(utils.CRI("waitEndCycle"));
- }
- }
- else
- {
- // qui attende meno...
- DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec / 2);
- if (iobObj.adpTryRestart && (DateTime.Now > dtVeto))
- {
- if (doLog)
- {
- lgInfo($"Retry Time Elapsed ({waitRecMSec / 2} ms)--> tryConnect");
- }
- lastStartTry = DateTime.Now;
- iobObj.tryConnect();
- }
- }
- }
- else
- {
- if (doLog)
- {
- lgInfo("Adapter stopped");
- }
- // verifico SE debba tentare il riavvio, ovvero NON running ma adpTryRestart
- // e non ho riprovato x oltre waitRecMSec
- DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec);
- if (iobObj.adpTryRestart && (DateTime.Now > dtVeto))
- {
- lastStartTry = DateTime.Now;
- avviaAdapter(chkForceDequeue.Checked);
- }
- }
- }
- catch (Exception exc)
- {
- lgError(string.Format("Eccezione in fase di gatherTick: {0}{1}", Environment.NewLine, exc));
- }
-
- // riavvio il timer...
- gather.Start();
- }
- }
-
- ///
- /// Init oggetti datamonitor
- ///
- private void initDatamonitor()
- {
- for (int i = 0; i < 4; i++)
- {
- dMonDisplVetoVeto.Add(i, DateTime.Now);
- dMonValues.Add(i, new List());
- }
- }
-
- ///
- /// Carica file ini della configurazione richiesta
- ///
- ///
- private void loadIniFile(string iniConfFile)
- {
- // out di cosa faccio...
- displayTaskAndLog($"[STARTUP] Loading ConfFile: {iniConfFile}");
- var appVers = Assembly.GetExecutingAssembly().GetName().Version;
- string path = fileMover.GetExecutingDirectoryName(); // Directory.GetCurrentDirectory();
- string fileName = Path.GetFileName(iniConfFile).Replace(".ini", ".iob");
- string dirPath = Path.Combine(path, "DATA", "CONF_RUN");
- // verifica directory
- baseUtils.checkDir(dirPath);
- string fullPath = Path.Combine(dirPath, fileName);
- // preparazione file conf con nuovo formato e salvataggio...
- IOBConfFull = IobConfTree.LoadFromINI(iniConfFile);
- if (IOBConfFull.General.FileName.EndsWith("ini"))
- {
- IOBConfFull.General.FileName = IOBConfFull.General.FileName.Replace("ini", "yaml");
- }
- // salvo anche yaml...
- IOBConfFull.SaveYaml(fullPath.Replace("iob", "yaml"));
-
- // carico IOB
- loadIobType();
- // invio file di conf!
- IOBConfFull.SendConfYaml(iobObj.urlSaveConfYaml);
-
- // avvio macchina con adapter specificato...
- if (utils.CRB("autoStartOnLoad"))
- {
- displayTaskAndLog("Auto Starting...", true);
- // avvio!
- avviaAdapter(chkForceDequeue.Checked);
- displayTaskAndLog("Auto Started!", true);
- }
- }
-
- ///
- /// Carica file yaml della configurazione richiesta
- ///
- ///
- private void loadYamlFile(string yamlConfFile)
- {
- // out di cosa faccio...
- displayTaskAndLog($"[STARTUP] Loading yamlConfFile: {yamlConfFile}");
- // leggo file
- IniFile fIni = new IniFile(yamlConfFile);
-
- // carivo vettore parametri opzionai
- Dictionary optParRead = new Dictionary();
- string[] optParRows = fIni.ReadSection("OPTPAR");
- if (optParRows.Length > 0)
- {
- try
- {
- string[] kvp;
- foreach (var item in optParRows)
- {
- kvp = item.Split('=');
- optParRead.Add(kvp[0], kvp[1]);
- }
- lgDebug($"Caricati {optParRead.Count} parametri opzionali da OPTPAR");
- }
- catch (Exception exc)
- {
- lgError(string.Format("EXCEPTION in fase di lettura OPTPAR: {0}{1}", Environment.NewLine, exc));
- }
- }
- var appVers = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
-
- loadIobType();
- // avvio macchina con adapter specificato...
- if (utils.CRB("autoStartOnLoad"))
- {
- displayTaskAndLog("Auto Starting...", true);
- // avvio!
- avviaAdapter(chkForceDequeue.Checked);
- displayTaskAndLog("Auto Started!", true);
- }
- }
-
-
- ///
- /// Verifica se il log di un dato errore sia permesso
- ///
- /// ID del valore log da loggare/verificare
- ///
- private bool logValuePermit(string logKey)
- {
- bool doLog = false;
- if (vetoLogError.ContainsKey(logKey))
- {
- // verifico se veto scaduto...
- if (DateTime.Now > vetoLogError[logKey])
- {
- doLog = true;
- vetoLogError[logKey] = DateTime.Now.AddMinutes(vetoPeriodMin);
- }
- }
- else
+ // verifico se veto scaduto...
+ if (DateTime.Now > vetoLogError[logKey])
{
doLog = true;
- vetoLogError.Add(logKey, DateTime.Now.AddMinutes(vetoPeriodMin));
- }
-
- return doLog;
- }
-
- ///
- /// Fase chiusura Form
- ///
- ///
- ///
- private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
- {
- lgTrace("MainForm_FormClosing");
- closeAdapter();
- }
-
- ///
- /// Completato resize form
- ///
- ///
- ///
- private void MainForm_Resize(object sender, EventArgs e)
- {
- }
-
- ///
- /// Mostrata form
- ///
- ///
- ///
- private void MainForm_Shown(object sender, EventArgs e)
- {
- displayTaskAndLog("Main Form SHOWN (Adapter)", true);
- }
-
- private void mLoadConf_Click(object sender, EventArgs e)
- {
- // mostro selettore file x leggere adapter..
- OpenFileDialog openFileDial = new OpenFileDialog();
-
- // directory iniziale
- openFileDial.InitialDirectory = utils.confDir; // string.Format(@"{0}\{1}", Application.StartupPath, utils.CRS("dataConfPath"));
- // Set filter options and filter index.
- openFileDial.Filter = "INI Files (.ini)|*.ini|All Files (*.*)|*.*";
- openFileDial.FilterIndex = 1;
- // altre opzioni
- openFileDial.Multiselect = false;
-
- // Call the ShowDialog method to show the dialog box.
- DialogResult userClickedOK = openFileDial.ShowDialog();
-
- // Process input if the user clicked OK.
- if (userClickedOK == DialogResult.OK)
- {
- string iniConfFile = openFileDial.FileName;
- loadIniFile(iniConfFile);
- lgInfo("INI LOADED");
+ vetoLogError[logKey] = DateTime.Now.AddMinutes(vetoPeriodMin);
}
}
-
- private void refreshFormData()
+ else
{
- // aggiorno visualizzazioni varie in form...
- alQueueLen = iobObj.QueueAlarm.Count;
- evQueueLen = iobObj.QueueIN.Count;
- flQueueLen = iobObj.QueueFLog.Count;
- msQueueLen = iobObj.QueueMessages.Count;
- rtrQueueLen = iobObj.QueueRawTransf.Count;
- ulQueueLen = iobObj.QueueULog.Count;
- // aggiorno labels counters...
- counterIob = $"pz IOB {iobObj.contapezziIOB}";
- counterMac = $"pz PLC {iobObj.contapezziPLC}";
- Dictionary setPar = new Dictionary();
- setPar.Add("IP", iobObj.IOBConfFull.Device.Connect.IpAddr);
- setPar.Add("PORT", iobObj.IOBConfFull.Device.Connect.Port);
- string note = $"{iobObj.IOBConfFull.General.FilenameIOB} | DT ultimo avvio: {iobObj.dtAvvioAdp}";
- // verifico IOB status
- IobWinStatus currIobStatus = new IobWinStatus()
- {
- CodIob = iobObj.IOBConfFull.General.FilenameIOB,
- IobType = $"{iobObj.IOBConfFull.General.IobType}",//iobObj.cIobConf.tipoIob.ToString(),
- queueAlLen = alQueueLen,
- queueEvLen = evQueueLen,
- queueFlLen = flQueueLen,
- queueMsLen = msQueueLen,
- queueRawTransfLen = rtrQueueLen,
- queueUlLen = ulQueueLen,
- counterIOB = iobObj.contapezziIOB,
- counterMAC = iobObj.contapezziPLC,
- lastUpdate = lastIobStatus.lastUpdate > iobObj.lastWatchDog ? lastIobStatus.lastUpdate : iobObj.lastWatchDog,
- online = utils.IOB_Online,
- lastDataIn = iobObj.lastReadPLC,
- lastDataOut = iobObj.lastIobOnline,
- setupParams = setPar,
- freeNotes = note
- };
- // se diverso SALVO!
- if (!currIobStatus.Equals(lastIobStatus))
- {
- // aggiorno data
- currIobStatus.lastUpdate = DateTime.Now;
- // salvo su redis e in obj corrente
- iobObj.redisMan.iobStatus = currIobStatus;
- lastIobStatus = currIobStatus;
- }
- // se diverso SALVO MP IO status
- if (lastSrvStatus.online != utils.MPIO_Online)
- {
- // aggiorno
- ServerMpStatus currSrvStatus = iobObj.redisMan.servStatus;
- currSrvStatus.online = utils.MPIO_Online;
- currSrvStatus.lastUpdate = DateTime.Now;
- // salvo su redis e in obj corrente
- iobObj.redisMan.servStatus = currSrvStatus;
- lastSrvStatus = currSrvStatus;
- }
+ doLog = true;
+ vetoLogError.Add(logKey, DateTime.Now.AddMinutes(vetoPeriodMin));
}
- ///
- /// Button restart
- ///
- ///
- ///
- private void restart_Click(object sender, EventArgs e)
- {
- string message = "Attenzione: con l'operazione di reset veranno persi (e non inviati) i dati eventualmente accumulati (indipendentemente dalla selezione del checkbox 'svuota coda').";
- string caption = "Conferma Reset Dati IOB";
- MessageBoxButtons buttons = MessageBoxButtons.YesNo;
- DialogResult result;
-
- // verifica con messagebox
- result = MessageBox.Show(message, caption, buttons);
- // solo se ho conferma da utente
- if (result == DialogResult.Yes)
- {
- // faccio stop... SENZA inviare
- fermaAdapter(false, false, true);
- displayTaskAndLog("RESTARTING: Adapter Stopped", true);
- // rileggo INI
- loadIniFile(defConfFilePath);
- displayTaskAndLog("RESTARTING: Ini File Reloaded", true);
- // faccio start... CON RESET delle code
- avviaAdapter(true);
- displayTaskAndLog("RESTARTING: Adapter Started", true);
- // resetto i data monitor...
- dataMonitor_0 = "";
- dataMonitor_1 = "";
- dataMonitor_2 = "";
- dataMonitor_3 = "";
- }
- }
-
- private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
- {
- }
-
- ///
- /// Avvio dell'adapter
- ///
- ///
- ///
- private void start_Click(object sender, EventArgs e)
- {
- avviaAdapter(chkForceDequeue.Checked);
- // salvo che ho avviato adapter
- lgInfo("Completato LOAD Adapter");
- }
-
- ///
- /// fermata dell'adapter
- ///
- ///
- ///
- private void stop_Click(object sender, EventArgs e)
- {
- fermaAdapter(false, chkForceDequeue.Checked, true);
- // salvo che ho fermato adapter
- lgInfo("UNLOAD Adapter");
- }
-
- private void TabData_Selected(object sender, TabControlEventArgs e)
- {
- }
-
- private void toggleEditMes2Plc()
- {
- // abilita i campi --> PLC per editing
- enableEditMes2Plc = !enableEditMes2Plc;
- checkEditMes2Plc();
- }
-
- private void txtMReadSize_TextChanged(object sender, EventArgs e)
- {
- checkAssignSize();
- }
-
- private void txtMReadStart_TextChanged(object sender, EventArgs e)
- {
- checkAssignStart();
- checkAssignSize();
- }
-
- #endregion Private Methods
+ return doLog;
}
+
+ ///
+ /// Fase chiusura Form
+ ///
+ ///
+ ///
+ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ lgTrace("MainForm_FormClosing");
+ closeAdapter();
+ }
+
+ ///
+ /// Completato resize form
+ ///
+ ///
+ ///
+ private void MainForm_Resize(object sender, EventArgs e)
+ {
+ }
+
+ ///
+ /// Mostrata form
+ ///
+ ///
+ ///
+ private void MainForm_Shown(object sender, EventArgs e)
+ {
+ displayTaskAndLog("Main Form SHOWN (Adapter)", true);
+ }
+
+ private void mLoadConf_Click(object sender, EventArgs e)
+ {
+ // mostro selettore file x leggere adapter..
+ OpenFileDialog openFileDial = new OpenFileDialog();
+
+ // directory iniziale
+ openFileDial.InitialDirectory = utils.confDir; // string.Format(@"{0}\{1}", Application.StartupPath, utils.CRS("dataConfPath"));
+ // Set filter options and filter index.
+ openFileDial.Filter = "INI Files (.ini)|*.ini|All Files (*.*)|*.*";
+ openFileDial.FilterIndex = 1;
+ // altre opzioni
+ openFileDial.Multiselect = false;
+
+ // Call the ShowDialog method to show the dialog box.
+ DialogResult userClickedOK = openFileDial.ShowDialog();
+
+ // Process input if the user clicked OK.
+ if (userClickedOK == DialogResult.OK)
+ {
+ string iniConfFile = openFileDial.FileName;
+ loadIniFile(iniConfFile);
+ lgInfo("INI LOADED");
+ }
+ }
+
+ private void refreshFormData()
+ {
+ // aggiorno visualizzazioni varie in form...
+ alQueueLen = iobObj.QueueAlarm.Count;
+ evQueueLen = iobObj.QueueIN.Count;
+ flQueueLen = iobObj.QueueFLog.Count;
+ msQueueLen = iobObj.QueueMessages.Count;
+ rtrQueueLen = iobObj.QueueRawTransf.Count;
+ ulQueueLen = iobObj.QueueULog.Count;
+ // aggiorno labels counters...
+ counterIob = $"pz IOB {iobObj.contapezziIOB}";
+ counterMac = $"pz PLC {iobObj.contapezziPLC}";
+ Dictionary setPar = new Dictionary();
+ setPar.Add("IP", iobObj.IOBConfFull.Device.Connect.IpAddr);
+ setPar.Add("PORT", iobObj.IOBConfFull.Device.Connect.Port);
+ string note = $"{iobObj.IOBConfFull.General.FilenameIOB} | DT ultimo avvio: {iobObj.dtAvvioAdp}";
+ // verifico IOB status
+ IobWinStatus currIobStatus = new IobWinStatus()
+ {
+ CodIob = iobObj.IOBConfFull.General.FilenameIOB,
+ IobType = $"{iobObj.IOBConfFull.General.IobType}",//iobObj.cIobConf.tipoIob.ToString(),
+ queueAlLen = alQueueLen,
+ queueEvLen = evQueueLen,
+ queueFlLen = flQueueLen,
+ queueMsLen = msQueueLen,
+ queueRawTransfLen = rtrQueueLen,
+ queueUlLen = ulQueueLen,
+ counterIOB = iobObj.contapezziIOB,
+ counterMAC = iobObj.contapezziPLC,
+ lastUpdate = lastIobStatus.lastUpdate > iobObj.lastWatchDog ? lastIobStatus.lastUpdate : iobObj.lastWatchDog,
+ online = utils.IOB_Online,
+ lastDataIn = iobObj.lastReadPLC,
+ lastDataOut = iobObj.lastIobOnline,
+ setupParams = setPar,
+ freeNotes = note
+ };
+ // se diverso SALVO!
+ if (!currIobStatus.Equals(lastIobStatus))
+ {
+ // aggiorno data
+ currIobStatus.lastUpdate = DateTime.Now;
+ // salvo su redis e in obj corrente
+ iobObj.redisMan.iobStatus = currIobStatus;
+ lastIobStatus = currIobStatus;
+ }
+ // se diverso SALVO MP IO status
+ if (lastSrvStatus.online != utils.MPIO_Online)
+ {
+ // aggiorno
+ ServerMpStatus currSrvStatus = iobObj.redisMan.servStatus;
+ currSrvStatus.online = utils.MPIO_Online;
+ currSrvStatus.lastUpdate = DateTime.Now;
+ // salvo su redis e in obj corrente
+ iobObj.redisMan.servStatus = currSrvStatus;
+ lastSrvStatus = currSrvStatus;
+ }
+ }
+
+ ///
+ /// Button restart
+ ///
+ ///
+ ///
+ private void restart_Click(object sender, EventArgs e)
+ {
+ string message = "Attenzione: con l'operazione di reset veranno persi (e non inviati) i dati eventualmente accumulati (indipendentemente dalla selezione del checkbox 'svuota coda').";
+ string caption = "Conferma Reset Dati IOB";
+ MessageBoxButtons buttons = MessageBoxButtons.YesNo;
+ DialogResult result;
+
+ // verifica con messagebox
+ result = MessageBox.Show(message, caption, buttons);
+ // solo se ho conferma da utente
+ if (result == DialogResult.Yes)
+ {
+ // faccio stop... SENZA inviare
+ fermaAdapter(false, false, true);
+ displayTaskAndLog("RESTARTING: Adapter Stopped", true);
+ // rileggo INI
+ loadIniFile(defConfFilePath);
+ displayTaskAndLog("RESTARTING: Ini File Reloaded", true);
+ // faccio start... CON RESET delle code
+ avviaAdapter(true);
+ displayTaskAndLog("RESTARTING: Adapter Started", true);
+ // resetto i data monitor...
+ dataMonitor_0 = "";
+ dataMonitor_1 = "";
+ dataMonitor_2 = "";
+ dataMonitor_3 = "";
+ }
+ }
+
+ private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
+ {
+ }
+
+ ///
+ /// Avvio dell'adapter
+ ///
+ ///
+ ///
+ private void start_Click(object sender, EventArgs e)
+ {
+ avviaAdapter(chkForceDequeue.Checked);
+ // salvo che ho avviato adapter
+ lgInfo("Completato LOAD Adapter");
+ }
+
+ ///
+ /// fermata dell'adapter
+ ///
+ ///
+ ///
+ private void stop_Click(object sender, EventArgs e)
+ {
+ fermaAdapter(false, chkForceDequeue.Checked, true);
+ // salvo che ho fermato adapter
+ lgInfo("UNLOAD Adapter");
+ }
+
+ private void TabData_Selected(object sender, TabControlEventArgs e)
+ {
+ }
+
+ private void toggleEditMes2Plc()
+ {
+ // abilita i campi --> PLC per editing
+ enableEditMes2Plc = !enableEditMes2Plc;
+ checkEditMes2Plc();
+ }
+
+ private void txtMReadSize_TextChanged(object sender, EventArgs e)
+ {
+ checkAssignSize();
+ }
+
+ private void txtMReadStart_TextChanged(object sender, EventArgs e)
+ {
+ checkAssignStart();
+ checkAssignSize();
+ }
+
+ #endregion Private Methods
+}
}
\ No newline at end of file
diff --git a/IOB-WIN-FORM/Iob/Generic.Protected.cs b/IOB-WIN-FORM/Iob/Generic.Protected.cs
index c37703ee..b98f3109 100644
--- a/IOB-WIN-FORM/Iob/Generic.Protected.cs
+++ b/IOB-WIN-FORM/Iob/Generic.Protected.cs
@@ -5213,6 +5213,7 @@ namespace IOB_WIN_FORM.Iob
string codIob = IOBConfFull.General.FilenameIOB;
bool useRedis = IOBConfFull.General.EnabRedisQue;
QueueAlarm = new DataQueue(codIob, "QueueAlarm", false, redisMan);
+ QueueIN.Dispose();
QueueIN = new DataQueue(codIob, "QueueIN", useRedis, redisMan);
// no coda redis
QueueFLog = new DataQueue(codIob, "QueueFLog", false, redisMan);
diff --git a/IOB-WIN-FORM/MainForm.cs b/IOB-WIN-FORM/MainForm.cs
index 30713d51..b59f3709 100644
--- a/IOB-WIN-FORM/MainForm.cs
+++ b/IOB-WIN-FORM/MainForm.cs
@@ -32,10 +32,12 @@ namespace IOB_WIN_FORM
///
public DateTime lastComCheck;
+#if false
///
/// Oggetto connessione REDIS
///
- public RedisIobCache redisMan;
+ public RedisIobCache redisMan;
+#endif
#endregion Public Fields
@@ -998,6 +1000,7 @@ namespace IOB_WIN_FORM
{
firstIob = IOB2START[0];
}
+#if false
try
{
redisMan = new RedisIobCache(MPIP, firstIob, "NA", MinDeltaSec);
@@ -1005,7 +1008,8 @@ namespace IOB_WIN_FORM
catch (Exception exc)
{
lgError($"Eccezione in salvataggio stato su redis{Environment.NewLine}{exc}");
- }
+ }
+#endif
}
///
@@ -1149,8 +1153,10 @@ namespace IOB_WIN_FORM
{
openChild(item);
}
+#if false
// effettuo upload dei file di configurazione...
- uploadIobConfFile();
+ uploadIobConfFile();
+#endif
}
///
@@ -1178,6 +1184,7 @@ namespace IOB_WIN_FORM
}
}
+#if false
///
/// Effettua upload dei file di configurazione IOB
///
@@ -1253,11 +1260,14 @@ namespace IOB_WIN_FORM
lgError($"Eccezione in upload IOB conf files{Environment.NewLine}{exc}");
}
}
- }
+ }
+#endif
private void uploadIOBConfToolStripMenuItem_Click(object sender, EventArgs e)
{
- uploadIobConfFile();
+#if false
+ uploadIobConfFile();
+#endif
}
#endregion Private Methods
diff --git a/IOB-WIN-OPC-UA/DATA/CONF/2014.ini b/IOB-WIN-OPC-UA/DATA/CONF/2014.ini
index 806e685f..978edd24 100644
--- a/IOB-WIN-OPC-UA/DATA/CONF/2014.ini
+++ b/IOB-WIN-OPC-UA/DATA/CONF/2014.ini
@@ -59,6 +59,7 @@ CHANGE_ODL_MODE=PZCOUNT_RESET
PZCOUNT_MODE=OPC
ENABLE_PZ_RESET=TRUE
ENABLE_PZ_RESET_ENDPROD=TRUE
+ENABLE_PZ_RESET_stopSetup=TRUE
DISABLE_PZCOUNT=FALSE
ENABLE_SEND_PZC_BLOCK=TRUE
MIN_SEND_PZC_BLOCK=0
diff --git a/IOB-WIN-OPC-UA/DATA/CONF/2014.json b/IOB-WIN-OPC-UA/DATA/CONF/2014.json
index 31779de7..e9eb720e 100644
--- a/IOB-WIN-OPC-UA/DATA/CONF/2014.json
+++ b/IOB-WIN-OPC-UA/DATA/CONF/2014.json
@@ -366,16 +366,6 @@
"index": 0,
"size": 1
},
- "OPC_acProg": {
- "name": "OPC_acProg",
- "description": "Program",
- "func": "MEDIAN",
- "period": 600,
- "tipoMem": "Int",
- "memAddr": "ns=2;s=/Channel/State/acProg",
- "index": 0,
- "size": 1
- },
"OPC_oldProgNetTime": {
"name": "OPC_oldProgNetTime",
"description": "Ultimo TCiclo",
diff --git a/IOB-WIN-OPC-UA/DATA/CONF/2015.json b/IOB-WIN-OPC-UA/DATA/CONF/2015.json
index 31779de7..e9eb720e 100644
--- a/IOB-WIN-OPC-UA/DATA/CONF/2015.json
+++ b/IOB-WIN-OPC-UA/DATA/CONF/2015.json
@@ -366,16 +366,6 @@
"index": 0,
"size": 1
},
- "OPC_acProg": {
- "name": "OPC_acProg",
- "description": "Program",
- "func": "MEDIAN",
- "period": 600,
- "tipoMem": "Int",
- "memAddr": "ns=2;s=/Channel/State/acProg",
- "index": 0,
- "size": 1
- },
"OPC_oldProgNetTime": {
"name": "OPC_oldProgNetTime",
"description": "Ultimo TCiclo",