Fix modalità abilitazione coda con bool in tutti gli IOB

This commit is contained in:
Samuele Locatelli
2023-09-08 18:45:45 +02:00
parent 805afb982f
commit 9d36511fa5
19 changed files with 119 additions and 54 deletions
+2
View File
@@ -933,6 +933,7 @@ namespace IOB_WIN_NEXT.Iob
// refresh stato allarmi!!!
if (connectionOk)
{
queueInEnabCurr = true;
dtAvvioAdp = DateTime.Now;
if (adpRunning)
{
@@ -996,6 +997,7 @@ namespace IOB_WIN_NEXT.Iob
{
lgError("IMPOSSIBILE effettuare disconnessione: Connessione non disponibile...");
}
queueInEnabCurr = false;
}
#endregion Public Methods
+56 -31
View File
@@ -414,6 +414,15 @@ namespace IOB_WIN_NEXT.Iob
}
}
protected bool queueInEnabCurr { get; set; } = false;
/// <summary>
/// Verifica veto coda QueueIN ed aggiorna abilitazione su variabile
/// </summary>
protected void checkVetoQueueIn()
{
queueInEnabCurr = dtVetoQueueIN < DateTime.Now;
}
/// <summary>
/// Indicazione VETO invio a server sino alla data-ora indicata
/// </summary>
@@ -1726,29 +1735,30 @@ namespace IOB_WIN_NEXT.Iob
else
{
// verifico non sia in veto invio iniziale...
if (dtVetoQueueIN >= adesso)
{
lgDebug($"[VETO FOR QUEUE-IN] | {qEncodeIN} - MESSAGE NOT SENT | {adesso:yyyyMMdd_HHmmss}");
}
else
if (queueInEnabCurr)
{
// --> accodo (valore già formattato)!
QueueIN.Enqueue(qEncodeIN);
// loggo!
lgDebug($"[QUEUE-IN] {qEncodeIN}");
}
}
// aggiorno counters ed eventuale reset
nReadFilt++;
if (nReadFilt > int.MaxValue - 1)
{
nReadFilt = 0; // per evitare buffer overflow...
}
else
{
lgDebug($"[VETO FOR QUEUE-IN] | {qEncodeIN} - MESSAGE NOT SENT | {adesso:yyyyMMdd_HHmmss}");
checkVetoQueueIn();
}
// aggiorno counters ed eventuale reset
nReadFilt++;
if (nReadFilt > int.MaxValue - 1)
{
nReadFilt = 0; // per evitare buffer overflow...
}
counterSigIN++;
if (counterSigIN > 9999)
{
counterSigIN = 0;
counterSigIN++;
if (counterSigIN > 9999)
{
counterSigIN = 0;
}
}
}
@@ -3107,7 +3117,7 @@ namespace IOB_WIN_NEXT.Iob
// resetto tutti i valori BYTE IN/PREV/OUT... così invio macchina spenta...
B_input = 0;
B_output = 0;
B_previous = 0;
B_previous = -1;
accodaSigIN(ref currDispData);
// update controllo
lastDisconnCheck = DateTime.Now;
@@ -3874,6 +3884,10 @@ namespace IOB_WIN_NEXT.Iob
// aggiungo altri defaults
setDefaults(resetQueue);
adpTryRestart = true;
// sistemo altri check avvio
queueInEnabCurr = false;
dtVetoQueueIN = DateTime.Now.AddSeconds(vetoQueueIn);
lgInfoStartup($"Impostato veto QUEUE-IN a {vetoQueueIn}s | fino alle {dtVetoQueueIN:yyyy.MM.dd HH:mm:ss}");
lgDebug("startAdapter completed");
}
@@ -4069,6 +4083,7 @@ namespace IOB_WIN_NEXT.Iob
public virtual void tryConnect()
{
dtAvvioAdp = DateTime.Now;
queueInEnabCurr = true;
}
/// <summary>
@@ -4076,6 +4091,7 @@ namespace IOB_WIN_NEXT.Iob
/// </summary>
public virtual void tryDisconnect()
{
queueInEnabCurr = false;
}
/// <summary>
@@ -4322,7 +4338,7 @@ namespace IOB_WIN_NEXT.Iob
/// <summary>
/// Vettore 32 BIT valori precedenti
/// </summary>
protected int B_previous;
protected int B_previous = -1;
/// <summary>
/// Num errori check alive
@@ -7815,21 +7831,30 @@ namespace IOB_WIN_NEXT.Iob
/// </summary>
private void processAllMemory()
{
// init obj display
newDisplayData currDispData = new newDisplayData();
// in primis SALVO valori previous/precedenti
B_previous = B_output;
// poi faccio lettura NUOVI valori
readAllData(ref currDispData);
// eseguo il filtering dei valori (per i bit "blinking")
filterData();
// effettuo confronto valori vecchi/nuovi... SE trovo variazione OPPURE se è passato +
// di un timeout di controllo...
if (B_output != B_previous)
//verifico se sia abilitato processing...
if (queueInEnabCurr)
{
accodaSigIN(ref currDispData);
// init obj display
newDisplayData currDispData = new newDisplayData();
// in primis SALVO valori previous/precedenti
B_previous = B_output;
// poi faccio lettura NUOVI valori
readAllData(ref currDispData);
// eseguo il filtering dei valori (per i bit "blinking")
filterData();
// effettuo confronto valori vecchi/nuovi... SE trovo variazione OPPURE se è passato +
// di un timeout di controllo...
if (B_output != B_previous)
{
accodaSigIN(ref currDispData);
}
raiseRefresh(currDispData);
}
else
{
lgInfo($"VETO on processAllMemory: queueIn disabled");
checkVetoQueueIn();
}
raiseRefresh(currDispData);
}
private void processMem2Write()
+2
View File
@@ -401,6 +401,7 @@ namespace IOB_WIN_NEXT.Iob
// verifico se sta girando
if (connectionOk)
{
queueInEnabCurr = true;
if (adpRunning)
{
lgInfo("Connessione OK");
@@ -462,6 +463,7 @@ namespace IOB_WIN_NEXT.Iob
{
lgError("IMPOSSIBILE effettuare disconnessione KAWASAKI: Connessione non disponibile...");
}
queueInEnabCurr = false;
needRefresh = true;
}
+16 -11
View File
@@ -18,8 +18,7 @@ namespace IOB_WIN_NEXT.Iob
#region Public Constructors
/// <summary>
/// Estende l'init della classe base, impiegando il pacchetto Nuget TrackHound
/// https://github.com/TrakHound/MTConnect.NET
/// Estende l'init della classe base, impiegando il pacchetto Nuget TrackHound https://github.com/TrakHound/MTConnect.NET
/// </summary>
/// <param name="caller"></param>
/// <param name="adpConf"></param>
@@ -128,11 +127,7 @@ namespace IOB_WIN_NEXT.Iob
DateTime adesso = DateTime.Now;
lastReadPLC = adesso;
// verifico non sia in veto invio iniziale...
if (dtVetoQueueIN >= adesso)
{
lgDebug($"[VETO readSemafori] | veto attivo sino alle {adesso:yyyy.MM.dd HH:mm:ss}");
}
else
if (queueInEnabCurr)
{
try
{
@@ -153,6 +148,11 @@ namespace IOB_WIN_NEXT.Iob
lgError($"Eccezione in readSemafori:{Environment.NewLine}{exc}");
}
}
else
{
lgDebug($"[VETO readSemafori] | veto attivo sino alle {adesso:yyyy.MM.dd HH:mm:ss}");
checkVetoQueueIn();
}
}
/// <summary>
@@ -206,6 +206,7 @@ namespace IOB_WIN_NEXT.Iob
// refresh stato allarmi!!!
if (connectionOk)
{
queueInEnabCurr = true;
if (adpRunning)
{
lgInfo("Connessione OK");
@@ -252,7 +253,7 @@ namespace IOB_WIN_NEXT.Iob
public override void tryDisconnect()
{
// verifico che NON sia in fase di avvio MTC...
if (isConnecting && DateTime.Now.Subtract(startConnecting).TotalSeconds<60)
if (isConnecting && DateTime.Now.Subtract(startConnecting).TotalSeconds < 60)
{
lgInfo("Disconnessione non effettuata: connessione ancora in corso");
}
@@ -280,6 +281,8 @@ namespace IOB_WIN_NEXT.Iob
lgError("IMPOSSIBILE effettuare disconnessione MTC: Connessione non disponibile...");
}
}
queueInEnabCurr = false;
needRefresh = true;
}
#endregion Public Methods
@@ -371,11 +374,15 @@ namespace IOB_WIN_NEXT.Iob
}
}
protected bool isConnecting { get; set; } = false;
/// <summary>
/// Parametri specifici MTC
/// </summary>
protected MtcParamConf mtcParams { get; set; }
protected DateTime startConnecting { get; set; } = DateTime.Today;
/// <summary>
/// URL x salvataggio elenco dataItems MTC
/// </summary>
@@ -502,7 +509,7 @@ namespace IOB_WIN_NEXT.Iob
if (newValue != null)
{
#if false
lgTrace($"Richiesta checkSaveSample per {newValue} | id: {newValue.DataItemId} | CDATA: {newValue.CDATA}");
lgTrace($"Richiesta checkSaveSample per {newValue} | id: {newValue.DataItemId} | CDATA: {newValue.CDATA}");
#endif
// verifico in memoria se ho l'oggetto condition ed il suo valore..
if (dataItemMem.ContainsKey(newValue.DataItemId))
@@ -1046,8 +1053,6 @@ namespace IOB_WIN_NEXT.Iob
lgInfo($"Trasformazione B_input: {B_input} | currRun = {currRun}");
}
}
protected bool isConnecting { get; set; } = false;
protected DateTime startConnecting { get; set; } = DateTime.Today;
/// <summary>
/// Vera connessione ad MTC
+2
View File
@@ -471,6 +471,7 @@ namespace IOB_WIN_NEXT.Iob
if (connectionOk)
{
dtAvvioAdp = DateTime.Now;
queueInEnabCurr = true;
if (adpRunning)
{
lgInfo("Connessione OK");
@@ -536,6 +537,7 @@ namespace IOB_WIN_NEXT.Iob
{
lgError("IMPOSSIBILE effettuare disconnessione: Connessione non disponibile...");
}
queueInEnabCurr = false;
}
#endregion Public Methods
+2
View File
@@ -207,6 +207,7 @@ namespace IOB_WIN_NEXT.Iob
// refresh stato connessione!!!
if (connectionOk)
{
queueInEnabCurr = true;
if (adpRunning)
{
lgInfo("Connessione OK");
@@ -271,6 +272,7 @@ namespace IOB_WIN_NEXT.Iob
{
lgError("IMPOSSIBILE effettuare disconnessione OMRON: Connessione non disponibile...");
}
queueInEnabCurr = false;
}
#endregion Public Methods
+2
View File
@@ -118,6 +118,7 @@ namespace IOB_WIN_NEXT.IobBeckhoff
{
setEventHandler();
readCurrVal();
queueInEnabCurr = true;
}
lgInfo($"Connected: {connectionOk}");
}
@@ -134,6 +135,7 @@ namespace IOB_WIN_NEXT.IobBeckhoff
AdsCli.dispose();
}
connectionOk = false;
queueInEnabCurr = false;
}
#endregion Public Methods
+2
View File
@@ -413,6 +413,7 @@ namespace IOB_WIN_NEXT.IobFile
var nextLevel = Eurom63.ComLevel.IsConnected;
var connectSession = confE63.ActiveSessions[0];
processSession(nextLevel, ref connectSession);
queueInEnabCurr = true;
}
/// <summary>
@@ -421,6 +422,7 @@ namespace IOB_WIN_NEXT.IobFile
public override void tryDisconnect()
{
connectionOk = false;
queueInEnabCurr = false;
try
{
abortPrevJob();
+2
View File
@@ -199,6 +199,7 @@ namespace IOB_WIN_NEXT.IobFile
connectionOk = Directory.Exists(BaseDir);
if (connectionOk)
{
queueInEnabCurr = true;
#if false
try
{
@@ -225,6 +226,7 @@ namespace IOB_WIN_NEXT.IobFile
public override void tryDisconnect()
{
connectionOk = false;
queueInEnabCurr = false;
try
{
#if false
+8 -5
View File
@@ -161,6 +161,7 @@ namespace IOB_WIN_NEXT.IobFile
// refresh stato connessione!!!
if (connectionOk)
{
queueInEnabCurr = true;
if (adpRunning)
{
lgInfo($"Connessione OK alla folder {logDirPath}");
@@ -201,6 +202,7 @@ namespace IOB_WIN_NEXT.IobFile
{
// registro solo che è disconnesso
connectionOk = false;
queueInEnabCurr = false;
}
#endregion Public Methods
@@ -529,11 +531,7 @@ namespace IOB_WIN_NEXT.IobFile
string currVal = getEncodSigLog(sLog2send.dtRif, valInt, counterSigIN);
// verifico non sia in veto invio iniziale...
if (dtVetoQueueIN >= adesso)
{
lgDebug($"[VETO FOR QUEUE-IN] | {currVal} - MESSAGE NOT SENT | {adesso:yyyyMMdd_HHmmss}");
}
else
if (queueInEnabCurr)
{
// --> accodo (valore già formattato)!
QueueIN.Enqueue(currVal);
@@ -545,6 +543,11 @@ namespace IOB_WIN_NEXT.IobFile
counterSigIN = 0;
}
}
else
{
lgDebug($"[VETO FOR QUEUE-IN] | {currVal} - MESSAGE NOT SENT | {adesso:yyyyMMdd_HHmmss}");
checkVetoQueueIn();
}
}
// salvo in last il valore di act...
+2
View File
@@ -523,6 +523,7 @@ namespace IOB_WIN_NEXT.IobModbusTCP
// refresh stato allarmi!!!
if (connectionOk)
{
queueInEnabCurr = true;
lgInfo($"Connessione OK: {connectionOk}");
if (adpRunning)
{
@@ -582,6 +583,7 @@ namespace IOB_WIN_NEXT.IobModbusTCP
}
}
connectionOk = false;
queueInEnabCurr = false;
// resetto last ping...
lastPING = DateTime.Now.AddMinutes(-1);
}
+2
View File
@@ -282,6 +282,7 @@ namespace IOB_WIN_NEXT.IobNet
// refresh stato connessione!!!
if (connectionOk)
{
queueInEnabCurr = true;
if (adpRunning)
{
lgInfo("Connessione OK");
@@ -320,6 +321,7 @@ namespace IOB_WIN_NEXT.IobNet
{
// registro solo che è disconnesso
connectionOk = false;
queueInEnabCurr = false;
}
#endregion Public Methods
+2
View File
@@ -149,6 +149,7 @@ namespace IOB_WIN_NEXT.IobNet
// in primis salvo data ping...
lastPING = DateTime.Now;
connectionOk = true;
queueInEnabCurr = true;
lgInfo("PING OK");
}
else
@@ -167,6 +168,7 @@ namespace IOB_WIN_NEXT.IobNet
{
lgInfo("Richiesta disconnessione adapter PING!");
connectionOk = false;
queueInEnabCurr = false;
}
#endregion Public Methods
+2
View File
@@ -203,6 +203,7 @@ namespace IOB_WIN_NEXT.IobNet
connectionOk = (testPingMachine == IPStatus.Success);
if (connectionOk)
{
queueInEnabCurr = true;
try
{
//var t = TaskEx.Run(() => startDriver());
@@ -229,6 +230,7 @@ namespace IOB_WIN_NEXT.IobNet
public override void tryDisconnect()
{
connectionOk = false;
queueInEnabCurr = false;
try
{
// in primis chiudo driver...
+3 -2
View File
@@ -109,7 +109,7 @@ namespace IOB_WIN_NEXT.IobOpc
lastPzCountSend = adesso;
lastWarnODL = adesso;
lastCurrent = adesso;
lgTrace($"Aggiornato IobOpcUa.lastCurrent: {lastCurrent}");
lgTrace($"Aggiornato IobOpcUa.lastCurrent: {lastCurrent}");
// ora leggo il file di conf specifico....
string jsonFileName = getOptPar("OPC_PARAM_CONF");
if (!string.IsNullOrEmpty(jsonFileName))
@@ -543,10 +543,10 @@ namespace IOB_WIN_NEXT.IobOpc
parentForm.commPlcActive = false;
// connesso se esito == 1...
connectionOk = (esitoLink == 1);
//connectionOk = true;
// refresh stato allarmi!!!
if (connectionOk)
{
queueInEnabCurr = true;
if (adpRunning)
{
lgInfo("Connessione OK");
@@ -618,6 +618,7 @@ namespace IOB_WIN_NEXT.IobOpc
{
lgDebug("IMPOSSIBILE effettuare disconnessione OpcUa: Connessione non disponibile...");
}
queueInEnabCurr = false;
}
#endregion Public Methods
+2
View File
@@ -1032,6 +1032,7 @@ namespace IOB_WIN_NEXT.IobSiemens
// refresh stato allarmi!!!
if (connectionOk)
{
queueInEnabCurr = true;
if (adpRunning)
{
lgInfo($"Connessione OK: {connectionOk} | adpRunning: {adpRunning}");
@@ -1080,6 +1081,7 @@ namespace IOB_WIN_NEXT.IobSiemens
{
currPLC.Close();
connectionOk = false;
queueInEnabCurr = false;
lgInfo(szStatusConnection);
lgInfo("Effettuata disconnessione adapter SIEMENS!");
}
+2
View File
@@ -207,6 +207,7 @@ namespace IOB_WIN_NEXT.IobSql
// refresh stato connessione!!!
if (connectionOk)
{
queueInEnabCurr = true;
if (adpRunning)
{
lgInfo("Connessione OK");
@@ -246,6 +247,7 @@ namespace IOB_WIN_NEXT.IobSql
{
// registro solo che è disconnesso
connectionOk = false;
queueInEnabCurr = false;
}
#endregion Public Methods
+2
View File
@@ -296,6 +296,7 @@ namespace IOB_WIN_NEXT.IobSql
// refresh stato connessione!!!
if (connectionOk)
{
queueInEnabCurr = true;
if (adpRunning)
{
lgInfo("Connessione OK");
@@ -335,6 +336,7 @@ namespace IOB_WIN_NEXT.IobSql
{
// registro solo che è disconnesso
connectionOk = false;
queueInEnabCurr = false;
}
#endregion Public Methods
+8 -5
View File
@@ -298,6 +298,7 @@ namespace IOB_WIN_NEXT.IobSql
// refresh stato connessione!!!
if (connectionOk)
{
queueInEnabCurr = true;
if (adpRunning)
{
lgInfo("Connessione OK");
@@ -337,6 +338,7 @@ namespace IOB_WIN_NEXT.IobSql
{
// registro solo che è disconnesso
connectionOk = false;
queueInEnabCurr = false;
}
#endregion Public Methods
@@ -640,11 +642,7 @@ namespace IOB_WIN_NEXT.IobSql
{
string currVal = getEncodSigLog(sLog2send.DtEve, sLog2send.ValInt, counterSigIN);
// verifico non sia in veto invio iniziale...
if (dtVetoQueueIN >= adesso)
{
lgDebug($"[VETO FOR QUEUE-IN] | {currVal} - MESSAGE NOT SENT | {adesso:yyyyMMdd_HHmmss}");
}
else
if (queueInEnabCurr)
{
// --> accodo (valore già formattato)!
QueueIN.Enqueue(currVal);
@@ -656,6 +654,11 @@ namespace IOB_WIN_NEXT.IobSql
counterSigIN = 0;
}
}
else
{
lgDebug($"[VETO FOR QUEUE-IN] | {currVal} - MESSAGE NOT SENT | {adesso:yyyyMMdd_HHmmss}");
checkVetoQueueIn();
}
}
}