From cf3ce43059f160bfe274f1693564ee7d859acf47 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Mon, 29 Jan 2018 14:44:56 +0100 Subject: [PATCH] update con abbozzo metodi siemens... --- IOB-WIN/IobFanuc.cs | 4 +- IOB-WIN/IobSiemensTorri.cs | 486 +++++++++++++++++++++++++++++++++++++ Jenkinsfile | 2 +- 3 files changed, 490 insertions(+), 2 deletions(-) diff --git a/IOB-WIN/IobFanuc.cs b/IOB-WIN/IobFanuc.cs index 0ead3757..8d4c74ec 100644 --- a/IOB-WIN/IobFanuc.cs +++ b/IOB-WIN/IobFanuc.cs @@ -196,7 +196,9 @@ namespace IOB_WIN processMemoryDiscon(); } } - + /// + /// lettura bit semafori + /// public override void readSemafori() { base.readSemafori(); diff --git a/IOB-WIN/IobSiemensTorri.cs b/IOB-WIN/IobSiemensTorri.cs index e32a5e3c..c84d435e 100644 --- a/IOB-WIN/IobSiemensTorri.cs +++ b/IOB-WIN/IobSiemensTorri.cs @@ -252,5 +252,491 @@ namespace IOB_WIN { } return answ; } + + + + #region da completare + + /// + /// Recupero dati override in formato dictionary + /// + /// + public override Dictionary getOverrides() + { + Dictionary outVal = new Dictionary(); + // !!!FARE!!! + outVal.Add("FEED_OVER", "0"); + outVal.Add("RAPID_OVER", "0"); + return outVal; + } + + /// + /// lettura bit semafori + /// + public override void readSemafori() + { + base.readSemafori(); +#if false + if (verboseLog) lg.Info("inizio read semafori"); + parentForm.sIN = Semaforo.SV; + // leggo SEMAFORI, leggo da Y8 ...leggo 3 bit in Y8..Y10 HARD CODED, rendere parametrico!!! + byte[] MemBlock = new byte[4]; + // Red: Y8.4 | Yellow: Y8.5 | Green Y8.6 | WrkZone Y8.7 | All DoorsClosed: Y10.5 + int memIndex = 8; + inizio = DateTime.Now; + FanucMemRW(R, FANUC.MemType.Y, memIndex, ref MemBlock); + if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-Y", MemBlock.Length), DateTime.Now.Subtract(inizio).Ticks); + // riporto! + Buffer.BlockCopy(MemBlock, 0, RawInput, 0, 4); + // ora mi leggo 2 byte in area X... HARD CODED, rendere parametrico... + MemBlock = new byte[2]; + // GESTIONE memoria endcycle + // la variabile X7.0 (da 1 a 0) oppure la X7.1 (da 0 a 1) indica il CONTAPEZZI --> copio 2 byte! + inizio = DateTime.Now; + FanucMemRW(R, FANUC.MemType.X, 6, ref MemBlock); + if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-X", MemBlockF.Length), DateTime.Now.Subtract(inizio).Ticks); + // riporto! + Buffer.BlockCopy(MemBlock, 0, RawInput, 4, 2); + if (verboseLog) lg.Info(string.Format("RawInput: {0}", utils.binaryForm((int)RawInput[0]))); +#endif + // salvo il solo BYTE dell'input decifrando il semaforo... + decodeToBitmap(); + } + /// + /// Effettua decodifica aree memoria alla bitmap usata x MAPO + /// + private void decodeToBitmap() + { + // init a zero... + B_input = 0; +#if false + // !!!FARE!!! generalizzazione... x ora usa dati "hard coded"... + //Red: Y8.4 | Yellow: Y8.5 | Green Y8.6 + + // leggo i byte interessati... + int byteSem = RawInput[0]; + int byteCount = RawInput[5]; + if (verboseLog) lg.Info(string.Format("PrimoByte: {0}", byteSem)); + + if (utils.CRB("macOnFromConn")) + { + // SE SI E' CONNESSO al FANUC allora è 1... + if (FANUC_ref.Connected) + { + B_input += 1 << 0; + } + } + else + { + // B0: facio un OR tra i 3 semafori... + if ((byteSem & 112) > 0) + { + B_input += 1 << 0; + } + } + // B1: verde! Y8.6 + if ((byteSem & 64) > 0) + { + B_input += 1 << 1; + } + // B2: contapezzi da area X + if ((byteCount & 2) > 0) + { + B_input += 1 << 2; + } + // B3: Rosso! Y8.4 + if ((byteSem & 16) > 0) + { + B_input += 1 << 3; + } + // B4: giallo! Y8.5 + if ((byteSem & 32) > 0) + { + B_input += 1 << 4; + } + // log opzionale! + if (verboseLog) lg.Info(string.Format("Trasformazione B_input: {0}", B_input)); +#endif + } + /// + /// Recupero programma in lavorazione + /// + /// + public override string getPrgName() + { + string prgName = ""; +#if false + // recupero NUOVO prgName... + try + { + // recupero nome programma MAIN + prgName = utils.purgedChar2String(FANUC_ref.getPrgNameMain()); + // trimmo path del programma, ovvero "CNCMEMUSERPATH1" + prgName = prgName.Replace(utils.CRS("basePrgMemPath"), ""); + } + catch (Exception exc) + { + lg.Error(string.Format("Eccezione in recupero PRG NAME MAIN:{0}{1}", Environment.NewLine, exc)); + } +#endif + return prgName; + } + + /// + /// Recupero programma in lavorazione come Dictionary FANUC... + /// - SYSINFO: (prima KEY globale) TUTTI i valori separati da # (x fare check modifica) + /// - altre stringhe: ogni singolo parametro / valore + /// + /// + public override Dictionary getSysInfo() + { + Dictionary outVal = new Dictionary(); +#if false + inizio = DateTime.Now; + CncLib.Focas1.ODBSYS answ = FANUC_ref.getSysInfo(); + if (utils.CRB("recTime")) TimingData.addResult(string.Format("SYS-INFO"), DateTime.Now.Subtract(inizio).Ticks); + try + { + string cnc_type = new string(answ.cnc_type); + string mt_type = new string(answ.mt_type); + string series = new string(answ.series); + string version = new string(answ.version); + string axes = new string(answ.axes); + //short addInfo = answ.addinfo; + short max_axis = answ.max_axis; + // preparo i singoli valori dell'array... + outVal.Add("SYSINFO", string.Format("{0}#{1}#{2}#{3}#{4}#{5}", cnc_type, mt_type, series, version, axes, max_axis)); + outVal.Add("CNC", cnc_type); + outVal.Add("MTT", mt_type); + outVal.Add("SER", series); + outVal.Add("VER", version); + outVal.Add("AXS", string.Format("{0}|{1}", axes, max_axis)); + } + catch (Exception exc) + { + lg.Error(exc, "Errore in getSysInfo"); + } +#endif + return outVal; + } + /// + /// Effettua vero processing contapezzi + /// + public override void processContapezzi() + { + if (utils.CRB("enableContapezzi")) + { + try + { +#if false + // 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(); + // deve usare F_RW_Param_Integer + FANUC_ref.F_RW_Param_Integer(false, 6711, 3, ref output); + lg.Info(string.Format("Contapezzi 6711: {0}", output)); + FANUC_ref.F_RW_Param_Integer(false, 6712, 3, ref output); + lg.Info(string.Format("Contapezzi 6712: {0}", output)); + FANUC_ref.F_RW_Param_Integer(false, 6713, 3, ref output); + lg.Info(string.Format("Contapezzi 6713: {0}", output)); + // !!!FARE!!! salvo numero!!! + + // 6711: pezzi lavorati + // 6712: pezzi lavorati totali + // 6713: pezzi richiesti + + // output! + + } + 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 + + + } + } +#endif + } + catch (Exception exc) + { + lg.Error(exc, "Errore in contapezzi SIEMENS-TORRI"); + } + } + } + /// + /// Esegue processing MODE (e nel contempo recupera altri dati dell'area G) + /// + public override void processMode() + { + if (utils.CRB("enableMode")) + { +#if false + try + { + inizio = DateTime.Now; + // leggo tutto da 0 a 43... + int memIndex = 0; + FanucMemRW(R, FANUC.MemType.G, memIndex, ref MemBlockG); + if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-G-AREA", MemBlockG.Length), DateTime.Now.Subtract(inizio).Ticks); + // verifico modo con valore corrente, se cambia aggiorno... + CNC_MODE newMode = decodeG43(MemBlockG[43]); + if (newMode != currMode) + { + // aggiorno! + currMode = newMode; + // conversione NUM MODE in descrizione da ENUM + string descrMode = Enum.GetName(typeof(CNC_MODE), currMode); + // accodo x invio + string sVal = string.Format("[CNC_MODE]{0}", descrMode); + // chiamo accodamento... + accodaFLog(sVal, qEncodeFLog("CNC_MODE", descrMode)); + } + } + catch (Exception exc) + { + lg.Error(exc, "Errore in process Mode G43"); + } +#endif + } + } +#if false + /// + /// decodifica il modo dai valori del byte G43 + /// + /// + /// + protected CNC_MODE decodeG43(byte currVal) + { + // hard coded da valori tabellari a MODI definiti in CNC_MODE... + CNC_MODE answ = CNC_MODE.ND; + switch (currVal) + { + case 0: + answ = CNC_MODE.MDI; + break; + case 1: + answ = CNC_MODE.MEN; + break; + case 3: + answ = CNC_MODE.EDIT; + break; + case 4: + answ = CNC_MODE.HANDLE_INC; + break; + case 5: + answ = CNC_MODE.JOG; + break; + case 6: + answ = CNC_MODE.TJOG; + break; + case 7: + answ = CNC_MODE.THND; + break; + case 33: + answ = CNC_MODE.RMT; + break; + case 133: + answ = CNC_MODE.REF; + break; + default: + answ = CNC_MODE.ND; + break; + } + return answ; + } +#endif + /// + /// Recupero dati dinamici... + /// + public override Dictionary getDynData() + { + Dictionary outVal = new Dictionary(); +#if false + inizio = DateTime.Now; + CncLib.Focas1.ODBDY2_1 answ = FANUC_ref.getAllDynData(); + if (utils.CRB("recTime")) TimingData.addResult(string.Format("PROC-DYN-DATA"), DateTime.Now.Subtract(inizio).Ticks); + try + { + string actf = answ.actf.ToString(); + string acts = answ.acts.ToString(); + //string numAlarm = answ.alarm.ToString(); + // preparo i singoli valori dell'array... + //outVal.Add("DYNDATA", string.Format("{0}#{1}#{2}", actf, acts, numAlarm)); + outVal.Add("DYNDATA", string.Format("FEED {0}#SPEED_RPM {1}", actf, acts)); + if (utils.CRB("SendFeedSpeed")) + { + outVal.Add("FEED", actf); + outVal.Add("SPEED_RPM", acts); + //outVal.Add("NUM_ALARM", numAlarm); + } + if (utils.CRB("SendAxPos")) + { + // salvo le posizioni... + CncLib.Focas1.FAXIS posAx = answ.pos; + int[] currPosAbs = posAx.absolute; + int i = 0; + foreach (var item in currPosAbs) + { + i++; + outVal.Add(string.Format("POS_{0:00}", i), item.ToString()); + } + } + } + catch (Exception exc) + { + lg.Error(exc, "Errore in getDynData"); + } +#endif + return outVal; + } + + /// + /// Override salvataggio valori in memoria... + /// + public override void saveMemDump() + { + dump_MemAreaD(); + dump_MemAreaY(); + } + public override void sampleMemDump() + { + dump_MemAreaD(6400, 400); + } + /// + /// Dump PERIODICO area D della memoria + /// + /// area memoria di partenza + /// + private void dump_MemAreaD(int memIndex, int memSyzeByte) + { + // leggo TUTTI i 9999 byte della memoria D... + byte[] MemBlockD = new byte[memSyzeByte]; + inizio = DateTime.Now; + if (verboseLog) lg.Info("START MemDump AreaD"); +#if false + FanucMemRW(R, FANUC.MemType.D, memIndex, ref MemBlockD); + if (verboseLog) lg.Info("END MemDump AreaD"); + if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-MemDumpD", MemBlockD.Length), DateTime.Now.Subtract(inizio).Ticks); + // file out! + string nomeFile = ""; + Dictionary mappaValori = new Dictionary(); + // salvo in file i dati letti come DWord (4byte) + nomeFile = string.Format(@"{0}\SAMPLES\MemDump_D_DW_{1:yyyyMMdd_HHmmss}.dat", utils.dataDatDir, DateTime.Now); + for (int i = 0; i < MemBlockD.Length / 4; i++) + { + mappaValori.Add(i.ToString("0000"), BitConverter.ToUInt32(MemBlockD, i * 4).ToString()); + } + utils.WritePlain(mappaValori, nomeFile); +#endif + } + /// + /// Dump area D della memoria + /// + private void dump_MemAreaD() + { + // faccio chaimate e salvo in file dump... + int memIndex = 0; + // leggo TUTTI i 9999 byte della memoria D... + byte[] MemBlockD = new byte[9999]; + inizio = DateTime.Now; + if (verboseLog) lg.Info("START MemDump AreaD"); +#if false + FanucMemRW(R, FANUC.MemType.D, memIndex, ref MemBlockD); + if (verboseLog) lg.Info("END MemDump AreaD"); + if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-MemDumpD", MemBlockD.Length), DateTime.Now.Subtract(inizio).Ticks); + // + string nomeFile = ""; + // salvo in file i dati letti come BYTE + nomeFile = string.Format(@"{0}\MemDump_D_Byte.dat", utils.dataDatDir); + Dictionary mappaValori = new Dictionary(); + for (int i = 0; i < MemBlockD.Length; i++) + { + mappaValori.Add(i.ToString("0000"), MemBlockD[i].ToString()); + } + utils.WritePlain(mappaValori, nomeFile); + + // salvo in file i dati letti come DWord (4byte) + nomeFile = string.Format(@"{0}\MemDump_D_DW.dat", utils.dataDatDir); + mappaValori = new Dictionary(); + for (int i = 0; i < MemBlockD.Length / 4; i++) + { + mappaValori.Add(i.ToString("0000"), BitConverter.ToUInt32(MemBlockD, i * 4).ToString()); + } + utils.WritePlain(mappaValori, nomeFile); + + // salvo in file i dati letti come DWord (4byte) + nomeFile = string.Format(@"{0}\MemDump_D_W.dat", utils.dataDatDir); + mappaValori = new Dictionary(); + for (int i = 0; i < MemBlockD.Length / 2; i++) + { + mappaValori.Add(i.ToString("0000"), BitConverter.ToUInt16(MemBlockD, i * 2).ToString()); + } + utils.WritePlain(mappaValori, nomeFile); +#endif + } + /// + /// Dump area Y della memoria + /// + private void dump_MemAreaY() + { + // faccio chaimate e salvo in file dump... + int memIndex = 0; + // leggo TUTTI i 9999 byte della memoria Y... + byte[] MemBlockY = new byte[10]; + inizio = DateTime.Now; + if (verboseLog) lg.Info("START MemDump AreaY"); +#if false + FanucMemRW(R, FANUC.MemType.Y, memIndex, ref MemBlockY); + if (verboseLog) lg.Info("END MemDump AreaY"); + if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-MemDumpY", MemBlockY.Length), DateTime.Now.Subtract(inizio).Ticks); + // + string nomeFile = ""; + // salvo in file i dati letti come BYTE + nomeFile = string.Format(@"{0}\MemDump_Y_Byte.dat", utils.dataDatDir); + Dictionary mappaValori = new Dictionary(); + for (int i = 0; i < MemBlockY.Length; i++) + { + mappaValori.Add(i.ToString("0000"), MemBlockY[i].ToString()); + } + utils.WritePlain(mappaValori, nomeFile); + + // salvo in file i dati letti come DWord (4byte) + nomeFile = string.Format(@"{0}\MemDump_Y_DW.dat", utils.dataDatDir); + mappaValori = new Dictionary(); + for (int i = 0; i < MemBlockY.Length / 4; i++) + { + mappaValori.Add(i.ToString("0000"), BitConverter.ToUInt32(MemBlockY, i * 4).ToString()); + } + utils.WritePlain(mappaValori, nomeFile); + + // salvo in file i dati letti come DWord (4byte) + nomeFile = string.Format(@"{0}\MemDump_Y_W.dat", utils.dataDatDir); + mappaValori = new Dictionary(); + for (int i = 0; i < MemBlockY.Length / 2; i++) + { + mappaValori.Add(i.ToString("0000"), BitConverter.ToUInt16(MemBlockY, i * 2).ToString()); + } + utils.WritePlain(mappaValori, nomeFile); +#endif + } + #endregion } } diff --git a/Jenkinsfile b/Jenkinsfile index ec3120a2..af38c67a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=197']) { + withEnv(['NEXT_BUILD_NUMBER=198']) { // 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'