EgtMachKernel 2.3b2 :

- migliorato simulatore per errori standard (outstroke = 1, collisione = 11) e relativa gestione.
This commit is contained in:
Dario Sassi
2021-02-11 07:10:24 +00:00
parent 016a796188
commit 09e0b3dab8
3 changed files with 33 additions and 15 deletions
+32 -15
View File
@@ -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) ;
}