From f5046662e9b5f5a46e24db7fd86f8c7b847eae4c Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 18 Dec 2019 19:51:16 +0100 Subject: [PATCH] Ancora update gest contapezzi... --- CVCncLib/testSam.dll | Bin 967680 -> 967680 bytes IOB-WIN/IobGeneric.cs | 33 +++++++++++++++++++++++++++------ IOB-WIN/IobSiemensTorri.cs | 2 +- IOB-WIN/IobSimula.cs | 14 +++++++++----- Jenkinsfile | 2 +- 5 files changed, 38 insertions(+), 13 deletions(-) diff --git a/CVCncLib/testSam.dll b/CVCncLib/testSam.dll index 532646bec4e74e449a5860398ffed16d35c4b5ee..43028d01747a09ef9dde6be3dca4da34e0cfa471 100644 GIT binary patch delta 152 zcmV;J0B8Szh&zCYJCKM2$!_|Ai-n5;g^L1(ivxv=1ci$Qg^LD-iwA{^2!)FYg^LP> ziwm`j3^Ab)rGcn+o?vD|l`zDH7$n6ehs>c2hs>c3x6Gjq{0;-iZu*zYunrk37k-2L z*b7EQkE5vIIC>%P0RR91Lpoelb7gXKTytS + /// Data/ora ultima volta che IOB è stato dichairato online + /// + public DateTime lastIobOnline = DateTime.Now.AddHours(-1); + /// /// Dizionario di VC da trattare come TimeSeries (con conf decodificata + processing successivo...) /// protected Dictionary TSVC_Data = new Dictionary(); @@ -978,7 +982,7 @@ namespace IOB_WIN { // NON AGGIORNO contapezzi = lastCountCNC; - lgInfo(string.Format("Errore lettura ODL: {0} - uso lastCountCNC --> {1}", lastIdxODL, contapezzi)); + lgInfo($"Errore lettura ODL (vuoto) resta tutto invariato contapezzi: {contapezzi} | lastCountCNC {lastCountCNC}"); } else { @@ -2759,6 +2763,7 @@ namespace IOB_WIN { // non controllo x meno... dtVetoCheckIOB = DateTime.Now.AddMilliseconds(baseUtils.nextPauseSendMSec * 5); + lastIobOnline = DateTime.Now; } } catch @@ -3143,9 +3148,7 @@ namespace IOB_WIN /// - invio in blocco pezzi /// - aggiornamento del contapezzi (passato come ref) x nuovo valore post invio /// - /// - /// - public void trySendPzCountBlock(ref int contapezzi, int lastCountCNC) + public void trySendPzCountBlock() { // in primis HA SENSO procedere SOLO SE server MP è Online... if (MPOnline) @@ -3155,10 +3158,12 @@ namespace IOB_WIN { int numIncr = 0; int qtyAdded = 0; - int delta = lastCountCNC - contapezzi; // verifico se la funzione SIA abilitata if (enableSendPzCountBlock) { + // rileggo qta da server... + pzCntReload(true); + int delta = lastCountCNC - contapezzi; // se è abilitata verifico differenza: se ho DELTA > minSendPzCountBlock --> invio un blocco <= maxSendPzCountBlock if (delta > minSendPzCountBlock) { @@ -3175,8 +3180,12 @@ namespace IOB_WIN int.TryParse(resp, out qtyAdded); if (qtyAdded > 0) { + // rileggo qta da server... + pzCntReload(true); +#if false // incremento il contapezzi della quantità restituita e confermata - contapezzi += qtyAdded; + contapezzi += qtyAdded; +#endif lgInfo($"Inviato incremento contapezzi: send {numIncr} | resp {qtyAdded}"); } } @@ -3974,6 +3983,12 @@ namespace IOB_WIN if (answ.Contains("OK")) { currDispData.semOut = Semaforo.SV; + // se oltre 1 min NON era online --> check pezzi! + if (DateTime.Now.Subtract(lastIobOnline).TotalMinutes > 1) + { + pzCntReload(true); + } + lastIobOnline = DateTime.Now; } else { @@ -4040,6 +4055,12 @@ namespace IOB_WIN string answ = callUrl(lastUrl, false); // loggo! lgInfo(string.Format("[SEND] {0} -> {1}", queueVal, answ)); + // se oltre 1 min NON era online --> check pezzi! + if (DateTime.Now.Subtract(lastIobOnline).TotalMinutes > 1) + { + pzCntReload(true); + } + lastIobOnline = DateTime.Now; // se "OK" verde, altrimenti errore --> ROSSO if (answ == "OK") { diff --git a/IOB-WIN/IobSiemensTorri.cs b/IOB-WIN/IobSiemensTorri.cs index 984e9015..bb0baed8 100644 --- a/IOB-WIN/IobSiemensTorri.cs +++ b/IOB-WIN/IobSiemensTorri.cs @@ -208,7 +208,7 @@ namespace IOB_WIN // verifico se variato contapezzi... e se passato ritardo minimo... if ((lastCountCNC - contapezzi) > minSendPzCountBlock) { - trySendPzCountBlock(ref contapezzi, lastCountCNC); + trySendPzCountBlock(); // salvo nuovo contapezzi (incremento di 1...) contapezzi++; // salvo in semaforo! diff --git a/IOB-WIN/IobSimula.cs b/IOB-WIN/IobSimula.cs index 9a7454f7..d27fd014 100644 --- a/IOB-WIN/IobSimula.cs +++ b/IOB-WIN/IobSimula.cs @@ -277,7 +277,7 @@ namespace IOB_WIN // invio SOLO SE sono OLTRE i numSim pz e li invio TUTTI in blocco if ((lastCountCNC - contapezzi) > minSendPzCountBlock) { - trySendPzCountBlock(ref contapezzi, lastCountCNC); + trySendPzCountBlock(); lgInfo($"Valori contatori: contapezzi macchina lastCountCNC: {lastCountCNC} | contapezzi: {contapezzi}"); } } @@ -325,9 +325,9 @@ namespace IOB_WIN } else if (bit2.wait <= 0) { - // salvo nuovo contapezziPLC (incremento RAND 0..3) + // salvo nuovo contapezziPLC (incremento RAND 0..5) var rand = new Random(); - int delta = rand.Next(0, 3); + int delta = rand.Next(1, 5); if (!isMulti) { lastCountCNC += delta; @@ -344,8 +344,12 @@ namespace IOB_WIN // se NON Multi fa contapezzi... else { - // segnalo BIT (1 pz) - B_input += (1 << 2); + // SE NON SONO GIA' OLTRE il contapezzi + if (contapezzi < lastCountCNC) + { + // segnalo BIT (1 pz) + B_input += (1 << 2); + } } // decremento duration bit2.duration--; diff --git a/Jenkinsfile b/Jenkinsfile index 21efa889..dcfd3945 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=608']) { + withEnv(['NEXT_BUILD_NUMBER=609']) { // env.versionNumber = VersionNumber(versionNumberString : '2.7.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '2.7.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO-IOB-WIN'