EgtMachKernel 2.3a2 :
- aggiunte funzioni lua EmtExecCollisionCheck e EmtOnCollision utilizzabili solo durante la simulazione.
This commit is contained in:
Binary file not shown.
@@ -433,6 +433,8 @@ class MachMgr : public IMachMgr
|
||||
const ToolData* GetMachiningToolData( void) const ;
|
||||
// Simulation
|
||||
bool SimAddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, double dPar2, double dPar3) ;
|
||||
bool SimExecCollisionCheck( int& nCdInd, int& nObjInd) ;
|
||||
bool SimOnCollision( int nCdInd, int nObjInd, int& nErr) ;
|
||||
// Machine
|
||||
bool GetHeadAbove( const std::string& sHead) const ;
|
||||
double GetAngDeltaMinForHome( void) const ;
|
||||
|
||||
@@ -158,3 +158,25 @@ MachMgr::SimAddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, do
|
||||
// aggiungo un oggetto da verificare per la collisione con il grezzo
|
||||
return m_pSimul->AddCollisionObj( nInd, nFrameId, nType, dPar1, dPar2, dPar3) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::SimExecCollisionCheck( int& nCdInd, int& nObjInd)
|
||||
{
|
||||
// verifico simulatore
|
||||
if ( m_pSimul == nullptr)
|
||||
return false ;
|
||||
// eseguo verifica di collisione (nessuna collisione -> true)
|
||||
return m_pSimul->ExecCollisionCheck( nCdInd, nObjInd) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::SimOnCollision( int nCdInd, int nObjInd, int& nErr)
|
||||
{
|
||||
// verifico simulatore
|
||||
if ( m_pSimul == nullptr)
|
||||
return false ;
|
||||
// lancio funzione di gestione collisione
|
||||
return m_pSimul->OnCollision( nCdInd, nObjInd, nErr) ;
|
||||
}
|
||||
|
||||
@@ -327,6 +327,8 @@ class Machine
|
||||
static int LuaEmtSetLastError( lua_State* L) ;
|
||||
static int LuaEmtSetWarning( lua_State* L) ;
|
||||
static int LuaEmtAddCollisionObj( lua_State* L) ;
|
||||
static int LuaEmtExecCollisionCheck( lua_State* L) ;
|
||||
static int LuaEmtOnCollision( lua_State* L) ;
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -120,6 +120,10 @@ Machine::LuaInit( const string& sMachineName)
|
||||
m_LuaMgr.RegisterFunction( "EmtSetWarning", Machine::LuaEmtSetWarning) ;
|
||||
// registro la funzione per aggiungere un oggetto da verificare per la collisione in simulazione
|
||||
m_LuaMgr.RegisterFunction( "EmtAddCollisionObj", Machine::LuaEmtAddCollisionObj) ;
|
||||
// registro la funzione di esecuzione della verifica di collisione in simulazione
|
||||
m_LuaMgr.RegisterFunction( "EmtExecCollisionCheck", Machine::LuaEmtExecCollisionCheck) ;
|
||||
// registro la funzione di gestione della collisione in simulazione
|
||||
m_LuaMgr.RegisterFunction( "EmtOnCollision", Machine::LuaEmtOnCollision) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -1179,3 +1183,44 @@ Machine::LuaEmtAddCollisionObj( lua_State* L)
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
Machine::LuaEmtExecCollisionCheck( lua_State* L)
|
||||
{
|
||||
// Nessun parametro
|
||||
LuaClearStack( L) ;
|
||||
// verifico ci sia una macchina attiva
|
||||
if ( m_pMchLua == nullptr)
|
||||
return luaL_error( L, " Unknown Machine") ;
|
||||
// eseguo la verifica di collisione (nessuna collisione -> true)
|
||||
int nCdInd = -1, nObjInd = -1 ;
|
||||
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimExecCollisionCheck( nCdInd, nObjInd)) ;
|
||||
// assegno risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
LuaSetParam( L, nCdInd) ;
|
||||
LuaSetParam( L, nObjInd) ;
|
||||
return 3 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
Machine::LuaEmtOnCollision( lua_State* L)
|
||||
{
|
||||
// Due parametri : nCdInd, nObjInd
|
||||
int nCdInd ;
|
||||
LuaCheckParam( L, 1, nCdInd)
|
||||
int nObjInd ;
|
||||
LuaCheckParam( L, 2, nObjInd)
|
||||
LuaClearStack( L) ;
|
||||
// verifico ci sia una macchina attiva
|
||||
if ( m_pMchLua == nullptr)
|
||||
return luaL_error( L, " Unknown Machine") ;
|
||||
// eseguo la verifica di collisione (nessuna collisione -> true)
|
||||
int nErr = 0 ;
|
||||
bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimOnCollision( nCdInd, nObjInd, nErr)) ;
|
||||
// assegno risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
LuaSetParam( L, nErr) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
+2
-2
@@ -38,6 +38,8 @@ class Simulator
|
||||
bool GetOperationInfo( std::string& sName, int& nType) const ;
|
||||
bool GetMoveInfo( int& nGmove, double& dFeed) const ;
|
||||
bool AddCollisionObj( int nInd, int nFrameId, int nType, double dPar1, double dPar2, double dPar3) ;
|
||||
bool ExecCollisionCheck( int& nCdInd, int& nObjInd) ;
|
||||
bool OnCollision( int nCdInd, int nObjInd, int& nErr) ;
|
||||
|
||||
private :
|
||||
bool UpdateTool( bool bFirst = false) ;
|
||||
@@ -62,7 +64,6 @@ class Simulator
|
||||
const Point3d& ptHf, const Vector3d& vtHf, const Vector3d& vtAf, const Frame3d& frVzmF) ;
|
||||
bool NeedCollisionCheck( void) const
|
||||
{ return ( ! m_CollObj.empty() && ! m_CdId.empty()) ; }
|
||||
bool ExecCollisionCheck( int& nCdInd, int& nObjInd) ;
|
||||
bool Stopped( void)
|
||||
{ return ( m_nUiStatus == MCH_UISIM_STOP) ; }
|
||||
bool OnStart( bool bFirst) ;
|
||||
@@ -85,7 +86,6 @@ class Simulator
|
||||
bool OnPathEnd( int nAE) ;
|
||||
bool OnMoveStart( const CamData* pCamData, int& nErr) ;
|
||||
bool OnMoveEnd( void) ;
|
||||
bool OnCollision( int nCdInd, int nObjInd, int& nErr) ;
|
||||
bool OnResetMachine( void) ;
|
||||
|
||||
private :
|
||||
|
||||
Reference in New Issue
Block a user