From 84ebc21fc32dfd1d18e23a7fdc843014872bc843 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 13 Apr 2018 14:09:43 +0200 Subject: [PATCH] implementato contapezzi 1:1 --- IOB-WIN/App.config | 4 +--- IOB-WIN/IobFanuc.cs | 39 +++++++++++++++++++++++++++++---------- Jenkinsfile | 2 +- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/IOB-WIN/App.config b/IOB-WIN/App.config index 5ea0564b..1b28e0ae 100644 --- a/IOB-WIN/App.config +++ b/IOB-WIN/App.config @@ -67,9 +67,7 @@ - - - + diff --git a/IOB-WIN/IobFanuc.cs b/IOB-WIN/IobFanuc.cs index e397c6de..7b367071 100644 --- a/IOB-WIN/IobFanuc.cs +++ b/IOB-WIN/IobFanuc.cs @@ -33,6 +33,14 @@ namespace IOB_WIN /// protected byte[] MemBlockY = new byte[2]; /// + /// Ultimo invio contapezzi (x invio delayed) + /// + protected DateTime lastPzCountSend; + /// + /// Ritardo minimo x invio contapezzi + /// + protected int pzCountDelay; + /// /// LookUpTable di decodifica da CNC a segnali tipo bitmap MAPO /// Dictionary signLUT = new Dictionary(); @@ -99,9 +107,12 @@ namespace IOB_WIN { // i dati RAW principali sono 6 byte... RawInput = new byte[6]; - // inizializzo correttamente aree memoria secondo CONF - iniFileName - // leggo file + // gestione invio ritardato contapezzi + pzCountDelay = utils.CRI("pzCountDelay"); + lastPzCountSend = DateTime.Now; + + // inizializzo correttamente aree memoria secondo CONF - iniFileName IniFile fIni = new IniFile(IOBConf.iniFileName); // inizializzo aree di memoria correnti... MemBlockG = new byte[fIni.ReadInteger("MEMORY", "AREAG_SIZE", 8)]; @@ -291,7 +302,7 @@ namespace IOB_WIN int memIndex = 0; stopwatch.Restart(); FanucMemRW(R, FANUC.MemType.Y, memIndex, ref MemBlockY); - if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-Y", MemBlock.Length), stopwatch.ElapsedTicks); + if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-Y", MemBlockY.Length), stopwatch.ElapsedTicks); // log if (verboseLog) { @@ -401,7 +412,6 @@ namespace IOB_WIN break; } // controllo se il bit sia attivo... - //if ((byte2check & (long)Math.Pow(2, bitNum)) > 0) if ((byte2check & (1 << bitNum)) == (1 << bitNum)) { B_input += 1 << i; @@ -409,14 +419,23 @@ namespace IOB_WIN } } - // verifico se variato contapezzi in 6711... - if (lastCount != contapezzi) + // 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 { - // FARE!!! deve incrementare di 1 il contapezzi e poi mettere un WAIT prima del successivo conteggio... da testare PRIMA di tutto... - // salvo nuovo contapezzi contapezzi = lastCount; - // salvo in semaforo! - B_input += 1 << 2; } #if false diff --git a/Jenkinsfile b/Jenkinsfile index 087644e3..6697bbff 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=221']) { + withEnv(['NEXT_BUILD_NUMBER=222']) { // 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'