From b6c60eb4dbf5347ca043add8ccb06321ad289c4c Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 22 Feb 2022 13:22:36 +0100 Subject: [PATCH] Update gestione scrittura x Siemens INGENIA --- IOB-WIN-NEXT/DATA/CONF/MAIN.ini | 3 +- IOB-WIN-NEXT/IobGeneric.cs | 53 ++++++++++++++++--------------- IOB-WIN-NEXT/IobSiemens.cs | 4 +-- IOB-WIN-NEXT/IobSiemensIngenia.cs | 6 ++-- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/IOB-WIN-NEXT/DATA/CONF/MAIN.ini b/IOB-WIN-NEXT/DATA/CONF/MAIN.ini index 06ca7fc5..af1b9fe2 100644 --- a/IOB-WIN-NEXT/DATA/CONF/MAIN.ini +++ b/IOB-WIN-NEXT/DATA/CONF/MAIN.ini @@ -73,6 +73,7 @@ CLI_INST=SteamWareSim ;STARTLIST=MECART_80 ;STARTLIST=PING ;STARTLIST=PIZ09 -STARTLIST=VL25 +;STARTLIST=VL25 +STARTLIST=SIMUL_02 MAXCNC=10 \ No newline at end of file diff --git a/IOB-WIN-NEXT/IobGeneric.cs b/IOB-WIN-NEXT/IobGeneric.cs index 35bf2210..31cad362 100644 --- a/IOB-WIN-NEXT/IobGeneric.cs +++ b/IOB-WIN-NEXT/IobGeneric.cs @@ -1637,7 +1637,7 @@ namespace IOB_WIN_NEXT } catch (Exception exc) { - lgError(exc, "Errore in composizione urlSaveMemConf"); + lgError(exc, "Errore in composizione urlUpdateWriteParams"); } return answ; } @@ -1905,28 +1905,31 @@ namespace IOB_WIN_NEXT // se devo scrivere --> riporto if (needWrite) { - // preparo obj da scrivere - objItem newWrite = new objItem() + if (memMap.mMapWrite.ContainsKey(item.Key)) { - uid = item.Key, - name = item.Key, - reqValue = memMap.mMapWrite[item.Key].value, - lastRequest = DateTime.Now, - writable = true - }; - updatedPar.Add(newWrite); + // preparo obj da scrivere + objItem newWrite = new objItem() + { + uid = item.Key, + name = item.Key, + reqValue = memMap.mMapWrite[item.Key].value, + lastRequest = DateTime.Now, + writable = true + }; + updatedPar.Add(newWrite); + } } } // se ho da scrivere... scrivo TUTTI! if (updatedPar.Count > 0) { // scrivo valore! - lgInfo("Chiamate processMem2Write --> plcWriteParams"); + lgInfo("Chiamata di plcWriteParams da processMem2Write"); plcWriteParams(ref updatedPar); // invio su cloud parametri! string rawData = JsonConvert.SerializeObject(updatedPar); utils.callUrl($"{urlUpdateWriteParams}", rawData); - lgInfo("Notifica a server scrittura parametri"); + lgInfo($"Notificato a server scrittura {updatedPar.Count} parametri"); } } @@ -2590,12 +2593,12 @@ namespace IOB_WIN_NEXT { //if (isVerboseLog) //{ - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB; - lg.Debug(message); - if (sendToForm) - { - sendToLogWatch("DEBUG", message); - } + lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB; + lg.Debug(message); + if (sendToForm) + { + sendToLogWatch("DEBUG", message); + } //} } /// @@ -2607,9 +2610,9 @@ namespace IOB_WIN_NEXT { //if (isVerboseLog) //{ - lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB; - lg.Debug(message, args); - sendToLogWatch("DEBUG", message, args); + lg.Factory.Configuration.Variables["codIOB"] = cIobConf.codIOB; + lg.Debug(message, args); + sendToLogWatch("DEBUG", message, args); //} } @@ -2820,7 +2823,7 @@ namespace IOB_WIN_NEXT answ += $" | Parameter {item.uid} --> {item.reqValue}"; // sistemo valori item.value = item.reqValue; - lgInfo($"Effettuato update parametro: actVal = {item.value} | reqVal = {item.reqValue}"); + lgInfo($"Richiesta update parametro {item.uid} | actVal = {item.value} | reqVal = {item.reqValue}"); item.reqValue = ""; // salvo in lista da ritrasmettere updatedPar.Add(item); @@ -3054,7 +3057,7 @@ namespace IOB_WIN_NEXT if (memMap != null) { // invio su cloud conf memoria... - string rawData = JsonConvert.SerializeObject(memMap); + string rawData = JsonConvert.SerializeObject(memMap, Formatting.Indented); var resp = utils.callUrlNow($"{urlSaveMemMap}", rawData); // salvo ANCHE come parametri i valori... objItem currItem = new objItem(); @@ -3088,7 +3091,7 @@ namespace IOB_WIN_NEXT allParam.Add(currItem); } // invio su cloud parametri! - rawData = JsonConvert.SerializeObject(allParam); + rawData = JsonConvert.SerializeObject(allParam, Formatting.Indented); utils.callUrl($"{urlSaveAllParams}", rawData); lgInfo($"setupMemMap | salvata conf memoria R/W"); } @@ -3473,7 +3476,7 @@ namespace IOB_WIN_NEXT bool fatto = false; if (vetoSplit < DateTime.Now) { - lgInfo("Richiesto forceSplitOdl"); + lgInfo("Richiesto forceSplitOdl"); // imposto veto x 1 minuto ad altre chiamate... vetoSplit = DateTime.Now.AddMinutes(1); // eseguo SOLO SE sono online... diff --git a/IOB-WIN-NEXT/IobSiemens.cs b/IOB-WIN-NEXT/IobSiemens.cs index aebe7a32..fe0cbfad 100644 --- a/IOB-WIN-NEXT/IobSiemens.cs +++ b/IOB-WIN-NEXT/IobSiemens.cs @@ -492,7 +492,7 @@ namespace IOB_WIN_NEXT default: break; } - lgInfo($"---------------MemBlock data---------------{Environment.NewLine}{BitConverter.ToString(MemBlock)}{Environment.NewLine}--------------- END data ---------------"); + lgInfo($"Preparo scrittura{Environment.NewLine}---------------MemBlock data---------------{Environment.NewLine}{BitConverter.ToString(MemBlock)}{Environment.NewLine}--------------- END data ---------------"); if (!string.IsNullOrEmpty(memAddrWrite)) { // scrivo su siemens @@ -1176,7 +1176,7 @@ namespace IOB_WIN_NEXT { case ErrorCode.NoError: answ = true; - maybeLogWrite(memAddrWrite, $"S7WriteBB-01 Effettuata correttamente scrittura su PLC: MEMORIA {memAddrWrite} | numByte: {Value.Length} | ValOriginale: {Value}"); + maybeLogWrite(memAddrWrite, $"S7WriteBB-01 Effettuata correttamente scrittura su PLC: MEMORIA {memAddrWrite} | numByte: {Value.Length} | ValOriginale: {BitConverter.ToString(Value)}"); break; case ErrorCode.WrongCPU_Type: diff --git a/IOB-WIN-NEXT/IobSiemensIngenia.cs b/IOB-WIN-NEXT/IobSiemensIngenia.cs index 801cca73..835e6f6c 100644 --- a/IOB-WIN-NEXT/IobSiemensIngenia.cs +++ b/IOB-WIN-NEXT/IobSiemensIngenia.cs @@ -188,8 +188,6 @@ namespace IOB_WIN_NEXT case taskType.fixStopSetup: case taskType.forceResetPzCount: case taskType.forceSetPzCount: - case taskType.setArt: - case taskType.setComm: case taskType.setProg: case taskType.startSetup: case taskType.stopSetup: @@ -207,6 +205,9 @@ namespace IOB_WIN_NEXT } break; + case taskType.setArt: + case taskType.setComm: + case taskType.setPzComm: case taskType.setParameter: // richiedo da URL i parametri WRITE da popolare lgInfo("Chiamata processMemWriteRequests"); @@ -225,6 +226,7 @@ namespace IOB_WIN_NEXT taskVal = $"WRONG REQUEST FOR SET PARAMETERS: {item.Value} doesnt contain pipe for splitting key/value"; } } + taskOk = true; break; default: