From 81a849a92c6933d6be4699bc5c24fd3ea87e41ff Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 31 May 2017 18:28:26 +0200 Subject: [PATCH] corretta la lettura posizione assi con oggetto "itemRead" a blocco... --- .../CMSCncLib/CNC/CNC.SIEMENS/CNC.SIEMENS.vb | 78 ++++++++++++------- MTC_Adapter/MTC/baseUtils.cs | 2 +- MTC_Adapter/MTC_Adapter/AdapterSiemens.cs | 10 ++- 3 files changed, 58 insertions(+), 32 deletions(-) diff --git a/MTC_Adapter/CMSCncLib/CNC/CNC.SIEMENS/CNC.SIEMENS.vb b/MTC_Adapter/CMSCncLib/CNC/CNC.SIEMENS/CNC.SIEMENS.vb index 9e71326..8a9ccf8 100644 --- a/MTC_Adapter/CMSCncLib/CNC/CNC.SIEMENS/CNC.SIEMENS.vb +++ b/MTC_Adapter/CMSCncLib/CNC/CNC.SIEMENS/CNC.SIEMENS.vb @@ -888,41 +888,63 @@ Namespace CNC #Region "Funzioni specifiche IOT" - Public Function getAllAxisPos() As Drive() + ''' + ''' Struttura dati asse + ''' + Public Structure AxData + ''' + ''' Carico Asse + ''' + Public Load As Single + ''' + ''' posizione attuale asse + ''' + Public PosAct As Single + ''' + ''' Velocità asse + ''' + Public Speed As Single + + End Structure + + Public Function getAllAxisPos() As AxData() ' RIFERIMENTO: - ' SinumerikOperate_net.pdf, pag 222 - - 'Dim nPathIdx As Integer - 'Dim nNumAxisRead As Integer - 'Dim nReturn As Integer - - Dim posizAssi As Drive() - - Dim m_SelectedDrive As Drive - Dim m_DrivesList As Drive() - - posizAssi = m_DriveSVC.ListDrives() - - 'm_SelectedDrive = m_DrivesList(0) + ' txt Giuseppe + ReDim itemRead(2) + itemRead(0) = New Item("DB241.DBD0:[16]") 'Posizione attuale + itemRead(1) = New Item("DB254.DBW140:[20]") 'Speed effettiva + itemRead(2) = New Item("DB254.DBB180:[20]") 'Carico effettivo - ''leggo il numero del processo attivo - 'nPathIdx = GetActivePath() - ''leggo num max assi dal cn - 'nNumAxisRead = Focas1.MAX_AXIS + Do + Try + m_DataSvcRW.Read(itemRead) + Exit Do + Catch ex As DataSvcBusyException + Debug.Print(ex.Message) + Catch ex As DataSvcException + Throw New CmsNcException("ERR GetStaticData CNC.SIEMENS DataSvcException", ex) + End Try + Loop - 'If Is30Series Then + Dim datiAssi(20) As AxData - ' ' leggo tutto!!! - ' nReturn = Focas1.cnc_rdposition(nLibHandle(nPathIdx), -1, nNumAxisRead, posizAssi) + ' faccio copia valori! ...posizione + For i As Integer = 0 To 15 + 'datiAssi(i).PosAct = itemRead(0).Value(i) + datiAssi(i).PosAct = UIntegerToSingle(itemRead(0).Value(i)) + Next i + For i As Integer = 0 To 19 + datiAssi(i).Speed = itemRead(1).Value(i) + 'datiAssi(i).Speed = UIntegerToSingle(itemRead(1).Value(i)) + Next i + For i As Integer = 0 To 19 + datiAssi(i).Load = itemRead(2).Value(i) + 'datiAssi(i).Load = UIntegerToSingle(itemRead(2).Value(i)) + Next i - ' If F_CheckRetError_Cnc(nReturn, "cnc_rdposition RefreshAxisPosition CNC.FANUC.CMS_CncLib") Then - ' Throw New CmsNcException("ERR cnc_rdposition RefreshAxisPosition CNC.FANUC.CMS_CncLib") - ' End If - 'End If - - Return posizAssi + Return datiAssi End Function diff --git a/MTC_Adapter/MTC/baseUtils.cs b/MTC_Adapter/MTC/baseUtils.cs index a79f302..15ff1ff 100644 --- a/MTC_Adapter/MTC/baseUtils.cs +++ b/MTC_Adapter/MTC/baseUtils.cs @@ -534,7 +534,7 @@ namespace MTC public int UnOpLoad; public int UnOpAccTime; } - + public struct AxisData { public int AxisSel; diff --git a/MTC_Adapter/MTC_Adapter/AdapterSiemens.cs b/MTC_Adapter/MTC_Adapter/AdapterSiemens.cs index 37bc27b..13ff133 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterSiemens.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterSiemens.cs @@ -1009,14 +1009,18 @@ namespace MTC_Adapter int memIndex = 0; inizio = DateTime.Now; - - // !!!FARE!!! leggere un MACRO blocco di dati (multi) x dati assi.... - // MODIFICA: leggo float direttamente x posizione assi... float[] axisPosFloat = new float[axisPosData.Length]; SIEMENSMemRW_Float(R, baseMemAx, memIndex, ref axisPosFloat); if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-AXIS_POS", MemBlockTop.Length), DateTime.Now.Subtract(inizio).Ticks); + + inizio = DateTime.Now; + // !!!FARE!!! test lettura di TUTTI i dati assi.... + SIEMENS.AxData[] ValAssi = SIEMENS_ref.getAllAxisPos(); + if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-AXIS_ALL", ValAssi.Length * 3 * 2), DateTime.Now.Subtract(inizio).Ticks); + + for (int i = 0; i < currAdpConf.nAxis; i++) { // per sicurezza try-catch