From 4af09db198734f8673fa287c8bcbe26fe3344b9a Mon Sep 17 00:00:00 2001 From: DarioS Date: Tue, 17 Jan 2023 18:19:49 +0100 Subject: [PATCH] EgtMachKernel : - miglioria alla funzione EmtMoveAxes per gestire anche rappresentazioni simboliche delle feed (con interi negativi). --- Simulator.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Simulator.cpp b/Simulator.cpp index 26d796b..746b56c 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -2078,10 +2078,26 @@ Simulator::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) bOkI = m_pGeomDB->GetGlobFrame( m_VmId[i], vFrVzmI[i]) && bOkI ; } // Determino gli step di movimento + static const int STEP_FEED = -1 ; + static const int STEP_RAPID = -2 ; + static const int STEP_RAPROT = -3 ; + static const int STEP_COLLROT = -4 ; int nStep = 1 ; for ( int i = 0 ; i < nAxCount ; ++ i) { double dMove = abs( vAxNaEpSt[i].dEndPos - vPrev[i]) ; - int nAxStep = int( dMove / max( vAxNaEpSt[i].dStep, 1.)) + 1 ; + double dStep = vAxNaEpSt[i].dStep ; + if ( dStep < 0) { + if ( abs( dStep - STEP_FEED) < EPS_SMALL) + dStep = m_dStep ; + else if ( abs( dStep - STEP_RAPID) < EPS_SMALL) + dStep = 4 * m_dStep ; + else if ( abs( dStep - STEP_RAPROT) < EPS_SMALL) + dStep = 0.4 * m_dStep ; + else // STEP_COLLROT + dStep = min( 0.4 * m_dStep, 10.) ; + } + dStep = max( dStep, 1.) ; + int nAxStep = int( dMove / dStep) + 1 ; nStep = max( nStep, nAxStep) ; } // Eseguo il movimento @@ -2153,10 +2169,11 @@ Simulator::MoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) if ( m_nUiStatus == MCH_UISIM_STOP) return SIM_AXMV_RES_STOP ; // Se cambia lo step di simulazione in modo significativo ... - if ( abs( ( m_dStep - dOrigStep) / ( m_dStep + dOrigStep)) > 0.2) { + if ( abs( m_dStep - dOrigStep) > 10 || abs( ( m_dStep - dOrigStep) / ( m_dStep + dOrigStep)) > 0.2) { double dRat = m_dStep / dOrigStep ; for ( int j = 0 ; j < nAxCount ; ++ j) { - const_cast( vAxNaEpSt[j].dStep) *= dRat ; + if ( vAxNaEpSt[j].dStep > 0) + const_cast( vAxNaEpSt[j].dStep) *= dRat ; } return MoveAxes( nMoveType, vAxNaEpSt) ; }