From eb313337e47896613ae5cd2ba040f472a6f4fc81 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 29 Oct 2016 15:47:22 +0000 Subject: [PATCH] EgtMachKernel : - aggiunta nuova VerifyFixture e vecchia rinominata VerifyFixtureInGroup. --- Disposition.cpp | 14 ++--- MachMgr.h | 3 +- MachMgrFixtures.cpp | 132 ++++++++++++++++++++++++-------------------- 3 files changed, 82 insertions(+), 67 deletions(-) diff --git a/Disposition.cpp b/Disposition.cpp index 0557c86..1d14577 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -498,7 +498,7 @@ Disposition::GetFirstFixture( void) // recupero il primo int nId = m_vFixData.front().nId ; // ne verifico la validità - if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixture( nId, false)) + if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixtureInGroup( nId, false)) return GDB_ID_NULL ; return nId ; } @@ -515,7 +515,7 @@ Disposition::GetNextFixture( int nId) // se esiste successivo e valido int j = i + 1 ; if ( j < nFxtTot && - m_pMchMgr != nullptr && m_pMchMgr->VerifyFixture( m_vFixData[j].nId, false)) + m_pMchMgr != nullptr && m_pMchMgr->VerifyFixtureInGroup( m_vFixData[j].nId, false)) return m_vFixData[j].nId ; else return GDB_ID_NULL ; @@ -529,7 +529,7 @@ bool Disposition::MoveFixture( int nId, const Vector3d& vtMove) { // verifica validità sottopezzo - if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixture( nId, false)) + if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixtureInGroup( nId, false)) return false ; // verifico aggiornamento tavola if ( ! m_bTabOk && ! SetTable( m_sTabName)) @@ -561,7 +561,7 @@ bool Disposition::RotateFixture( int nId, double dDeltaAngDeg) { // verifica validità sottopezzo - if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixture( nId, false)) + if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixtureInGroup( nId, false)) return false ; // verifico aggiornamento tavola if ( ! m_bTabOk && ! SetTable( m_sTabName)) @@ -583,7 +583,7 @@ bool Disposition::MoveFixtureMobile( int nId, double dDeltaMov) { // verifica validità sottopezzo - if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixture( nId, false)) + if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixtureInGroup( nId, false)) return false ; // verifico aggiornamento tavola if ( ! m_bTabOk && ! SetTable( m_sTabName)) @@ -613,7 +613,7 @@ bool Disposition::PlaceFixture( int nId, const Point3d& ptPos, double dAngDeg, double dMov) { // verifica validità sottopezzo - if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixture( nId, false)) + if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixtureInGroup( nId, false)) return false ; // verifico aggiornamento tavola if ( ! m_bTabOk && ! SetTable( m_sTabName)) @@ -664,7 +664,7 @@ bool Disposition::RemoveFixture( int nId) { // verifica validità sottopezzo - if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixture( nId, false)) + if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyFixtureInGroup( nId, false)) return false ; // verifico aggiornamento tavola if ( ! m_bTabOk && ! SetTable( m_sTabName)) diff --git a/MachMgr.h b/MachMgr.h index c567d3b..1ac86fd 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -126,6 +126,7 @@ class MachMgr : public IMachMgr int AddFixture( const std::string& sName, const Point3d& ptPos, double dAngRotDeg, double dMov) override ; bool KeepFixture( int nFxtId, int nSouPhase) override ; bool RemoveFixture( int nFxtId) override ; + bool VerifyFixture( int nFxtId) const override ; int GetFirstFixture( void) override ; int GetNextFixture( int nFxtId) override ; bool MoveFixture( int nId, const Vector3d& vtMove) override ; @@ -312,7 +313,7 @@ class MachMgr : public IMachMgr bool GetRawPartPhases( int nRawId, INTVECTOR& vPhase) const ; bool GetRawPartCenter( int nRawId, Point3d& ptCen) ; // Tables and Fixtures - bool VerifyFixture( int nFxtId, bool bLinkedAllowed = true) const ; + bool VerifyFixtureInGroup( int nFxtId, bool bLinkedAllowed = true) const ; bool GetFixturePhases( int nFxtId, INTVECTOR& vPhase) const ; int GetUnusedFixture( const string& sName, int nPhase) ; // Machines diff --git a/MachMgrFixtures.cpp b/MachMgrFixtures.cpp index 83907bd..8e74d64 100644 --- a/MachMgrFixtures.cpp +++ b/MachMgrFixtures.cpp @@ -91,65 +91,6 @@ MachMgr::ShowOnlyTable( bool bVal) return pMch->SetLook( bVal ? MCH_LOOK_TAB : MCH_LOOK_ALL) ; } -//---------------------------------------------------------------------------- -bool -MachMgr::VerifyFixture( int nFxtId, bool bLinkedAllowed) const -{ - // se il bloccaggio fa parte del gruppo dei bloccaggi, va bene - int nFxtGroupId = GetCurrFixtGroupId() ; - if ( nFxtGroupId != GDB_ID_NULL && m_pGeomDB->GetParentId( nFxtId) == nFxtGroupId) - return true ; - // se consentito linkaggio ed il bloccaggio è linkato ad un gruppo della macchina corrente, va bene - if ( bLinkedAllowed) { - Machine* pMch = GetCurrMachine() ; - if ( pMch != nullptr && pMch->IsLinkedFixture( nFxtId)) - return true ; - } - // altrimenti errore - return false ; -} - -//---------------------------------------------------------------------------- -bool -MachMgr::GetFixturePhases( int nFxtId, INTVECTOR& vPhase) const -{ - // pulisco parametro di ritorno - vPhase.clear() ; - // verifica validità bloccaggio - if ( ! VerifyFixture( nFxtId)) - return false ; - // recupero le fasi in cui è presente la fixture (se manca è fase 1) - if ( ! m_pGeomDB->GetInfo( nFxtId, MACH_FXT_PHASE, vPhase) || vPhase.empty()) - vPhase.emplace_back( 1) ; - return true ; -} - -//---------------------------------------------------------------------------- -int -MachMgr::GetUnusedFixture( const string& sName, int nPhase) -{ - // Verifico validità nome - if ( IsEmptyOrSpaces( sName)) - return false ; - // Recupero il gruppo dei bloccaggi - int nFxtGroupId = GetCurrFixtGroupId() ; - // Cerco i bloccaggi non usati nella fase indicata - int nId = m_pGeomDB->GetFirstNameInGroup( nFxtGroupId, sName) ; - while ( nId != GDB_ID_NULL) { - // recupero le fasi in cui è già usato - INTVECTOR vPhase ; - if ( ! m_pGeomDB->GetInfo( nId, MACH_FXT_PHASE, vPhase) || vPhase.empty()) - vPhase.emplace_back( 1) ; - // se non c'è la fase corrente, è libero - if ( find( vPhase.begin(), vPhase.end(), nPhase) == vPhase.end()) - return nId ; - // passo al successivo - nId = m_pGeomDB->GetNextName( nId, sName) ; - } - // non trovato - return GDB_ID_NULL ; -} - //---------------------------------------------------------------------------- int MachMgr::AddFixture( const string& sName, const Point3d& ptPos, double dAngRotDeg, double dMov) @@ -207,6 +148,20 @@ MachMgr::RemoveFixture( int nFxtId) return pDisp->RemoveFixture( nFxtId) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::VerifyFixture( int nFxtId) const +{ + // verifica validità bloccaggio + if ( ! VerifyFixtureInGroup( nFxtId, false)) + return false ; + // recupero fasi in cui è presente + INTVECTOR vPhase ; + if ( ! GetFixturePhases( nFxtId, vPhase)) + return false ; + return ( find( vPhase.begin(), vPhase.end(), m_nCurrPhase) != vPhase.end()) ; +} + //---------------------------------------------------------------------------- int MachMgr::GetFirstFixture( void) @@ -266,3 +221,62 @@ MachMgr::MoveFixtureMobile( int nId, double dDeltaMov) // eseguo l'operazione return pDisp->MoveFixtureMobile( nId, dDeltaMov) ; } + +//---------------------------------------------------------------------------- +bool +MachMgr::VerifyFixtureInGroup( int nFxtId, bool bLinkedAllowed) const +{ + // se il bloccaggio fa parte del gruppo dei bloccaggi, va bene + int nFxtGroupId = GetCurrFixtGroupId() ; + if ( nFxtGroupId != GDB_ID_NULL && m_pGeomDB->GetParentId( nFxtId) == nFxtGroupId) + return true ; + // se consentito linkaggio ed il bloccaggio è linkato ad un gruppo della macchina corrente, va bene + if ( bLinkedAllowed) { + Machine* pMch = GetCurrMachine() ; + if ( pMch != nullptr && pMch->IsLinkedFixture( nFxtId)) + return true ; + } + // altrimenti errore + return false ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::GetFixturePhases( int nFxtId, INTVECTOR& vPhase) const +{ + // pulisco parametro di ritorno + vPhase.clear() ; + // verifica validità bloccaggio + if ( ! VerifyFixtureInGroup( nFxtId)) + return false ; + // recupero le fasi in cui è presente la fixture (se manca è fase 1) + if ( ! m_pGeomDB->GetInfo( nFxtId, MACH_FXT_PHASE, vPhase) || vPhase.empty()) + vPhase.emplace_back( 1) ; + return true ; +} + +//---------------------------------------------------------------------------- +int +MachMgr::GetUnusedFixture( const string& sName, int nPhase) +{ + // Verifico validità nome + if ( IsEmptyOrSpaces( sName)) + return false ; + // Recupero il gruppo dei bloccaggi + int nFxtGroupId = GetCurrFixtGroupId() ; + // Cerco i bloccaggi non usati nella fase indicata + int nId = m_pGeomDB->GetFirstNameInGroup( nFxtGroupId, sName) ; + while ( nId != GDB_ID_NULL) { + // recupero le fasi in cui è già usato + INTVECTOR vPhase ; + if ( ! m_pGeomDB->GetInfo( nId, MACH_FXT_PHASE, vPhase) || vPhase.empty()) + vPhase.emplace_back( 1) ; + // se non c'è la fase corrente, è libero + if ( find( vPhase.begin(), vPhase.end(), nPhase) == vPhase.end()) + return nId ; + // passo al successivo + nId = m_pGeomDB->GetNextName( nId, sName) ; + } + // non trovato + return GDB_ID_NULL ; +}