From 2d573f8a950c9ae00385b7ed5e75ce939b08a78f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 3 Sep 2024 12:20:53 +0200 Subject: [PATCH] Aggiunta LUT stati semaforo in RAM --- MapoDb/resoconti.cs | 135 ++++++++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 61 deletions(-) diff --git a/MapoDb/resoconti.cs b/MapoDb/resoconti.cs index 17a775f1..00461832 100644 --- a/MapoDb/resoconti.cs +++ b/MapoDb/resoconti.cs @@ -1,5 +1,5 @@ -using AjaxControlToolkit; using MapoDb; +using MapoDb.DS_applicazioneTableAdapters; using Newtonsoft.Json; using SteamWare; using System; @@ -164,6 +164,39 @@ public class resoconti return _answ; } + /// + /// Recupera commessa attiva al momento indicato + /// + /// + /// + /// + /// + /// + public string commessaAttiva(string idxMacchina, DateTime inizio, DateTime fine, DateTime dataRif) + { + string answ = "NA"; + var tabOdl = OdlPeriodo(idxMacchina, inizio, fine); + if (tabOdl != null) + { + var currRow = tabOdl + .Where(x => x.DataInizio <= dataRif && (x.DataFine >= dataRif || x.DataFine == null)) + .FirstOrDefault(); + // 2023.05.17: se NON trovasse "sposto avanti" un sec... + if (currRow == null) + { + dataRif = dataRif.AddSeconds(1); + currRow = tabOdl + .Where(x => x.DataInizio <= dataRif && (x.DataFine >= dataRif || x.DataFine == null)) + .FirstOrDefault(); + } + if (currRow != null) + { + answ = currRow.KeyRichiesta; + } + } + return answ; + } + /// /// oggetto GRUPPI x sequencer formato VisJS /// @@ -283,13 +316,22 @@ public class resoconti public string semaforoDaIdxStato(int idx) { string _answ = ""; - if (memLayer.ML.CRB("fastColorDecode")) + // cerco in LUT... + if (SemapLUT.ContainsKey(idx)) { - _answ = codSemaforo[idx]; + _answ = SemapLUT[idx]; } else { - _answ = Stati.FindByIdxStato(idx).Semaforo; + if (memLayer.ML.CRB("fastColorDecode")) + { + _answ = codSemaforo[idx]; + } + else + { + _answ = Stati.FindByIdxStato(idx).Semaforo; + } + SemapLUT.Add(idx, _answ); } return _answ; } @@ -576,16 +618,17 @@ public class resoconti protected DS_applicazione.MacchineDataTable _Macchine; protected DS_applicazione.AnagraficaStatiDataTable _Stati; protected DS_applicazione.StatoMacchineDataTable _StatoMacchine; + protected Dictionary SemapLUT = new Dictionary(); protected MapoDb.DS_applicazioneTableAdapters.AnagArticoliTableAdapter taAnagArt; protected MapoDb.DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter taAnagOpr; protected MapoDb.DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter taAnagraficaEventi; protected MapoDb.DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter taDiarioDiBordo; protected MapoDb.DS_applicazioneTableAdapters.MacchineTableAdapter taMacchine; + protected MapoDb.DS_ProdTempiTableAdapters.ODLTableAdapter taODL; protected MapoDb.DS_applicazioneTableAdapters.ParetoDurateTableAdapter taParetoDurate; protected MapoDb.DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter taStati; protected MapoDb.DS_applicazioneTableAdapters.StatoMacchineTableAdapter taStatoMacchine; protected MapoDb.DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter taTempiCiclo; - protected MapoDb.DS_ProdTempiTableAdapters.ODLTableAdapter taODL; #endregion Protected Fields @@ -803,6 +846,32 @@ public class resoconti return _StatoMacchine; } } + + #endregion Protected Properties + + #region Protected Methods + + /// + /// Recupera record odl al momento indicato + /// + /// + /// + /// + /// + /// + protected DS_ProdTempi.ODLRow currOdl(string idxMacchina, DateTime inizio, DateTime fine, DateTime dataRif) + { + DS_ProdTempi.ODLRow answ = null; + var tabOdl = OdlPeriodo(idxMacchina, inizio, fine); + if (tabOdl != null) + { + answ = tabOdl + .Where(x => x.DataInizio <= dataRif && (x.DataFine >= dataRif || x.DataFine == null)) + .FirstOrDefault(); + } + return answ; + } + /// /// Recupera tab ODL per periodo e impianto indicati /// @@ -834,62 +903,6 @@ public class resoconti } return odlReq; } - /// - /// Recupera record odl al momento indicato - /// - /// - /// - /// - /// - /// - protected DS_ProdTempi.ODLRow currOdl(string idxMacchina, DateTime inizio, DateTime fine, DateTime dataRif) - { - DS_ProdTempi.ODLRow answ = null; - var tabOdl = OdlPeriodo(idxMacchina, inizio, fine); - if (tabOdl != null) - { - answ = tabOdl - .Where(x => x.DataInizio <= dataRif && (x.DataFine >= dataRif || x.DataFine == null)) - .FirstOrDefault(); - } - return answ; - } - /// - /// Recupera commessa attiva al momento indicato - /// - /// - /// - /// - /// - /// - public string commessaAttiva(string idxMacchina, DateTime inizio, DateTime fine, DateTime dataRif) - { - string answ = "NA"; - var tabOdl = OdlPeriodo(idxMacchina, inizio, fine); - if (tabOdl != null) - { - var currRow = tabOdl - .Where(x => x.DataInizio <= dataRif && (x.DataFine >= dataRif || x.DataFine == null)) - .FirstOrDefault(); - // 2023.05.17: se NON trovasse "sposto avanti" un sec... - if (currRow == null) - { - dataRif = dataRif.AddSeconds(1); - currRow = tabOdl - .Where(x => x.DataInizio <= dataRif && (x.DataFine >= dataRif || x.DataFine == null)) - .FirstOrDefault(); - } - if (currRow != null) - { - answ = currRow.KeyRichiesta; - } - } - return answ; - } - - #endregion Protected Properties - - #region Protected Methods /// /// Effettua riduzione per accorpamento valori