EgtMachKernel :

- aggiunta funzione lua EmtSetLastError per segnalare errori nel PostProc
- migliorie a simulazione con introduzione stato di movimento STOP.
This commit is contained in:
Dario Sassi
2018-08-17 18:42:16 +00:00
parent bd74a8c9e7
commit 6d5f24bc51
3 changed files with 56 additions and 89 deletions
+34 -89
View File
@@ -416,7 +416,7 @@ Simulator::UpdateTool( bool bFirst)
if ( sTool != m_sTool && ! m_sTool.empty()) {
// eventuale lancio script per scarico utensile
if ( ! OnToolDeselect( sTool, sHead, nExit, sTcPos))
return Stopped() ;
return false ;
}
// se cambiato oppure prima volta, attivo l'utensile della lavorazione
if ( sTool != m_sTool || bFirst) {
@@ -449,7 +449,7 @@ Simulator::UpdateTool( bool bFirst)
}
// eventuale lancio script
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst))
return Stopped() ;
return false ;
}
return true ;
}
@@ -463,7 +463,7 @@ Simulator::UpdateTool( bool bFirst)
if ( ! m_sTool.empty() && sTool != m_sTool) {
// eventuale lancio script per scarico utensile
if ( ! OnToolDeselect( sTool, sHead, nExit, sTcPos))
return Stopped() ;
return false ;
}
// carico l'utensile
if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit))
@@ -474,7 +474,7 @@ Simulator::UpdateTool( bool bFirst)
return false ;
// eventuale lancio script
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst))
return Stopped() ;
return false ;
return true ;
}
return false ;
@@ -574,7 +574,7 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus)
if ( pMch != nullptr && ! pMch->IsEmpty()) {
// aggiorno utensile e assi conseguenti
if ( ! UpdateTool( bFirst)) {
nStatus = MCH_SIM_ERR ;
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return false ;
}
++ m_nOpInd ;
@@ -587,12 +587,8 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus)
m_pGeomDB->GetInfo( nClId, KEY_MMAX, ptMax) ;
// richiamo gestione evento inizio lavorazione
if ( ! OnMachiningStart( m_nOpId, m_nOpInd, ptMin, ptMax)) {
if ( Stopped())
return true ;
else {
nStatus = MCH_SIM_ERR ;
return false ;
}
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return false ;
}
break ;
}
@@ -616,29 +612,21 @@ 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)) {
if ( Stopped())
return true ;
else {
nStatus = MCH_SIM_ERR ;
return false ;
}
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return false ;
}
// cambio fase
m_pMchMgr->SetCurrPhase( nPhase, ( nPhase == 1)) ;
// aggiorno utensile e assi conseguenti
if ( ! UpdateTool( bFirst)) {
nStatus = MCH_SIM_ERR ;
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return false ;
}
++ m_nOpInd ;
// richiamo gestione evento inizio disposizione
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, nPhase, sTable, ptOri1, false, bSomeByHand)) {
if ( Stopped())
return true ;
else {
nStatus = MCH_SIM_ERR ;
return false ;
}
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return false ;
}
// se ci sono movimenti manuali, aggiorno visualizzazione e breve pausa (200 ms)
if ( bSomeByHand)
@@ -649,12 +637,8 @@ 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)) {
if ( Stopped())
return true ;
else {
nStatus = MCH_SIM_ERR ;
return false ;
}
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return false ;
}
// cambio fase
m_pMchMgr->SetCurrPhase( nPhase, ( nPhase == 1)) ;
@@ -662,12 +646,8 @@ 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()) {
if ( Stopped())
return true ;
else {
nStatus = MCH_SIM_ERR ;
return false ;
}
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return false ;
}
// se non è inizio, aggiorno visualizzazione e breve pausa (200 ms)
if ( nPhase != 1) {
@@ -701,15 +681,9 @@ Simulator::ManageOperationEnd( int& nStatus)
bOk = OnDispositionEnd() ;
}
// gestione stato
if ( ! bOk) {
if ( Stopped())
return true ;
else {
nStatus = MCH_SIM_ERR ;
return false ;
}
}
return true ;
if ( ! bOk)
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return bOk ;
}
//----------------------------------------------------------------------------
@@ -766,12 +740,8 @@ 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, dElev)) {
if ( Stopped())
return true ;
else {
nStatus = MCH_SIM_ERR ;
return false ;
}
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return false ;
}
}
// se altrimenti trovato nuovo CL path vuoto
@@ -797,15 +767,11 @@ Simulator::ManagePathEnd( int& nStatus)
m_nAuxETot = 0 ;
m_nAuxEInd = 0 ;
// richiamo gestione evento fine percorso di lavoro
if ( ! OnPathEnd( m_nAuxETot)) {
if ( Stopped())
return true ;
else {
nStatus = MCH_SIM_ERR ;
return false ;
}
}
return true ;
bool bOk = OnPathEnd( m_nAuxETot) ;
// gestione stato
if ( ! bOk)
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return bOk ;
}
//----------------------------------------------------------------------------
@@ -822,12 +788,8 @@ Simulator::ManagePathStartAux( int& nStatus)
}
// richiamo gestione evento ausiliario prima di inizio percorso di lavoro
if ( ! OnPathStartAux( m_nAuxSInd, sAS)) {
if ( Stopped())
return true ;
else {
nStatus = MCH_SIM_ERR ;
return false ;
}
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return false ;
}
nStatus = MCH_SIM_END_STEP ;
return true ;
@@ -847,12 +809,8 @@ Simulator::ManagePathEndAux( int& nStatus)
}
// richiamo gestione evento ausiliario dopo fine percorso di lavoro
if ( ! OnPathEndAux( m_nAuxEInd, sAE)) {
if ( Stopped())
return true ;
else {
nStatus = MCH_SIM_ERR ;
return false ;
}
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return false ;
}
nStatus = MCH_SIM_END_STEP ;
return true ;
@@ -869,8 +827,6 @@ Simulator::ManageMove( int& nStatus)
double dMove ;
if ( ! ManageSingleMove( nStatus, dMove))
return false ;
if ( Stopped())
return true ;
dCurrMove += dMove ;
// se modalità play e fine entità e non raggiunta la lunghezza di movimento voluto
if ( m_nUiStatus == MCH_UISIM_PLAY && nStatus == MCH_SIM_END_STEP && dCurrMove < 0.75 * m_dStep) {
@@ -929,15 +885,8 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
++ m_nEntInd ;
int nErr ;
if ( ! OnMoveStart( pCamData, nErr)) {
if ( Stopped())
return true ;
else {
if ( nErr == 1)
nStatus = MCH_SIM_OUTSTROKE ;
else
nStatus = MCH_SIM_ERR ;
return false ;
}
nStatus = ( Stopped() ? MCH_SIM_STOP : ( nErr == 1 ? MCH_SIM_OUTSTROKE : MCH_SIM_ERR)) ;
return false ;
}
}
@@ -1057,12 +1006,8 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
nStatus = MCH_SIM_END_STEP ;
// richiamo gestione evento fine entità
if ( ! OnMoveEnd()) {
if ( Stopped())
return true ;
else {
nStatus = MCH_SIM_ERR ;
return false ;
}
nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ;
return false ;
}
}
// Altrimenti sto muovendomi all'interno dell'entità