diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index bb2d97c..e0a455d 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Milling.cpp b/Milling.cpp index 3596563..c255885 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -977,7 +977,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) // recupero il box del grezzo in globale BBox3d b3Raw ; if ( ! GetRawGlobBox( m_nPhase, nPathId, b3Raw) || b3Raw.IsEmpty()) { - LOG_INFO( GetEMkLogger(), "Error in SawFinishing : Empty RawBox") ; + LOG_INFO( GetEMkLogger(), "Error in Milling : Empty RawBox") ; return false ; } diff --git a/OutputConst.h b/OutputConst.h index f37cec1..4d03fb5 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -126,6 +126,7 @@ static const std::string ON_RAPID = "OnRapid" ; static const std::string ON_LINEAR = "OnLinear" ; static const std::string ON_ARC = "OnArc" ; // Funzioni simulazione +static const std::string ON_SIMUL_DISPOSITION_STARTING = "OnSimulDispositionStarting" ; static const std::string ON_SIMUL_DISPOSITION_START = "OnSimulDispositionStart" ; static const std::string ON_SIMUL_DISPOSITION_END = "OnSimulDispositionEnd" ; static const std::string ON_SIMUL_TOOL_SELECT = "OnSimulToolSelect" ; diff --git a/Simulator.cpp b/Simulator.cpp index 171f920..b8385f7 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -208,8 +208,6 @@ Simulator::Move( int& nStatus) // se disposizione con cambio di fase Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nOpId)) ; if ( pDisp != nullptr) { - // cambio fase - m_pMchMgr->SetCurrPhase( pDisp->GetPhase()) ; // recupero dati tavola string sTable ; pDisp->GetTable( sTable) ; @@ -217,6 +215,13 @@ Simulator::Move( int& nStatus) pDisp->GetTableRef1( ptOri1) ; // se con movimenti autonomi if ( ! pDisp->IsEmpty()) { + // richiamo gestione evento appena prima di inizio disposizione + if ( ! OnDispositionStarting( m_nOpId, m_nOpInd, pDisp->GetPhase(), sTable, ptOri1, false)) { + nStatus = MCH_SIM_ERR ; + return false ; + } + // cambio fase + m_pMchMgr->SetCurrPhase( pDisp->GetPhase()) ; // aggiorno utensile e assi conseguenti if ( ! UpdateTool()) { nStatus = MCH_SIM_ERR ; @@ -234,6 +239,8 @@ Simulator::Move( int& nStatus) } // altrimenti disposizione passiva else { + // cambio fase + m_pMchMgr->SetCurrPhase( pDisp->GetPhase()) ; ++ m_nOpInd ; // richiamo gestione evento inizio e fine disposizione if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), sTable, ptOri1, true) || @@ -602,6 +609,29 @@ Simulator::OnOperationEnd( void) return false ; } +//---------------------------------------------------------------------------- +bool +Simulator::OnDispositionStarting( int nOpId, int nOpInd, int nPhase, + const string& sTable, const Point3d& ptOri1, bool bEmpty) +{ + // assegno identificativo e indice disposizione + bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPID, nOpId) ; + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPIND, nOpInd) ; + // assegno nuovo indice di fase + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PHASE, nPhase) ; + // assegno nome e valore riferimento della tavola corrente + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TABNAME, sTable) ; + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TABORI1, ptOri1) ; + // assegno flag disposizione passiva + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EMPTY, bEmpty) ; + // verifico esistenza funzione + if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_DISPOSITION_STARTING)) + return true ; + // chiamo la funzione di inizio disposizione + bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_DISPOSITION_STARTING) ; + return bOk ; +} + //---------------------------------------------------------------------------- bool Simulator::OnDispositionStart( int nOpId, int nOpInd, int nPhase, diff --git a/Simulator.h b/Simulator.h index cfb49d7..67d7357 100644 --- a/Simulator.h +++ b/Simulator.h @@ -43,6 +43,8 @@ class Simulator private : bool OnOperationEnd( void) ; + bool OnDispositionStarting( int nOpId, int nOpInd, int nPhase, + const std::string& sTable, const Point3d& ptOri1, bool bEmpty) ; bool OnDispositionStart( int nOpId, int nOpInd, int nPhase, const std::string& sTable, const Point3d& ptOri1, bool bEmpty) ; bool OnDispositionEnd( void) ;