SIEMENS:
- aggiunto veto scrittura PLC in avvio MITSUBISHI - modifica update dati prod curr/last da lettura
This commit is contained in:
+108
-73
@@ -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}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -4203,6 +4208,32 @@ namespace IOB_WIN_FORM.Iob
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserimento/aggiornamento chiavi/valore in lastProdData
|
||||
/// </summary>
|
||||
/// <param name="chiave"></param>
|
||||
/// <param name="valore"></param>
|
||||
/// <returns>True se modificato/inserito, false se INVARIATO</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Formatta URL x invio in DataBlock Json dei dati FLog / eventi
|
||||
/// </summary>
|
||||
@@ -4631,7 +4662,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// <summary>
|
||||
/// Durata in secondi del divieto accodamento segnali IN alla fase di startup
|
||||
/// </summary>
|
||||
protected int vetoQueueIn = 1;
|
||||
protected int vetoQueueIn = 10;
|
||||
|
||||
/// <summary>
|
||||
/// 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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Variabile x vietare rilettura conf memoria (se è stato letto metto veto lungo ad 10 min x evitare loop in avvio)
|
||||
/// </summary>
|
||||
private DateTime vetoReloadConf = DateTime.Now.AddMinutes(-1);
|
||||
|
||||
/// <summary>
|
||||
/// Lettura memorie conf speciali (json) ...SE inserito in [OPTPAR] come PARAM_CONF=nome.json
|
||||
/// </summary>
|
||||
@@ -7841,6 +7867,11 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// </summary>
|
||||
private DateTime VetoProcessAutoOdl = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Variabile x vietare rilettura conf memoria (se è stato letto metto veto lungo ad 10 min x evitare loop in avvio)
|
||||
/// </summary>
|
||||
private DateTime vetoReloadConf = DateTime.Now.AddMinutes(-1);
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario dei valori bloccati x evitare log basato su veto temporale
|
||||
/// </summary>
|
||||
@@ -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<objItem> updatedPar = new List<objItem>();
|
||||
List<objItem> currWritePar = new List<objItem>();
|
||||
// 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<objItem> updatedPar = new List<objItem>();
|
||||
List<objItem> currWritePar = new List<objItem>();
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user