From 09e0b3dab8bc9084429a6f99bcb3e137851240df Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 11 Feb 2021 07:10:24 +0000 Subject: [PATCH] EgtMachKernel 2.3b2 : - migliorato simulatore per errori standard (outstroke = 1, collisione = 11) e relativa gestione. --- EgtMachKernel.rc | Bin 11774 -> 11774 bytes Simulator.cpp | 47 ++++++++++++++++++++++++++++++++--------------- Simulator.h | 1 + 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 053770ac6ada98db3c6a2060eb7a24c229bad730..96dd2af1452a6e9af041a9203184c4ee41561938 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 980e1cb..d404a08 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -602,7 +602,7 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus) if ( pMch != nullptr && ! pMch->IsEmpty()) { // aggiorno utensile e assi conseguenti if ( ! UpdateTool( bFirst)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + nStatus = CalcStatusOnError( 0) ; return false ; } ++ m_nOpInd ; @@ -618,7 +618,7 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus) m_pGeomDB->GetInfo( nClId, KEY_MAXMAX, vAxMax) ; // richiamo gestione evento inizio lavorazione if ( ! OnMachiningStart( m_nOpId, m_nOpInd, ptMin, ptMax, vAxMin, vAxMax)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + nStatus = CalcStatusOnError( 0) ; return false ; } break ; @@ -643,20 +643,20 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus) if ( ! bEmpty) { // richiamo gestione evento appena prima di inizio disposizione if ( ! OnDispositionStarting( m_nOpId, m_nOpInd, nPhase, sTable, ptOri1, false, bSomeByHand)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + nStatus = CalcStatusOnError( 0) ; return false ; } // cambio fase m_pMchMgr->SetCurrPhase( nPhase, ( nPhase == 1)) ; // aggiorno utensile e assi conseguenti if ( ! UpdateTool( bFirst)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + nStatus = CalcStatusOnError( 0) ; return false ; } ++ m_nOpInd ; // richiamo gestione evento inizio disposizione if ( ! OnDispositionStart( m_nOpId, m_nOpInd, nPhase, sTable, ptOri1, false, bSomeByHand)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + nStatus = CalcStatusOnError( 0) ; return false ; } // se ci sono movimenti manuali, aggiorno visualizzazione e breve pausa (200 ms) @@ -668,7 +668,7 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus) else { // richiamo gestione evento appena prima di inizio disposizione if ( ! OnDispositionStarting( m_nOpId, m_nOpInd, nPhase, sTable, ptOri1, true, bSomeByHand)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + nStatus = CalcStatusOnError( 0) ; return false ; } // cambio fase @@ -677,7 +677,7 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus) // richiamo gestione evento inizio e fine disposizione if ( ! OnDispositionStart( m_nOpId, m_nOpInd, nPhase, sTable, ptOri1, true, bSomeByHand) || ! OnDispositionEnd()) { - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + nStatus = CalcStatusOnError( 0) ; return false ; } // se non è inizio, aggiorno visualizzazione e breve pausa (200 ms) @@ -713,7 +713,7 @@ Simulator::ManageOperationEnd( int& nStatus) } // gestione stato if ( ! bOk) - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + nStatus = CalcStatusOnError( 0) ; return bOk ; } @@ -775,7 +775,7 @@ Simulator::FindAndManagePathStart( int& nStatus) m_nAuxETot = 0 ; // richiamo gestione evento inizio percorso di lavoro if ( ! OnPathStart( m_nCLPathId, m_nCLPathInd, m_nAuxSTot, ptStart, ptEnd, vtExtr, ptMin, ptMax, vAxMin, vAxMax, dElev)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + nStatus = CalcStatusOnError( 0) ; return false ; } } @@ -805,7 +805,7 @@ Simulator::ManagePathEnd( int& nStatus) bool bOk = OnPathEnd( m_nAuxETot) ; // gestione stato if ( ! bOk) - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + nStatus = CalcStatusOnError( 0) ; return bOk ; } @@ -824,7 +824,7 @@ Simulator::ManagePathStartAux( int& nStatus) // richiamo gestione evento ausiliario prima di inizio percorso di lavoro int nErr ; if ( ! OnPathStartAux( m_nAuxSInd, sAS, nErr)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : ( nErr == 1 ? MCH_SIM_OUTSTROKE : MCH_SIM_ERR)) ; + nStatus = CalcStatusOnError( nErr) ; return false ; } nStatus = MCH_SIM_END_STEP ; @@ -846,7 +846,7 @@ Simulator::ManagePathEndAux( int& nStatus) // richiamo gestione evento ausiliario dopo fine percorso di lavoro int nErr ; if ( ! OnPathEndAux( m_nAuxEInd, sAE, nErr)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : ( nErr == 1 ? MCH_SIM_OUTSTROKE : MCH_SIM_ERR)) ; + nStatus = CalcStatusOnError( nErr) ; return false ; } nStatus = MCH_SIM_END_STEP ; @@ -922,7 +922,7 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove) ++ m_nEntInd ; int nErr ; if ( ! OnMoveStart( pCamData, nErr)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : ( nErr == 1 ? MCH_SIM_OUTSTROKE : MCH_SIM_ERR)) ; + nStatus = CalcStatusOnError( nErr) ; return false ; } // Se movimento in rapido aggiorno quote degli assi disabilitati dal mask @@ -1088,7 +1088,7 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove) // Richiamo funzione di convalida collisione int nErr ; if ( ! OnCollision( nCdInd, nObjInd, nErr)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : ( nErr == 1 ? MCH_SIM_COLLISION : MCH_SIM_ERR)) ; + nStatus = CalcStatusOnError( nErr) ; // Se arrivato a fine interpolazione movimento, salvo posizioni if ( m_dCoeff > COEFF_LIM && m_bEnabAxes) { for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) @@ -1107,7 +1107,7 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove) nStatus = MCH_SIM_END_STEP ; // richiamo gestione evento fine entità if ( ! OnMoveEnd()) { - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + nStatus = CalcStatusOnError( 0) ; return false ; } } @@ -1118,6 +1118,20 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove) return true ; } +//---------------------------------------------------------------------------- +int +Simulator::CalcStatusOnError( int nErr) +{ + if ( Stopped()) + return MCH_SIM_STOP ; + else if ( nErr == 1) + return MCH_SIM_OUTSTROKE ; + else if ( nErr == 11) + return MCH_SIM_COLLISION ; + else + return MCH_SIM_ERR ; +} + //---------------------------------------------------------------------------- bool Simulator::GetHeadCurrPosDirAux( Point3d& ptH, Vector3d& vtH, Vector3d& vtA) @@ -1707,6 +1721,9 @@ Simulator::OnCollision( int nCdInd, int nObjInd, int& nErr) return false ; // verifico codice di errore m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ; + // l'errore standard di collisione è stato portato da 1 a 11 per non collidere con altri tipi di errori + if ( nErr == 1) + nErr = 11 ; return ( nErr == 0) ; } diff --git a/Simulator.h b/Simulator.h index 2fc72c9..5ed44f6 100644 --- a/Simulator.h +++ b/Simulator.h @@ -59,6 +59,7 @@ class Simulator bool ManagePathEndAux( int& nStatus) ; bool ManageMove( int& nStatus) ; bool ManageSingleMove( int& nStatus, double& dMove) ; + int CalcStatusOnError( int nErr) ; bool GetHeadCurrPosDirAux( Point3d& ptH, Vector3d& vtH, Vector3d& vtA) ; bool ExecLineVmill( int nVmId, const Point3d& ptHi, const Vector3d& vtHi, const Vector3d& vtAi, const Frame3d& frVzmI, const Point3d& ptHf, const Vector3d& vtHf, const Vector3d& vtAf, const Frame3d& frVzmF) ;