From 7d9b58fa3ec3ea1f7f20ae04efb3b7f5431bfc80 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 13 Apr 2018 14:31:57 +0200 Subject: [PATCH] cambiocontapezzi x CMZ --- IOB-WIN/DATA/CONF/3003.ini | 2 +- IOB-WIN/IobFanuc.cs | 195 +++++++++++++++++++++---------------- IOB-WIN/IobGeneric.cs | 4 +- Jenkinsfile | 2 +- 4 files changed, 114 insertions(+), 89 deletions(-) diff --git a/IOB-WIN/DATA/CONF/3003.ini b/IOB-WIN/DATA/CONF/3003.ini index 07033e3a..f4eb2033 100644 --- a/IOB-WIN/DATA/CONF/3003.ini +++ b/IOB-WIN/DATA/CONF/3003.ini @@ -28,7 +28,7 @@ AREAY_SIZE=8 ; Red: Y3.7 | Yellow: Y3.6 | Green Y3.5 | All DoorsClosed: Y4.0 (X5.1) | ..........WrkZone Y8.7 ;BIT0=CONN BIT1=Y3.5 -;BIT2=PAR6711 +BIT2=PZCOUNT BIT3=Y3.7 BIT4=Y3.6 diff --git a/IOB-WIN/IobFanuc.cs b/IOB-WIN/IobFanuc.cs index 7b367071..a1e22b3c 100644 --- a/IOB-WIN/IobFanuc.cs +++ b/IOB-WIN/IobFanuc.cs @@ -387,79 +387,119 @@ namespace IOB_WIN { // recupero nome variabile... bVal = signLUT[bKey]; - area = bVal[0]; - memArea = bVal.Substring(1, bVal.Length - 1); - memIdx = memArea.Split('.'); - // calcolo bit e byte number... - int.TryParse(memIdx[0], out byteNum); - if (memIdx.Length > 1) + // se l'area è PZCOUNT... processo PUNTUALMENTE il CONTAPEZZI... + if (bVal == "PZCOUNT") { - int.TryParse(memIdx[1], out bitNum); + // controllo se è passato intervallo minimo pre invio + if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay)) + { + if (utils.CRB("enableContapezzi")) + { + try + { + // verifico quale modalità sia richiesta: STD (6711) oppure BIT (Custom, con indicazione area) + if (currIobConf.optPar.Count > 0 && currIobConf.optPar["PZCOUNT_MODE"] != "") + { + if (currIobConf.optPar["PZCOUNT_MODE"] == "STD") + { + object output = new object(); + // processo parametro contapezzi (lavorati) !!!FARE!!! sposatre su ciclo + HF + stopwatch.Restart(); + FANUC_ref.F_RW_Param_Integer(false, 6711, 3, ref output); + if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PAR", 2), stopwatch.ElapsedTicks); + lg.Info(string.Format("Contapezzi Lavorati 6711: {0}", output)); + // salvo ultimo conteggio rilevato + Int32.TryParse(output.ToString(), out lastCount); + + // 6711: pezzi lavorati + // 6712: pezzi lavorati totali + // 6713: pezzi richiesti + + // output! + stopwatch.Stop(); + } + else if (currIobConf.optPar["PZCOUNT_MODE"] == "BIT") + { + // posizioni DWord + //1602:543809: NUM PEZZI x ciclo (6408..6411) + //1603:5300: NUM PEZZI RICHIESTI (6412..6415) + //1604:5007: NUM PEZZI FATTI (6416..6419) + //1605:543809: NUM PEZZI TOTALI (6420..6423) + + //[OPTPAR] + //ENDCYCLE_MADDR=X7.1 + //PZ_CAD_MADDR=1602 + //PZ_REQ_MADDR=1603 + //PZ_DONE_MADDR=1604 + //PZ_GTOT_MADDR=1605 + + // LEGGO le memorie DW dei vari contatori + + // salvo in area locale e confronto con precedenti, dove cambiato INVIO come dato aggiuntivo + + } + } + } + catch (Exception exc) + { + lg.Error(exc, "Errore in contapezzi FANUC"); + connectionOk = false; + } + } + + // verifico se variato contapezzi in area STD PAR6711... e se passato ritardo minimo... + if (lastCount > contapezzi) + { + // salvo nuovo contapezzi (incremento di 1...) + contapezzi++; + // salvo in semaforo! + B_input += 1 << 2; + // registro contapezzi + lg.Info(string.Format("Contapezzi FANUC: {0} | Contapezzi interno {1}", lastCount, contapezzi)); + lastPzCountSend = DateTime.Now; + } + else if (contapezzi > lastCount) // in questo caso resetto + { + contapezzi = lastCount; + } + } } - // in base al nome cerco in una delle aree.. e prendo solo solo quel bit di quel byte... - switch (area) + else // area "normale" byte.bit { - case 'G': - byte2check = MemBlockG[byteNum]; - break; - case 'X': - byte2check = MemBlockX[byteNum]; - break; - case 'Y': - byte2check = MemBlockY[byteNum]; - break; - default: - break; - } - // controllo se il bit sia attivo... - if ((byte2check & (1 << bitNum)) == (1 << bitNum)) - { - B_input += 1 << i; + area = bVal[0]; + // altrimenti decodifico area... + memArea = bVal.Substring(1, bVal.Length - 1); + memIdx = memArea.Split('.'); + // calcolo bit e byte number... + int.TryParse(memIdx[0], out byteNum); + if (memIdx.Length > 1) + { + int.TryParse(memIdx[1], out bitNum); + } + // in base al nome cerco in una delle aree.. e prendo solo solo quel bit di quel byte... + switch (area) + { + case 'G': + byte2check = MemBlockG[byteNum]; + break; + case 'X': + byte2check = MemBlockX[byteNum]; + break; + case 'Y': + byte2check = MemBlockY[byteNum]; + break; + default: + break; + } + // controllo se il bit sia attivo... + if ((byte2check & (1 << bitNum)) == (1 << bitNum)) + { + B_input += 1 << i; + } } } } - - // verifico se variato contapezzi in 6711... e se passato ritardo minimo... - if (lastCount > contapezzi) - { - // controllo se è passato intervallo minimo pre invio - if (lastPzCountSend.AddMilliseconds(pzCountDelay) < DateTime.Now) - { - // salvo nuovo contapezzi (incremento di 1...) - contapezzi++; - // salvo in semaforo! - B_input += 1 << 2; - // registro contapezzi - lg.Info(string.Format("Contapezzi FANUC: {0} | Contapezzi interno {1}", lastCount, contapezzi)); - } - } - else if (contapezzi > lastCount) // in questo caso resetto - { - contapezzi = lastCount; - } - -#if false - // B1: verde! Y3.5 (era Y8.6) - if ((byteSem & 32) > 0) - { - B_input += 1 << 1; - } - - - - // B3: Rosso! Y3.7 (era Y8.4) - if ((byteSem & 128) > 0) - { - B_input += 1 << 3; - } - // B4: giallo! Y3.6 (era Y8.5) - if ((byteSem & 64) > 0) - { - B_input += 1 << 4; - } -#endif } - // log opzionale! if (verboseLog) lg.Info(string.Format("Trasformazione B_input: {0}", B_input)); } @@ -527,7 +567,7 @@ namespace IOB_WIN /// public override void processContapezzi() { - Dictionary outVal = new Dictionary(); +#if false if (utils.CRB("enableContapezzi")) { try @@ -545,27 +585,9 @@ namespace IOB_WIN FANUC_ref.F_RW_Param_Integer(false, 6711, 3, ref output); if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PAR", 2), stopwatch.ElapsedTicks); lg.Info(string.Format("Contapezzi Lavorati 6711: {0}", output)); - outVal.Add("6711_PzLavorati", output.ToString()); // salvo ultimo conteggio rilevato Int32.TryParse(output.ToString(), out lastCount); - // commento x ridurre carico e vedere come si comporta... -#if false - // processo pz lavorati totali - inizio = DateTime.Now; - FANUC_ref.F_RW_Param_Integer(false, 6712, 3, ref output); - if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PAR", 2), DateTime.Now.Subtract(inizio).Ticks); - lg.Info(string.Format("Contapezzi Lav Tot 6712: {0}", output)); - outVal.Add("6712_PzLavTotali", output.ToString()); - - // processo pz richiesti - inizio = DateTime.Now; - FANUC_ref.F_RW_Param_Integer(false, 6713, 3, ref output); - if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PAR", 2), DateTime.Now.Subtract(inizio).Ticks); - lg.Info(string.Format("Pz Richiesti 6713: {0}", output)); - outVal.Add("6713_PzRichiesti", output.ToString()); -#endif - // 6711: pezzi lavorati // 6712: pezzi lavorati totali // 6713: pezzi richiesti @@ -601,7 +623,8 @@ namespace IOB_WIN lg.Error(exc, "Errore in contapezzi FANUC"); connectionOk = false; } - } + } +#endif } /// /// Esegue processing MODE (e nel contempo recupera altri dati dell'area G) diff --git a/IOB-WIN/IobGeneric.cs b/IOB-WIN/IobGeneric.cs index 76e3f8b6..daac93c2 100644 --- a/IOB-WIN/IobGeneric.cs +++ b/IOB-WIN/IobGeneric.cs @@ -455,7 +455,9 @@ namespace IOB_WIN } else if (ciclo == gatherCycle.LF) { - processContapezzi(); +#if false + processContapezzi(); +#endif processProgram(); } else if (ciclo == gatherCycle.VLF) diff --git a/Jenkinsfile b/Jenkinsfile index 6697bbff..d65970d3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=222']) { + withEnv(['NEXT_BUILD_NUMBER=223']) { // env.versionNumber = VersionNumber(versionNumberString : '1.17.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '1.17.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO-IOB-WIN'