From ab63e1908ccc49279a48a02fd60c5f5a03efd846 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 16 Oct 2024 17:11:50 +0200 Subject: [PATCH] EgtMachKernel : - aggiunto controllo che gli assi mossi in Disposition siano assi dipendenti dalla tavola (MachMgr::IsDispositionAxis). --- Disposition.cpp | 8 ++++---- MachMgr.h | 2 +- MachMgrMachines.cpp | 29 +++++++++++++++++++++++++++++ Machine.h | 26 +++++++++++++------------- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/Disposition.cpp b/Disposition.cpp index dd519c6..6d5aa92 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -574,8 +574,8 @@ Disposition::MoveAxis( const string& sName, double dPos) // verifico tavola if ( ! m_bTabOk && ! SetTable( m_sTabName)) return false ; - // verifico esistenza asse - if ( m_pMchMgr->GetAxisId( sName) == GDB_ID_NULL) + // verifico sia un asse di disposizione (ovvero dipendente dalla tavola) + if ( ! m_pMchMgr->IsDispositionAxis( sName, m_sTabName)) return false ; // cerco eventuale movimento dello stesso asse già inserito int nInd = -1 ; @@ -607,8 +607,8 @@ Disposition::RemoveAxis( const string& sName) // verifico tavola if ( ! m_bTabOk && ! SetTable( m_sTabName)) return false ; - // verifico esistenza asse - if ( m_pMchMgr->GetAxisId( sName) == GDB_ID_NULL) + // verifico sia un asse di disposizione (ovvero dipendente dalla tavola) + if ( ! m_pMchMgr->IsDispositionAxis( sName, m_sTabName)) return false ; // cerco eventuale movimento dello stesso asse già inserito int nInd = -1 ; diff --git a/MachMgr.h b/MachMgr.h index 36cf665..e756844 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -480,8 +480,8 @@ class MachMgr : public IMachMgr bool SimEnableToolsForVmill( bool bEnable) ; int SimMoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) ; bool SimSaveCmd( int nType, int nPar, const std::string& sPar, const std::string& sPar2) ; - // Machine + bool IsDispositionAxis( const std::string& sAxis, const std::string& sTable = "") const ; bool GetHeadAbove( const std::string& sHead) const ; double GetAngDeltaMinForHome( void) const ; diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index 6663561..662c8df 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -405,6 +405,35 @@ MachMgr::ResetAxisPos( const string& sAxis) return ( ( pMch != nullptr) ? pMch->ResetAxisPos( sAxis) : false) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::IsDispositionAxis( const string& sAxis, const string& sTable) const +{ + Machine* pMch = GetCurrMachine() ; + if ( m_pGeomDB == nullptr || pMch == nullptr) + return false ; + // recupero Id asse + int nAxId = pMch->GetAxisId( sAxis) ; + if ( nAxId == GDB_ID_NULL) + return false ; + // recupero eventuale Id tavola + int nTabId = GDB_ID_NULL ; + if ( ! sTable.empty()) { + nTabId = pMch->GetTableId( sTable) ; + if ( nTabId == GDB_ID_NULL) + return false ; + } + // se direttamente dipendente dalla tavola + int nParentId = m_pGeomDB->GetParentId( nAxId) ; + if ( ( nTabId != GDB_ID_NULL && nParentId == nTabId) || pMch->IsTableGroup( nParentId)) + return true ; + // altrimenti deve dipendere da asse dipendente dalla tavola + if ( ! pMch->IsAxisGroup( nParentId)) + return false ; + int nGrParId = m_pGeomDB->GetParentId( nParentId) ; + return ( ( nTabId != GDB_ID_NULL && nGrParId == nTabId) || pMch->IsTableGroup( nGrParId)) ; +} + //---------------------------------------------------------------------------- bool MachMgr::ResetAllAxesPos( void) diff --git a/Machine.h b/Machine.h index 25eb8fa..879eddf 100644 --- a/Machine.h +++ b/Machine.h @@ -60,6 +60,19 @@ class Machine int GetTcPosId( const std::string& sTcPos) const { int nId = GetGroup( sTcPos) ; return ( IsTcPosGroup( nId) ? nId : GDB_ID_NULL) ; } + bool IsBaseGroup( int nGroup) const ; + bool IsAxisGroup( int nGroup) const + { return ( GetAxis( nGroup) != nullptr) ; } + bool IsLinearAxisGroup( int nGroup) const ; + bool IsRotaryAxisGroup( int nGroup) const ; + bool IsTableGroup( int nGroup) const + { return ( GetTable( nGroup) != nullptr) ; } + bool IsHeadGroup( int nGroup) const + { return ( GetHead( nGroup) != nullptr) ; } + bool IsTcPosGroup( int nGroup) const + { return ( GetTcPos( nGroup) != nullptr) ; } + bool IsExitGroup( int nGroup) const + { return ( GetExit( nGroup) != nullptr) ; } bool GetAllTablesNames( STRVECTOR& vNames) const ; bool GetAllAxesNames( STRVECTOR& vNames) const ; bool GetAllHeadsNames( STRVECTOR& vNames) const ; @@ -233,24 +246,11 @@ class Machine const MUEXITVECTOR& vMuExit, const Vector3d& vtADir, const std::string& sGeo, const STRVECTOR& vsAux) ; int GetGroup( const std::string& sGroup) const ; - bool IsBaseGroup( int nGroup) const ; Axis* GetAxis( int nGroup) const ; - bool IsAxisGroup( int nGroup) const - { return ( GetAxis( nGroup) != nullptr) ; } - bool IsLinearAxisGroup( int nGroup) const ; - bool IsRotaryAxisGroup( int nGroup) const ; Table* GetTable( int nGroup) const ; - bool IsTableGroup( int nGroup) const - { return ( GetTable( nGroup) != nullptr) ; } Head* GetHead( int nGroup) const ; - bool IsHeadGroup( int nGroup) const - { return ( GetHead( nGroup) != nullptr) ; } TcPos* GetTcPos( int nGroup) const ; - bool IsTcPosGroup( int nGroup) const - { return ( GetTcPos( nGroup) != nullptr) ; } Exit* GetExit( int nGroup) const ; - bool IsExitGroup( int nGroup) const - { return ( GetExit( nGroup) != nullptr) ; } bool AddHeadToSet( const std::string& sHSet, const std::string& sName) ; const STRVECTOR& GetHSet( const std::string& sHead) const ; bool EnableHeadInSet( const std::string& sHead) ;