From 2278d7796fc3341b1a2de27144186930e7dcb7d9 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 20 Sep 2023 16:34:32 +0200 Subject: [PATCH 1/3] Update logica gomba x invio parametri --- IOB-WIN-NEXT/DATA/CONF/IMI_GOMBA.json | 26 ++++++------- IOB-WIN-NEXT/DATA/CONF/MAIN.ini | 2 +- IOB-WIN-NEXT/IOB-WIN-NEXT.csproj | 8 +++- IOB-WIN-NEXT/IobSoap/Gomba.cs | 56 ++++++++++++++++----------- 4 files changed, 54 insertions(+), 38 deletions(-) diff --git a/IOB-WIN-NEXT/DATA/CONF/IMI_GOMBA.json b/IOB-WIN-NEXT/DATA/CONF/IMI_GOMBA.json index d3065b70..668e5a18 100644 --- a/IOB-WIN-NEXT/DATA/CONF/IMI_GOMBA.json +++ b/IOB-WIN-NEXT/DATA/CONF/IMI_GOMBA.json @@ -1,23 +1,14 @@ { "mMapWrite": { - "reqIN": { - "name": "reqIN", - "description": "Registra Peso IN", + "reqPesata": { + "name": "reqPesata", + "description": "Registra Peso IN/OUT", "memAddr": "000", "tipoMem": "String", "index": 0, "size": 1, "displOrdinal": 5 - }, - "reqOUT": { - "name": "reqOUT", - "description": "Registra Peso OUT", - "memAddr": "000", - "tipoMem": "String", - "index": 0, - "size": 1, - "displOrdinal": 6 - }, + }, "RM": { "name": "RM", "description": "Codice Pesata", @@ -83,6 +74,15 @@ } }, "mMapRead": { + "logReq": { + "name": "logReq", + "description": "Esito Comando Pesata", + "memAddr": "000", + "tipoMem": "String", + "index": 0, + "size": 1, + "displOrdinal": 6 + }, "lastWeightIn": { "name": "lastWeightIn", "description": "Ultima Pesata IN (kg)", diff --git a/IOB-WIN-NEXT/DATA/CONF/MAIN.ini b/IOB-WIN-NEXT/DATA/CONF/MAIN.ini index 419b72e8..24c869da 100644 --- a/IOB-WIN-NEXT/DATA/CONF/MAIN.ini +++ b/IOB-WIN-NEXT/DATA/CONF/MAIN.ini @@ -59,6 +59,6 @@ CLI_INST=SteamWareSim ;STARTLIST=SIMUL_02 ;NB: mettere copy always ai file di conf x fare test... -STARTLIST=SIMUL_01 +STARTLIST=IMI_GOMBA MAXCNC=10 \ No newline at end of file diff --git a/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj b/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj index 16546474..384d2f35 100644 --- a/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj +++ b/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj @@ -489,10 +489,14 @@ - + + Always + - + + Always + diff --git a/IOB-WIN-NEXT/IobSoap/Gomba.cs b/IOB-WIN-NEXT/IobSoap/Gomba.cs index 0ff70286..1b1ef722 100644 --- a/IOB-WIN-NEXT/IobSoap/Gomba.cs +++ b/IOB-WIN-NEXT/IobSoap/Gomba.cs @@ -114,11 +114,6 @@ namespace IOB_WIN_NEXT.IobSoap { // valore non presente in vers default... se gestito fare override Dictionary outVal = new Dictionary(); - - // FIXME TODO FARE !!! - // recuperare elenco pesate e inserire in param list elenco nuove pesate (eventualmente ripetendo ultima?) - // usare redis x salvare ultima pesata registrata in locale... - Stopwatch sw = new Stopwatch(); sw.Start(); // test lettura elenco pesate... se NON nullo --> OK! @@ -127,7 +122,6 @@ namespace IOB_WIN_NEXT.IobSoap listPesateCurr = weightArray.OrderByDescending(x => x.dateIn).ToList(); sw.Stop(); lgInfo($"getDynData | SOAP: effettuata chiamata reqWeightList in {sw.Elapsed.TotalMilliseconds}ms | {dataFrom} --> {dataTo} | {listPesateCurr.Count} rec"); - // verifico se siano pesate nuove o meno... if (listPesateCurr.Count != listPesateArch.Count) { @@ -172,10 +166,19 @@ namespace IOB_WIN_NEXT.IobSoap listPesateArch = tmpPesate; } } + + // rileggo comunque dati IN... + if (memMap.mMapRead.Count > 0) + { + foreach (var item in memMap.mMapRead) + { + } + } lastReadPLC = DateTime.Now; return outVal; } + /// /// Effettua lettura semafori principale Parametri da /// aggiornare x display in form @@ -187,10 +190,7 @@ namespace IOB_WIN_NEXT.IobSoap B_input = 1; currDispData.semIn = Semaforo.SV; - // refresh pesate... - // se ho pesate in memoria nel periodo richiesto --> RUN - if (listPesateCurr != null && listPesateCurr.Count > 0) { B_input += (1 << 1); @@ -334,6 +334,7 @@ namespace IOB_WIN_NEXT.IobSoap protected override void plcWriteParams(ref List updatedPar) { lgTrace($"plcWriteParams: richiesta per {updatedPar.Count} params"); + List extraPar = new List(); foreach (var item in updatedPar) { lgInfo($"ITEM | {item.uid} | {item.value}"); @@ -341,17 +342,14 @@ namespace IOB_WIN_NEXT.IobSoap upsertKey(item.uid, item.value); bool fatto = false; bool isPesata = false; + bool isIN = false; gestWeightOut answ = new gestWeightOut(); // se è richiesta pesata IN/OUT --> mando chiamata - if (item.uid == "reqIN") + if (item.uid == "reqPesata") { isPesata = true; - answ = reqWeight(true); - } - else if (item.uid == "reqOUT") - { - isPesata = true; - answ = reqWeight(false); + isIN = item.value.ToUpper() == "IN"; + answ = reqWeight(isIN); } else if (item.uid == "RM" || item.uid.StartsWith("Cod")) { @@ -365,19 +363,33 @@ namespace IOB_WIN_NEXT.IobSoap // se è OK if (answ.feedback == "C") { - item.value = $"{answ.feedback} | {answ.notes}"; - item.reqValue = ""; - item.lastRead = DateTime.Now; - item.UM = ""; string recPesata = formatPesata(answ, item.uid == "reqIN"); lgInfo($"reqWeight | OK effettuato pesata | {recPesata}"); + // aggiorno dati pesate IN/OUT... + if(isIN) + { + upsertKey("lastWeightIn", answ.weightIn); + upsertKey("lastRecIn", recPesata); + } + else + { + upsertKey("lastWeightOut", answ.weightIn); + upsertKey("lastRecOut", recPesata); + } } else { - item.value = $"{answ.feedback} | {answ.notes}"; - item.reqValue = ""; lgError($"reqWeight | Errore in richiesta peso GOMBA | {answ.feedback} | {answ.notes}"); } + item.value = $""; + //item.value = $"{answ.feedback} | {answ.notes}"; + item.reqValue = ""; + item.lastRead = DateTime.Now; + item.UM = ""; + // salvo esito richiesta comunque + upsertKey("logReq", $"{answ.feedback} | {answ.notes}"); + // faccio in modo di eseguire subito getDynData + demFactDynData = 1; } else { From 4a9289d180886c63b600e9db16404eccb3d12a0a Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 20 Sep 2023 17:30:50 +0200 Subject: [PATCH 2/3] Merge gestione Gomba x rilettura info --- IOB-WIN-NEXT/Iob/Generic.cs | 2 +- IOB-WIN-NEXT/IobSoap/Gomba.cs | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/IOB-WIN-NEXT/Iob/Generic.cs b/IOB-WIN-NEXT/Iob/Generic.cs index 298e3eef..afa8f992 100644 --- a/IOB-WIN-NEXT/Iob/Generic.cs +++ b/IOB-WIN-NEXT/Iob/Generic.cs @@ -6106,7 +6106,7 @@ namespace IOB_WIN_NEXT.Iob if (trovato == null) { currValore = ""; - //se ho valori current li impiego... + // se ho valori current li impiego... if (currProdData.ContainsKey(item.Value.name)) { currValore = currProdData[item.Value.name]; diff --git a/IOB-WIN-NEXT/IobSoap/Gomba.cs b/IOB-WIN-NEXT/IobSoap/Gomba.cs index 0ff70286..17e4c6e7 100644 --- a/IOB-WIN-NEXT/IobSoap/Gomba.cs +++ b/IOB-WIN-NEXT/IobSoap/Gomba.cs @@ -128,7 +128,7 @@ namespace IOB_WIN_NEXT.IobSoap sw.Stop(); lgInfo($"getDynData | SOAP: effettuata chiamata reqWeightList in {sw.Elapsed.TotalMilliseconds}ms | {dataFrom} --> {dataTo} | {listPesateCurr.Count} rec"); - // verifico se siano pesate nuove o meno... + // verifico se CI SIANO siano pesate nuove o meno... if (listPesateCurr.Count != listPesateArch.Count) { // elenco indici @@ -172,6 +172,16 @@ namespace IOB_WIN_NEXT.IobSoap listPesateArch = tmpPesate; } } + + // processo comunque le aree memoria READ... + if (memMap.mMapRead.Count > 0) + { + foreach (var item in memMap.mMapRead) + { + var currVal = getCurrProdData(item.Key, ""); + outVal.Add(item.Key, $"{currVal}"); + } + } lastReadPLC = DateTime.Now; return outVal; } @@ -187,10 +197,7 @@ namespace IOB_WIN_NEXT.IobSoap B_input = 1; currDispData.semIn = Semaforo.SV; - // refresh pesate... - // se ho pesate in memoria nel periodo richiesto --> RUN - if (listPesateCurr != null && listPesateCurr.Count > 0) { B_input += (1 << 1); @@ -365,7 +372,7 @@ namespace IOB_WIN_NEXT.IobSoap // se è OK if (answ.feedback == "C") { - item.value = $"{answ.feedback} | {answ.notes}"; + item.value = $"{answ.feedback} | {answ.notes}"; item.reqValue = ""; item.lastRead = DateTime.Now; item.UM = ""; From 5947e1cfec66ccce5d9479874950086132914331 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 20 Sep 2023 17:33:56 +0200 Subject: [PATCH 3/3] Fix weight out --- IOB-WIN-NEXT/IobSoap/Gomba.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IOB-WIN-NEXT/IobSoap/Gomba.cs b/IOB-WIN-NEXT/IobSoap/Gomba.cs index 651c27ed..d7a8a435 100644 --- a/IOB-WIN-NEXT/IobSoap/Gomba.cs +++ b/IOB-WIN-NEXT/IobSoap/Gomba.cs @@ -377,7 +377,7 @@ namespace IOB_WIN_NEXT.IobSoap } else { - upsertKey("lastWeightOut", answ.weightIn); + upsertKey("lastWeightOut", answ.weightOut); upsertKey("lastRecOut", recPesata); } }