From b2dacc0cefa0e53ecb7f362f348cc05f218db46d Mon Sep 17 00:00:00 2001 From: DarioS Date: Wed, 18 Jan 2023 08:43:12 +0100 Subject: [PATCH] =?UTF-8?q?EgtMachKernel=20:=20-=20aggiunto=20flag=20bTool?= =?UTF-8?q?On=20a=20EmtAddCollisionObjEx=20per=20dichiarare=20che=20=C3=A8?= =?UTF-8?q?=20utensile=20in=20lavoro=20(necessario=20quando=20si=20usano?= =?UTF-8?q?=20pi=C3=B9=20utensili=20contemporaneamente).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MachMgr.h | 2 +- MachMgrSimulation.cpp | 4 ++-- MachineLua.cpp | 8 +++++--- Simulator.cpp | 8 ++++---- Simulator.h | 9 +++++---- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/MachMgr.h b/MachMgr.h index 0a8e69f..45469e3 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -452,7 +452,7 @@ class MachMgr : public IMachMgr bool GetOperationNewName( std::string& sName) const ; const ToolData* GetMachiningToolData( void) const ; // Simulation - bool SimAddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ; + bool SimAddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ; bool SimExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ; bool SimOnCollision( int nCdInd, int nObjInd, int& nErr) ; bool SimSetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst) ; diff --git a/MachMgrSimulation.cpp b/MachMgrSimulation.cpp index b77fc69..d2b75b1 100644 --- a/MachMgrSimulation.cpp +++ b/MachMgrSimulation.cpp @@ -150,13 +150,13 @@ MachMgr::SimExit( void) //---------------------------------------------------------------------------- bool -MachMgr::SimAddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) +MachMgr::SimAddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) { // verifico simulatore if ( m_pSimul == nullptr) return false ; // aggiungo un oggetto da verificare per la collisione con il grezzo - return m_pSimul->AddCollisionObj( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ; + return m_pSimul->AddCollisionObj( nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ; } //---------------------------------------------------------------------------- diff --git a/MachineLua.cpp b/MachineLua.cpp index 512298c..886c719 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -1262,7 +1262,7 @@ Machine::LuaEmtAddCollisionObj( lua_State* L) if ( m_pMchLua == nullptr) return luaL_error( L, " Unknown Machine") ; // assegno i dati - bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, nFrameId, nType, Vector3d(), dPar1, dPar2, dPar3)) ; + bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, false, nFrameId, nType, Vector3d(), dPar1, dPar2, dPar3)) ; // assegno risultato LuaSetParam( L, bOk) ; return 1 ; @@ -1272,7 +1272,7 @@ Machine::LuaEmtAddCollisionObj( lua_State* L) int Machine::LuaEmtAddCollisionObjEx( lua_State* L) { - // 7 parametri : nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3 + // 7 o 8 parametri : nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3 [,bToolOn] int nInd ; LuaCheckParam( L, 1, nInd) int nFrameId ; @@ -1287,12 +1287,14 @@ Machine::LuaEmtAddCollisionObjEx( lua_State* L) LuaCheckParam( L, 6, dPar2) double dPar3 ; LuaCheckParam( L, 7, dPar3) + bool bToolOn = false ; + LuaGetParam( L, 8, bToolOn) ; LuaClearStack( L) ; // verifico ci sia una macchina attiva if ( m_pMchLua == nullptr) return luaL_error( L, " Unknown Machine") ; // assegno i dati - bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3)) ; + bool bOk = ( m_pMchLua->m_pMchMgr != nullptr && m_pMchLua->m_pMchMgr->SimAddCollisionObj( nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3)) ; // assegno risultato LuaSetParam( L, bOk) ; return 1 ; diff --git a/Simulator.cpp b/Simulator.cpp index 746b56c..31211e0 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -1319,8 +1319,8 @@ Simulator::ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) // verifico se è l'utensile attivo string sHead ; m_pGeomDB->GetName( m_pGeomDB->GetParentId( m_CollObj[j].nFrameId), sHead) ; string sExit ; m_pGeomDB->GetName( m_CollObj[j].nFrameId, sExit) ; - bool bIsTool = ( sHead == m_sHead && - ( sExit == string( "_T") + ToString( m_nExit) || sExit == string( "_TT") + ToString( m_nExit))) ; + bool bIsTool = m_CollObj[j].bToolOn || + ( sHead == m_sHead && ( sExit == "_T" + ToString( m_nExit) || sExit == "_TT" + ToString( m_nExit))) ; // se utensile attivo su grezzo in lavoro e non è rapido, salto if ( bIsTool && bIsRaw && nMoveType != 0) continue ; @@ -1922,7 +1922,7 @@ Simulator::OnResetMachine( void) //---------------------------------------------------------------------------- bool -Simulator::AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) +Simulator::AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) { // verifiche sui parametri if ( nInd <= 0 || nFrameId <= GDB_ID_NULL) @@ -1948,7 +1948,7 @@ Simulator::AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& v return false ; } // aggiungo al vettore - m_CollObj.emplace_back( nInd, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ; + m_CollObj.emplace_back( nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ; return true ; } diff --git a/Simulator.h b/Simulator.h index 86edcd8..21808d5 100644 --- a/Simulator.h +++ b/Simulator.h @@ -53,7 +53,7 @@ class Simulator bool GetToolInfo( std::string& sName, double& dSpeed) const ; bool GetOperationInfo( std::string& sName, int& nType) const ; bool GetMoveInfo( int& nGmove, double& dFeed) const ; - bool AddCollisionObj( int nInd, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ; + bool AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3) ; bool ExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType) ; bool OnCollision( int nCdInd, int nObjInd, int& nErr) ; bool SetToolForVmill( const std::string& sTool, const std::string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst) ; @@ -111,15 +111,16 @@ class Simulator private : struct CollObj { int nInd ; + bool bToolOn ; int nFrameId ; int nType ; Vector3d vtMove ; double dPar1 ; double dPar2 ; double dPar3 ; - CollObj( void) : nInd( 0), nFrameId( -1), nType( 0), vtMove(), dPar1( 0), dPar2( 0), dPar3( 0) {} - CollObj( int nI, int nF, int nT, const Vector3d& vtM, double dP1, double dP2, double dP3) - : nInd( nI), nFrameId( nF), nType( nT), vtMove( vtM), dPar1( dP1), dPar2( dP2), dPar3( dP3) {} + CollObj( void) : nInd( 0), bToolOn( false), nFrameId( -1), nType( 0), vtMove(), dPar1( 0), dPar2( 0), dPar3( 0) {} + CollObj( int nI, bool bTOn, int nF, int nT, const Vector3d& vtM, double dP1, double dP2, double dP3) + : nInd( nI), bToolOn( bTOn), nFrameId( nF), nType( nT), vtMove( vtM), dPar1( dP1), dPar2( dP2), dPar3( dP3) {} } ; typedef std::vector COBVECTOR ; struct VmTool