diff --git a/IOB-WIN/DATA/CONF/VL24.ini b/IOB-WIN/DATA/CONF/VL24.ini index adff03df..544e430f 100644 --- a/IOB-WIN/DATA/CONF/VL24.ini +++ b/IOB-WIN/DATA/CONF/VL24.ini @@ -57,6 +57,8 @@ PZCOUNT_MODE=STD.DB1275.DBDW4 DISABLE_PZCOUNT=TRUE ENABLE_DYN_DATA=TRUE FORCE_DYN_DATA=TRUE +ENABLE_SEND_PZC_BLOCK=TRUE +MAX_SEND_PZC_BLOCK=10 ; conf parametri memoria READ/WRITE PARAM_CONF=VL24.json diff --git a/IOB-WIN/IobGeneric.cs b/IOB-WIN/IobGeneric.cs index 1b2540d4..cb787389 100644 --- a/IOB-WIN/IobGeneric.cs +++ b/IOB-WIN/IobGeneric.cs @@ -273,6 +273,16 @@ namespace IOB_WIN /// Ultimo Override set letto /// public string lastOverrideRapid { get; set; } + + /// + /// Abilitazione invio pezzi "in blocco" per recupero contapezzi + /// + public bool enableSendPzCountBlock { get; set; } = false; + /// + /// Massimo numero di px da inviare in blocco + /// + public int maxSendPzCountBlock { get; set; } = 0; + /// /// Array dei contatori x segnali blinking @@ -603,6 +613,28 @@ namespace IOB_WIN protected virtual void loadMemConf() { lgInfo("BEGIN loadMemConf"); + // variabili x gestione send contapezzi in blocco + string currPar = getOptPar("ENABLE_SEND_PZC_BLOCK"); + if (!string.IsNullOrEmpty(currPar)) + { + bool enableSend = false; + bool.TryParse(currPar, out enableSend); + enableSendPzCountBlock = enableSend; + // se abilitato leggo num pezzi da reinviare in blocco + if (enableSendPzCountBlock) + { + currPar = getOptPar("MAX_SEND_PZC_BLOCK"); + if (!string.IsNullOrEmpty(currPar)) + { + int numMax = 0; + int.TryParse(currPar, out numMax); + if (numMax > 0) + { + maxSendPzCountBlock = numMax; + } + } + } + } // inizializzo LUT decodifica string jsonConf = getOptPar("PARAM_CONF"); if (!string.IsNullOrEmpty(jsonConf)) @@ -2169,6 +2201,44 @@ namespace IOB_WIN } } /// + /// URL per salvataggio contapezzi (quelli della macchina: PLC/CNC)... + /// + public string urlSetPzCountMAC + { + get + { + string answ = ""; + try + { + answ = string.Format(@"http://{0}{1}{2}/setCounter/MAC_{3}?counter=", cIobConf.serverData.MPIP, cIobConf.serverData.MPURL, cIobConf.serverData.CMDALIVE, cIobConf.codIOB); + } + catch (Exception exc) + { + lgError(exc, "Errore in composizione urlSetPzCountMAC"); + } + return answ; + } + } + /// + /// URL per INVIO IN BLOCCO di un INCREMENTO x contapezzi (quelli della macchina: PLC/CNC)... + /// + public string urlAddPzCount + { + get + { + string answ = ""; + try + { + answ = string.Format(@"http://{0}{1}{2}/doPzCountInc/{3}?qty=", cIobConf.serverData.MPIP, cIobConf.serverData.MPURL, cIobConf.serverData.CMDALIVE, cIobConf.codIOB); + } + catch (Exception exc) + { + lgError(exc, "Errore in composizione urlAddPzCount"); + } + return answ; + } + } + /// /// URL per salvataggio VALORI opzionali... /// public string urlSetOptVal @@ -3010,7 +3080,43 @@ namespace IOB_WIN accodaFLog(sVal, qEncodeFLog("PROG", currPrgName)); } } - + /// + /// Effettua verifica se abilitato invio pezzi in blocco e nel caso + /// - invio in blocco pezzi + /// - aggiornamento del contapezzi (passato come ref) x nuovo valore post invio + /// + /// + /// + public void trySendPzCountBlock(ref int contapezzi, int lastCountCNC) + { + int numIncr = 0; + int qtyAdded = 0; + int delta = lastCountCNC - contapezzi; + // verifico se la funzione SIA abilitata + if (enableSendPzCountBlock) + { + // se è abilitata verifico differenza: se ho DELTA > 3 --> invio un blocco <= maxSendPzCountBlock + if (delta > 2) + { + numIncr = delta > maxSendPzCountBlock ? maxSendPzCountBlock : delta - 1; + // invio il num max di pezzi ammesso in blocco! + lgInfo($"Predisposizione chiamata incremento contapezzi in blocco per {numIncr} pezzi"); + string resp = utils.callUrlNow(urlAddPzCount + numIncr.ToString()); + if (!string.IsNullOrEmpty(resp)) + { + lgInfo($"Risposta chiamata incremento contapezzi: {resp}"); + // dalla risposta (come numero) capisco SE ha aggiunto i pezzi (e quanti) + int.TryParse(resp, out qtyAdded); + if (qtyAdded > 0) + { + // incremento il contapezzi della quantità restituita e confermata + contapezzi += qtyAdded; + lgInfo($"Confermato incremento contapezzi interno a {contapezzi} post chiamata diretta"); + } + } + } + } + } /// /// Verifica se sia machcina multi = DoppioPallet da CONF /// @@ -3041,7 +3147,6 @@ namespace IOB_WIN /// /// Verifica e processing x gestione ODL automatica /// - public void processAutoOdl() { bool fatto = false; diff --git a/IOB-WIN/IobSiemensTorri.cs b/IOB-WIN/IobSiemensTorri.cs index 67840dd4..adc44bde 100644 --- a/IOB-WIN/IobSiemensTorri.cs +++ b/IOB-WIN/IobSiemensTorri.cs @@ -157,11 +157,11 @@ namespace IOB_WIN { currODL = utils.callUrl(urlGetCurrODL); // solo SE HO un ODL... - if (currODL == "" || currODL == "0") + if (string.IsNullOrEmpty(currODL) || currODL == "0") { if (periodicLog) { - lgInfo(string.Format("SiemensTorri | Lettura ODL andata a vuoto: currODL: {0}", currODL)); + lgInfo($"SiemensTorri | Lettura ODL andata a vuoto: currODL: {currODL}"); } } else @@ -169,7 +169,7 @@ namespace IOB_WIN // se variato o scaduto timeout log... if (periodicLog || (currIdxODL.ToString() != currODL)) { - lgInfo(string.Format("SiemensTorri | Lettura ODL, currODL: {0} --> currIdxODL prec: {1}", currODL, currIdxODL)); + lgInfo($"SiemensTorri | Lettura ODL, currODL: {currODL} --> currIdxODL prec: {currIdxODL}"); } // provo a salvare nuovo ODL int.TryParse(currODL, out currIdxODL); @@ -179,42 +179,53 @@ namespace IOB_WIN { if (DateTime.Now.Subtract(lastWarnODL).TotalSeconds > 15) { - lgError(exc, "Errore in fase di chiamata URL x ODL corrente | URL chiamato: {0}", urlGetCurrODL); + lgError(exc, $"Errore in fase di chiamata URL x ODL corrente | URL chiamato: {urlGetCurrODL}"); lastWarnODL = DateTime.Now; } } - if (currODL != null && currODL != "" && currODL != "0") + if (!string.IsNullOrEmpty(currODL) && currODL != "0") { // ora processo il contapezzi... + string retVal = ""; // controllo se è passato intervallo minimo tra 2 controlli/elaborazioni x distanziare invio e ridurre letture if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay)) { + // PRIMA salvo il contapezzi della macchina + retVal = utils.callUrlNow(urlSetPzCountMAC + lastCountCNC.ToString()); + // verifica se tutto OK + if (retVal != "OK") + { + // errore salvataggio contapezzi + lgInfo($"Errore salvataggio Contapezzi PLC SIEMENST-TORRI: {lastCountCNC} | Contapezzi interno IOB {contapezzi} | Errore salvataggio: {retVal}"); + } // se sono differenti MOSTRO... if (lastCountCNC != contapezzi) { // registro contapezzi - lgInfo(string.Format("Differenza Contapezzi: CNC READ: {0} | Interno IOB {1}", lastCountCNC, contapezzi)); + lgInfo($"Differenza Contapezzi: CNC READ: {lastCountCNC} | Interno IOB {contapezzi}"); } // verifico se variato contapezzi... e se passato ritardo minimo... if (lastCountCNC > contapezzi) { + trySendPzCountBlock(ref contapezzi, lastCountCNC); // salvo nuovo contapezzi (incremento di 1...) contapezzi++; // salvo in semaforo! B_input += 1 << 2; // registro contapezzi - lgInfo(string.Format("Contapezzi SIEMENST-TORRI: {0} | Contapezzi interno IOB {1}", lastCountCNC, contapezzi)); + lgInfo($"Contapezzi SIEMENST-TORRI: {lastCountCNC} | Contapezzi interno IOB {contapezzi}"); } // invio a server contapezzi (aggiornato) - string retVal = utils.callUrl(urlSetPzCount + contapezzi.ToString()); + retVal = utils.callUrlNow(urlSetPzCount + contapezzi.ToString()); // verifica se tutto OK if (retVal != "OK") { // errore salvataggio contapezzi - lgInfo(string.Format("Errore salvataggio Contapezzi SIEMENST-TORRI: {0} | Contapezzi interno IOB {1} | Errore salvataggio: {2}", lastCountCNC, contapezzi, retVal)); + lgInfo($"Errore salvataggio Contapezzi SIEMENST-TORRI: {lastCountCNC} | Contapezzi interno IOB {contapezzi} | Errore salvataggio: {retVal}"); } + // resetto timer... lastPzCountSend = DateTime.Now; } @@ -223,7 +234,7 @@ namespace IOB_WIN { if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay)) { - lgInfo(string.Format("Attenzione: mancanza ODL non procedo con gestione contapezzi. Contapezzi SIEMENST-TORRI: {0} | Contapezzi interno {1}", lastCountCNC, contapezzi)); + lgInfo($"Attenzione: mancanza ODL non procedo con gestione contapezzi. Contapezzi SIEMENST-TORRI: {lastCountCNC} | Contapezzi interno {contapezzi}"); // resetto timer... lastPzCountSend = DateTime.Now; } @@ -232,9 +243,11 @@ namespace IOB_WIN // log opzionale! if (verboseLog) { - lgInfo(string.Format("Trasformazione B_input: {0}", B_input)); + lgInfo("Trasformazione B_input: {B_input}"); } } + + /// /// Recupero programma in lavorazione /// diff --git a/Jenkinsfile b/Jenkinsfile index 00815b4c..97f30a93 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=588']) { + withEnv(['NEXT_BUILD_NUMBER=589']) { // env.versionNumber = VersionNumber(versionNumberString : '2.6.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '2.6.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO-IOB-WIN'