Update MBus x reinvio dati variabiliWrite x MBus (es Pizzaferri)
This commit is contained in:
+61
-18
@@ -2984,10 +2984,12 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// </summary>
|
||||
public void processDynData()
|
||||
{
|
||||
// FixMe Todo: generalizzare parametri nell'obj?
|
||||
bool enableByApp = utils.CRB("enableDynData");
|
||||
bool enableByIob = (getOptPar("ENABLE_DYN_DATA") == "TRUE");
|
||||
bool forceSendByIob = (getOptPar("FORCE_DYN_DATA") == "TRUE");
|
||||
bool disableDynData = (getOptPar("DISABLE_DYN_DATA") == "TRUE");
|
||||
bool copyDynToProd = (getOptPar("COPY_DYN2PROD_DATA") == "TRUE");
|
||||
Dictionary<string, string> currDynData = new Dictionary<string, string>();
|
||||
|
||||
if (enableByApp || enableByIob)
|
||||
@@ -3065,6 +3067,19 @@ 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)
|
||||
{
|
||||
// se presente nelle memorie write/read --> metto in curr data...
|
||||
if (memMap.mMapWrite.ContainsKey(item.Key) && !string.IsNullOrEmpty(item.Value))
|
||||
{
|
||||
upsertKey(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4568,6 +4583,11 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// </summary>
|
||||
protected DateTime lastWarnODL;
|
||||
|
||||
/// <summary>
|
||||
/// ultima data-ora invio parametri write x ribadire status
|
||||
/// </summary>
|
||||
protected DateTime lastWriteParamsUpsert = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Separatore linea (tipicamente x commenti)
|
||||
/// </summary>
|
||||
@@ -4666,6 +4686,11 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// </summary>
|
||||
protected int vetoQueueIn = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Periodo di veto prima di invio nuova conferma dei valori write correnti, default ogni 5 min
|
||||
/// </summary>
|
||||
protected int vetoSendWriteUpsert = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Periodo wathdog di default (2 sec se non specificato)
|
||||
/// </summary>
|
||||
@@ -6282,6 +6307,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
currOut = $" | Parameter {item.uid} | {item.value} --> {item.reqValue}";
|
||||
// sistemo valori
|
||||
item.value = item.reqValue;
|
||||
// forzo variabile writeable
|
||||
item.writable = true;
|
||||
lgInfo($"Richiesta update parametro {currOut}");
|
||||
// salvo in lista da ritrasmettere
|
||||
updatedPar.Add(item);
|
||||
@@ -8313,7 +8340,9 @@ namespace IOB_WIN_FORM.Iob
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -8334,26 +8363,30 @@ namespace IOB_WIN_FORM.Iob
|
||||
needWrite = true;
|
||||
lastProdData.Add(item.Key, item.Value);
|
||||
}
|
||||
// se devo scrivere --> riporto
|
||||
if (needWrite)
|
||||
if (memMap != null && memMap.mMapWrite.ContainsKey(item.Key))
|
||||
{
|
||||
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 = item.Value,
|
||||
value = item.Value,
|
||||
lastRequest = adesso,
|
||||
writable = true,
|
||||
displOrdinal = memMap.mMapWrite[item.Key].displOrdinal
|
||||
};
|
||||
|
||||
// se devo scrivere --> riporto
|
||||
if (needWrite)
|
||||
{
|
||||
// preparo obj da scrivere
|
||||
objItem newWrite = new objItem()
|
||||
{
|
||||
uid = item.Key,
|
||||
name = item.Key,
|
||||
description = memMap.mMapWrite[item.Key].description,
|
||||
//reqValue = memMap.mMapWrite[item.Key].value,
|
||||
reqValue = item.Value,
|
||||
value = item.Value,
|
||||
lastRequest = DateTime.Now,
|
||||
writable = true,
|
||||
displOrdinal = memMap.mMapWrite[item.Key].displOrdinal
|
||||
};
|
||||
updatedPar.Add(newWrite);
|
||||
}
|
||||
else
|
||||
{
|
||||
currWritePar.Add(newWrite);
|
||||
}
|
||||
}
|
||||
}
|
||||
// se ho da scrivere... scrivo TUTTI!
|
||||
@@ -8363,10 +8396,20 @@ namespace IOB_WIN_FORM.Iob
|
||||
lgInfo($"Chiamata di plcWriteParams da processMem2Write: {updatedPar.Count} updatedPar");
|
||||
plcWriteParams(ref updatedPar);
|
||||
// invio su cloud parametri!
|
||||
string rawData = JsonConvert.SerializeObject(updatedPar);
|
||||
utils.callUrl($"{urlUpdateWriteParams}", rawData);
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -22,8 +22,8 @@ CLI_INST=SteamWareSim
|
||||
;NB: mettere copy always ai file di conf x fare test...
|
||||
;STARTLIST=SIMUL_01
|
||||
;STARTLIST=WPS
|
||||
;STARTLIST=PIZ10
|
||||
STARTLIST=Tend_FIMAT_01
|
||||
STARTLIST=PIZ09
|
||||
;STARTLIST=Tend_FIMAT_01
|
||||
|
||||
|
||||
MAXCNC=10
|
||||
@@ -51,7 +51,7 @@ BLINK_FILT=0
|
||||
|
||||
[OPTPAR]
|
||||
;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice
|
||||
PZCOUNT_MODE=STD.DB85.DBRE16
|
||||
PZCOUNT_MODE=STD.Level
|
||||
DISABLE_PZCOUNT=TRUE
|
||||
ENABLE_SEND_PZC_BLOCK=TRUE
|
||||
MIN_SEND_PZC_BLOCK=0
|
||||
|
||||
@@ -242,10 +242,18 @@
|
||||
<None Include="DATA\CONF\PIZ05.json" />
|
||||
<None Include="DATA\CONF\PIZ05_alarm.json" />
|
||||
<None Include="DATA\CONF\PIZ05_MBlock.json" />
|
||||
<None Include="DATA\CONF\PIZ09.ini" />
|
||||
<None Include="DATA\CONF\PIZ09.json" />
|
||||
<None Include="DATA\CONF\PIZ09_alarm.json" />
|
||||
<None Include="DATA\CONF\PIZ09_MBlock.json" />
|
||||
<None Include="DATA\CONF\PIZ09.ini">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="DATA\CONF\PIZ09.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="DATA\CONF\PIZ09_alarm.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="DATA\CONF\PIZ09_MBlock.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="DATA\CONF\PIZ10.ini" />
|
||||
<None Include="DATA\CONF\PIZ10.json" />
|
||||
<None Include="DATA\CONF\PIZ10_alarm.json" />
|
||||
|
||||
@@ -299,6 +299,9 @@ namespace IOB_WIN_MBUS.IobModbusTCP
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gestione contapezzi
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
if ((enablePzCountByApp || enablePzCountByIob) && !(disablePzCountByIob))
|
||||
|
||||
Reference in New Issue
Block a user