From 752fa4b63e845272510d03353621d1b4473521b3 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Tue, 9 May 2017 12:02:24 +0200 Subject: [PATCH] unificata gestione FANUC/OSAI x lettura load/speed/speedOverride delel UnOp --- MTC_Adapter/MTC_Adapter/AdapterFanuc.cs | 34 ++--------------------- MTC_Adapter/MTC_Adapter/AdapterGeneric.cs | 30 ++++++++++++++++++++ MTC_Adapter/MTC_Adapter/AdapterOsai.cs | 26 +---------------- 3 files changed, 33 insertions(+), 57 deletions(-) diff --git a/MTC_Adapter/MTC_Adapter/AdapterFanuc.cs b/MTC_Adapter/MTC_Adapter/AdapterFanuc.cs index 3cfb769..481f3fa 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterFanuc.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterFanuc.cs @@ -1124,8 +1124,6 @@ namespace MTC_Adapter /// public override void getUnOp() { - base.getUnOp(); - // leggo in blocco tutte le speed da memoria... int memIndex = 3140; // buffer memoria 60 byte... speed (16bit 2 * 20) + load (8bit 1 * 20) visto che sono 20 teste max @@ -1134,36 +1132,8 @@ namespace MTC_Adapter inizio = DateTime.Now; FanucMemRW(R, FANUC.MemType.D, memIndex, ref unOpSpeedMem); if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-SPEED_UNOP", unOpSpeedMem.Length), DateTime.Now.Subtract(inizio).Ticks); - - // NON VA: RICHIEDE OPZIONE... The extended driver/library function is necessary. -#if false - // recupero vettore load spindle... - inizio = DateTime.Now; - CMSCncLib.Focas1.ODBSPN spindleVect = FANUC_ref.getSpindleLoad(); - if (utils.CRB("recTime")) TimingData.addResult("R-SpindleLoad", DateTime.Now.Subtract(inizio).Ticks); -#endif - StringBuilder sb = new StringBuilder(); - - int numUnOp = currAdpConf.nUnOp; - // cicl su path x leggere le velocità dell'UnOp - for (int i = 0; i < numUnOp; i++) - { - // leggo valore Codice - SpeedRate = BitConverter.ToUInt16(unOpSpeedMem, 2 * i); - - // leggo 41° byte = indice 40 + 2*i x le var del carico UnOp - UnOpLoad = unOpSpeedMem[40 + i]; - - //vettUnOp[i].mUnOpNumCU.Value = uoData.UnOpNumCU; - //vettUnOp[i].mUnOpStatus.Value = uoData.UnOpStatus; - //vettUnOp[i].mUnOpAccTime.Value = uoData.UnOpAccTime; - - sb.AppendLine(string.Format("SpeedRate UnOp_{0}: {1} rpm", i + 1, SpeedRate)); - sb.AppendLine(string.Format("Load UnOp_{0}: {1}", i + 1, UnOpLoad)); - } - - - parentForm.dataMonitor_1 += sb.ToString(); + + procUnOp(unOpSpeedMem); } /// /// Procedura di processing lettura memoria x DatiUt - Step 4 diff --git a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs index 51603f5..7a2d685 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs @@ -2005,13 +2005,43 @@ namespace MTC_Adapter /// public virtual void getUnOp() { +#if false // cicl su UnOp for (int i = 0; i < currAdpConf.nUnOp; i++) { vettUnOp[i].mUnOpSpeed.Value = SpeedRate; vettUnOp[i].mUnOpSpeedOverr.Value = SpeedRateOver; vettUnOp[i].mUnOpLoad.Value = UnOpLoad; + } +#endif + } + /// + /// Processing dati UnOp + /// + /// + public void procUnOp(byte[] unOpSpeedMem) + { + StringBuilder sb = new StringBuilder(); + + int numUnOp = currAdpConf.nUnOp; + // cicl su path x leggere le velocità dell'UnOp + for (int i = 0; i < numUnOp; i++) + { + // leggo valore Codice + SpeedRate = BitConverter.ToUInt16(unOpSpeedMem, 2 * i); + + // leggo 41° byte = indice 40 + 2*i x le var del carico UnOp + UnOpLoad = unOpSpeedMem[40 + i]; + + vettUnOp[i].mUnOpSpeed.Value = SpeedRate; + vettUnOp[i].mUnOpLoad.Value = UnOpLoad; + vettUnOp[i].mUnOpSpeedOverr.Value = SpeedRateOver; + + sb.AppendLine(string.Format("UnOp_{0}: SpeedRate {1} rpm | Load {2}", i + 1, SpeedRate, UnOpLoad)); } + + + parentForm.dataMonitor_2 += sb.ToString(); } /// /// recupero dati ASSI diff --git a/MTC_Adapter/MTC_Adapter/AdapterOsai.cs b/MTC_Adapter/MTC_Adapter/AdapterOsai.cs index 4793f80..4ef3c20 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterOsai.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterOsai.cs @@ -1371,8 +1371,6 @@ namespace MTC_Adapter /// public override void getUnOp() { - // NON uso il metodo base!!!! - // leggo in blocco tutte le speed da memoria... int memIndex = 2950; // buffer memoria 60 byte... speed (16bit 2 * 20) + load (8bit 1 * 20) visto che sono 20 teste max @@ -1384,29 +1382,7 @@ namespace MTC_Adapter // travaso in modalità byte... Buffer.BlockCopy(unOpSpeedMemW, 0, unOpSpeedMem, 0, unOpSpeedMem.Length); - - - StringBuilder sb = new StringBuilder(); - - int numUnOp = currAdpConf.nUnOp; - // cicl su path x leggere le velocità dell'UnOp - for (int i = 0; i < numUnOp; i++) - { - // leggo valore Codice - SpeedRate = BitConverter.ToUInt16(unOpSpeedMem, 2 * i); - - // leggo 41° byte = indice 40 + 2*i x le var del carico UnOp - UnOpLoad = unOpSpeedMem[40 + i]; - - vettUnOp[i].mUnOpSpeed.Value = SpeedRate; - vettUnOp[i].mUnOpLoad.Value = UnOpLoad; - vettUnOp[i].mUnOpSpeedOverr.Value = SpeedRateOver; - - sb.AppendLine(string.Format("UnOp_{0}: SpeedRate {1} rpm | Load {2}", i + 1, SpeedRate, UnOpLoad)); - } - - - parentForm.dataMonitor_2 += sb.ToString(); + procUnOp(unOpSpeedMem); } ///