diff --git a/EgtMachKernel.sln b/EgtMachKernel.sln index 1171052..b0c916a 100644 --- a/EgtMachKernel.sln +++ b/EgtMachKernel.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.12.35527.113 d17.12 +VisualStudioVersion = 17.12.35527.113 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EgtMachKernel", "EgtMachKernel.vcxproj", "{0BD58222-92F3-48B2-B656-4497D1956874}" EndProject diff --git a/MachConst.h b/MachConst.h index c8ed6c5..7170113 100644 --- a/MachConst.h +++ b/MachConst.h @@ -143,6 +143,7 @@ const double MAX_ANG_CEN = 150.001 ; //---------------------------------------------------------------------------- // Tolleranza su elevazione per attacchi e uscite const double LIO_ELEV_TOL = 2.0 ; +const double LIO_ELEV_FLOAT = 10.0 ; //---------------------------------------------------------------------------- // Per FlatParts (vedi Nesting di EgtExecutor) diff --git a/Machine.h b/Machine.h index dccf2c2..da86b7a 100644 --- a/Machine.h +++ b/Machine.h @@ -127,6 +127,7 @@ class Machine int GetCurrExit( void) const ; bool GetCurrExit( int& nExit) const ; bool GetCurrHeadCollGroups( INTVECTOR& vIds) const ; + bool IsCurrToolFloating( void) const ; double GetCurrRot1W( void) const { return m_dCalcRot1W ; } bool GetCurrMaxDeltaR2OnFirst( void) const diff --git a/MachineCalc.cpp b/MachineCalc.cpp index d5f2791..d0e70ea 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -479,6 +479,18 @@ Machine::GetCurrHeadCollGroups( INTVECTOR& vIds) const return true ; } +//---------------------------------------------------------------------------- +bool +Machine::IsCurrToolFloating( void) const +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return false ; + // leggo info con tipo + string sType ; + return ( m_pGeomDB->GetInfo( m_nCalcToolId, TTH_TYPE, sType) && sType == TTH_TYPE_FLOAT) ; +} + //---------------------------------------------------------------------------- bool Machine::ClearKinematicChain( void) diff --git a/MachineHeads.cpp b/MachineHeads.cpp index edcc83b..dffb89c 100644 --- a/MachineHeads.cpp +++ b/MachineHeads.cpp @@ -182,7 +182,7 @@ Machine::LoadTool( Exit* pExit, const string& sTool) if ( nSolidId == GDB_ID_NULL) return false ; // sposto eventuali info relative al porta utensile (ToolHolder) nel gruppo SOLID - double dVal ; + double dVal ; string sVal ; if ( m_pGeomDB->GetInfo( nTGrpId, TTH_BASE, dVal)) m_pGeomDB->SetInfo( nSolidId, TTH_BASE, dVal) ; if ( m_pGeomDB->GetInfo( nTGrpId, TTH_LEN, dVal)) @@ -191,6 +191,8 @@ Machine::LoadTool( Exit* pExit, const string& sTool) m_pGeomDB->SetInfo( nSolidId, TTH_DIAM, dVal) ; if ( m_pGeomDB->GetInfo( nTGrpId, TTH_STEM_DIAM, dVal)) m_pGeomDB->SetInfo( nSolidId, TTH_STEM_DIAM, dVal) ; + if ( m_pGeomDB->GetInfo( nTGrpId, TTH_TYPE, sVal)) + m_pGeomDB->SetInfo( nSolidId, TTH_TYPE, sVal) ; // sposto il gruppo SOLID nell'uscita ed elimino la sua vecchia base m_pGeomDB->RelocateGlob( nSolidId, nExGrp, GDB_FIRST_SON) ; m_pGeomDB->Erase( nTGrpId) ; diff --git a/Milling.cpp b/Milling.cpp index 9f401af..91a4fe9 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -118,6 +118,7 @@ Milling::Clone( void) const pMill->m_dTHoldBase = m_dTHoldBase ; pMill->m_dTHoldLen = m_dTHoldLen ; pMill->m_dTHoldDiam = m_dTHoldDiam ; + pMill->m_bTHoldFloating = m_bTHoldFloating ; pMill->m_nStatus = m_nStatus ; pMill->m_nMills = m_nMills ; pMill->m_bStepOn = m_bStepOn ; @@ -245,6 +246,7 @@ Milling::Milling( void) m_dTHoldBase = 0 ; m_dTHoldLen = 0 ; m_dTHoldDiam = 0 ; + m_bTHoldFloating = false ; m_nStatus = MCH_ST_TO_VERIFY ; m_nMills = 0 ; m_bStepOn = false ; @@ -671,6 +673,7 @@ Milling::Preview( bool bRecalc) m_pGeomDB->GetInfo( nToolId, TTH_LEN, m_dTHoldLen) ; m_dTHoldDiam = 0 ; m_pGeomDB->GetInfo( nToolId, TTH_DIAM, m_dTHoldDiam) ; + m_bTHoldFloating = m_pMchMgr->GetCurrMachine()->IsCurrToolFloating() ; // se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria if ( bChain && ! Chain( nAuxId)) { @@ -786,6 +789,7 @@ Milling::Apply( bool bRecalc, bool bPostApply) m_pGeomDB->GetInfo( nToolId, TTH_LEN, m_dTHoldLen) ; m_dTHoldDiam = 0 ; m_pGeomDB->GetInfo( nToolId, TTH_DIAM, m_dTHoldDiam) ; + m_bTHoldFloating = m_pMchMgr->GetCurrMachine()->IsCurrToolFloating() ; // recupero gruppo per geometria di lavorazione (Cutter Location) int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ; @@ -1841,7 +1845,9 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) // verifico che lo step dell'utensile sia sensato double dOkStep = 0 ; bool bStepUp = false ; - if ( m_Params.m_dStep > EPS_SMALL) + if ( m_bTHoldFloating) + dOkStep = 0 ; + else if ( m_Params.m_dStep > EPS_SMALL) dOkStep = m_Params.m_dStep + EPS_ZERO ; else if ( m_Params.m_dStep < -EPS_SMALL && ( m_TParams.m_nType == TT_MILL_NOTIP || @@ -2377,8 +2383,8 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo dStElev = max( dStElev - dExtraLen, 0.) ; // se attacco a zigzag o a spirale, l'elevazione va nell'attacco if ( IsLeadInHelixOrZigzag()) { - ptP1 += vtTool * ( dStElev + LIO_ELEV_TOL) ; - dStElev = -LIO_ELEV_TOL ; + ptP1 += vtTool * ( dStElev + GetLeadInOutToler()) ; + dStElev = - GetLeadInOutToler() ; } // approccio al punto iniziale if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dExtrAppr, bOutStart, bAboveStart, true, bSplitArcs)) { @@ -2753,8 +2759,8 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool m_TParams.m_dLen, false, dSafeZ, vtEscape, dStElev) ; // se attacco a zigzag o a spirale, l'elevazione va nell'attacco if ( IsLeadInHelixOrZigzag()) { - ptP1 += vtTool * ( dStElev + LIO_ELEV_TOL) ; - dStElev = - LIO_ELEV_TOL ; + ptP1 += vtTool * ( dStElev + GetLeadInOutToler()) ; + dStElev = - GetLeadInOutToler() ; } // approccio al punto iniziale if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dExtrAppr, bOutStart, bAboveStart, true, bSplitArcs)) { @@ -2844,8 +2850,8 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool } // se attacco a zigzag o a spirale, non affondo else if ( IsLeadInHelixOrZigzagOrGlide()) { - ptP1 += vtTool * ( dStElev + LIO_ELEV_TOL) ; - dStElev = - LIO_ELEV_TOL ; + ptP1 += vtTool * ( dStElev + GetLeadInOutToler()) ; + dStElev = - GetLeadInOutToler() ; } // altrimenti, affondo in feed opportuna else { @@ -2917,7 +2923,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool Vector3d vtDir1 ; if ( ! IsLeadInHelixOrZigzag() || k == nStep) { if ( k != nStep && GetLeadInType() == MILL_LI_GLIDE) - dEndElev = -LIO_ELEV_TOL ; + dEndElev = - GetLeadInOutToler() ; SetFeed( GetEndFeed()) ; if ( ! AddLeadOut( ptEnd, vtEnd, vtTool, dEndElev, bInvert, pCompo, bSplitArcs, ptP1, vtDir1)) { m_pMchMgr->SetLastError( 2311, "Error in Milling : LeadOut not computable") ; @@ -3998,7 +4004,7 @@ Milling::AddSawZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtT dStElev = dElev ; } else - dStElev = dStep - LIO_ELEV_TOL - 10 * EPS_SMALL ; + dStElev = dStep - GetLeadInOutToler() - 10 * EPS_SMALL ; // determino inizio attacco Point3d ptP1 ; Vector3d vtDir1 ; @@ -4076,7 +4082,7 @@ Milling::AddSawZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtT dEndElev = dElev ; } else - dEndElev = - LIO_ELEV_TOL ; + dEndElev = - GetLeadInOutToler() ; // aggiungo uscita Point3d ptP1 ; Vector3d vtDir1 ; @@ -4177,7 +4183,7 @@ Milling::AddSawOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtT dStElev = dElev ; } else - dStElev = dStep - LIO_ELEV_TOL - 10 * EPS_SMALL ; + dStElev = dStep - GetLeadInOutToler() - 10 * EPS_SMALL ; // determino inizio attacco Point3d ptP1 ; Vector3d vtDir1 ; @@ -4263,7 +4269,7 @@ Milling::AddSawOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtT dEndElev = dElev ; } else - dEndElev = - LIO_ELEV_TOL ; + dEndElev = - GetLeadInOutToler() ; // aggiungo uscita Point3d ptP1 ; Vector3d vtDir1 ; @@ -4704,7 +4710,7 @@ Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const int nType = GetLeadInType() ; double dTang = m_Params.m_dLiTang ; double dPerp = m_Params.m_dLiPerp ; - double dElev = min( m_Params.m_dLiElev, dStElev + LIO_ELEV_TOL) ; + double dElev = min( m_Params.m_dLiElev, dStElev + GetLeadInOutToler()) ; // se step invertito if ( bInvert) { // va aggiustato se non zigzag o spirale @@ -4720,7 +4726,7 @@ Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const if ( m_Params.m_nLeadOutType != MILL_LO_AS_LI) { dTang = m_Params.m_dLoTang ; dPerp = m_Params.m_dLoPerp ; - dElev = min( m_Params.m_dLoElev, dStElev + LIO_ELEV_TOL) ; + dElev = min( m_Params.m_dLoElev, dStElev + GetLeadInOutToler()) ; } } } @@ -4826,7 +4832,7 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& int nType = GetLeadInType() ; double dTang = m_Params.m_dLiTang ; double dPerp = m_Params.m_dLiPerp ; - double dElev = min( m_Params.m_dLiElev, dStElev + LIO_ELEV_TOL) ; + double dElev = min( m_Params.m_dLiElev, dStElev + GetLeadInOutToler()) ; // se step invertito if ( bInvert) { // va aggiustato se non zigzag o spirale @@ -4842,6 +4848,7 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& if ( m_Params.m_nLeadOutType != MILL_LO_AS_LI) { dTang = m_Params.m_dLoTang ; dPerp = m_Params.m_dLoPerp ; + dElev = min( m_Params.m_dLoElev, dStElev + GetLeadInOutToler()) ; } } } @@ -4856,6 +4863,13 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& case MILL_LI_NONE : return true ; case MILL_LI_LINEAR : + // se c'è elevazione di attacco e utensile flottante faccio precedere solo movimento in elevazione + if ( m_bTHoldFloating && dElev > 10 * EPS_SMALL) { + Point3d ptMid = ptP1 - dElev * vtTool ; + if ( AddLinearMove( ptMid, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL) + return false ; + dElev = 0 ; + } // eventuale movimento ortogonale (estensione di inserimento compensazione raggio utensile) if ( m_Params.m_dLiCompLen > 10 * EPS_SMALL) { Vector3d vtPerp = vtStart ; @@ -4878,6 +4892,13 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& case MILL_LI_TANGENT : { Point3d ptMid = ptP1 ; + // se c'è elevazione di attacco e utensile flottante faccio precedere solo movimento in elevazione + if ( m_bTHoldFloating && dElev > 10 * EPS_SMALL) { + ptMid += - dElev * vtTool ; + if ( AddLinearMove( ptMid, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL) + return false ; + dElev = 0 ; + } // eventuale movimento ortogonale (estensione di inserimento compensazione raggio utensile) if ( m_Params.m_dLiCompLen > 10 * EPS_SMALL) { Vector3d vtPerp = vtStart ; @@ -5049,7 +5070,7 @@ Milling::CalcLeadOutEnd( const Point3d& ptEnd, const Vector3d& vtEnd, const Vect int nType = GetLeadOutType() ; double dTang = m_Params.m_dLoTang ; double dPerp = m_Params.m_dLoPerp ; - double dElev = min( m_Params.m_dLoElev, dEndElev + LIO_ELEV_TOL) ; + double dElev = min( m_Params.m_dLoElev, dEndElev + GetLeadInOutToler()) ; // se uscita come ingresso o step invertito if ( nType == MILL_LO_AS_LI || bInvert) { int nLiType = GetLeadInType() ; @@ -5068,7 +5089,7 @@ Milling::CalcLeadOutEnd( const Point3d& ptEnd, const Vector3d& vtEnd, const Vect dTang = 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam) ; dPerp = dTang ; } - dElev = min( m_Params.m_dLiElev, dEndElev + LIO_ELEV_TOL) ; + dElev = min( m_Params.m_dLiElev, dEndElev + GetLeadInOutToler()) ; } // senso di rotazione da dir tg a dir esterna bool bCcwRot = (( ! bInvert && m_Params.m_nWorkSide == MILL_WS_LEFT) || @@ -5180,7 +5201,7 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d int nType = GetLeadOutType() ; double dTang = m_Params.m_dLoTang ; double dPerp = m_Params.m_dLoPerp ; - double dElev = min( m_Params.m_dLoElev, dEndElev + LIO_ELEV_TOL) ; + double dElev = min( m_Params.m_dLoElev, dEndElev + GetLeadInOutToler()) ; // se uscita come ingresso o step invertito if ( nType == MILL_LO_AS_LI || bInvert) { int nLiType = GetLeadInType() ; @@ -5199,7 +5220,7 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d dTang = 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam) ; dPerp = dTang ; } - dElev = min( m_Params.m_dLiElev, dEndElev + LIO_ELEV_TOL) ; + dElev = min( m_Params.m_dLiElev, dEndElev + GetLeadInOutToler()) ; } // senso di rotazione da dir tg a dir esterna bool bCcwRot = (( ! bInvert && m_Params.m_nWorkSide == MILL_WS_LEFT) || @@ -5215,6 +5236,11 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d return true ; case MILL_LO_LINEAR : { + // se utensile flottante, l'elevazione va tutta in un movimento finale aggiuntivo + double dFloatElev = 0 ; + if ( m_bTHoldFloating) + swap( dElev, dFloatElev) ; + // calcolo punto finale dell'uscita Vector3d vtPerp = vtEnd ; Vector3d vtRot = OrthoCompo( vtTool, vtEnd) ; vtPerp.Rotate( vtRot, 0, ( bCcwRot ? 1 : - 1)) ; @@ -5222,6 +5248,7 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d vtDir1 = ptP1 - ptEnd ; if ( ! vtDir1.Normalize()) return false ; + // inserisco movimento di uscita bool bOk = ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ; // eventuale movimento ortogonale (estensione di inserimento compensazione raggio utensile) if ( m_Params.m_dLoCompLen > 10 * EPS_SMALL) { @@ -5231,6 +5258,11 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d ptP1 += vtDir1 * m_Params.m_dLoCompLen ; bOk = bOk && ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ; } + // eventuale movimento in elevazione per flottante + if ( m_bTHoldFloating && dFloatElev > 10 * EPS_SMALL) { + ptP1 += dFloatElev * vtTool ; + bOk = bOk && ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ; + } return bOk ; } case MILL_LO_PERP_TG : @@ -5246,6 +5278,10 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d } case MILL_LO_TANGENT : { + // se utensile flottante, l'elevazione va tutta in un movimento finale aggiuntivo + double dFloatElev = 0 ; + if ( m_bTHoldFloating) + swap( dElev, dFloatElev) ; // calcolo punto finale dell'uscita Vector3d vtPerp = vtEnd ; Vector3d vtRot = OrthoCompo( vtTool, vtEnd) ; @@ -5254,16 +5290,14 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d vtDir1 = ptP1 - ptEnd ; if ( ! vtDir1.Normalize()) return false ; - // inserisco uscita + // inserisco movimento di uscita PtrOwner pCrv( GetArc2PVN( ptEnd, ptP1, vtEnd, vtTool)) ; if ( IsNull( pCrv)) return false ; - // assegno direzione finale dell'uscita Vector3d vtDirF ; if ( ! pCrv->GetEndDir( vtDirF)) return false ; bool bOk = true ; - // emetto movimento bOk = ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ; // eventuale movimento ortogonale (estensione di inserimento compensazione raggio utensile) if ( m_Params.m_dLoCompLen > 10 * EPS_SMALL) { @@ -5273,6 +5307,11 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d ptP1 += vtDir1 * m_Params.m_dLoCompLen ; bOk = bOk && ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ; } + // eventuale movimento in elevazione per flottante + if ( m_bTHoldFloating && dFloatElev > 10 * EPS_SMALL) { + ptP1 += dFloatElev * vtTool ; + bOk = bOk && ( AddLinearMove( ptP1, bSplitArcs, MCH_CL_LEADOUT) != GDB_ID_NULL) ; + } return bOk ; } case MILL_LO_GLIDE : diff --git a/Milling.h b/Milling.h index ca5080f..78e153f 100644 --- a/Milling.h +++ b/Milling.h @@ -163,7 +163,9 @@ class Milling : public Machining return true ; return ( IsLeadInHelixOrZigzag() && m_Params.m_dLiTang >= 0.9 * m_TParams.m_dDiam && m_Params.m_dLiElev <= 2) ; } - friend class LeadIOStatus ; + double GetLeadInOutToler( void) const + { return ( m_bTHoldFloating ? LIO_ELEV_FLOAT : LIO_ELEV_TOL) ; } + friend class LeadIOStatus ; private : SELVECTOR m_vId ; // identificativi entità geometriche da lavorare @@ -172,6 +174,7 @@ class Milling : public Machining double m_dTHoldBase ; // posizione base del porta-utensile double m_dTHoldLen ; // lunghezza del porta-utensile double m_dTHoldDiam ; // diametro del porta-utensile + bool m_bTHoldFloating ; // flag di portautensili flottante int m_nStatus ; // stato di aggiornamento della lavorazione int m_nMills ; // numero di percorsi di lavoro generati bool m_bStepOn ; // flag per indicare che effettivamente si lavora a step diff --git a/OutputConst.h b/OutputConst.h index 0fce80f..f1ac027 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -61,6 +61,7 @@ static const std::string GVAR_HEAD = ".HEAD" ; // (string) nome test static const std::string GVAR_EXIT = ".EXIT" ; // (int) indice uscita static const std::string GVAR_TCPOS = ".TCPOS" ; // (string) eventuale posizione utensile nel TC static const std::string GVAR_TTYPE = ".TTYPE" ; // (int) tipo utensile +static const std::string GVAR_TFLOAT = ".TFLOAT" ; // (bool) flag per utensile flottante static const std::string GVAR_TCOMP = ".TCOMP" ; // (int) numero correttore utensile static const std::string GVAR_TDIAM = ".TDIAM" ; // (num) diametro utensile static const std::string GVAR_TTOTDIAM = ".TTOTDIAM" ; // (num) diametro totale utensile diff --git a/Processor.cpp b/Processor.cpp index 9438862..756eb01 100644 --- a/Processor.cpp +++ b/Processor.cpp @@ -207,7 +207,7 @@ Processor::ProcessDisposition( int nOpId, int nOpInd) return false ; // Se utensile non definito o cambiato, emetto selezione nuovo utensile if ( m_sTool.empty() || m_sTool != m_sPrevTool) { - if ( ! OnToolSelect( sTool, sHead, nExit, sTcPos)) + if ( ! OnToolSelect( sTool, sHead, nExit, sTcPos, false)) return false ; } } @@ -322,7 +322,8 @@ Processor::ProcessMachining( int nOpId, int nOpInd) m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nExit) ; m_pMchMgr->TdbGetCurrToolParam( TPA_TCPOS, sTcPos) ; } - if ( ! OnToolSelect( sTool, sHead, nExit, sTcPos)) + bool bFloating = m_pMachine->IsCurrToolFloating() ; + if ( ! OnToolSelect( sTool, sHead, nExit, sTcPos, bFloating)) return false ; } @@ -840,13 +841,14 @@ Processor::OnRawMoveData( int nRawId, int RawMoveInd, int nType, const Point3d& //---------------------------------------------------------------------------- bool -Processor::OnToolSelect( const string& sTool, const string& sHead, int nExit, const string& sTcPos) +Processor::OnToolSelect( const string& sTool, const string& sHead, int nExit, const string& sTcPos, bool bFloating) { // assegno il nome dell'utensile, la testa, l'uscita e l'eventuale posizione nel toolchanger bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, sTool) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, sHead) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, sTcPos) ; + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TFLOAT, bFloating) ; // assegno il token e il nome degli assi bool bIsRobot = m_pMchMgr->GetCurrIsRobot() ; int nNumAxes = int( m_AxesName.size()) ; diff --git a/Processor.h b/Processor.h index 1bab9f4..bef3865 100644 --- a/Processor.h +++ b/Processor.h @@ -42,7 +42,7 @@ class Processor bool OnProgramStart( const std::string& sMachName, const std::string& sCncFile, const std::string& sInfo, bool bSetup) ; bool OnProgramEnd( void) ; bool ProcessToolData( void) ; - bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit, const std::string& sTcPos) ; + bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit, const std::string& sTcPos, bool bFloating) ; bool OnToolDeselect( const std::string& sNextTool, const std::string& sNextHead, int nNextExit, const std::string& sNextTcPos) ; bool OnDispositionStart( int nOpId, int nOpInd, int nPhase, bool bEmpty, bool bSomeByHand) ; bool OnDispositionEnd( void) ; diff --git a/SimulatorMP.cpp b/SimulatorMP.cpp index f69542a..32e2483 100644 --- a/SimulatorMP.cpp +++ b/SimulatorMP.cpp @@ -639,8 +639,9 @@ SimulatorMP::UpdateMachiningTool( bool bFirst, int& nChangeTool, int& nErr) return false ; // se cambiato oppure prima volta, lancio lo script di selezione if ( ( bDiffTool || bFirst) && nChangeTool != 2) { + bool bFloating = m_pMachine->IsCurrToolFloating() ; int nCurrErr ; - if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, nCurrErr)) { + if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, bFloating, nCurrErr)) { nErr = ( nErr != ERR_NONE ? nErr : nCurrErr) ; if ( nCurrErr != ERR_COLLISION) return false ; @@ -691,7 +692,7 @@ SimulatorMP::UpdateDispositionTool( bool bFirst, int& nErr) return false ; // eventuale lancio script int nCurrErr ; - if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, nCurrErr)) { + if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, false, nCurrErr)) { nErr = ( nErr != ERR_NONE ? nErr : nCurrErr) ; if ( nCurrErr != ERR_COLLISION) return false ; @@ -1828,7 +1829,7 @@ SimulatorMP::OnDispositionEnd( void) //---------------------------------------------------------------------------- bool SimulatorMP::OnToolSelect( const string& sTool, const string& sHead, int nExit, const string& sTcPos, - bool bFirst, int& nErr) + bool bFirst, bool bFloating, int& nErr) { // reset stato di errore da script nErr = ERR_NONE ; @@ -1838,7 +1839,8 @@ SimulatorMP::OnToolSelect( const string& sTool, const string& sHead, int nExit, if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, sTool) || ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, sHead) || ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit) || - ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, sTcPos)) + ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, sTcPos) || + ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TFLOAT, bFloating)) return false ; // assegno il token e il nome degli assi bool bIsRobot = m_pMchMgr->GetCurrIsRobot() ; @@ -2343,7 +2345,11 @@ SimulatorMP::SetToolForVmill( const string& sTool, const string& sHead, int nExi double dSideAng ; m_pMchMgr->TdbGetCurrToolParam( TPA_SIDEANG, dSideAng) ; double dMaxMat ; m_pMchMgr->TdbGetCurrToolParam( TPA_MAXMAT, dMaxMat) ; string sNotes ; m_pMchMgr->TdbGetCurrToolParam( TPA_USERNOTES, sNotes) ; + // verifico se additivo bool bAdditive = ( nFlag == 1) ; + // se flottante, il primo parametro è l'offset di lunghezza + if ( nFlag == 2) + dLen += dPar1 ; // ricerca dell'outline e del diametro gambo int nExitId = m_pMachine->GetExitId( sHead, nExit) ; int nToolId = m_pGeomDB->GetFirstNameInGroup( nExitId, sTool) ; diff --git a/SimulatorMP.h b/SimulatorMP.h index fea8c2d..b3d5f53 100644 --- a/SimulatorMP.h +++ b/SimulatorMP.h @@ -91,7 +91,8 @@ class SimulatorMP : public ISimulator bool OnDispositionStart( int nOpId, int nOpInd, int nPhase, const std::string& sTable, const Point3d& ptOri1, bool bEmpty, bool bSomeByHand) ; bool OnDispositionEnd( void) ; - bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit, const std::string& sTcPos, bool bFirst, int& nErr) ; + bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit, const std::string& sTcPos, + bool bFirst, bool bFloating, int& nErr) ; bool OnToolDeselect( const std::string& sNextTool, const std::string& sNextHead, int nNextExit, const std::string& sNextTcPos, int& nErr) ; bool OnMachiningStart( int nOpId, int nOpInd, const Point3d& ptMin, const Point3d& ptMax, const DBLVECTOR& vAxMin, const DBLVECTOR& vAxMax) ; diff --git a/SimulatorSP.cpp b/SimulatorSP.cpp index f6cb5d2..0f9cc35 100644 --- a/SimulatorSP.cpp +++ b/SimulatorSP.cpp @@ -583,8 +583,9 @@ SimulatorSP::UpdateTool( bool bFirst, int& nErr) return false ; // se cambiato oppure prima volta, lancio lo script di selezione if ( bDiffTool || bFirst) { + bool bFloating = m_pMachine->IsCurrToolFloating() ; int nCurrErr ; - if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, nCurrErr)) { + if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, bFloating, nCurrErr)) { nErr = ( nErr != 0 ? nErr : nCurrErr) ; if ( nCurrErr != ERR_COLLISION) return false ; @@ -623,7 +624,7 @@ SimulatorSP::UpdateTool( bool bFirst, int& nErr) return false ; // eventuale lancio script int nCurrErr ; - if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, nCurrErr)) { + if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, false, nCurrErr)) { nErr = ( nErr != 0 ? nErr : nCurrErr) ; if ( nCurrErr != ERR_COLLISION) return false ; @@ -1744,7 +1745,7 @@ SimulatorSP::OnDispositionEnd( void) //---------------------------------------------------------------------------- bool SimulatorSP::OnToolSelect( const string& sTool, const string& sHead, int nExit, const string& sTcPos, - bool bFirst, int& nErr) + bool bFirst, bool bFloating, int& nErr) { // reset stato di errore da script nErr = 0 ; @@ -1754,7 +1755,8 @@ SimulatorSP::OnToolSelect( const string& sTool, const string& sHead, int nExit, if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, sTool) || ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, sHead) || ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit) || - ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, sTcPos)) + ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, sTcPos) || + ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TFLOAT, bFloating)) return false ; // assegno il token e il nome degli assi bool bIsRobot = m_pMchMgr->GetCurrIsRobot() ; @@ -2256,7 +2258,7 @@ SimulatorSP::AddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, c //---------------------------------------------------------------------------- bool SimulatorSP::SetToolForVmill( const string& sTool, const string& sHead, int nExit, int nFlag, double dPar1, double dPar2, - const INTVECTOR& vVmill, bool bFirst) + const INTVECTOR& vVmill, bool bFirst) { // disabilito eventuale registrazione comandi EXE (riabilitazione automatica) CmdLogOff cmdLogOff ; @@ -2288,7 +2290,11 @@ SimulatorSP::SetToolForVmill( const string& sTool, const string& sHead, int nExi double dSideAng ; m_pMchMgr->TdbGetCurrToolParam( TPA_SIDEANG, dSideAng) ; double dMaxMat ; m_pMchMgr->TdbGetCurrToolParam( TPA_MAXMAT, dMaxMat) ; string sNotes ; m_pMchMgr->TdbGetCurrToolParam( TPA_USERNOTES, sNotes) ; + // verifico se additivo bool bAdditive = ( nFlag == 1) ; + // se flottante, il primo parametro è l'offset di lunghezza + if ( nFlag == 2) + dLen += dPar1 ; // ricerca dell'outline e del diametro gambo int nExitId = m_pMachine->GetExitId( sHead, nExit) ; int nToolId = m_pGeomDB->GetFirstNameInGroup( nExitId, sTool) ; diff --git a/SimulatorSP.h b/SimulatorSP.h index d2cddf6..774d44a 100644 --- a/SimulatorSP.h +++ b/SimulatorSP.h @@ -90,7 +90,8 @@ class SimulatorSP : public ISimulator bool OnDispositionStart( int nOpId, int nOpInd, int nPhase, const std::string& sTable, const Point3d& ptOri1, bool bEmpty, bool bSomeByHand) ; bool OnDispositionEnd( void) ; - bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit, const std::string& sTcPos, bool bFirst, int& nErr) ; + bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit, const std::string& sTcPos, + bool bFirst, bool bFloating, int& nErr) ; bool OnToolDeselect( const std::string& sNextTool, const std::string& sNextHead, int nNextExit, const std::string& sNextTcPos, int& nErr) ; bool OnMachiningStart( int nOpId, int nOpInd, const Point3d& ptMin, const Point3d& ptMax, const DBLVECTOR& vAxMin, const DBLVECTOR& vAxMax) ;