diff --git a/Drilling.cpp b/Drilling.cpp index 90cbce0..88c016f 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -616,6 +616,12 @@ Drilling::Apply( bool bRecalc, bool bPostApply) nDblId = GDB_ID_NULL ; } + // rendo corrente l'utensile usato nella lavorazione + if ( ! m_pMchMgr->SetCalcTool( m_TParams.m_sName, m_TParams.m_sHead, m_TParams.m_nExit)) { + m_pMchMgr->SetLastError( 2322, "Error in Milling : Tool loading failed") ; + return false ; + } + // se lavorazione standard if ( m_Params.m_nSubType == DRI_SUB_STD) { if ( ! StandardProcess( bRecalc, GDB_ID_NULL, nClId)) @@ -721,19 +727,19 @@ Drilling::StandardProcess( bool bRecalc, int nPvId, int nClId) if ( ! m_pMchMgr->GetCurrMachine()->GetCurrHead( sCurrHead)) return false ; int nExitCnt = m_pMchMgr->GetCurrMachine()->GetHeadExitCount( sCurrHead) ; - TABMHDRILL tabDrills ; - double dMHOff = 0 ; - // se ho più uscite... - if ( nExitCnt > 1) { + bool bAggrBottom = IsAggrBottom( sCurrHead) ; + // se ho più uscite e non è aggregato da sotto ... + if ( nExitCnt > 1 && ! bAggrBottom) { + TABMHDRILL tabDrills ; + double dMHOff = 0 ; if ( ! MultiHeadDrilling( nExitCnt, m_vId, nClId, tabDrills, dMHOff)) return false ; - if( tabDrills.size() == 0) + if ( tabDrills.empty()) return true ; - int j = 0 ; for ( int i = 0 ; i < ( int)tabDrills.size() ; ++i) { // se richiesto preview if ( nPvId != GDB_ID_NULL) { - if ( ! GenerateHolePv( j, m_vId[tabDrills[i][0].nInd_id_hole], MCH_PATH, nClId)) + if ( ! GenerateHolePv( i, m_vId[tabDrills[i][0].nInd_id_hole], MCH_PATH, nClId)) return false ; // creo la regione di ingombro del foro int nDriId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetLastGroupInGroup( nPvId)) ; @@ -741,17 +747,15 @@ Drilling::StandardProcess( bool bRecalc, int nPvId, int nClId) } // se richiesta lavorazione if ( nClId != GDB_ID_NULL) { - if ( ! GenerateHoleCl( j, m_vId[tabDrills[i][0].nInd_id_hole], MCH_PATH, nClId, dMHOff, tabDrills[i][0].vtAux)) + if ( ! GenerateHoleCl( i, m_vId[tabDrills[i][0].nInd_id_hole], MCH_PATH, nClId, dMHOff, tabDrills[i][0].vtAux)) return false ; } - // incremento indice - ++j ; } return true ; } // ... altrimenti elaboro i singoli fori - int i = 0 ; - for ( const auto& vId : m_vId) { + for ( int i = 0 ; i < int( m_vId.size()) ; ++ i) { + const auto& vId = m_vId[i] ; // se richiesto preview if ( nPvId != GDB_ID_NULL) { if ( ! GenerateHolePv( i, vId, MCH_PATH, nPvId)) @@ -765,8 +769,6 @@ Drilling::StandardProcess( bool bRecalc, int nPvId, int nClId) if ( ! GenerateHoleCl( i, vId, MCH_PATH, nClId)) return false ; } - // incremento indice - ++i ; } return true ; @@ -816,9 +818,21 @@ Drilling::MultiHeadDrilling( int nExitCnt, const SELVECTOR& vId, int nClId, TABM return false ; } - // carico i dati della testa con le sue uscite + // recupero i dati dell'uscita dell'utensile principale Vector3d vtTool, vtAux ; + Point3d ptExit ; + m_pMchMgr->GetCurrMachine()->GetHeadExitPosDirAux( sHead, nMainToolInd + 1, ptExit, vtTool, vtAux) ; + vTools[nMainToolInd].ptToolTip = ptExit - vtTool * vTools[nMainToolInd].pTool->m_dLen ; + if ( vtTool.IsSmall() || vtAux.IsSmall()) { + m_pMchMgr->SetLastError( 2117, "Error in Drilling : incorrect multi drilling head") ; + return false ; + } + + // carico gli altri dati della testa con le sue uscite for ( int nT = 0 ; nT < nExitCnt ; ++ nT) { + // se utensile principale, salto al successivo + if ( nT == nMainToolInd) + continue ; // se non attrezzato, salto al successivo if ( vTools[nT].pTool == nullptr) continue ; @@ -826,26 +840,14 @@ Drilling::MultiHeadDrilling( int nExitCnt, const SELVECTOR& vId, int nClId, TABM Point3d ptExit ; Vector3d vtCurrDir, vtCurrAux ; m_pMchMgr->GetCurrMachine()->GetHeadExitPosDirAux( sHead, nT + 1, ptExit, vtCurrDir, vtCurrAux) ; - // se utensile successivo - if ( ! vtTool.IsSmall()) { - // controllo abbia la stessa direzione dei precedenti, altrimenti errore - if ( ! AreSameVectorApprox( vtCurrDir, vtTool)) { - vtTool = V_NULL ; - break ; - } - } - // altrimenti primo utensile - else { - vtTool = vtCurrDir ; - vtAux = vtCurrAux ; + // controllo abbia la stessa direzione del principale, altrimenti disattrezzo + if ( ! AreSameVectorApprox( vtCurrDir, vtTool)) { + vTools[nT].pTool = nullptr ; + continue ; } // assegno tip utensile vTools[nT].ptToolTip = ptExit - vtCurrDir * vTools[nT].pTool->m_dLen ; } - if ( vtTool.IsSmall() || vtAux.IsSmall()) { - m_pMchMgr->SetLastError( 2117, "Error in Drilling : incorrect multi drilling head") ; - return false ; - } // Recupero le geometrie dei fori bool bSomeHoleOk = false ; @@ -886,7 +888,7 @@ Drilling::MultiHeadDrilling( int nExitCnt, const SELVECTOR& vId, int nClId, TABM // i fori con dimensione 0 del vettore vToolHole non possono essere lavorati int nNoDrillHoles = 0 ; for ( int i = 0 ; i < ( int)vHoles.size() ; ++ i) { - if ( vHoles[i].vToolHole.size() == 0) + if ( vHoles[i].vToolHole.empty()) ++ nNoDrillHoles ; } @@ -897,10 +899,19 @@ Drilling::MultiHeadDrilling( int nExitCnt, const SELVECTOR& vId, int nClId, TABM // numero di fori lavorati int nOkHole = 0 ; + // se c'è un solo foro va sicuramente bene + if ( vHoles.size() == 1 && ! vHoles[0].vVtAux.empty()) { + vHoles[0].bForToolM = true ; + vHoles[0].nIndTool = nMainToolInd ; + vHoles[0].nIndHoleToolM = 0 ; + vHoles[0].vtAux = vHoles[0].vVtAux[0] ; + } + // decido in quali fori inserire il tool principale for ( int nCheck = 1 ; nCheck < ( int)vHoles.size() && nOkHole < ( int)vHoles.size() - nNoDrillHoles ; ++ nCheck) { for ( int i = 0 ; i < ( int)vHoles.size() ; ++i) { - if ( vHoles[i].vToolHole.size() == nCheck && ! vHoles[i].bDrill) { // prendo tutti i fori con vToolHope di lunghezza nCheck non già svuotati + // prendo tutti i fori con vToolHope di lunghezza nCheck non già lavorati + if ( vHoles[i].vToolHole.size() == nCheck && ! vHoles[i].bDrill) { vHoles[vHoles[i].vToolHole[0]].bForToolM = true ; vHoles[vHoles[i].vToolHole[0]].nIndTool = nMainToolInd ; vHoles[vHoles[i].vToolHole[0]].nIndHoleToolM = vHoles[i].vToolHole[0] ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 7ae9c2f..a9594c9 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Operation.cpp b/Operation.cpp index 34b6502..a1f92df 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -3648,4 +3648,20 @@ Operation::GetAggrBottomData( const string& sHead, AggrBottom& agbData) const m_pGeomDB->GetInfo( nHeadId, MCH_AGB_ENCV, agbData.dEncV) ; m_pGeomDB->GetInfo( nHeadId, MCH_AGB_MDIR, agbData.vtMDir) ; return true ; -} \ No newline at end of file +} + +//---------------------------------------------------------------------------- +bool +Operation::IsAggrBottom( const string& sHead) const +{ + // verifiche + if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) + return false ; + // recupero identificativo della testa + int nHeadId = m_pMchMgr->GetHeadId( sHead) ; + if ( nHeadId == GDB_ID_NULL) + return false ; + // recupero info se aggregato + int nAggrBott = 0 ; + return ( m_pGeomDB->GetInfo( nHeadId, MCH_AGB_TYPE, nAggrBott) && nAggrBott != 0) ; +} diff --git a/Operation.h b/Operation.h index 2fa7c4d..282f161 100644 --- a/Operation.h +++ b/Operation.h @@ -157,6 +157,7 @@ class Operation : public IUserObj bool SpecialMoveRapid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, DBLVECTOR& vAxNew, bool& bModif) ; bool GetAggrBottomData( const std::string& sHead, AggrBottom& agbData) const ; + bool IsAggrBottom( const std::string& sHead) const ; protected : int m_nOwnerId ; // identificativo dell'oggetto geometrico possessore diff --git a/Simulator.cpp b/Simulator.cpp index ca9762d..c1558aa 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -175,6 +175,19 @@ Simulator::Start( bool bFirst) int nStatus ; if ( ! FindAndManageOperationStart( true, bFirst, nStatus) && nStatus != MCH_SIM_STOP) bOk = false ; + // se sono ancora su disposizione + if ( m_pMchMgr->GetOperationType( m_nOpId) == OPER_DISP) { + // ricerca e gestione inizio percorso di lavoro + if ( ! FindAndManagePathStart( nStatus)) + return false ; + // eventuali comandi ausiliari di inizio percorso + while ( m_nAuxSInd < m_nAuxSTot) { + if ( ! ManagePathStartAux( nStatus)) + return false ; + } + // aggiornamento assi per eventuali teste caricate + UpdateAxes() ; + } // Reset timer if ( m_pPerfCnt != nullptr) @@ -833,8 +846,9 @@ Simulator::FindAndManagePathStart( int& nStatus) } // se altrimenti trovato nuovo CL path vuoto else if ( m_nCLPathId != GDB_ID_NULL) { - // non ci possono essere eventi ausiliari di inizio - m_nAuxSTot = 0 ; + // recupero il numero di eventi ausiliari di inizio + if ( ! m_pGeomDB->GetInfo( m_nCLPathId, KEY_AS_TOT, m_nAuxSTot)) + m_nAuxSTot = 0 ; m_nAuxSInd = 0 ; // recupero il numero di eventi ausiliari di fine if ( ! m_pGeomDB->GetInfo( m_nCLPathId, KEY_AE_TOT, m_nAuxETot))