Merge branch 'release/AdapterFormUpdate_01'
This commit is contained in:
@@ -33,4 +33,5 @@ CLI_INST=SteamWareSim
|
||||
;STARTLIST=3001
|
||||
STARTLIST=SIMUL_01
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace IOB_WIN_FANUC.Iob
|
||||
FANUC_ref = (FANUC)Runtime.NC;
|
||||
|
||||
tryDisconnect();
|
||||
Thread.Sleep(500);
|
||||
Thread.Sleep(200);
|
||||
|
||||
lgInfo("FANUC: tryConnect");
|
||||
tryConnect();
|
||||
@@ -1570,7 +1570,7 @@ namespace IOB_WIN_FANUC.Iob
|
||||
FANUC_ref.Disconnect(ref szStatusConnection);
|
||||
lgInfo($"FANUC_ref preliminary DISCONNECT | connStatus: {FANUC_ref.Connected}| szStatusConnection: {szStatusConnection}");
|
||||
// aspetto
|
||||
Thread.Sleep(500);
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
FANUC_ref.Connect(ref szStatusConnection);
|
||||
parentForm.commPlcActive = false;
|
||||
@@ -1627,7 +1627,7 @@ namespace IOB_WIN_FANUC.Iob
|
||||
try
|
||||
{
|
||||
FANUC_ref.Disconnect(ref szStatusConnection);
|
||||
Thread.Sleep(500);
|
||||
Thread.Sleep(200);
|
||||
connectionOk = false;
|
||||
// resetto timing!
|
||||
TimingData.resetData();
|
||||
|
||||
Generated
+24
-30
@@ -33,7 +33,6 @@
|
||||
this.lblPzCountIob = new System.Windows.Forms.Label();
|
||||
this.lblPzCountMac = new System.Windows.Forms.Label();
|
||||
this.chkForceDequeue = new System.Windows.Forms.CheckBox();
|
||||
this.displTimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.tabMes = new System.Windows.Forms.TabPage();
|
||||
this.btnForceAutoOdl = new System.Windows.Forms.Button();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
@@ -150,7 +149,7 @@
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tableLayoutPanel1.ColumnCount = 10;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 24F));
|
||||
@@ -183,8 +182,8 @@
|
||||
//
|
||||
// restart
|
||||
//
|
||||
this.restart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.restart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.restart.BackColor = System.Drawing.Color.Red;
|
||||
this.restart.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -199,8 +198,8 @@
|
||||
//
|
||||
// stop
|
||||
//
|
||||
this.stop.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.stop.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.stop.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.stop.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
@@ -226,8 +225,8 @@
|
||||
//
|
||||
// start
|
||||
//
|
||||
this.start.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.start.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.start.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.start.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -242,8 +241,8 @@
|
||||
//
|
||||
// bIN
|
||||
//
|
||||
this.bIN.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.bIN.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.bIN.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.bIN.Location = new System.Drawing.Point(2, 2);
|
||||
@@ -257,8 +256,8 @@
|
||||
//
|
||||
// bOUT
|
||||
//
|
||||
this.bOUT.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.bOUT.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.bOUT.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.bOUT.Location = new System.Drawing.Point(879, 2);
|
||||
@@ -285,8 +284,8 @@
|
||||
//
|
||||
// lblPzCountIob
|
||||
//
|
||||
this.lblPzCountIob.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.lblPzCountIob.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblPzCountIob.AutoSize = true;
|
||||
this.lblPzCountIob.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -323,10 +322,6 @@
|
||||
this.chkForceDequeue.Text = "F";
|
||||
this.chkForceDequeue.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// displTimer
|
||||
//
|
||||
this.displTimer.Tick += new System.EventHandler(this.displTimer_Tick);
|
||||
//
|
||||
// tabMes
|
||||
//
|
||||
this.tabMes.BackColor = System.Drawing.Color.Transparent;
|
||||
@@ -607,8 +602,8 @@
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.panel2.AutoScroll = true;
|
||||
this.panel2.Controls.Add(this.lblTaskLog);
|
||||
@@ -875,8 +870,8 @@
|
||||
//
|
||||
// flowLayoutPanel1
|
||||
//
|
||||
this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.flowLayoutPanel1.Controls.Add(this.lblLogfile);
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(6, 22);
|
||||
@@ -910,8 +905,8 @@
|
||||
//
|
||||
// tableLayoutPanel2
|
||||
//
|
||||
this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tableLayoutPanel2.BackColor = System.Drawing.Color.Black;
|
||||
this.tableLayoutPanel2.ColumnCount = 4;
|
||||
@@ -974,7 +969,7 @@
|
||||
//
|
||||
// lblRawData
|
||||
//
|
||||
this.lblRawData.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.lblRawData.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblRawData.AutoSize = true;
|
||||
this.lblRawData.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -1011,7 +1006,7 @@
|
||||
//
|
||||
// lblOutMessage3
|
||||
//
|
||||
this.lblOutMessage3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.lblOutMessage3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblOutMessage3.AutoSize = true;
|
||||
this.lblOutMessage3.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -1025,7 +1020,7 @@
|
||||
//
|
||||
// lblOutMessage2
|
||||
//
|
||||
this.lblOutMessage2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.lblOutMessage2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblOutMessage2.AutoSize = true;
|
||||
this.lblOutMessage2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -1038,8 +1033,8 @@
|
||||
//
|
||||
// tabData
|
||||
//
|
||||
this.tabData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.tabData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tabData.Controls.Add(this.tabRealtime);
|
||||
this.tabData.Controls.Add(this.tabLog);
|
||||
@@ -1110,7 +1105,6 @@
|
||||
private System.Windows.Forms.Button start;
|
||||
private System.Windows.Forms.TextBox nLines;
|
||||
private System.Windows.Forms.Button bIN;
|
||||
private System.Windows.Forms.Timer displTimer;
|
||||
private System.Windows.Forms.Button restart;
|
||||
private System.Windows.Forms.CheckBox chkForceDequeue;
|
||||
private System.Windows.Forms.Button bOUT;
|
||||
|
||||
+122
-17
@@ -1342,6 +1342,10 @@ namespace IOB_WIN_FORM
|
||||
/// Cancellation tocken x processi verso server
|
||||
/// </summary>
|
||||
private CancellationTokenSource _ctsServer;
|
||||
/// <summary>
|
||||
/// Cancellation tocken x processi verso Redis
|
||||
/// </summary>
|
||||
private CancellationTokenSource _ctsRedis;
|
||||
|
||||
/// <summary>
|
||||
/// Ritardo per errori (extra nei cicli)
|
||||
@@ -1354,6 +1358,7 @@ namespace IOB_WIN_FORM
|
||||
private FormWindowState _lastState = FormWindowState.Minimized;
|
||||
|
||||
private Thread _machineThread;
|
||||
private Task _redisTask;
|
||||
private Task _workerTask;
|
||||
|
||||
/// <summary>
|
||||
@@ -1444,11 +1449,6 @@ namespace IOB_WIN_FORM
|
||||
gather.Enabled = true;
|
||||
displayTaskAndLog($"Main UI timer set: {gather.Interval}ms", true);
|
||||
|
||||
// Start timer periodico interfaccia
|
||||
displTimer.Interval = utils.CRI("timerIntMs");
|
||||
displTimer.Enabled = true;
|
||||
displayTaskAndLog("UI Program Running", true);
|
||||
|
||||
// check oggetto not null
|
||||
if (iobObj != null)
|
||||
{
|
||||
@@ -1691,18 +1691,12 @@ namespace IOB_WIN_FORM
|
||||
|
||||
private void CloseTimers()
|
||||
{
|
||||
displTimer?.Stop();
|
||||
displTimer?.Dispose();
|
||||
gather?.Stop();
|
||||
gather?.Dispose();
|
||||
_isSuspended = true;
|
||||
_ = StopWorker();
|
||||
}
|
||||
|
||||
private void displTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metodo principale esecuzione task in thread background (no interferenza con UI) x processi IO bound
|
||||
/// </summary>
|
||||
@@ -2140,6 +2134,9 @@ namespace IOB_WIN_FORM
|
||||
|
||||
private void refreshFormData()
|
||||
{
|
||||
// verifica se mostrare update
|
||||
if (!ShouldUpdateUI()) return;
|
||||
|
||||
// aggiorno visualizzazioni varie in form...
|
||||
alQueueLen = iobObj.QHelp.QueueAlarm.Count;
|
||||
evQueueLen = iobObj.QHelp.QueueIN.Count;
|
||||
@@ -2150,6 +2147,7 @@ namespace IOB_WIN_FORM
|
||||
// aggiorno labels counters...
|
||||
counterIob = $"pz MES {iobObj.contapezziIOB}";
|
||||
counterMac = $"pz PLC {iobObj.contapezziPLC}";
|
||||
#if false
|
||||
Dictionary<string, string> setPar = new Dictionary<string, string>();
|
||||
setPar.Add("IP", iobObj.IOBConfFull.Device.Connect.IpAddr);
|
||||
setPar.Add("PORT", iobObj.IOBConfFull.Device.Connect.Port);
|
||||
@@ -2193,7 +2191,8 @@ namespace IOB_WIN_FORM
|
||||
// salvo su redis e in obj corrente
|
||||
iobObj.redisMan.servStatus = currSrvStatus;
|
||||
lastSrvStatus = currSrvStatus;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2338,10 +2337,6 @@ namespace IOB_WIN_FORM
|
||||
/// </summary>
|
||||
private void StartWorker()
|
||||
{
|
||||
//// FixMe ToDo !!! togliere o fare alternativa pooled
|
||||
//if (iobObj.IOBConfFull.General.MachWLoopSingleThread || true)
|
||||
//{
|
||||
//}
|
||||
lock (_threadLock)
|
||||
{
|
||||
// rimozione isSuspended
|
||||
@@ -2374,7 +2369,22 @@ namespace IOB_WIN_FORM
|
||||
_machineThread.Start();
|
||||
lgInfo("--- WORKER MACHINE AVVIATO ---");
|
||||
|
||||
// avvio altro thread comunque...
|
||||
// avvio altro thread di verifica status IOB verso REDIS...
|
||||
// 1. Controllo se è già in esecuzione
|
||||
if (_redisTask != null && !_redisTask.IsCompleted)
|
||||
{
|
||||
lgTrace("Worker Redis già in esecuzione. Richiesta ignorata.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// avvio componente multithreaded x update
|
||||
_ctsRedis = new CancellationTokenSource();
|
||||
_redisTask = Task.Run(() => RedisWorkerLoopAsync(_ctsRedis.Token));
|
||||
lgInfo("--- WORKER REDIS AVVIATO ---");
|
||||
}
|
||||
|
||||
|
||||
// avvio altro thread di comunicazione server...
|
||||
// 1. Controllo se è già in esecuzione
|
||||
if (_workerTask != null && !_workerTask.IsCompleted)
|
||||
{
|
||||
@@ -2454,6 +2464,101 @@ namespace IOB_WIN_FORM
|
||||
checkAssignSize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metodo x gestione I/O Redis (status IOB)
|
||||
/// </summary>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
private async Task RedisWorkerLoopAsync(CancellationToken token)
|
||||
{
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (iobObj != null)
|
||||
{
|
||||
// 1. Estrazione dati dalle code (operazione logica)
|
||||
long alQueueLen = iobObj.QHelp.QueueAlarm.Count;
|
||||
long evQueueLen = iobObj.QHelp.QueueIN.Count;
|
||||
long flQueueLen = iobObj.QHelp.QueueFLog.Count;
|
||||
long msQueueLen = iobObj.QHelp.QueueMessages.Count;
|
||||
long rtrQueueLen = iobObj.QHelp.QueueRawTransf.Count;
|
||||
long ulQueueLen = iobObj.QHelp.QueueULog.Count;
|
||||
|
||||
var setPar = new Dictionary<string, string>
|
||||
{
|
||||
{ "IP", iobObj.IOBConfFull.Device.Connect.IpAddr },
|
||||
{ "PORT", iobObj.IOBConfFull.Device.Connect.Port }
|
||||
};
|
||||
|
||||
IobWinStatus currIobStatus = new IobWinStatus()
|
||||
{
|
||||
CodIob = iobObj.IOBConfFull.General.FilenameIOB,
|
||||
IobType = $"{iobObj.IOBConfFull.General.IobType}",
|
||||
queueAlLen = alQueueLen,
|
||||
queueEvLen = evQueueLen,
|
||||
queueFlLen = flQueueLen,
|
||||
queueMsLen = msQueueLen,
|
||||
queueRawTransfLen = rtrQueueLen,
|
||||
queueUlLen = ulQueueLen,
|
||||
counterIOB = iobObj.contapezziIOB,
|
||||
counterMAC = iobObj.contapezziPLC,
|
||||
lastUpdate = lastIobStatus.lastUpdate > iobObj.DtHelp.lastWatchDog ? lastIobStatus.lastUpdate : iobObj.DtHelp.lastWatchDog,
|
||||
online = utils.IOB_Online,
|
||||
lastDataIn = iobObj.DtHelp.lastReadPLC,
|
||||
lastDataOut = iobObj.DtHelp.lastIobOnline,
|
||||
setupParams = setPar,
|
||||
freeNotes = $"{iobObj.IOBConfFull.General.FilenameIOB} | DT ultimo avvio: {iobObj.DtHelp.AvvioAdp}"
|
||||
};
|
||||
|
||||
// 2. Logica di salvataggio su REDIS (Rete -> Thread di background!)
|
||||
if (!currIobStatus.Equals(lastIobStatus))
|
||||
{
|
||||
currIobStatus.lastUpdate = DateTime.Now;
|
||||
iobObj.redisMan.iobStatus = currIobStatus;
|
||||
lastIobStatus = currIobStatus;
|
||||
}
|
||||
|
||||
if (lastSrvStatus.online != utils.MPIO_Online)
|
||||
{
|
||||
ServerMpStatus currSrvStatus = iobObj.redisMan.servStatus;
|
||||
currSrvStatus.online = utils.MPIO_Online;
|
||||
currSrvStatus.lastUpdate = DateTime.Now;
|
||||
iobObj.redisMan.servStatus = currSrvStatus;
|
||||
lastSrvStatus = currSrvStatus;
|
||||
}
|
||||
|
||||
// 3. Prepariamo i dati per la UI e li salviamo in modo thread-safe
|
||||
lock (_statusLock)
|
||||
{
|
||||
_latestSnapshotForUI = currIobStatus;
|
||||
_cachedCounterIob = $"pz MES {iobObj.contapezziIOB}";
|
||||
_cachedCounterMac = $"pz PLC {iobObj.contapezziPLC}";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError($"Eccezione nel background gather: {exc}");
|
||||
}
|
||||
|
||||
// Frequenza di aggiornamento Redis/Code (es. ogni 1 secondo)
|
||||
// Rilascia la CPU senza fare context switch distruttivi
|
||||
await Task.Delay(1000, token);
|
||||
}
|
||||
}
|
||||
|
||||
// Oggetto per il lock thread-safe
|
||||
private readonly object _statusLock = new object();
|
||||
|
||||
// Questa variabile conterrà l'ultimo stato valido calcolato in background
|
||||
private IobWinStatus _latestSnapshotForUI;
|
||||
|
||||
// Stringhe pronte per la UI calcolate in background per evitare manipolazioni di stringhe sul thread UI
|
||||
private string _cachedCounterIob = "";
|
||||
private string _cachedCounterMac = "";
|
||||
private string _cachedNote = "";
|
||||
|
||||
/// <summary>
|
||||
/// Loop di gestione worker
|
||||
/// </summary>
|
||||
|
||||
@@ -123,9 +123,6 @@
|
||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>118, 17</value>
|
||||
</metadata>
|
||||
<metadata name="displTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>645, 17</value>
|
||||
</metadata>
|
||||
<data name="lblLogfile.Text" xml:space="preserve">
|
||||
<value>----------------------------------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -757,33 +757,23 @@ namespace IOB_WIN_FORM.Iob
|
||||
else if (ciclo == gatherCycle.HF)
|
||||
{
|
||||
processWhatchDog();
|
||||
//Thread.Sleep(5);
|
||||
processAllMemory();
|
||||
}
|
||||
else if (ciclo == gatherCycle.MF)
|
||||
{
|
||||
processMode();
|
||||
//Thread.Sleep(5);
|
||||
ExecServerRequests();
|
||||
//Thread.Sleep(5);
|
||||
processCustomTaskMF();
|
||||
//Thread.Sleep(5);
|
||||
processOverride();
|
||||
//Thread.Sleep(5);
|
||||
processContapezzi();
|
||||
//Thread.Sleep(5);
|
||||
processCncAlarms();
|
||||
//Thread.Sleep(5);
|
||||
processDynData();
|
||||
//Thread.Sleep(5);
|
||||
processMem2Write();
|
||||
}
|
||||
else if (ciclo == gatherCycle.LF)
|
||||
{
|
||||
processCustomTaskLF();
|
||||
//Thread.Sleep(5);
|
||||
processOtherCounters().GetAwaiter().GetResult(); ;
|
||||
//Thread.Sleep(5);
|
||||
processProgram();
|
||||
}
|
||||
else if (ciclo == gatherCycle.VLF)
|
||||
@@ -793,7 +783,6 @@ namespace IOB_WIN_FORM.Iob
|
||||
processSysInfo();
|
||||
if (enableSlowData)
|
||||
{
|
||||
//Thread.Sleep(5);
|
||||
processSlowDataRead();
|
||||
}
|
||||
}
|
||||
|
||||
+20
-30
@@ -958,41 +958,31 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// </summary>
|
||||
protected override void ProcessDataSync()
|
||||
{
|
||||
try
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
// Eseguiamo il lavoro in un Task per non bloccare il thread chiamante,
|
||||
// ma evitiamo il .GetAwaiter().GetResult() che causerebbe un blocco sincrono pesante.
|
||||
// In un ambiente WinForms, questo permette al thread di polling di non restare in attesa attiva.
|
||||
_ = Task.Run(async () =>
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
// Esecuzione dei task sincroni esistenti
|
||||
iobWriteLocalCSV();
|
||||
iobSendFTP("");
|
||||
IobGetDataFromServer();
|
||||
// Esecuzione dei task sincroni esistenti
|
||||
iobWriteLocalCSV();
|
||||
iobSendFTP("");
|
||||
IobGetDataFromServer();
|
||||
|
||||
// Avvio dei task asincroni in parallelo
|
||||
var taskOdl = ProcessAutoOdlAsync();
|
||||
var taskImport = ProcessFileImportAsync();
|
||||
var taskRecipe = ProcessRecipeFileRetAsync();
|
||||
// Avvio dei task asincroni in parallelo
|
||||
var taskOdl = ProcessAutoOdlAsync();
|
||||
var taskImport = ProcessFileImportAsync();
|
||||
var taskRecipe = ProcessRecipeFileRetAsync();
|
||||
|
||||
// Attendiamo il completamento dei task asincroni senza bloccare thread di sistema
|
||||
await Task.WhenAll(taskOdl, taskImport, taskRecipe);
|
||||
// Attendiamo il completamento dei task asincroni senza bloccare thread di sistema
|
||||
await Task.WhenAll(taskOdl, taskImport, taskRecipe);
|
||||
|
||||
// Task finale sincrono
|
||||
ProcessAutoDossier();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lgError($"Errore interno Task.Run in ProcessDataSync: {ex.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError($"Eccezione in ProcessDataSync (wrapper): {exc.Message}");
|
||||
}
|
||||
// Task finale sincrono
|
||||
ProcessAutoDossier();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lgError($"Errore asincrono Task.Run in ProcessDataSync: {ex.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -21,3 +21,4 @@ STARTLIST=FTP_SONATEST
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
|
||||
@@ -27,3 +27,4 @@ STARTLIST=3024
|
||||
;STARTLIST=LVF652
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
@@ -34,3 +34,4 @@ STARTLIST=SIMUL_01
|
||||
;STARTLIST=3026
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
@@ -21,4 +21,3 @@ STARTLIST=SIMUL_01
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
|
||||
@@ -41,4 +41,5 @@ CLI_INST=SteamWareSim
|
||||
;STARTLIST=SIMUL_01
|
||||
STARTLIST=3010
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
|
||||
@@ -23,4 +23,5 @@ STARTLIST=3018
|
||||
;STARTLIST=3019
|
||||
;STARTLIST=SIMUL_06
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user