From 28c55b6262bd768212401c14498b0179f526c65b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 18 Sep 2023 11:25:58 +0200 Subject: [PATCH 1/2] pulizia Gomba + rec RM code --- IOB-WIN-NEXT/DATA/CONF/IMI_GOMBA.json | 20 ++++++++++---------- IOB-WIN-NEXT/Iob/Generic.cs | 2 +- IOB-WIN-NEXT/IobSoap/Gomba.cs | 4 ++++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/IOB-WIN-NEXT/DATA/CONF/IMI_GOMBA.json b/IOB-WIN-NEXT/DATA/CONF/IMI_GOMBA.json index 9ea5ddaf..3bfa8a2c 100644 --- a/IOB-WIN-NEXT/DATA/CONF/IMI_GOMBA.json +++ b/IOB-WIN-NEXT/DATA/CONF/IMI_GOMBA.json @@ -4,16 +4,16 @@ "name": "reqIN", "description": "Registra Peso IN", "memAddr": "000", - "tipoMem": "SOAP", + "tipoMem": "String", "index": 0, "size": 1, - "displayOrder": 5 + "displayOrder": 5 }, "reqOUT": { "name": "reqOUT", "description": "Registra Peso OUT", "memAddr": "000", - "tipoMem": "SOAP", + "tipoMem": "String", "index": 0, "size": 1, "displayOrder": 6 @@ -22,7 +22,7 @@ "name": "RM", "description": "Codice Pesata", "memAddr": "000", - "tipoMem": "SOAP", + "tipoMem": "String", "index": 0, "size": 1, "displayOrder": 7 @@ -31,7 +31,7 @@ "name": "Cod1", "description": "Codice Cliente", "memAddr": "000", - "tipoMem": "SOAP", + "tipoMem": "String", "index": 0, "size": 1, "displayOrder": 8 @@ -40,7 +40,7 @@ "name": "Cod2", "description": "Targa Automezzo", "memAddr": "000", - "tipoMem": "SOAP", + "tipoMem": "String", "index": 0, "size": 1, "displayOrder": 9 @@ -49,7 +49,7 @@ "name": "Cod3", "description": "Codice Articolo", "memAddr": "000", - "tipoMem": "SOAP", + "tipoMem": "String", "index": 0, "size": 1, "displayOrder": 10 @@ -58,7 +58,7 @@ "name": "Cod4", "description": "Note Ingresso", "memAddr": "000", - "tipoMem": "SOAP", + "tipoMem": "String", "index": 0, "size": 1, "displayOrder": 11 @@ -67,7 +67,7 @@ "name": "Cod5", "description": "Note Uscita", "memAddr": "000", - "tipoMem": "SOAP", + "tipoMem": "String", "index": 0, "size": 1, "displayOrder": 12 @@ -76,7 +76,7 @@ "name": "Cod6", "description": "Note", "memAddr": "000", - "tipoMem": "SOAP", + "tipoMem": "String", "index": 0, "size": 1, "displayOrder": 13 diff --git a/IOB-WIN-NEXT/Iob/Generic.cs b/IOB-WIN-NEXT/Iob/Generic.cs index 715d1e08..2cc7498c 100644 --- a/IOB-WIN-NEXT/Iob/Generic.cs +++ b/IOB-WIN-NEXT/Iob/Generic.cs @@ -3050,7 +3050,7 @@ namespace IOB_WIN_NEXT.Iob if (demFactDynData > 1) { lgTrace($"Non eseguo processDynData: fatt veto {demFactDynData}"); - // ricudo... + // riduco... demFactDynData--; } else diff --git a/IOB-WIN-NEXT/IobSoap/Gomba.cs b/IOB-WIN-NEXT/IobSoap/Gomba.cs index ebefe7aa..3a358d04 100644 --- a/IOB-WIN-NEXT/IobSoap/Gomba.cs +++ b/IOB-WIN-NEXT/IobSoap/Gomba.cs @@ -229,6 +229,10 @@ namespace IOB_WIN_NEXT.IobSoap { // prendo la prima var firstRec = listPesateCurr.Find(x => x.rm == listRmCurr[0]); + if (firstRec != null) + { + outVal.Add("RM", firstRec.rm); + } // accodo x invio pesata valide IN se presenti... if (firstRec.dateInSpecified) { From 496b05492eabf5664f9371a106c47943ae4ba7e0 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 18 Sep 2023 12:06:47 +0200 Subject: [PATCH 2/2] Gestione scrittura GOMBA: richeista pesate, da provare --- IOB-WIN-NEXT/IobSoap/Gomba.cs | 221 +++++++++++----------------------- 1 file changed, 68 insertions(+), 153 deletions(-) diff --git a/IOB-WIN-NEXT/IobSoap/Gomba.cs b/IOB-WIN-NEXT/IobSoap/Gomba.cs index 3a358d04..6acc9109 100644 --- a/IOB-WIN-NEXT/IobSoap/Gomba.cs +++ b/IOB-WIN-NEXT/IobSoap/Gomba.cs @@ -102,6 +102,13 @@ namespace IOB_WIN_NEXT.IobSoap #endregion Public Constructors + + public enum gombaTaskType + { + reqIN, + reqOUT, + } + #region Public Methods /// @@ -113,12 +120,9 @@ namespace IOB_WIN_NEXT.IobSoap { /*--------------------------------------- * fixme todo fare !!! - * gestione execute task SPECIFICI x il sizer: - * - recupero anagrafice variety/layout (attivi) - * - recupero grower - * - invio batch da accodare - * - recupero dati da sizer (OVE disponibili) - * - recupero batch corrente (modalità force/resync?) + * gestione execute task SPECIFICI x pesa: + * - salva i parametri richiesta (RM, cod1..cod6) + * - esegue metodo richiesta (IN/OUT) * *---------------------------------------*/ @@ -127,14 +131,14 @@ namespace IOB_WIN_NEXT.IobSoap if (task2exe != null) { // FIXME TODO FARE !!! - // va inserita la richiesta di pesatura IN piuttosto che OUT (2 comandi? 1 solo con parametro? vedere Baglietto) -#if false + // va inserita la richiesta di pesatura IN piuttosto che OUT (2 comandi) + // controllo se memMap != null... if (memMap != null) { bool taskOk = false; string taskVal = ""; - // cerco task specifici: se ho startSetup --> imposto bit DBB701.DBB0.4 + // cerco task specifici: qui sono NON standard... foreach (var item in task2exe) { taskOk = false; @@ -145,12 +149,6 @@ namespace IOB_WIN_NEXT.IobSoap // controllo sulla KEY... switch (tName) { - case taskType.setSupplier: - - string cmdArgs = item.Value; - taskVal = executeSetSupplier(cmdArgs); - break; - case taskType.setParameter: // richiedo da URL i parametri WRITE da popolare lgInfo("Chiamata setParameter --> processMemWriteRequests"); @@ -183,8 +181,8 @@ namespace IOB_WIN_NEXT.IobSoap else { lgError($"Attenzione! memMap è nullo, non posso eseguire task2exe!"); - } -#endif + } + } return taskDone; @@ -209,7 +207,7 @@ namespace IOB_WIN_NEXT.IobSoap // riordino DESC listPesateCurr = weightArray.OrderByDescending(x => x.dateIn).ToList(); sw.Stop(); - lgInfo($"SOAP: effettuata chiamata reqWeightList in {sw.Elapsed.TotalMilliseconds}ms | {dataFrom} --> {dataTo} | {listPesateCurr.Count} rec"); + 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) @@ -254,34 +252,6 @@ namespace IOB_WIN_NEXT.IobSoap tmpPesate.Add(firstRec); listPesateArch = tmpPesate; } -#if false - - // ciclo i vari indici rimasti - foreach (var item in listRmCurr) - { - // recupero pesata da indice ordinato... - var rec = listPesateCurr.Find(x => x.rm == item); - // accodo x invio pesata valide IN se presenti... - if (rec.dateInSpecified) - { - // invio record SOLO PESO - outVal.Add("lastWeightIn", $"{rec.weightIn}"); - // registro record completo ultima pesata - outVal.Add("lastRecIn", formatPesata(rec, true)); - } - // accodo x invio pesata valide OUT se presenti... - if (rec.dateOutSpecified) - { - // invio record SOLO PESO - outVal.Add("lastWeightOut", $"{rec.weightIn}"); - // registro record completo ultima pesata - outVal.Add("lastRecOut", formatPesata(rec, false)); - } - } - - // salvo nuovo elenco pesate - listPesateArch = listPesateCurr; -#endif } lastReadPLC = DateTime.Now; return outVal; @@ -309,20 +279,6 @@ namespace IOB_WIN_NEXT.IobSoap currVal += formatCode(rec.cod4); currVal += formatCode(rec.cod5); currVal += formatCode(rec.cod6); -#if false - if (!string.IsNullOrEmpty(rec.cod1)) - currVal += $" | {rec.cod1}"; - if (!string.IsNullOrEmpty(rec.cod2)) - currVal += $" | {rec.cod2}"; - if (!string.IsNullOrEmpty(rec.cod3)) - currVal += $" | {rec.cod3}"; - if (!string.IsNullOrEmpty(rec.cod4)) - currVal += $" | {rec.cod4}"; - if (!string.IsNullOrEmpty(rec.cod5)) - currVal += $" | {rec.cod5}"; - if (!string.IsNullOrEmpty(rec.cod6)) - currVal += $" | {rec.cod6}"; -#endif return currVal; } @@ -332,43 +288,6 @@ namespace IOB_WIN_NEXT.IobSoap return $" | {code}"; } - /// - /// Effettua processing CUSTOM x Icoel: - /// - recupera elenco batch delle 2 linee - /// - invia al sistema - /// - public override void processCustomTaskLF() - { - lgInfo($"Richiesto processCustomTaskLF"); - - // FIXME TODO FARE !!! - // forse NON necessario -#if false - var currBatch = IcoelSizer.GetCurrentBatch(); - lgTrace("SOAP: effettuata chiamata IcoelSizer.GetCurrentBatch()"); - if (currBatch != null) - { - // verifico se i batch siano variati... e quindi da inviare... - bool doSend = (currBatchList == null || currBatchList.Count == 0); - if (currBatch.Count > 0 && !doSend) - { - foreach (var item in currBatch) - { - // se variato ID è cambiato - doSend = doSend || (currBatchList[item.Key].Id != item.Value.Id); - } - } - // se devo inviare impacchetto dati - if (doSend) - { - accodaRawData(rawTransfType.IcoelBatch, currBatch); - currBatchList = currBatch; - } - } -#endif - - lastReadPLC = DateTime.Now; - } /// /// Effettua lettura semafori principale Parametri da @@ -395,41 +314,6 @@ namespace IOB_WIN_NEXT.IobSoap B_input += (1 << 4); } - // FIXME TODO FARE !!! - // se risponde è VERDE... altrimenti grigia... e basta! -#if false - if (currBatchList == null) - { - // se nullo --> provo a leggere! - var currBatch = IcoelSizer.GetCurrentBatch(); - lgTrace("SOAP: effettuata chiamata IcoelSizer.GetCurrentBatch()"); - if (currBatch != null) - { - currBatchList = currBatch; - accodaRawData(rawTransfType.IcoelBatch, currBatch); - } - } - else - { - //se i perf parameters mi danno valire > 0 x quantità frutta... - if (perfParamDict != null && perfParamDict.Count > 0) - { - if (perfParamDict.ContainsKey("VelFruttiMinuto")) - { - if (perfParamDict["VelFruttiMinuto"] > 0) - { - B_input += (1 << 1); - } - // metto manuale - else - { - B_input += (1 << 4); - } - } - } - - } -#endif // accodo NON emergenza B_input += (1 << 7); } @@ -561,30 +445,61 @@ namespace IOB_WIN_NEXT.IobSoap { foreach (var item in updatedPar) { - // FIXME TODO FARE !!! - // rivedere: unico parametro da scrivere è il richiesta pesata (IN/OUT) con aprametri 1..6 opzionali... pensarci su... - -#if false - // cerco se sia setSupplier - if (item.uid == "setSupplier") + // salvo i valori di setup x prox pesata... + upsertKey(item.uid, item.reqValue); + bool fatto = false; + // se è richiesta pesata IN/OUT --> mando chiamata + if (item.uid == "reqIN") { - string reqVal = !string.IsNullOrEmpty(item.reqValue) ? item.reqValue : item.value; - // chiamo - var taskVal = executeSetSupplier(reqVal); - bool fatto = taskVal.StartsWith("REQUEST"); - // se fatto --> aggiorno! - if (fatto) - { - //item.value = item.reqValue; - item.reqValue = ""; - item.lastRead = DateTime.Now; - item.UM = ""; - } - } -#endif + fatto = reqWeight(true); + } + else if (item.uid == "reqOUT") + { + fatto = reqWeight(false); + } + // se fatto --> aggiorno! + if (fatto) + { + //item.value = item.reqValue; + item.reqValue = ""; + item.lastRead = DateTime.Now; + item.UM = ""; + } } } - + /// + /// Esegue richiesta PESO + /// + /// Tipo richiesta: IN (true) / OUT (false) + /// + protected bool reqWeight(bool reqIN) + { + bool fatto = false; + try + { + Stopwatch sw = new Stopwatch(); + sw.Start(); + // preparo parametri + string tipoRic = reqIN ? "IN" : "OUT"; + string rm = string.IsNullOrEmpty(currProdData["RM"]) ? $"{DateTime.Now:yyyyMMdd-HHmmss}" : currProdData["RM"]; + string Cod1 = string.IsNullOrEmpty(currProdData["Cod1"]) ? "" : currProdData["Cod1"]; + string Cod2 = string.IsNullOrEmpty(currProdData["Cod2"]) ? "" : currProdData["Cod2"]; + string Cod3 = string.IsNullOrEmpty(currProdData["Cod3"]) ? "" : currProdData["Cod3"]; + string Cod4 = string.IsNullOrEmpty(currProdData["Cod4"]) ? "" : currProdData["Cod4"]; + string Cod5 = string.IsNullOrEmpty(currProdData["Cod5"]) ? "" : currProdData["Cod5"]; + string Cod6 = string.IsNullOrEmpty(currProdData["Cod6"]) ? "" : currProdData["Cod6"]; + // faccio chiamata + var answ = gombaConn.memWeight(tipoRic, rm, Cod1, Cod2, Cod3, Cod4, Cod5, Cod6); + fatto = answ.feedback == "C"; + sw.Stop(); + lgInfo($"SOAP: effettuata chiamata reqWeightList in {sw.Elapsed.TotalMilliseconds}ms | {dataFrom} --> {dataTo}"); + } + catch (Exception exc) + { + lgError($"reqWeight | errore richiesta pesatura{Environment.NewLine}{exc}"); + } + return fatto; + } #endregion Protected Methods