From afec834281fbaebca7f4895a23ab5b7b53f96518 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sun, 6 May 2018 16:58:17 +0000 Subject: [PATCH] =?UTF-8?q?EgtMachKernel=201.9e2=20:=20-=20migliorata=20ge?= =?UTF-8?q?stione=20velocit=C3=A0=20simulazione=20con=20Virtual=20Milling.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EgtMachKernel.rc | Bin 11774 -> 11774 bytes Simulator.cpp | 38 +++++++++++++++++++++++++++++++++++--- Simulator.h | 1 + 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 55d2ce8a3cc5cbfb66b5a90e1d201b804fc8d917..730c2a78d8b8247d460b2dd1572f4a5d30d59568 100644 GIT binary patch delta 97 zcmewt{V#gMFE&P_&A-`fnHh~HKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmU8!BZvS1 delta 97 zcmewt{V#gMFE&QQ&A-`fnHdcyKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmU3rBY*$^ diff --git a/Simulator.cpp b/Simulator.cpp index c8ec910..e3e7e39 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -32,6 +32,9 @@ using namespace std ; //------------------------------ Errors -------------------------------------- // 1001 = "Error with setup : xxx" +//---------------------------------------------------------------------------- +const double COEFF_LIM = 0.999 ; + //---------------------------------------------------------------------------- Simulator::Simulator( void) { @@ -159,7 +162,7 @@ Simulator::Move( int& nStatus) } // Se arrivato alla fine dell'interpolazione - if ( m_dCoeff > 0.999) { + if ( m_dCoeff > COEFF_LIM) { // recupero una nuova entità m_nEntId = m_pGeomDB->GetNext( m_nEntId) ; m_dCoeff = 0 ; @@ -851,6 +854,32 @@ Simulator::ManagePathEndAux( int& nStatus) //---------------------------------------------------------------------------- bool Simulator::ManageMove( int& nStatus) +{ + // Imposto lunghezza di movimento effettuata + double dCurrMove = 0 ; + while ( m_nEntId != GDB_ID_NULL) { + // eseguo movimento singolo + double dMove ; + if ( ! ManageSingleMove( nStatus, dMove)) + return false ; + if ( Stopped()) + return true ; + dCurrMove += dMove ; + // se non raggiunto lo step + if ( m_dCoeff > COEFF_LIM && dCurrMove < 0.9 * m_dStep) { + // recupero una nuova entità + m_nEntId = m_pGeomDB->GetNext( m_nEntId) ; + m_dCoeff = 0 ; + } + else + break ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +Simulator::ManageSingleMove( int& nStatus, double& dMove) { // Recupero posizione finale const CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( m_nEntId)) ; @@ -909,7 +938,7 @@ Simulator::ManageMove( int& nStatus) // Calcolo distanza di movimento double dSqDist = 0 ; for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) { - // coefficiente moltiplicativo per differenziare assi lineari (primi3) e rotanti (altri) + // coefficiente moltiplicativo per differenziare assi lineari (primi 3) e rotanti (altri) double dSqCoeff = (( i < 3) ? 1 : 100) ; dSqDist += dSqCoeff * ( AxesEnd[i] - m_AxesVal[i]) * ( AxesEnd[i] - m_AxesVal[i]) ; } @@ -923,6 +952,7 @@ Simulator::ManageMove( int& nStatus) } else m_dCoeff = 1 ; + dMove = ( m_dCoeff - dPrevCoeff) * dDist ; // Posizione e direzione attuali dell'utensile e riferimento attuale del pezzo (per Vmill) Point3d ptNoseI ; Vector3d vtDirI ; Vector3d vtAuxI ; Frame3d frVzmI ; @@ -992,6 +1022,7 @@ Simulator::ManageMove( int& nStatus) double dSqCoeff = ( m_AuxAxesLinear[i] ? 1 : 100) ; dSqDist += dSqCoeff * ( m_AuxAxesEnd[i] - m_AuxAxesVal[i]) * ( m_AuxAxesEnd[i] - m_AuxAxesVal[i]) ; } + double dPrevCoeff = m_dCoeff ; double dDist = sqrt( dSqDist) ; if ( dDist > EPS_SMALL) { int nStep = int( max( dDist / ( ( nMoveType == 0 ? 4 : 1) * m_dStep), 1.)) ; @@ -1001,6 +1032,7 @@ Simulator::ManageMove( int& nStatus) } else m_dCoeff = 1 ; + dMove = ( m_dCoeff - dPrevCoeff) * dDist ; } // Muovo eventuali assi ausiliari @@ -1010,7 +1042,7 @@ Simulator::ManageMove( int& nStatus) } // Se arrivato a fine interpolazione movimento, salvo posizioni e segnalo - if ( m_dCoeff > 0.999) { + if ( m_dCoeff > COEFF_LIM) { if ( m_bEnabAxes) { for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) m_AxesVal[i] = AxesEnd[i] ; diff --git a/Simulator.h b/Simulator.h index ea766c0..fd52781 100644 --- a/Simulator.h +++ b/Simulator.h @@ -54,6 +54,7 @@ class Simulator bool ManagePathStartAux( int& nStatus) ; bool ManagePathEndAux( int& nStatus) ; bool ManageMove( int& nStatus) ; + bool ManageSingleMove( int& nStatus, double& dMove) ; bool GetHeadCurrPosDirAux( Point3d& ptH, Vector3d& vtH, Vector3d& vtA) ; bool ExecVmillOnLine( const Point3d& ptHi, const Vector3d& vtHi, const Vector3d& vtAi, const Frame3d& frVzmI, const Point3d& ptHf, const Vector3d& vtHf, const Vector3d& vtAf, const Frame3d& frVzmF) ;