diff --git a/Disposition.cpp b/Disposition.cpp index 0984588..ed8e763 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -1353,7 +1353,8 @@ Disposition::SpecialApply( bool bRecalc) bOk = bOk && pMch->LuaResetGlobVar( EMC_VAR) ; // segnalo errori ed esco if ( ! bOk || nErr > 0) { - m_nShifts = -2 ; + if ( m_nShifts != -1) + m_nShifts = -2 ; string sOut = sMsg ; if ( IsEmptyOrSpaces( sOut)) sOut = " Error in " + ON_SPECIAL_APPLY + " (" + ToString( nErr) + ")" ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index a6bbd63..a683cea 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Generator.cpp b/Generator.cpp index 8457ed1..264d683 100644 --- a/Generator.cpp +++ b/Generator.cpp @@ -19,6 +19,7 @@ #include "OutputConst.h" #include "/EgtDev/Include/EMkDllMain.h" #include "/EgtDev/Include/EGnFileUtils.h" +#include "/EgtDev/Include/EGnGetKeyData.h" using namespace std ; @@ -46,19 +47,31 @@ Generator::Init( MachMgr* pMchMgr) bool Generator::Run( const string& sCncFile, const string& sInfo) { - // verifico sia abilitato dalla licenza - bool bEnabled = false ; - if ( GetEMkNetHwKey()) { - bEnabled = true ; - } - else { - unsigned int nOpt1, nOpt2 ; - int nOptExpDays ; + // Controllo della licenza + unsigned int nOpt1, nOpt2 ; + int nOptExpDays ; + int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, + nOpt1, nOpt2, nOptExpDays) ; + if ( ! GetEMkNetHwKey()) int nRet = GetKeyOptions( GetEMkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, nOpt1, nOpt2, nOptExpDays) ; - bEnabled = ( nRet == KEY_OK && ( nOpt1 & KEYOPT_EMK_NC_OFF) == 0) ; - } - if ( bEnabled) { + + // Verifica della abilitazione + bool bMinTime = false ; + if ( nOptExpDays >= GetMinDay()) + bMinTime = true ; + bool bCurrTime = false ; + if ( nOptExpDays >= GetCurrDay()) + bCurrTime = true ; + bool bKey = false ; + if ( nRet == KEY_OK) + bKey = true ; + bool bOption = false ; + if ( ( nOpt1 & KEYOPT_EMK_NC_OFF) == 0) + bOption = true ; + + // Esecuzione + if ( bMinTime && bCurrTime && bKey && bOption) { // emetto info di log { string sOut = "Generator Run : " + sCncFile ; @@ -79,6 +92,11 @@ Generator::Run( const string& sCncFile, const string& sInfo) return bOk ; } + // cancello l'eventuale file di uscita (e anche il file errore) + EraseFile( sCncFile) ; + string sErrFile = ChangeFileExtension( sCncFile, ERR_EXT) ; + EraseFile( sErrFile) ; + // Generazione non abilitata m_pMchMgr->SetLastError( 1000, "NC_OFF") ; std::string sErr = "Warning on Key (MKC/NCO)" ; diff --git a/Machine.h b/Machine.h index 116cbba..2a19ccd 100644 --- a/Machine.h +++ b/Machine.h @@ -125,6 +125,8 @@ class Machine bool GetAllCurrAxesToken( STRVECTOR& vAxToken) const ; bool GetCurrAxisMin( int nInd, double& dMin) const ; bool GetCurrAxisMax( int nInd, double& dMax) const ; + bool GetCurrAxisOffset( int nInd, double& dOffset) const ; + bool GetCurrAxisInvert( int nInd, bool& bInvert) const ; bool GetCurrAxisHomePos( int nInd, double& dHome) const ; bool GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const ; const Frame3d& GetCurrLinAxesFrame( void) const diff --git a/MachineCalc.cpp b/MachineCalc.cpp index ff32903..6f6b963 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -1827,6 +1827,52 @@ Machine::GetCurrAxisMax( int nInd, double& dMax) const return false ; } +//---------------------------------------------------------------------------- +bool +Machine::GetCurrAxisOffset( int nInd, double& dOffset) const +{ + int nLinAxes = int( m_vCalcLinAx.size()) ; + int nRotAxes = int( m_vCalcRotAx.size()) ; + if ( nInd >= 0 && nInd < nLinAxes) { + Axis* pAx = GetAxis( m_vCalcLinAx[nInd].nGrpId) ; + if ( pAx == nullptr) + return false ; + dOffset = pAx->GetOffset() ; + return true ; + } + else if ( nInd >= nLinAxes && nInd < nLinAxes + nRotAxes) { + Axis* pAx = GetAxis( m_vCalcRotAx[nInd-nLinAxes].nGrpId) ; + if ( pAx == nullptr) + return false ; + dOffset = pAx->GetOffset() ; + return true ; + } + return false ; +} + +//---------------------------------------------------------------------------- +bool +Machine::GetCurrAxisInvert( int nInd, bool& bInvert) const +{ + int nLinAxes = int( m_vCalcLinAx.size()) ; + int nRotAxes = int( m_vCalcRotAx.size()) ; + if ( nInd >= 0 && nInd < nLinAxes) { + Axis* pAx = GetAxis( m_vCalcLinAx[nInd].nGrpId) ; + if ( pAx == nullptr) + return false ; + bInvert = pAx->GetInvert() ; + return true ; + } + else if ( nInd >= nLinAxes && nInd < nLinAxes + nRotAxes) { + Axis* pAx = GetAxis( m_vCalcRotAx[nInd-nLinAxes].nGrpId) ; + if ( pAx == nullptr) + return false ; + bInvert = pAx->GetInvert() ; + return true ; + } + return false ; +} + //---------------------------------------------------------------------------- bool Machine::GetCurrAxisHomePos( int nInd, double& dHome) const diff --git a/Milling.cpp b/Milling.cpp index e76cdcb..a03406a 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -2569,7 +2569,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo bOk = false ; } // aggiungo opportuna retrazione - if ( ! AddSawBladeSideRetract( ptP1, vtRetr, dSafeZ, dSawEndElev, dAppr)) { + if ( ! AddSawBladeSideRetract( ptP1, vtRetr, vtTool, dSafeZ, dSawEndElev, dAppr)) { m_pMchMgr->SetLastError( 2312, "Error in Milling : Retract not computable") ; return false ; } @@ -2915,7 +2915,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool bOk = false ; } // aggiungo opportuna retrazione - if ( ! AddSawBladeSideRetract( ptP1, vtRetr, dSafeZ, dSawEndElev, dAppr)) { + if ( ! AddSawBladeSideRetract( ptP1, vtRetr, vtTool, dSafeZ, dSawEndElev, dAppr)) { m_pMchMgr->SetLastError( 2312, "Error in Milling : Retract not computable") ; return false ; } @@ -3377,7 +3377,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool bOk = false ; } // aggiungo opportuna retrazione - if ( ! AddSawBladeSideRetract( ptP1, vtRetr, dSafeZ, dSawEndElev, dAppr)) { + if ( ! AddSawBladeSideRetract( ptP1, vtRetr, vtTool, dSafeZ, dSawEndElev, dAppr)) { m_pMchMgr->SetLastError( 2312, "Error in Milling : Retract not computable") ; return false ; } @@ -4196,7 +4196,8 @@ Milling::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, //---------------------------------------------------------------------------- bool -Milling::AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, double dSafeZ, double dEndElev, double dAppr) +Milling::AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, const Vector3d& vtTool, + double dSafeZ, double dEndElev, double dAppr) { // per retrazione orizzontale vtAppr deve essere già stato sistemato dal chiamante // se sopra uscita c'è spazio per sicurezza o approccio @@ -4217,7 +4218,16 @@ Milling::AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, dou return false ; } // 4b -> movimento di risalita sopra il punto finale - Point3d ptP4b = ptP4a + vtRetr * ( dSafeZ - dAppr) ; + Vector3d vtMove = vtRetr ; + double dMove = dSafeZ - dAppr ; + if ( ! m_bTiltingTab && vtRetr.z < sin( -ANG_RIGHT / 2)) { + vtMove = Vector3d( vtTool.x, vtTool.y, 0) ; + if ( vtMove.Normalize()) + dMove = dSafeZ ; + else + vtMove = vtRetr ; + } + Point3d ptP4b = ptP4a + vtMove * dMove ; if ( AddRapidMove( ptP4b) == GDB_ID_NULL) return false ; } diff --git a/Milling.h b/Milling.h index 6494654..686c233 100644 --- a/Milling.h +++ b/Milling.h @@ -102,7 +102,8 @@ class Milling : public Machining bool AddDirectApproach( const Point3d& ptP) ; bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ, double dElev, double dAppr, bool bAboveEnd) ; - bool AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, double dSafeZ, double dEndElev, double dAppr) ; + bool AddSawBladeSideRetract( const Point3d& ptP, const Vector3d& vtRetr, const Vector3d& vtTool, + double dSafeZ, double dEndElev, double dAppr) ; bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, double dStElev, bool bInvert, const ICurveComposite* pCompo, Point3d& ptP1) const ; bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, diff --git a/Operation.cpp b/Operation.cpp index 4f3dac5..bad0fc1 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -1917,8 +1917,17 @@ Operation::CalculateAxesValues( const string& sHint, bool bRotContOnNext, bool b if ( m_pMchMgr->GetCurrMachine()->GetCurrAxisToken( nLinAxes + i, sAxToken) && szKey == Trim( sAxToken)) { double dVal ; - if ( FromString( szVal, dVal)) + if ( FromString( szVal, dVal)) { + double dOffset = 0 ; + m_pMchMgr->GetCurrMachine()->GetCurrAxisOffset( nLinAxes + i, dOffset) ; + if ( abs( dOffset) > EPS_ANG_SMALL) + dVal -= dOffset ; + bool bInvert = false ; + m_pMchMgr->GetCurrMachine()->GetCurrAxisInvert( nLinAxes + i, bInvert) ; + if ( bInvert) + dVal = -dVal ; vAxRotPrec[i] = dVal ; + } break ; } } diff --git a/Pocketing.cpp b/Pocketing.cpp index 7a87610..71dbe09 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -7606,14 +7606,22 @@ Pocketing::AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveC } } - // se il lato opposto a quello di riferimento è chiuso ha senso aggiungere solo se il punto è sotto la linea di svuotatura + // se il lato opposto a quello di riferimento � chiuso bisogna distinguere i casi else { if ( ptP2.y < dYCoord) { pCompo->AddPoint( ptP2) ; - Point3d ptCrv ; - pMCrv->GetStartPoint( ptCrv) ; - pCompo->AddLine( ptCrv) ; } + else { + Vector3d vtDir ; + pLine->GetStartDir( vtDir) ; + if ( bStart) + vtDir.Invert() ; + Point3d ptP2N = ptP2 - m_TParams.m_dDiam / 2 * abs( vtDir.x / vtDir.y) * vtDir ; + pCompo->AddPoint( ptP2N) ; + } + Point3d ptCrv ; + pMCrv->GetStartPoint( ptCrv) ; + pCompo->AddLine( ptCrv) ; } // setto temp prop per ricordare che è curva aggiuntiva per pulire angoli @@ -7793,8 +7801,13 @@ Pocketing::ComputeTrapezoidSpiralLeadInLeadOut( ICurveComposite* pCompo, const V // return false ; if( ! GetSignedDistFromStmRaw( m_nPhase, ptP, vtDirP, dDist, vtNorm)) return false ; + if ( abs( dDist) < EPS_SMALL) { + ptP -= vtDirP ; + if ( ! CalcDistanceFromRawSurface( m_nPhase, ptP, vtDirP, dDist, vtNorm)) + return false ; + } - // calcolo eventuali fattori correttivi + // calcolo eventuali fattori correttivi (se uscita approx. con fianco utensile) double dCorr = 1 ; double dDistRef = dDist ; double dDistMin ;