From d736d879bf8936ae6cff8d70266d988e38dd0b6b Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 12 Sep 2018 09:00:11 +0200 Subject: [PATCH] controllo se abilitato MODE x blocco memorie G --- IOB-WIN/IobFanuc.cs | 176 +++++++++++++++++++++++++++++++++----------- Jenkinsfile | 2 +- 2 files changed, 136 insertions(+), 42 deletions(-) diff --git a/IOB-WIN/IobFanuc.cs b/IOB-WIN/IobFanuc.cs index 10909574..7908e1b9 100644 --- a/IOB-WIN/IobFanuc.cs +++ b/IOB-WIN/IobFanuc.cs @@ -1,13 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using CncLib.CNC; using IOB_UT; -using CncLib.CNC; -using System.Net.NetworkInformation; +using System; +using System.Collections.Generic; using System.Net; -using NLog; +using System.Net.NetworkInformation; namespace IOB_WIN { @@ -183,7 +179,10 @@ namespace IOB_WIN currBit = string.Format("BIT{0}", i); memArea = fIni.ReadString("MEMORY", currBit, ""); // se trovo un valore... - if (memArea != "") signLUT.Add(currBit, memArea); + if (memArea != "") + { + signLUT.Add(currBit, memArea); + } } // è little endian (NON serve conversione) @@ -197,10 +196,17 @@ namespace IOB_WIN // aggiungo referenza obj FANUC FANUC_ref = (FANUC)Runtime.NC; - if (utils.CRB("verbose")) lgInfo("FANUC_ref da CncLib"); + if (utils.CRB("verbose")) + { + lgInfo("FANUC_ref da CncLib"); + } // disconnetto e connetto... - if (utils.CRB("verbose")) lgInfo("FANUC: tryDisconnect"); + if (utils.CRB("verbose")) + { + lgInfo("FANUC: tryDisconnect"); + } + tryDisconnect(); lgInfo("FANUC: tryConnect"); tryConnect(); @@ -279,7 +285,10 @@ namespace IOB_WIN // controllo che il ping sia stato tentato almeno pingTestSec fa... if (DateTime.Now.Subtract(lastPING).TotalSeconds > utils.CRI("pingTestSec")) { - if (verboseLog || periodicLog) lgInfo("ConnKO - tryConnect"); + if (verboseLog || periodicLog) + { + lgInfo("ConnKO - tryConnect"); + } // in primis salvo data ping... lastPING = DateTime.Now; // ora PING!!! @@ -331,7 +340,10 @@ namespace IOB_WIN { // loggo no risposta ping ... connectionOk = false; - if (verboseLog || periodicLog) lgInfo(string.Format("Attenzione: controllo PING fallito per IP {0} - {1}", currIobConf.cncIpAddr, reply.Status)); + if (verboseLog || periodicLog) + { + lgInfo(string.Format("Attenzione: controllo PING fallito per IP {0} - {1}", currIobConf.cncIpAddr, reply.Status)); + } } } } @@ -350,7 +362,11 @@ namespace IOB_WIN base.readSemafori(); try { - if (verboseLog) lgInfo("inizio read semafori"); + if (verboseLog) + { + lgInfo("inizio read semafori"); + } + parentForm.sIN = Semaforo.SV; // inizio letture, SEMPRE DA ZERO (possibile ottimizzazione...) int memIndex = 0; @@ -359,13 +375,16 @@ namespace IOB_WIN { stopwatch.Restart(); FanucMemRW(R, FANUC.MemType.R, memIndex, ref MemBlockR); - if (utils.CRB("recTime")) TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-R", MemBlockR.Length), stopwatch.ElapsedTicks); + if (utils.CRB("recTime")) + { + TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-R", MemBlockR.Length), stopwatch.ElapsedTicks); + } // log if (verboseLog) { for (int i = 0; i < MemBlockR.Length; i++) { - lgInfo(string.Format("MemBlockR{0}: {1}", i, utils.binaryForm((int)MemBlockR[i]))); + lgInfo(string.Format("MemBlockR{0}: {1}", i, utils.binaryForm(MemBlockR[i]))); } } } @@ -374,13 +393,16 @@ namespace IOB_WIN { stopwatch.Restart(); FanucMemRW(R, FANUC.MemType.X, memIndex, ref MemBlockX); - if (utils.CRB("recTime")) TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-X", MemBlockX.Length), stopwatch.ElapsedTicks); + if (utils.CRB("recTime")) + { + TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-X", MemBlockX.Length), stopwatch.ElapsedTicks); + } // log if (verboseLog) { for (int i = 0; i < MemBlockX.Length; i++) { - lgInfo(string.Format("MemBlockX{0}: {1}", i, utils.binaryForm((int)MemBlockX[i]))); + lgInfo(string.Format("MemBlockX{0}: {1}", i, utils.binaryForm(MemBlockX[i]))); } } } @@ -389,13 +411,16 @@ namespace IOB_WIN { stopwatch.Restart(); FanucMemRW(R, FANUC.MemType.Y, memIndex, ref MemBlockY); - if (utils.CRB("recTime")) TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-Y", MemBlockY.Length), stopwatch.ElapsedTicks); + if (utils.CRB("recTime")) + { + TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-Y", MemBlockY.Length), stopwatch.ElapsedTicks); + } // log if (verboseLog) { for (int i = 0; i < MemBlockY.Length; i++) { - lgInfo(string.Format("MemBlockY{0}: {1}", i, utils.binaryForm((int)MemBlockY[i]))); + lgInfo(string.Format("MemBlockY{0}: {1}", i, utils.binaryForm(MemBlockY[i]))); } } } @@ -576,7 +601,10 @@ namespace IOB_WIN } } // log opzionale! - if (verboseLog) lgInfo(string.Format("Trasformazione B_input: {0}", B_input)); + if (verboseLog) + { + lgInfo(string.Format("Trasformazione B_input: {0}", B_input)); + } } /// /// Recupero programma in lavorazione @@ -613,7 +641,11 @@ namespace IOB_WIN Dictionary outVal = new Dictionary(); stopwatch.Restart(); CncLib.Focas1.ODBSYS answ = FANUC_ref.getSysInfo(); - if (utils.CRB("recTime")) TimingData.addResult(currIobConf.codIOB, string.Format("SYS-INFO"), stopwatch.ElapsedTicks); + if (utils.CRB("recTime")) + { + TimingData.addResult(currIobConf.codIOB, string.Format("SYS-INFO"), stopwatch.ElapsedTicks); + } + try { string cnc_type = new string(answ.cnc_type); @@ -666,12 +698,18 @@ namespace IOB_WIN { // recupero parametro... int.TryParse(memAddr.Replace("PAR.", ""), out cntAddr); - if (cntAddr == 0) cntAddr = 6711; + if (cntAddr == 0) + { + cntAddr = 6711; + } // processo parametro contapezzi (lavorati) stopwatch.Restart(); FANUC_ref.F_RW_Param_Integer(false, cntAddr, 3, ref outputVal); - if (utils.CRB("recTime")) TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-PAR", 4), stopwatch.ElapsedTicks); + if (utils.CRB("recTime")) + { + TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-PAR", 4), stopwatch.ElapsedTicks); + } // salvo ultimo conteggio rilevato Int32.TryParse(outputVal.ToString(), out lastCountCNC); @@ -681,7 +719,10 @@ namespace IOB_WIN { memAddressFanuc areaCounter = new memAddressFanuc(memAddr); - if (utils.CRB("verbose")) lgInfo("[0] area memoria: {0}.{1}.{2}", areaCounter.mType, areaCounter.mPos, areaCounter.vType); + if (utils.CRB("verbose")) + { + lgInfo("[0] area memoria: {0}.{1}.{2}", areaCounter.mType, areaCounter.mPos, areaCounter.vType); + } // leggo! stopwatch.Restart(); @@ -701,18 +742,32 @@ namespace IOB_WIN case "DW": uint valDW = 0; FANUC_ref.F_RW_DWord(false, areaCounter.mType, areaCounter.mPos, ref valDW); - if (utils.CRB("verbose")) lgInfo("[1] valDW contapezzi: {0}", valDW); + if (utils.CRB("verbose")) + { + lgInfo("[1] valDW contapezzi: {0}", valDW); + } + outputVal = valDW; - if (utils.CRB("verbose")) lgInfo("[2] outputVal contapezzi: {0}", outputVal); + if (utils.CRB("verbose")) + { + lgInfo("[2] outputVal contapezzi: {0}", outputVal); + } + break; default: break; } - if (utils.CRB("recTime")) TimingData.addResult(currIobConf.codIOB, string.Format("R-{0}.{1}.{2}", areaCounter.mType, areaCounter.mPos, areaCounter.vType), stopwatch.ElapsedTicks); + if (utils.CRB("recTime")) + { + TimingData.addResult(currIobConf.codIOB, string.Format("R-{0}.{1}.{2}", areaCounter.mType, areaCounter.mPos, areaCounter.vType), stopwatch.ElapsedTicks); + } // salvo... Int32.TryParse(outputVal.ToString(), out lastCountCNC); - if (utils.CRB("verbose")) lgInfo("[3] lastCountCNC contapezzi: {0}", lastCountCNC); + if (utils.CRB("verbose")) + { + lgInfo("[3] lastCountCNC contapezzi: {0}", lastCountCNC); + } } stopwatch.Stop(); } @@ -739,7 +794,11 @@ namespace IOB_WIN // controllo modalità lettura memoria stopwatch.Restart(); FanucMemRW(R, FANUC.MemType.G, memIndex, ref MemBlockG); - if (utils.CRB("recTime")) TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-G-AREA", MemBlockG.Length), stopwatch.ElapsedTicks); + if (utils.CRB("recTime")) + { + TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-G-AREA", MemBlockG.Length), stopwatch.ElapsedTicks); + } + stopwatch.Stop(); // verifico modo con valore corrente, se cambia aggiorno... CNC_MODE newMode = decodeG43(MemBlockG[43]); @@ -815,7 +874,11 @@ namespace IOB_WIN Dictionary outVal = new Dictionary(); stopwatch.Restart(); CncLib.Focas1.ODBDY2_1 answ = FANUC_ref.getAllDynData(); - if (utils.CRB("recTime")) TimingData.addResult(currIobConf.codIOB, string.Format("PROC-DYN-DATA"), stopwatch.ElapsedTicks); + if (utils.CRB("recTime")) + { + TimingData.addResult(currIobConf.codIOB, string.Format("PROC-DYN-DATA"), stopwatch.ElapsedTicks); + } + try { string actf = answ.actf.ToString(); @@ -857,8 +920,11 @@ namespace IOB_WIN public override Dictionary getOverrides() { Dictionary outVal = new Dictionary(); - outVal.Add("FEED_OVER", MemBlockG[30].ToString()); - outVal.Add("RAPID_OVER", MemBlockG[12].ToString()); + if (utils.CRB("enableMode") && MemBlockG != null) + { + outVal.Add("FEED_OVER", MemBlockG[30].ToString()); + outVal.Add("RAPID_OVER", MemBlockG[12].ToString()); + } return outVal; } @@ -909,14 +975,28 @@ namespace IOB_WIN string nomeFileDW = ""; Dictionary mappaValori = new Dictionary(); // per sicurezza verifico < 9999 byte - if (memSizeByte > 9999) memSizeByte = 9999; + if (memSizeByte > 9999) + { + memSizeByte = 9999; + } // leggo TUTTI i (MAX 9999) byte della memoria D... byte[] MemBlockCurr = new byte[memSizeByte]; - if (verboseLog) lgInfo("START MemDump", tipoMem); + if (verboseLog) + { + lgInfo("START MemDump", tipoMem); + } + stopwatch.Restart(); FanucMemRW(R, tipoMem, memIndex, ref MemBlockCurr); - if (utils.CRB("recTime")) TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-{1}", MemBlockCurr.Length, tipoMem), stopwatch.ElapsedTicks); - if (verboseLog) lgInfo("END MemDump", tipoMem); + if (utils.CRB("recTime")) + { + TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-{1}", MemBlockCurr.Length, tipoMem), stopwatch.ElapsedTicks); + } + + if (verboseLog) + { + lgInfo("END MemDump", tipoMem); + } // seconda del tipo di lettura definisco i nomi delle variabili... if (tipo == dumpType.SAMPLE) @@ -969,19 +1049,33 @@ namespace IOB_WIN string nomeFile = ""; Dictionary mappaValori = new Dictionary(); // per sicurezza verifico < 9999 parametri - if (numPar > 9999) numPar = 9999; + if (numPar > 9999) + { + numPar = 9999; + } // leggo TUTTI i (MAX 9999) byte della memoria D... object[] paramsArray = new object[numPar]; - if (verboseLog) lgInfo("START ParamDump"); + if (verboseLog) + { + lgInfo("START ParamDump"); + } + stopwatch.Restart(); for (int i = 0; i < numPar; i++) { FANUC_ref.F_RW_Param_Integer(false, memIndex + i, 3, ref paramsArray[i]); } - if (utils.CRB("recTime")) TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-PAR", 4 * numPar), stopwatch.ElapsedTicks); - if (verboseLog) lgInfo("END ParamDump"); + if (utils.CRB("recTime")) + { + TimingData.addResult(currIobConf.codIOB, string.Format("R{0}-PAR", 4 * numPar), stopwatch.ElapsedTicks); + } + + if (verboseLog) + { + lgInfo("END ParamDump"); + } // seconda del tipo di lettura definisco i nomi delle variabili... if (tipo == dumpType.SAMPLE) diff --git a/Jenkinsfile b/Jenkinsfile index 859eccf3..ce6f4c3f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=285']) { + withEnv(['NEXT_BUILD_NUMBER=286']) { // env.versionNumber = VersionNumber(versionNumberString : '1.18.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '1.18.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO-IOB-WIN'