diff --git a/OutputConst.h b/OutputConst.h index efd2358..a4900af 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -60,6 +60,7 @@ static const std::string GVAR_TCOMP = ".TCOMP" ; // (int) numero cor static const std::string GVAR_TDIAM = ".TDIAM" ; // (num) diametro utensile static const std::string GVAR_TLEN = ".TLEN" ; // (num) lunghezza utensile static const std::string GVAR_SMAX = ".SMAX" ; // (num) massima speed utensile +static const std::string GVAR_FIRST = ".FIRST" ; // (bool) flag per primo utensile static const std::string GVAR_NEXTTOOL = ".NEXTTOOL" ; // (string) nome del prossimo utensile static const std::string GVAR_NEXTHEAD = ".NEXTHEAD" ; // (string) nome testa del prossimo utensile static const std::string GVAR_NEXTEXIT = ".NEXTEXIT" ; // (int) indice uscita su testa del prox utensile diff --git a/Simulator.cpp b/Simulator.cpp index 78b99ca..eacd233 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -326,7 +326,7 @@ Simulator::UpdateTool( bool bFirst) if ( ! UpdateAxes()) return false ; // eventuale lancio script - if ( ! bFirst && ! OnToolSelect( m_sTool, sHead, nExit, sTcPos)) + if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst)) return false ; } return true ; @@ -351,7 +351,7 @@ Simulator::UpdateTool( bool bFirst) if ( ! UpdateAxes()) return false ; // eventuale lancio script - if ( ! bFirst && ! OnToolSelect( m_sTool, sHead, nExit, sTcPos)) + if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst)) return false ; return true ; } @@ -482,7 +482,7 @@ Simulator::FindAndManageOperationStart( bool bFirst, int& nStatus) // cambio fase m_pMchMgr->SetCurrPhase( pDisp->GetPhase()) ; // aggiorno utensile e assi conseguenti - if ( ! UpdateTool()) { + if ( ! UpdateTool( bFirst)) { nStatus = MCH_SIM_ERR ; return false ; } @@ -855,7 +855,8 @@ Simulator::OnDispositionEnd( void) //---------------------------------------------------------------------------- bool -Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, const string& sTcPos) +Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, const string& sTcPos, + bool bFirst) { // assegno il nome dell'utensile, la testa e l'uscita if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, sTool) || @@ -877,6 +878,9 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, co return false ; } } + // assegno il flag di chiamata di utensile iniziale + if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIRST, bFirst)) + return false ; // verifico esistenza funzione if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_TOOL_SELECT)) return true ; diff --git a/Simulator.h b/Simulator.h index 7e50c39..9eaaf24 100644 --- a/Simulator.h +++ b/Simulator.h @@ -56,7 +56,7 @@ class Simulator bool OnDispositionStart( int nOpId, int nOpInd, int nPhase, const std::string& sTable, const Point3d& ptOri1, bool bEmpty) ; bool OnDispositionEnd( void) ; - bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit, const std::string& sTcPos) ; + bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit, const std::string& sTcPos, bool bFirst) ; bool OnToolDeselect( const std::string& sNextTool, const std::string& sNextHead, int nNextExit, const std::string& sNextTcPos) ; bool OnMachiningStart( int nOpId, int nOpInd) ; bool OnMachiningEnd( void) ;