diff --git a/Disposition.cpp b/Disposition.cpp index 6d5aa92..5724dc4 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -471,6 +471,8 @@ Disposition::Apply( bool bVerifyTab) if ( ( ! m_bTabOk || bVerifyTab) && ! SetTable( m_sTabName)) return false ; bool bOk = true ; + // annullo movimento assi + m_pMchMgr->ResetAllAxesPos( false, true) ; // aggiornamento movimenti assi for ( auto& AxData : m_vAxData) { if ( ! m_pMchMgr->SetAxisPos( AxData.sName, AxData.dPos)) { diff --git a/MachMgr.h b/MachMgr.h index e756844..c564bd4 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -158,6 +158,7 @@ class MachMgr : public IMachMgr bool ShowOnlyTable( bool bVal) override ; bool MoveDispAxis( const std::string& sName, double dPos) override ; bool RemoveDispAxis( const std::string& sName) override ; + bool KeepAllDispAxes( int nSouPhase) override ; 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 ; @@ -481,6 +482,7 @@ class MachMgr : public IMachMgr int SimMoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt) ; bool SimSaveCmd( int nType, int nPar, const std::string& sPar, const std::string& sPar2) ; // Machine + bool ResetAllAxesPos( bool bStdAxes, bool bDispAxes) ; 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/MachMgrFixtures.cpp b/MachMgrFixtures.cpp index 51c943c..50ddf00 100644 --- a/MachMgrFixtures.cpp +++ b/MachMgrFixtures.cpp @@ -159,6 +159,28 @@ MachMgr::RemoveDispAxis( const string& sName) return pDisp->RemoveAxis( sName) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::KeepAllDispAxes( int nSouPhase) +{ + // se fase di origine non definita o uguale alla corrente, esco con successo + if ( nSouPhase == 0 || nSouPhase == m_nCurrPhase) + return true ; + // copio il posizionamento + Disposition* pSouDisp = GetDisposition( m_pGeomDB->GetUserObj( GetPhaseDisposition( nSouPhase))) ; + Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( GetPhaseDisposition( m_nCurrPhase))) ; + if ( pSouDisp == nullptr || pDisp == nullptr) + return false ; + for ( int i = 0 ; ; ++ i) { + string sName ; double dPos ; + if ( pSouDisp->GetMoveAxisData( i, sName, dPos)) + pDisp->MoveAxis( sName, dPos) ; + else + break ; + } + return true ; +} + //---------------------------------------------------------------------------- int MachMgr::AddFixture( const string& sName, const Point3d& ptPos, double dAngRotDeg, double dMov) @@ -182,8 +204,8 @@ MachMgr::KeepFixture( int nFxtId, int nSouPhase) // se fase corrente già presente, non devo fare alcunché if ( find( vPhase.begin(), vPhase.end(), m_nCurrPhase) != vPhase.end()) return true ; - // se fase di origine non definita, esco con successo - if ( nSouPhase == 0) + // se fase di origine non definita o uguale alla corrente, esco con successo + if ( nSouPhase == 0 || nSouPhase == m_nCurrPhase) return true ; // copio il posizionamento Disposition* pSouDisp = GetDisposition( m_pGeomDB->GetUserObj( GetPhaseDisposition( nSouPhase))) ; diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index 662c8df..2151456 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -410,36 +410,22 @@ 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)) ; + return ( ( pMch != nullptr) ? pMch->IsDispositionAxis( sAxis, sTable) : false) ; } //---------------------------------------------------------------------------- bool MachMgr::ResetAllAxesPos( void) +{ + return ResetAllAxesPos( true, false) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::ResetAllAxesPos( bool bStdAxes, bool bDispAxes) { Machine* pMch = GetCurrMachine() ; - return ( ( pMch != nullptr) ? pMch->ResetAllAxesPos() : false) ; + return ( ( pMch != nullptr) ? pMch->ResetAllAxesPos( bStdAxes, bDispAxes) : false) ; } //---------------------------------------------------------------------------- diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index a5d262f..8c99988 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -601,6 +601,7 @@ MachMgr::AddDisposition( const string& sName) m_pGeomDB->SetUserObj( nId, pDisp) ; pDisp->Init( this) ; pDisp->SetPhase( m_nCurrPhase) ; + ResetAllAxesPos( false, true) ; return nId ; } diff --git a/MachMgrRawParts.cpp b/MachMgrRawParts.cpp index 771bccc..cbe4c6e 100644 --- a/MachMgrRawParts.cpp +++ b/MachMgrRawParts.cpp @@ -737,8 +737,8 @@ MachMgr::KeepRawPart( int nRawId, int nSouPhase) return false ; if ( ! SwapRawPartParts( nRawId, true)) return false ; - // se fase di origine non definita, esco con successo - if ( nSouPhase == 0) + // se fase di origine non definita o uguale alla corrente, esco con successo + if ( nSouPhase == 0 || nSouPhase == m_nCurrPhase) return true ; // copio il posizionamento Disposition* pSouDisp = GetDisposition( m_pGeomDB->GetUserObj( GetPhaseDisposition( nSouPhase))) ; diff --git a/Machine.cpp b/Machine.cpp index f1d5e45..f361680 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -143,7 +143,7 @@ Machine::Init( const string& sMachineName, const string& sMachineDir, MachMgr* p // imposto stato di visualizzazione m_nMachineLook = ( bOk ? MCH_LOOK_ALL : MCH_LOOK_NONE) ; // metto tutti gli assi in posizione home - bOk = bOk && ResetAllAxesPos() ; + bOk = bOk && ResetAllAxesPos( true, true) ; // reset catena cinematica corrente m_nCalcChainType = KIN_CHAIN_NONE ; return bOk ; diff --git a/Machine.h b/Machine.h index 879eddf..214dbfa 100644 --- a/Machine.h +++ b/Machine.h @@ -104,8 +104,9 @@ class Machine bool GetAxisMin( const std::string& sAxis, double& dMin) const ; bool GetAxisMax( const std::string& sAxis, double& dMax) const ; bool GetAxisHomePos( const std::string& sAxis, double& dHomeVal) const ; + bool IsDispositionAxis( const std::string& sAxis, const std::string& sTable = "") const ; bool ResetAxisPos( const std::string& sAxis) ; - bool ResetAllAxesPos( void) ; + bool ResetAllAxesPos( bool bStdAxes, bool bDispAxes) ; bool SetCurrTable( const std::string& sTable) ; bool ResetCurrTable( void) ; int GetCurrTable( void) const ; diff --git a/MachineAxes.cpp b/MachineAxes.cpp index bdb1413..33327f6 100644 --- a/MachineAxes.cpp +++ b/MachineAxes.cpp @@ -224,6 +224,34 @@ Machine::GetAxisHomePos( const string& sAxis, double& dHomeVal) const return true ; } +//---------------------------------------------------------------------------- +bool +Machine::IsDispositionAxis( const string& sAxis, const string& sTable) const +{ + if ( m_pGeomDB == nullptr) + return false ; + // recupero Id asse + int nAxId = GetAxisId( sAxis) ; + if ( nAxId == GDB_ID_NULL) + return false ; + // recupero eventuale Id tavola + int nTabId = GDB_ID_NULL ; + if ( ! sTable.empty()) { + nTabId = 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) || IsTableGroup( nParentId)) + return true ; + // altrimenti deve dipendere da asse dipendente dalla tavola + if ( ! IsAxisGroup( nParentId)) + return false ; + int nGrParId = m_pGeomDB->GetParentId( nParentId) ; + return ( ( nTabId != GDB_ID_NULL && nGrParId == nTabId) || IsTableGroup( nGrParId)) ; +} + //---------------------------------------------------------------------------- bool Machine::ResetAxisPos( const string& sAxis) @@ -241,13 +269,17 @@ Machine::ResetAxisPos( const string& sAxis) //---------------------------------------------------------------------------- bool -Machine::ResetAllAxesPos( void) +Machine::ResetAllAxesPos( bool bStdAxes, bool bDispAxes) { // ciclo sui gruppi della macchina for ( auto Iter = m_mapGroups.cbegin() ; Iter != m_mapGroups.cend() ; ++ Iter) { if ( IsAxisGroup( Iter->second)) { - if ( ! ResetAxisPos( Iter->first)) - return false ; + if ( ( bStdAxes && bDispAxes) || + ( bStdAxes && ! IsDispositionAxis( Iter->first)) || + ( bDispAxes && IsDispositionAxis( Iter->first))) { + if ( ! ResetAxisPos( Iter->first)) + return false ; + } } } return true ; diff --git a/Operation.cpp b/Operation.cpp index 4dbcbef..18a6647 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -4016,7 +4016,7 @@ ResetMachine( Machine* pMch) if ( pMch == nullptr) return false ; // Riporto la macchina in home - pMch->ResetAllAxesPos() ; + pMch->ResetAllAxesPos( true, false) ; // Sgancio pezzi, grezzi e sottopezzi dalla tavola corrente pMch->UnlinkAllPartsFromGroups() ; pMch->UnlinkAllRawPartsFromGroups() ; @@ -4044,7 +4044,7 @@ Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEn return false ; // Porto la macchina in home - pMch->ResetAllAxesPos() ; + pMch->ResetAllAxesPos( true, false) ; // Elenco grezzi attivi INTVECTOR vRawId ; int nRawId = m_pMchMgr->GetFirstRawPart() ;