EgtMachKernel :
- aggiunta gestione stato simulazione utente per script di movimento per permettere stop e pausa.
This commit is contained in:
+89
-29
@@ -334,6 +334,16 @@ Simulator::SetStep( double dStep)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::SetUiStatus( int nUiStatus)
|
||||
{
|
||||
m_nUiStatus = nUiStatus ;
|
||||
// imposto stato simulatore a livello utente per movimenti gestiti nelle macro di simulazione
|
||||
m_pMachine->LuaSetGlobVar( GLOB_VAR + ".SIMUISTAT", m_nUiStatus) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Simulator::GoHome( void)
|
||||
@@ -396,7 +406,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 false ;
|
||||
return Stopped() ;
|
||||
}
|
||||
// se cambiato oppure prima volta, attivo l'utensile della lavorazione
|
||||
if ( sTool != m_sTool || bFirst) {
|
||||
@@ -429,7 +439,7 @@ Simulator::UpdateTool( bool bFirst)
|
||||
}
|
||||
// eventuale lancio script
|
||||
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst))
|
||||
return false ;
|
||||
return Stopped() ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -443,7 +453,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 false ;
|
||||
return Stopped() ;
|
||||
}
|
||||
// carico l'utensile
|
||||
if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit))
|
||||
@@ -454,7 +464,7 @@ Simulator::UpdateTool( bool bFirst)
|
||||
return false ;
|
||||
// eventuale lancio script
|
||||
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst))
|
||||
return false ;
|
||||
return Stopped() ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
@@ -562,8 +572,12 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus)
|
||||
m_pMchMgr->SetCurrMachining( m_nOpId) ;
|
||||
// richiamo gestione evento inizio lavorazione
|
||||
if ( ! OnMachiningStart( m_nOpId, m_nOpInd)) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
if ( Stopped())
|
||||
return true ;
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
}
|
||||
@@ -587,8 +601,12 @@ 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 = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
if ( Stopped())
|
||||
return true ;
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// cambio fase
|
||||
m_pMchMgr->SetCurrPhase( nPhase, ( nPhase == 1)) ;
|
||||
@@ -600,8 +618,12 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus)
|
||||
++ m_nOpInd ;
|
||||
// richiamo gestione evento inizio disposizione
|
||||
if ( ! OnDispositionStart( m_nOpId, m_nOpInd, nPhase, sTable, ptOri1, false, bSomeByHand)) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
if ( Stopped())
|
||||
return true ;
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se ci sono movimenti manuali, aggiorno visualizzazione e breve pausa (200 ms)
|
||||
if ( bSomeByHand)
|
||||
@@ -612,8 +634,12 @@ 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 = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
if ( Stopped())
|
||||
return true ;
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// cambio fase
|
||||
m_pMchMgr->SetCurrPhase( nPhase, ( nPhase == 1)) ;
|
||||
@@ -621,8 +647,12 @@ 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 = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
if ( Stopped())
|
||||
return true ;
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se non è inizio, aggiorno visualizzazione e breve pausa (200 ms)
|
||||
if ( nPhase != 1) {
|
||||
@@ -656,9 +686,15 @@ Simulator::ManageOperationEnd( int& nStatus)
|
||||
bOk = OnDispositionEnd() ;
|
||||
}
|
||||
// gestione stato
|
||||
if ( ! bOk)
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return bOk ;
|
||||
if ( ! bOk) {
|
||||
if ( Stopped())
|
||||
return true ;
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -713,8 +749,12 @@ Simulator::FindAndManagePathStart( int& nStatus)
|
||||
m_nAuxETot = 0 ;
|
||||
// richiamo gestione evento inizio percorso di lavoro
|
||||
if ( ! OnPathStart( m_nCLPathId, m_nCLPathInd, m_nAuxSTot, ptStart, vtExtr, ptMin, ptMax, dElev)) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
if ( Stopped())
|
||||
return true ;
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se altrimenti trovato nuovo CL path vuoto
|
||||
@@ -741,8 +781,12 @@ Simulator::ManagePathEnd( int& nStatus)
|
||||
m_nAuxEInd = 0 ;
|
||||
// richiamo gestione evento fine percorso di lavoro
|
||||
if ( ! OnPathEnd( m_nAuxETot)) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
if ( Stopped())
|
||||
return true ;
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -761,8 +805,12 @@ Simulator::ManagePathStartAux( int& nStatus)
|
||||
}
|
||||
// richiamo gestione evento ausiliario prima di inizio percorso di lavoro
|
||||
if ( ! OnPathStartAux( m_nAuxSInd, sAS)) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
if ( Stopped())
|
||||
return true ;
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
nStatus = MCH_SIM_END_STEP ;
|
||||
return true ;
|
||||
@@ -782,8 +830,12 @@ Simulator::ManagePathEndAux( int& nStatus)
|
||||
}
|
||||
// richiamo gestione evento ausiliario dopo fine percorso di lavoro
|
||||
if ( ! OnPathEndAux( m_nAuxEInd, sAE)) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
if ( Stopped())
|
||||
return true ;
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
nStatus = MCH_SIM_END_STEP ;
|
||||
return true ;
|
||||
@@ -833,8 +885,12 @@ Simulator::ManageMove( int& nStatus)
|
||||
if ( m_nEntId != GDB_ID_NULL && m_dCoeff < EPS_ZERO) {
|
||||
++ m_nEntInd ;
|
||||
if ( ! OnMoveStart( pCamData)) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
if ( Stopped())
|
||||
return true ;
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,8 +1005,12 @@ Simulator::ManageMove( int& nStatus)
|
||||
nStatus = MCH_SIM_END_STEP ;
|
||||
// richiamo gestione evento fine entità
|
||||
if ( ! OnMoveEnd()) {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
if ( Stopped())
|
||||
return true ;
|
||||
else {
|
||||
nStatus = MCH_SIM_ERR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Altrimenti sto muovendomi all'interno dello step
|
||||
|
||||
Reference in New Issue
Block a user