diff --git a/MP.IOC/Data/MpDataService.cs b/MP.IOC/Data/MpDataService.cs
index 1f570087..cd2cd890 100644
--- a/MP.IOC/Data/MpDataService.cs
+++ b/MP.IOC/Data/MpDataService.cs
@@ -1748,6 +1748,38 @@ namespace MP.IOC.Data
return val != null && (val == "1" || val.ToLower() == "true");
}
+ ///
+ /// Restituisce il valore booleano se la macchina sia abilitata all'inserimento COMPLETO nel
+ /// Signal Log
+ ///
+ ///
+ ///
+ public async Task IobSLogEnabAsync(string idxMacchina)
+ {
+ bool answ = false;
+ // ORA recupero da memoria redis...
+ try
+ {
+ var currHash = Utils.RedKeyDatiMacc(idxMacchina, MpIoNS);
+ RedisValue rawData = await redisDb.HashGetAsync(currHash, (RedisValue)"sLogEnabled");
+ // se è vuoto... leggo da DB e popolo!
+ if (!rawData.HasValue)
+ {
+ await ResetDatiMacchinaAsync(idxMacchina);
+ // riprovo
+ rawData = await redisDb.HashGetAsync(currHash, (RedisValue)"sLogEnabled");
+ }
+
+ // provo conversione
+ bool.TryParse($"{rawData}", out answ);
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Errore IobSLogEnabAsync | idxMacchina {idxMacchina}:{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
///
///
/// idxMacc odl da cercare
@@ -3114,7 +3146,7 @@ namespace MP.IOC.Data
if (idxMacchina != "" && valore != "")
{
// se abilitato registro evento sul DB
- if (!string.IsNullOrEmpty(idxMacchina) && await sLogEnabAsync(idxMacchina))
+ if (!string.IsNullOrEmpty(idxMacchina) && await IobSLogEnabAsync(idxMacchina))
{
int cntVal = 0;
int.TryParse(contatore, out cntVal);
@@ -3400,30 +3432,6 @@ namespace MP.IOC.Data
return answ;
}
- ///
- /// Esegue eliminazione memoria redis keyVal
- ///
- ///
- ///
- public async Task RedisDelKeyAsync(string keyVal)
- {
- return await RedisDelKeyAsync((RedisKey)keyVal);
-#if false
- bool answ = false;
- var listEndpoints = redisConnAdmin.GetEndPoints();
- foreach (var endPoint in listEndpoints)
- {
- var server = redisConnAdmin.GetServer(endPoint);
- if (server != null)
- {
- await redisDb.KeyDeleteAsync((RedisKey)keyVal);
- answ = true;
- }
- }
- return answ;
-#endif
- }
-
///
/// Esegue eliminazione memoria redis keyVal
///
@@ -3530,7 +3538,6 @@ namespace MP.IOC.Data
return await redisDb.KeyExistsAsync(key);
}
-
public void RedisSetHash(RedisKey redKey, KeyValuePair[] valori, double expireSeconds = -1.0)
{
HashEntry[] redHash = valori.Select(x => new HashEntry(x.Key, x.Value)).ToArray();
@@ -3704,7 +3711,7 @@ namespace MP.IOC.Data
public KeyValuePair[] resetMSMI(string idxMacchina)
{
var currHash = Utils.RedKeyMsmi(idxMacchina);
- //currTask = RedisGetHash(currHash);
+ //currTask = RedisGetHash(redKey);
// recupero records
var tabMSMI = IocDbController.VMSFDGetMultiByMacc(idxMacchina);
@@ -4131,38 +4138,6 @@ namespace MP.IOC.Data
return answ;
}
- ///
- /// Restituisce il valore booleano se la macchina sia abilitata all'inserimento COMPLETO nel
- /// Signal Log
- ///
- ///
- ///
- public async Task sLogEnabAsync(string idxMacchina)
- {
- bool answ = false;
- // ORA recupero da memoria redis...
- try
- {
- var currHash = Utils.RedKeyDatiMacc(idxMacchina, MpIoNS);
- RedisValue rawData = await redisDb.HashGetAsync(currHash, (RedisValue)"sLogEnabled");
- // se è vuoto... leggo da DB e popolo!
- if (!rawData.HasValue)
- {
- await ResetDatiMacchinaAsync(idxMacchina);
- // riprovo
- rawData = await redisDb.HashGetAsync(currHash, (RedisValue)"sLogEnabled");
- }
-
- // provo conversione
- bool.TryParse($"{rawData}", out answ);
- }
- catch (Exception exc)
- {
- Log.Error($"Errore sLogEnabAsync | idxMacchina {idxMacchina}:{Environment.NewLine}{exc}");
- }
- return answ;
- }
-
///
/// Restitusice elenco KVP dei campi della State Machine ingressi nel formato
/// currKey: cState_nVal (current MICRO-STATE + "_" + new Value)
@@ -4193,6 +4168,7 @@ namespace MP.IOC.Data
}
return answ;
}
+
///
/// Restitusice elenco KVP dei campi della State Machine ingressi nel formato
/// currKey: cState_nVal (current MICRO-STATE + "_" + new Value)
@@ -4794,76 +4770,6 @@ namespace MP.IOC.Data
await RedisFlushPatternAsync(pattern);
}
- ///
- /// Restitusice elenco KVP dei campi DatiMacchine + StatoMacchine per l'impianto indicato
- ///
- ///
- ///
- private Dictionary ResetDatiMacchina(string idxMacc)
- {
- var currHash = Utils.RedKeyDatiMacc(idxMacc, MpIoNS);
- // inizio con un bel reset...
- RedisFlushPattern($"{currHash}");
- Dictionary? result = new Dictionary();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- var dbResults = IocDbController.VMSFDGetByMacc(idxMacc);
- double numSecCache = redisLongTimeCache;
- // converto in formato dizionario...
- if (dbResults != null && dbResults.Count > 0)
- {
- var rowResult = dbResults[0];
- // salvo 1:1 i valori... STATO
- result.Add("IdxMicroStato", $"{rowResult.IdxMicroStato}");
- result.Add("IdxStato", $"{rowResult.IdxStato}");
- result.Add("CodArticolo", $"{rowResult.CodArticolo}");
- result.Add("insEnabled", $"{rowResult.InsEnabled}");
- result.Add("sLogEnabled", $"{rowResult.SLogEnabled}");
- result.Add("pallet", $"{rowResult.Pallet}");
- result.Add("CodArticolo_A", $"{rowResult.CodArticoloA}");
- result.Add("CodArticolo_B", $"{rowResult.CodArticoloB}");
- result.Add("TempoCicloBase", $"{rowResult.TempoCicloBase}");
- result.Add("PzPalletProd", $"{rowResult.PzPalletProd}");
- result.Add("MatrOpr", $"{rowResult.MatrOpr}");
- result.Add("lastVal", $"{rowResult.LastVal}");
- result.Add("TCBase", $"{rowResult.TempoCicloBase}");
-
- //...e SETUP
- result.Add("CodMacc", $"{rowResult.Codmacchina}");
- result.Add("IdxFamIn", $"{rowResult.IdxFamigliaIngresso}");
- result.Add("Multi", $"{rowResult.Multi}");
- result.Add("BitFilt", $"{rowResult.BitFilt}");
- result.Add("MaxVal", $"{rowResult.MaxVal}");
- result.Add("BSR", $"{rowResult.Bsr}");
- result.Add("ExplodeBit", $"{rowResult.ExplodeBit}");
- result.Add("NumBit", $"{rowResult.NumBit}");
- result.Add("IdxFamMacc", $"{rowResult.IdxFamiglia}");
- result.Add("simplePallet", $"{rowResult.SimplePallet}");
- result.Add("palletChange", $"{rowResult.PalletChange}");
- //double numSecCache = ((result["insEnabled"].ToLower() == "true") ? redisShortTimeCache : redisLongTimeCache);
- numSecCache = rowResult.InsEnabled ? redisShortTimeCache : redisLongTimeCache;
- }
- // cerco info Master/slave...
- var m2sTab = Macchine2SlaveGetAll();
- string isMaster = m2sTab.Where(x => x.IdxMacchina == idxMacc).Count() > 0 ? "1" : "0";
- string isSlave = m2sTab.Where(x => x.IdxMacchinaSlave == idxMacc).Count() > 0 ? "1" : "0";
- result.Add("Master", isMaster);
- result.Add("Slave", isSlave);
-
- // ...e salvo...
- RedisSetHashDict(currHash, result, numSecCache);
-
- if (result == null)
- {
- result = new Dictionary();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"GetCurrMSFDMacc | Read from {readType}: {ts.TotalMilliseconds}ms");
- return result;
- }
-
///
/// Restitusice elenco KVP dei campi DatiMacchine + StatoMacchine per l'impianto indicato
///
@@ -4871,11 +4777,7 @@ namespace MP.IOC.Data
///
private async Task> ResetDatiMacchinaAsync(string idxMacc)
{
- var currHash = Utils.RedKeyDatiMacc(idxMacc, MpIoNS);
- RedisValue pattern = (RedisValue)$"{currHash}";
- // inizio con un bel reset...
- await RedisFlushPatternAsync(pattern);
- Dictionary? result = new Dictionary();
+ Dictionary result = new Dictionary();
var dbResult = await IocDbController.VMSFDGetByMaccAsync(idxMacc);
double numSecCache = redisLongTimeCache;
@@ -4919,13 +4821,19 @@ namespace MP.IOC.Data
result.Add("Master", isMaster);
result.Add("Slave", isSlave);
+ // elimino valore precedente...
+ var redKey = Utils.RedKeyDatiMacc(idxMacc, MpIoNS);
+#if false
+ await RedisDelKeyAsync(redKey);
// ...e salvo...
- await RedisSetHashDictAsync(currHash, result, numSecCache);
+ await RedisSetHashDictAsync(redKey, result, numSecCache);
+#endif
+ // Creiamo i task senza attenderli immediatamente
+ var delTask = RedisDelKeyAsync(redKey);
+ var setTask = RedisSetHashDictAsync(redKey, result, numSecCache);
+ // Attendiamo entrambi i task contemporaneamente (1 solo RTT percepito)
+ await Task.WhenAll(delTask, setTask);
- if (result == null)
- {
- result = new Dictionary();
- }
return result;
}
@@ -4965,6 +4873,7 @@ namespace MP.IOC.Data
RedisSetHash(currHash, answ, tOut);
return answ;
}
+
///
/// Resetta (rileggendo) i dati della State Machine ingressi nel formato
/// currKey: cState_nVal (current MICRO-STATE + "_" + new Value)
@@ -5027,7 +4936,7 @@ namespace MP.IOC.Data
answ.outValue = inserito.ToString();
answ.needStatusRefresh = true;
return answ;
- }
+ }
#endif
///
diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj
index a93bab28..0285811b 100644
--- a/MP.IOC/MP.IOC.csproj
+++ b/MP.IOC/MP.IOC.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 6.16.2604.1814
+ 6.16.2604.1815
diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html
index 0a8754c6..20a00042 100644
--- a/MP.IOC/Resources/ChangeLog.html
+++ b/MP.IOC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MP-IOC
- Versione: 6.16.2604.1814
+ Versione: 6.16.2604.1815
Note di rilascio:
-
diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt
index e12d298d..7143b205 100644
--- a/MP.IOC/Resources/VersNum.txt
+++ b/MP.IOC/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2604.1814
+6.16.2604.1815
diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml
index 0f350468..709b8456 100644
--- a/MP.IOC/Resources/manifest.xml
+++ b/MP.IOC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2604.1814
+ 6.16.2604.1815
https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip
https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html
false