diff --git a/IOB-WIN-FORM/Iob/Generic.cs b/IOB-WIN-FORM/Iob/Generic.cs index b1203711..e144feea 100644 --- a/IOB-WIN-FORM/Iob/Generic.cs +++ b/IOB-WIN-FORM/Iob/Generic.cs @@ -3088,11 +3088,11 @@ namespace IOB_WIN_FORM.Iob lgError(exc, "Eccezione in processDynData"); } } - // se configurato - if (copyDynToProd) + // ora popolo prod data dai dynData... + foreach (var item in currDynData) { - // ora popolo prod data dai dynData... - foreach (var item in currDynData) + // se configurato x scrivere valori in WRITE PROD + if (copyDynToProd) { // se presente nelle memorie write/read --> metto in curr data... if (memMap.mMapWrite.ContainsKey(item.Key) && !string.IsNullOrEmpty(item.Value)) @@ -3100,6 +3100,11 @@ namespace IOB_WIN_FORM.Iob upsertKey(item.Key, item.Value); } } + // verifico area read x i lastProd... + if (memMap.mMapRead.ContainsKey(item.Key) && !string.IsNullOrEmpty(item.Value)) + { + upsertKeyLP(item.Key, item.Value); + } } } else @@ -3963,10 +3968,10 @@ namespace IOB_WIN_FORM.Iob setDefaults(resetQueue); adpTryRestart = true; // sistemo altri check avvio - queueInEnabCurr = false; dtVetoQueueIN = DateTime.Now.AddSeconds(vetoQueueIn); + queueInEnabCurr = false; lgInfoStartup($"Impostato veto QUEUE-IN a {vetoQueueIn}s | fino alle {dtVetoQueueIN:yyyy.MM.dd HH:mm:ss}"); - lgDebug("startAdapter completed"); + lgDebug($"startAdapter completed | veto queueIn impostato per {vetoQueueIn}s fino alle {dtVetoQueueIN:yyyy.MM.dd HH:mm:ss}"); } /// @@ -4203,6 +4208,32 @@ namespace IOB_WIN_FORM.Iob return done; } + /// + /// Inserimento/aggiornamento chiavi/valore in lastProdData + /// + /// + /// + /// True se modificato/inserito, false se INVARIATO + public bool upsertKeyLP(string chiave, string valore) + { + bool done = false; + if (lastProdData.ContainsKey(chiave)) + { + // se variato inserisco... + if (lastProdData[chiave] != valore) + { + lastProdData[chiave] = valore; + done = true; + } + } + else + { + lastProdData.Add(chiave, valore); + done = true; + } + return done; + } + /// /// Formatta URL x invio in DataBlock Json dei dati FLog / eventi /// @@ -4631,7 +4662,7 @@ namespace IOB_WIN_FORM.Iob /// /// Durata in secondi del divieto accodamento segnali IN alla fase di startup /// - protected int vetoQueueIn = 1; + protected int vetoQueueIn = 10; /// /// Periodo di veto prima di invio nuova conferma dei valori write correnti, default ogni 5 min @@ -5924,11 +5955,6 @@ namespace IOB_WIN_FORM.Iob lgInfo(string.Format("Fine caricamento vettore di {0} variabili per file {1}", numRiga, nomeFile)); } - /// - /// Variabile x vietare rilettura conf memoria (se è stato letto metto veto lungo ad 10 min x evitare loop in avvio) - /// - private DateTime vetoReloadConf = DateTime.Now.AddMinutes(-1); - /// /// Lettura memorie conf speciali (json) ...SE inserito in [OPTPAR] come PARAM_CONF=nome.json /// @@ -7841,6 +7867,11 @@ namespace IOB_WIN_FORM.Iob /// private DateTime VetoProcessAutoOdl = DateTime.Now; + /// + /// Variabile x vietare rilettura conf memoria (se è stato letto metto veto lungo ad 10 min x evitare loop in avvio) + /// + private DateTime vetoReloadConf = DateTime.Now.AddMinutes(-1); + /// /// Dizionario dei valori bloccati x evitare log basato su veto temporale /// @@ -8425,83 +8456,87 @@ namespace IOB_WIN_FORM.Iob } else { - lgInfo($"VETO on processAllMemory: queueIn disabled"); + lgInfo($"VETO on processAllMemory | queueInEnabCurr = {queueInEnabCurr}"); checkVetoQueueIn(); } } private void processMem2Write() { - DateTime adesso = DateTime.Now; - List updatedPar = new List(); - List currWritePar = new List(); - // ciclo tutti gli oggetti write x vedere se modificati... - foreach (var item in currProdData) + // solo SE queue in enabled è true... + if (queueInEnabCurr) { - bool needWrite = false; - string lastVal = item.Value; - // li cerco su last... se non ci sono o modificati --> salvo da scrivere e copio - if (lastProdData.ContainsKey(item.Key)) + DateTime adesso = DateTime.Now; + List updatedPar = new List(); + List currWritePar = new List(); + // ciclo tutti gli oggetti write x vedere se modificati... + foreach (var item in currProdData) { - lastVal = lastProdData[item.Key]; - // verifico se variato... - if (!item.Value.Equals(lastProdData[item.Key])) + bool needWrite = false; + string lastVal = item.Value; + // li cerco su last... se non ci sono o modificati --> salvo da scrivere e copio + if (lastProdData.ContainsKey(item.Key)) { - needWrite = true; - lastProdData[item.Key] = item.Value; - } - } - // aggiungo - else - { - needWrite = true; - lastProdData.Add(item.Key, item.Value); - } - if (memMap != null && memMap.mMapWrite.ContainsKey(item.Key)) - { - // preparo obj da scrivere - objItem newWrite = new objItem() - { - uid = item.Key, - name = item.Key, - description = memMap.mMapWrite[item.Key].description, - reqValue = needWrite ? item.Value : "", - value = lastVal, //item.Value, - lastRequest = adesso, - writable = true, - displOrdinal = memMap.mMapWrite[item.Key].displOrdinal - }; - - // se devo scrivere --> riporto - if (needWrite) - { - updatedPar.Add(newWrite); + lastVal = lastProdData[item.Key]; + // verifico se variato... + if (!item.Value.Equals(lastProdData[item.Key])) + { + needWrite = true; + lastProdData[item.Key] = item.Value; + } } + // aggiungo else { - currWritePar.Add(newWrite); + needWrite = true; + lastProdData.Add(item.Key, item.Value); + } + if (memMap != null && memMap.mMapWrite.ContainsKey(item.Key)) + { + // preparo obj da scrivere + objItem newWrite = new objItem() + { + uid = item.Key, + name = item.Key, + description = memMap.mMapWrite[item.Key].description, + reqValue = needWrite ? item.Value : "", + value = lastVal, //item.Value, + lastRequest = adesso, + writable = true, + displOrdinal = memMap.mMapWrite[item.Key].displOrdinal + }; + + // se devo scrivere --> riporto + if (needWrite) + { + updatedPar.Add(newWrite); + } + else + { + currWritePar.Add(newWrite); + } } } - } - // se ho da scrivere... scrivo TUTTI! - if (updatedPar.Count > 0 && ENABLE_MEM_REWRITE) - { - // scrivo valore! - lgInfo($"Chiamata di plcWriteParams da processMem2Write: {updatedPar.Count} updatedPar"); - plcWriteParams(ref updatedPar); - // invio su cloud parametri! - utils.callUrl($"{urlUpdateWriteParams}", JsonConvert.SerializeObject(updatedPar)); - lgInfo($"Notificato a server scrittura {updatedPar.Count} parametri"); - } - else - { - // se scaduto tempo da ultimo invio... e ho valori - if (currWritePar.Count > 0 && (lastWriteParamsUpsert.AddMinutes(vetoSendWriteUpsert) < adesso)) + // se ho da scrivere... scrivo TUTTI! + if (updatedPar.Count > 0 && ENABLE_MEM_REWRITE) { - lastWriteParamsUpsert = adesso; + // scrivo valore! + lgInfo($"Chiamata di plcWriteParams da processMem2Write: {updatedPar.Count} updatedPar"); + plcWriteParams(ref updatedPar); // invio su cloud parametri! - utils.callUrl($"{urlUpdateWriteParams}", JsonConvert.SerializeObject(currWritePar)); - lgInfo($"Reinviato a server stato {updatedPar.Count} parametri WRITE"); + utils.callUrl($"{urlUpdateWriteParams}", JsonConvert.SerializeObject(updatedPar)); + lgInfo($"Notificato a server scrittura {updatedPar.Count} parametri"); + } + else + { + // se scaduto tempo da ultimo invio... e ho valori + if (currWritePar.Count > 0 && (lastWriteParamsUpsert.AddMinutes(vetoSendWriteUpsert) < adesso)) + { + lastWriteParamsUpsert = adesso; + // invio su cloud parametri! + utils.callUrl($"{urlUpdateWriteParams}", JsonConvert.SerializeObject(currWritePar)); + lgInfo($"Reinviato a server stato {updatedPar.Count} parametri WRITE"); + } } } } diff --git a/IOB-WIN-MITSUBISHI/Iob/Mitsubishi.cs b/IOB-WIN-MITSUBISHI/Iob/Mitsubishi.cs index 507274f2..de995008 100644 --- a/IOB-WIN-MITSUBISHI/Iob/Mitsubishi.cs +++ b/IOB-WIN-MITSUBISHI/Iob/Mitsubishi.cs @@ -462,8 +462,13 @@ namespace IOB_WIN_MITSUBISHI.Iob // cerco in dizionario... if (DictVar.ContainsKey(iVar)) { - outVal.Add(item.Key, $"{DictVar[iVar]}"); - upsertKey(item.Key, $"{DictVar[iVar]}"); + // se NON presente... + if (!outVal.ContainsKey(item.Key)) + { + outVal.Add(item.Key, $"{DictVar[iVar]}"); + } + //upsertKey(item.Key, $"{DictVar[iVar]}"); + upsertKeyLP(item.Key, $"{DictVar[iVar]}"); } } } diff --git a/IOB-WIN-SIEMENS/DATA/CONF/VL26.ini b/IOB-WIN-SIEMENS/DATA/CONF/VL26.ini index 418bf7ae..04d3b733 100644 --- a/IOB-WIN-SIEMENS/DATA/CONF/VL26.ini +++ b/IOB-WIN-SIEMENS/DATA/CONF/VL26.ini @@ -55,6 +55,7 @@ MAX_SEND_PZC_BLOCK=100 ; GEST DATI DYN ENABLE_DYN_DATA=TRUE FORCE_DYN_DATA=TRUE +VETO_QUEUE_IN= 15 ; conf parametri memoria READ/WRITE