From 28b74604e125c0a57103b1c62fcc4fcd06ea0991 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Tue, 27 Nov 2018 22:10:16 +0100 Subject: [PATCH] pulizia aree commentate in classe siemens base + overrides in fape --- IOB-WIN/IobSiemens.cs | 296 +------------------------------------- IOB-WIN/IobSiemensFape.cs | 191 +----------------------- 2 files changed, 11 insertions(+), 476 deletions(-) diff --git a/IOB-WIN/IobSiemens.cs b/IOB-WIN/IobSiemens.cs index 6ab2976f..abd6f535 100644 --- a/IOB-WIN/IobSiemens.cs +++ b/IOB-WIN/IobSiemens.cs @@ -606,7 +606,7 @@ namespace IOB_WIN /// /// /// - protected string decodeCurrMode(byte currModeBitmap) + protected virtual string decodeCurrMode(byte currModeBitmap) { string answ = ""; if (verboseLog) @@ -879,21 +879,8 @@ namespace IOB_WIN /// 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) - { - lgError(string.Format("Eccezione in recupero PRG NAME MAIN:{0}{1}", Environment.NewLine, exc)); - } -#endif + // valore non presente in vers default... se gestito fare override + string prgName = ""; return prgName; } @@ -905,33 +892,8 @@ namespace IOB_WIN /// public override Dictionary getSysInfo() { + // valore non presente in vers default... se gestito fare override 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) - { - lgError(exc, "Errore in getSysInfo"); - } -#endif return outVal; } /// @@ -939,265 +901,21 @@ namespace IOB_WIN /// public override void processMode() { + // valore non presente in vers default... se gestito fare override 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) - { - lgError(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() { + // valore non presente in vers default... se gestito fare override 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) - { - lgError(exc, "Errore in getDynData"); - } -#endif return outVal; } - - /// - /// Override salvataggio valori in memoria... - /// - /// tipo di DUMP - public override void saveMemDump(dumpType tipo) - { -#if false - dump_MemAreaD(); - dump_MemAreaY(); -#endif - } - /// - /// 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]; - stopwatch.Restart(); - if (verboseLog) - { - lgInfo("START MemDump AreaD"); - } -#if false - FanucMemRW(R, FANUC.MemType.D, memIndex, ref MemBlockD); - if (verboseLog) lgInfo("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]; - stopwatch.Restart(); - if (verboseLog) - { - lgInfo("START MemDump AreaD"); - } -#if false - FanucMemRW(R, FANUC.MemType.D, memIndex, ref MemBlockD); - if (verboseLog) lgInfo("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]; - stopwatch.Restart(); - if (verboseLog) - { - lgInfo("START MemDump AreaY"); - } -#if false - FanucMemRW(R, FANUC.MemType.Y, memIndex, ref MemBlockY); - if (verboseLog) lgInfo("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/IOB-WIN/IobSiemensFape.cs b/IOB-WIN/IobSiemensFape.cs index 4994e42f..bdbfdb8d 100644 --- a/IOB-WIN/IobSiemensFape.cs +++ b/IOB-WIN/IobSiemensFape.cs @@ -200,17 +200,8 @@ namespace IOB_WIN /// public override Dictionary getOverrides() { + // non ci sono dati override, EMPTY! Dictionary outVal = new Dictionary(); - uint valDW = 0; - // !!!FARE!!! recuperare da conf memoria, ora HARD CODED - outVal.Add("FEED_OVER", RawInput[19].ToString()); - outVal.Add("RAPID_OVER", RawInput[20].ToString()); - outVal.Add("CURR_MODE", decodeCurrMode(RawInput[21])); - // recupero RPM pezzo/mola !!!FARE!!! cambio nome da config, qui sono 01:conduttrice e 02:operatrice (3013), mentre sono pezzo/mola nella V100 - valDW = S7.Net.Types.DWord.FromByteArray(RawInput.Skip(24).Take(4).ToArray()); - outVal.Add("RPM_01", valDW.ToString()); - valDW = S7.Net.Types.DWord.FromByteArray(RawInput.Skip(28).Take(4).ToArray()); - outVal.Add("RPM_02", valDW.ToString()); return outVal; } @@ -244,7 +235,7 @@ namespace IOB_WIN /// /// /// - protected string decodeCurrMode(byte currModeBitmap) + protected override string decodeCurrMode(byte currModeBitmap) { string answ = ""; if (verboseLog) @@ -390,188 +381,14 @@ namespace IOB_WIN lastPzCountSend = DateTime.Now; } } - -#if false - // SE SI E' CONNESSO al PLC allora è 1=powerON... - if (connectionOk) - { - B_input += 1 << 0; - } - - // decodifico impiegando dictionary... cercando il TIPO di memoria & co... - string bKey = ""; - string bVal = ""; - char area; - // valore INVERTED (default è false) - bool invSignal = false; - string memArea = ""; - string[] memIdx; - int bitNum = 0; - int byteNum = 0; - int byte2check = 0; - for (int i = 0; i < 8; i++) - { - bKey = string.Format("BIT{0}", i); - // cerco se ci sia in LUT - if (signLUT.ContainsKey(bKey)) - { - // recupero nome variabile... - bVal = signLUT[bKey]; - // se l'area è PZCOUNT... processo PUNTUALMENTE il CONTAPEZZI... - if (bVal.StartsWith("PZCOUNT")) - { - // controllo se è passato intervallo minimo tra 2 controlli/elaborazioni x distanziare invio e ridurre letture - if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay)) - { - // verifico se variato contapezzi in area STD PAR6711... e se passato ritardo minimo... - if (lastCountCNC > contapezzi) - { - // salvo nuovo contapezzi (incremento di 1...) - contapezzi++; - // salvo in semaforo! - B_input += 1 << 2; - // registro contapezzi - lgInfo(string.Format("Contapezzi FANUC: {0} | Contapezzi interno {1}", lastCountCNC, contapezzi)); - } - else if (contapezzi > lastCountCNC) // in questo caso resetto - { - contapezzi = lastCountCNC; - } - // invio a server contapezzi (aggiornato) - utils.callUrl(urlSetPzCount + contapezzi.ToString()); - // resetto timer... - lastPzCountSend = DateTime.Now; - } - } - else // area "normale" byte.bit - { - // di norma è segnale normale => 1, altrimenti inverse => 0... - invSignal = false; - // cerco se sia inverse (ultimo char "!") --> registro e elimino char... - invSignal = bVal.StartsWith("!"); - // tolgo comunque inversione... - bVal = bVal.Replace("!", ""); - // recupero area... - 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 'R': - byte2check = MemBlockR[byteNum]; - break; - case 'X': - byte2check = MemBlockX[byteNum]; - break; - case 'Y': - byte2check = MemBlockY[byteNum]; - break; - default: - break; - } - // a secondo che sia segnale normale o inverso... - if (invSignal) - { - // controllo se il bit sia NON attivo (basso)... == 0... - if ((byte2check & (1 << bitNum)) == 0) - { - B_input += 1 << i; - } - } - else - { - // controllo se il bit sia attivo (alto)... != 0 - if ((byte2check & (1 << bitNum)) != 0) - { - B_input += 1 << i; - } - } - } - - } - } - // log opzionale! - if (verboseLog) lgInfo(string.Format("Trasformazione B_input: {0}", B_input)); -#endif - + // log opzionale! if (verboseLog) { lgInfo(string.Format("Trasformazione B_input: {0}", B_input)); } - } - /// - /// 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) - { - lgError(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) - { - lgError(exc, "Errore in getSysInfo"); - } -#endif - return outVal; - } /// /// Esegue processing MODE (e nel contempo recupera altri dati dell'area G) ///