diff --git a/MP.IOC/Controllers/BenchController.cs b/MP.IOC/Controllers/BenchController.cs
index 3d5e6fd2..ca3aeea5 100644
--- a/MP.IOC/Controllers/BenchController.cs
+++ b/MP.IOC/Controllers/BenchController.cs
@@ -62,7 +62,7 @@ namespace MP.IOC.Controllers
///
///
[HttpGet("DatiMacc")]
- public string DatiMacc(string id)
+ public async Task DatiMacc(string id)
{
string answ = "ND";
Stopwatch stopWatch = new Stopwatch();
@@ -77,8 +77,7 @@ namespace MP.IOC.Controllers
answ = "";
try
{
- Dictionary valori = DService.mDatiMacchine(id);
- //Dictionary valori = DService.ResetDatiMacchina(id);
+ Dictionary valori = await DService.mDatiMacchineAsync(id);
foreach (var item in valori)
{
answ += $"{item.Key}|{item.Value}{Environment.NewLine}";
@@ -154,7 +153,7 @@ namespace MP.IOC.Controllers
///
///
[HttpGet("InsEnab")]
- public string InsEnab(string id)
+ public async Task InsEnab(string id)
{
string answ = "ND";
Stopwatch stopWatch = new Stopwatch();
@@ -167,13 +166,8 @@ namespace MP.IOC.Controllers
else
{
// recupero microstato macchina da chiave relativa
- answ = "";
- try
- {
- answ += $"Macchina {id}, insEnabled {DService.IobInsEnab(id)}{Environment.NewLine}";
- }
- catch
- { }
+ var insEnab = await DService.IobInsEnabAsync(id);
+ answ = $"Macchina {id}, insEnabled {insEnab}{Environment.NewLine}";
}
stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
diff --git a/MP.IOC/Data/MpDataService.cs b/MP.IOC/Data/MpDataService.cs
index c3aa09bd..1f570087 100644
--- a/MP.IOC/Data/MpDataService.cs
+++ b/MP.IOC/Data/MpDataService.cs
@@ -1703,17 +1703,6 @@ namespace MP.IOC.Data
return mongoController.InitRecipe(confPath, idxPODL, CalcArgs);
}
- ///
- /// Restituisce il valore booleano se la macchina sia abilitata all'input
- ///
- ///
- ///
- public bool IobInsEnab(string idxMacchina)
- {
- bool answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "insEnabled"));
- return answ;
- }
-
///
/// Restituisce il valore booleano se la macchina sia abilitata all'input
///
@@ -1723,18 +1712,14 @@ namespace MP.IOC.Data
{
var key = Utils.RedKeyDatiMacc(idxMacchina, MpIoNS);
- // 1. Tentativo ottimizzato: leggiamo solo il campo che ci serve
- // Supponendo che tu usi StackExchange.Redis direttamente o un wrapper
string? val = await redisDb.HashGetAsync(key, "insEnabled");
- // 2. Se non c'è in cache, carichiamo/resettiamo tutto
if (val == null)
{
var data = await ResetDatiMacchinaAsync(idxMacchina);
data.TryGetValue("insEnabled", out val);
}
- // 3. Parsing sicuro
return val != null && (val == "1" || val.ToLower() == "true");
}
@@ -2230,6 +2215,7 @@ namespace MP.IOC.Data
return answ;
}
+#if false
///
/// Restituisce valore di una singola chiave del dizionario DatiMacchina
///
@@ -2273,6 +2259,7 @@ namespace MP.IOC.Data
}
return answ;
}
+#endif
///
/// Restitusice elenco KVP dei campi DatiMacchine + StatoMacchine per l'impianto indicato
@@ -4822,6 +4809,7 @@ namespace MP.IOC.Data
stopWatch.Start();
string readType = "DB";
var dbResults = IocDbController.VMSFDGetByMacc(idxMacc);
+ double numSecCache = redisLongTimeCache;
// converto in formato dizionario...
if (dbResults != null && dbResults.Count > 0)
{
@@ -4853,6 +4841,8 @@ namespace MP.IOC.Data
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();
@@ -4861,8 +4851,6 @@ namespace MP.IOC.Data
result.Add("Master", isMaster);
result.Add("Slave", isSlave);
- // durata cache in secondi dal valore insEnabled...
- double numSecCache = ((result["insEnabled"].ToLower() == "true") ? redisShortTimeCache : redisLongTimeCache);
// ...e salvo...
RedisSetHashDict(currHash, result, numSecCache);
@@ -4890,6 +4878,7 @@ namespace MP.IOC.Data
Dictionary? result = new Dictionary();
var dbResult = await IocDbController.VMSFDGetByMaccAsync(idxMacc);
+ double numSecCache = redisLongTimeCache;
// converto in formato dizionario...
if (dbResult != null)
{ // salvo 1:1 i valori... STATO
@@ -4919,6 +4908,9 @@ namespace MP.IOC.Data
result.Add("IdxFamMacc", $"{dbResult.IdxFamiglia}");
result.Add("simplePallet", $"{dbResult.SimplePallet}");
result.Add("palletChange", $"{dbResult.PalletChange}");
+ // durata cache in secondi dal valore insEnabled...
+ //double numSecCache = ((result["insEnabled"].ToLower() == "true") ? redisShortTimeCache : redisLongTimeCache);
+ numSecCache = dbResult.InsEnabled ? redisShortTimeCache : redisLongTimeCache;
}
// cerco info Master/slave...
var m2sTab = await Macchine2SlaveGetAllAsync();
@@ -4927,8 +4919,6 @@ namespace MP.IOC.Data
result.Add("Master", isMaster);
result.Add("Slave", isSlave);
- // durata cache in secondi dal valore insEnabled...
- double numSecCache = ((result["insEnabled"].ToLower() == "true") ? redisShortTimeCache : redisLongTimeCache);
// ...e salvo...
await RedisSetHashDictAsync(currHash, result, numSecCache);
@@ -5189,157 +5179,6 @@ namespace MP.IOC.Data
return RedisGetHashField(currHash, field);
}
-#if false
- ///
- /// controlla se da il segnale di "microstato" deriva un evento da generare - modalità OFFLINE
- ///
- /// idx macchina
- /// valore ingresso
- /// data-ora evento (server)
- ///
- public inputComandoMapo checkMicroStato(string idxMacchina, string valore, DateTime dtEve)
- {
- if (cMemLayer.CRI("_logLevel") > 6)
- {
- Log.Info(string.Format("{2}---------------------------{2}Richiesta verifica INPUT per Macchina {0}, seriale {1}", idxMacchina, valore, Environment.NewLine), tipoLog.INFO);
- }
- // formatto output
- inputComandoMapo answ = new inputComandoMapo();
- DS_applicazione.TransizioneIngressiDataTable TabTransIn;
- DS_applicazione.TransizioneIngressiRow rigaTransIn = null;
- // verifico se esista la macchina altrimenti la creo...
- verificaIdxMacchina(idxMacchina);
- string CodArticolo = "";
- // recupero CodArticolo corretto
- try
- {
- // 2017.07.10 forzo init x errori "sovrapposizioni"
- taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter();
- CodArticolo = taDatiMacchine.getByIdx(idxMacchina)[0].CodArticolo_A;
- }
- catch (Exception exc)
- {
- Log.Info(string.Format("[ChkMiSt_4b] - Eccezione in recupero CodArticolo:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
- }
- // recupero next microstato
- //int? valINT = Convert.ToInt32(valore);
- int? valINT = 0;
- try
- {
- // 2017.06.09 forzo init x errori "sovrapposizioni"
- MapoDbObj.taTransIngr = new DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter();
- valINT = int.Parse(valore, System.Globalization.NumberStyles.HexNumber);
- TabTransIn = MapoDbObj.taTransIngr.getByIdxMacchinaValore(idxMacchina, valINT);
- if (TabTransIn.Rows.Count > 0)
- {
- rigaTransIn = TabTransIn[0];
- }
- }
- catch (Exception exc)
- {
- Log.Info(string.Format("[ChkMiSt_5b] - Eccezione in recupero riga Trans ingressi per idxMacchina {3} e valore {2}:{0}{1}", Environment.NewLine, exc, valINT, idxMacchina), tipoLog.EXCEPTION);
- }
- int _logLevel = cMemLayer.CRI("_logLevel");
- // effettuo update vari
- if (rigaTransIn != null)
- {
- try
- {
- if (_logLevel > 5)
- {
- Log.Info(string.Format("[ChkMiSt_6b] - Salvo Update Microstato:{0}macchina: {1} | valore seriale: {2} | next micro stato: {3}", Environment.NewLine, idxMacchina, valINT, rigaTransIn.next_IdxMicroStato), tipoLog.INFO);
- }
- // salvo nuovo microstato...
- MapoDbObj.taMSM.updateQuery(rigaTransIn.next_IdxMicroStato, dtEve, valore, idxMacchina);
- // controllo se c'è evento
- if (rigaTransIn.IdxTipoEvento > 0)
- {
- if (_logLevel > 5)
- {
- Log.Info(string.Format("[ChkMiSt_7b] - Salvo evento:{0}macchina: {1} | tipoEvento: {2} | CodArticolo: {3}", Environment.NewLine, idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo), tipoLog.INFO);
- }
- answ = scriviRigaEvento(idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo, valore, 0, "-", dtEve, DateTime.Now);
- if (_logLevel > 5)
- {
- Log.Info(string.Format("[ChkMiSt_b] -Macchina {0}, seriale(INT) {1}{2}---------------------------{2}", idxMacchina, valINT, Environment.NewLine), tipoLog.INFO);
- }
- }
- }
- catch (Exception exc)
- {
- Log.Info(string.Format("[ChkMiSt_8b] - Eccezione:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
- }
- }
- return answ;
- }
-
- ///
- /// controlla se da il segnale di "microstato" deriva un evento da generare
- ///
- ///
- ///
- ///
- public inputComandoMapo checkMicroStato(string idxMacchina, string valore)
- {
- // wrapper ad ora corrente...
- return checkMicroStato(idxMacchina, valore, DateTime.Now);
- }
-#endif
-
- ///
- /// cerca codice in anagrafica macchine ed eventualmente inserisce nuova macchina
- ///
- ///
- private void verificaIdxMacchina(string IdxMacchina)
- {
- bool needDB = false;
- try
- {
- // esecuzione in REDIS...cerco status macchina...
- if (mDatiMacchine(IdxMacchina).Count == 0)
- {
- needDB = true;
- }
- }
- catch { }
-
- if (needDB)
- {
- // verifico se esiste su DB
- var dbRec = IocDbController.MacchineGetByIdx(IdxMacchina);
- if (dbRec == null)
- {
- MacchineModel newRec = new MacchineModel()
- {
- IdxMacchina = IdxMacchina,
- CodMacchina = "0000",
- Nome = IdxMacchina,
- Descrizione = "Macchina non codificata",
- Note = "-",
- locazione = "",
- RecipeArchivePath = "",
- RecipePath = ""
- };
- IocDbController.MacchineUpsert(newRec);
-
- // verifico ci sia un microstato macchina...
- var recMSM = IocDbController.MicroStatoMacchinaGetByIdxMacc(IdxMacchina);
- if (recMSM.Count == 0)
- {
- // inserisco nuovo stato...
- MicroStatoMacchinaModel msRec = new MicroStatoMacchinaModel()
- {
- IdxMacchina = IdxMacchina,
- IdxMicroStato = 0,
- InizioStato = DateTime.Now,
- Value = "00"
- };
- IocDbController.MicroStatoMacchinaUpsert(msRec);
- }
- }
- }
- }
-
///
/// cerca codice in anagrafica macchine ed eventualmente inserisce nuova macchina
///
diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj
index 961daab3..a93bab28 100644
--- a/MP.IOC/MP.IOC.csproj
+++ b/MP.IOC/MP.IOC.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 6.16.2604.1812
+ 6.16.2604.1814
diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html
index 2543ff32..0a8754c6 100644
--- a/MP.IOC/Resources/ChangeLog.html
+++ b/MP.IOC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MP-IOC
- Versione: 6.16.2604.1812
+ Versione: 6.16.2604.1814
Note di rilascio:
-
diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt
index 80f19f09..e12d298d 100644
--- a/MP.IOC/Resources/VersNum.txt
+++ b/MP.IOC/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2604.1812
+6.16.2604.1814
diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml
index 889d57f8..0f350468 100644
--- a/MP.IOC/Resources/manifest.xml
+++ b/MP.IOC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2604.1812
+ 6.16.2604.1814
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