From 385bf15d220da7bb4010bd33f88cbe2a52d67edc Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Tue, 20 Jul 2021 19:13:03 +0200 Subject: [PATCH] Aggiunta decodifica watchdog --- AppData/ComLib.cs | 33 ++++++++++++++++--- NKC_WF/WebUserControls/cmp_MachSem.ascx | 3 +- NKC_WF/WebUserControls/cmp_MachSem.ascx.cs | 23 ++++++------- .../cmp_MachSem.ascx.designer.cs | 27 ++++++++++----- 4 files changed, 57 insertions(+), 29 deletions(-) diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs index e1c2e1d..af1a26c 100644 --- a/AppData/ComLib.cs +++ b/AppData/ComLib.cs @@ -66,6 +66,7 @@ namespace AppData public static string redProdMachClock = "NKC:PROD:MACH:CLOCK"; public static string redProdMachList = "NKC:PROD:MACH:LIST"; public static string redProdMachStateData = "NKC:PROD:MACH:STATE"; + public static string redProdMachStateLive = "NKC:PROD:MACH:LIVE"; public static string redProdReq = "NKC:SERV:BUNKS"; public static string redProdStatDec = "NKC:PROD:MACH:STATDEC"; @@ -487,6 +488,29 @@ namespace AppData return currData; } + public static bool setMachLiveStatus(string machine, bool isLive) + { + string redKey = $"{redProdMachStateLive}:{machine}"; + string redVal = $"{isLive}"; + // salvo x 90 sec + bool done = memLayer.ML.setRSV(redKey, redVal, 90); + return done; + } + + public static bool getMachLiveStatus(string machine) + { + bool isLive = false; + /// cerco in redis... + string redKey = $"{redProdMachStateLive}:{machine}"; + string redVal = memLayer.ML.getRSV(redKey); + if (!string.IsNullOrEmpty(redVal)) + { + bool.TryParse(redVal, out isLive); + } + return isLive; + } + + /// /// Salvo in Redis il SUCCESSIVO bunk da lavorare /// @@ -1914,7 +1938,6 @@ namespace AppData public static List prodMachStateDataGet() { List answ = new List(); - string redVal = memLayer.ML.getRSV(redProdMachStateData); if (!string.IsNullOrEmpty(redVal)) { @@ -1986,11 +2009,11 @@ namespace AppData memLayer.ML.setRSV(clockDriftKey, $"{driftSec}"); break; - //case "01": - // // x ora lo ignoro ma so che ora la macchina รจ ALIVE... - // break; - case "01": + // savo status alive + ComLib.setMachLiveStatus(updateRecords.Machine, true); + break; + default: DLMan.taStatLog.insert(item.DtRecord.AddMilliseconds(driftSec), updateRecords.Machine, item.Station, item.Code, item.Payload, 0); break; diff --git a/NKC_WF/WebUserControls/cmp_MachSem.ascx b/NKC_WF/WebUserControls/cmp_MachSem.ascx index 850a829..2c5cd82 100644 --- a/NKC_WF/WebUserControls/cmp_MachSem.ascx +++ b/NKC_WF/WebUserControls/cmp_MachSem.ascx @@ -11,7 +11,6 @@ -
@@ -26,7 +25,7 @@
-  <%: hfMachine.Value %> +  <%: hfMachine.Value %> 
diff --git a/NKC_WF/WebUserControls/cmp_MachSem.ascx.cs b/NKC_WF/WebUserControls/cmp_MachSem.ascx.cs index 86cb5f6..52d854c 100644 --- a/NKC_WF/WebUserControls/cmp_MachSem.ascx.cs +++ b/NKC_WF/WebUserControls/cmp_MachSem.ascx.cs @@ -122,17 +122,6 @@ namespace NKC_WF.WebUserControls #region Public Methods - public bool isLive - { - get - { - bool answ = false; - bool.TryParse(hfLive.Value, out answ); - return answ; - } - } - - public void doUpdate() { // verifico status delle 3 parti e mostro relativo semaforo... @@ -174,8 +163,16 @@ namespace NKC_WF.WebUserControls hfStat03.Value = state03.Descript; } - DS_App.StatusDecodeRow liveState = getState(currState, "LINE"); - hfLive.Value = $"{liveState != null}"; + icnLiveOk.Visible = false; + icnLiveKo.Visible = false; + if (ComLib.getMachLiveStatus(currMachine)) + { + icnLiveOk.Visible = true; + } + else + { + icnLiveKo.Visible = true; + } } #endregion Public Methods diff --git a/NKC_WF/WebUserControls/cmp_MachSem.ascx.designer.cs b/NKC_WF/WebUserControls/cmp_MachSem.ascx.designer.cs index b02de89..64a23e9 100644 --- a/NKC_WF/WebUserControls/cmp_MachSem.ascx.designer.cs +++ b/NKC_WF/WebUserControls/cmp_MachSem.ascx.designer.cs @@ -113,15 +113,6 @@ namespace NKC_WF.WebUserControls /// protected global::System.Web.UI.WebControls.HiddenField hfCss03; - /// - /// Controllo hfLive. - /// - /// - /// Campo generato automaticamente. - /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. - /// - protected global::System.Web.UI.WebControls.HiddenField hfLive; - /// /// Controllo divSelect. /// @@ -175,5 +166,23 @@ namespace NKC_WF.WebUserControls /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.WebControls.LinkButton lbtReset; + + /// + /// Controllo icnLiveOk. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl icnLiveOk; + + /// + /// Controllo icnLiveKo. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl icnLiveKo; } }