diff --git a/Disposition.cpp b/Disposition.cpp index 4d9a7b9..c97e088 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -875,7 +875,8 @@ Disposition::SpecialApply( bool bRecalc) if ( m_nShifts == 0) return bOk ; // calcolo assi macchina - bOk = bOk && CalculateAxesValues() ; + string sHint = "" ; + bOk = bOk && CalculateAxesValues( sHint) ; // gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine di tutti bOk = bOk && AdjustStartEndMovements() ; return bOk ; diff --git a/Drilling.cpp b/Drilling.cpp index 8b50d29..745fee0 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -467,7 +467,8 @@ Drilling::Apply( bool bRecalc) return true ; // calcolo gli assi macchina - if ( ! CalculateAxesValues()) + string sHint = ExtractHint( m_Params.m_sUserNotes) ; + if ( ! CalculateAxesValues( sHint)) return false ; // gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine della lavorazione diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 9a47851..32b19ec 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/MachMgr.h b/MachMgr.h index 89c2fe4..c973a4a 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -237,19 +237,20 @@ class MachMgr : public IMachMgr bool SetCalcTable( const std::string& sTable) override ; bool SetCalcTool( const std::string& sTool, const std::string& sHead, int nExit) override ; bool SetRotAxisBlock( const std::string& sAxis, double dVal) override ; - bool GetCalcTool( std::string& sTool) override ; + bool GetCalcTool( std::string& sTool) const override ; bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, - int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) override ; + int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const override ; bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, - int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) ; + int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) const ; bool GetCalcPositions( const Point3d& ptP, double dAngA, double dAngB, - int& nStat, double& dX, double& dY, double& dZ) override ; + int& nStat, double& dX, double& dY, double& dZ) const override ; bool GetCalcPositions( const Point3d& ptP, DBLVECTOR& vAng, - int& nStat, double& dX, double& dY, double& dZ) ; + int& nStat, double& dX, double& dY, double& dZ) const ; bool GetCalcTipFromPositions( double dX, double dY, double dZ, double dAngA, double dAngB, - bool bOverall, bool bBottom, Point3d& ptTip) override ; - bool GetCalcToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) override ; - bool GetNearestAngleInStroke( int nInd, double dAngRef, double& dAng) override ; + bool bOverall, bool bBottom, Point3d& ptTip) const override ; + bool GetCalcToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) const override ; + bool GetNearestAngleInStroke( int nInd, double dAngRef, double& dAng) const override ; + bool LimitAngleToStroke( int nInd, double& dAng) const override ; bool VerifyOutstroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) override ; bool VerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng, int& nStat) ; const std::string& GetOutstrokeInfo( void) const override ; @@ -264,7 +265,7 @@ class MachMgr : public IMachMgr bool ResetAxisPos( const std::string& sAxis) override ; bool ResetAllAxesPos( void) override ; bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) override ; - bool GetLoadedTool( const std::string& sHead, int nExit, std::string& sTool) override ; + bool GetLoadedTool( const std::string& sHead, int nExit, std::string& sTool) const override ; bool UnloadTool( const std::string& sHead, int nExit) override ; bool ResetHeadSet( const std::string& sHead) override ; bool SetMachineLook( int nFlag) override ; @@ -272,13 +273,13 @@ class MachMgr : public IMachMgr public : MachMgr( void) ; // Basic - int GetContextId( void) + int GetContextId( void) const { return m_nContextId ; } - IGeomDB* GetGeomDB( void) + IGeomDB* GetGeomDB( void) const { return m_pGeomDB ; } - int GetMachBaseId( void) + int GetMachBaseId( void) const { return m_nMachBaseId ; } - int GetMachAuxId( void) + int GetMachAuxId( void) const { return m_nMachAuxId ; } std::string GetLuaLibsDir( void) const { return m_sLuaLibsDir ; } @@ -305,13 +306,13 @@ class MachMgr : public IMachMgr ToolsMgr* GetCurrToolsMgr( void) const ; MachiningsMgr* GetCurrMachiningsMgr( void) const ; // MachineCalc - int GetCurrLinAxes( void) ; - int GetCurrRotAxes( void) ; - bool GetAllCurrAxesName( STRVECTOR& vAxName) ; - bool GetAllCalcAxesHomePos( DBLVECTOR& vAxHomeVal) ; + int GetCurrLinAxes( void) const ; + int GetCurrRotAxes( void) const ; + bool GetAllCurrAxesName( STRVECTOR& vAxName) const ; + bool GetAllCalcAxesHomePos( DBLVECTOR& vAxHomeVal) const ; bool ApplyRotAxisBlock( void) ; - bool IsKinematicRotAxisBlocked( int nInd) ; - double GetCalcRot1W( void) ; + bool IsKinematicRotAxisBlocked( int nInd) const ; + double GetCalcRot1W( void) const ; bool SetCalcSolCh( int nScc) ; // operations bool GetOperationNewName( std::string& sName) const ; diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index 0c93f6f..868a6c9 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -250,7 +250,7 @@ MachMgr::LoadTool( const string& sHead, int nExit, const string& sTool) //---------------------------------------------------------------------------- bool -MachMgr::GetLoadedTool( const string& sHead, int nExit, string& sTool) +MachMgr::GetLoadedTool( const string& sHead, int nExit, string& sTool) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetLoadedTool( sHead, nExit, sTool) : false) ; @@ -322,7 +322,7 @@ MachMgr::ApplyRotAxisBlock( void) //---------------------------------------------------------------------------- bool -MachMgr::IsKinematicRotAxisBlocked( int nInd) +MachMgr::IsKinematicRotAxisBlocked( int nInd) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->IsKinematicRotAxisBlocked( nInd) : false) ; @@ -341,7 +341,7 @@ MachMgr::SetCalcSolCh( int nScc) //---------------------------------------------------------------------------- bool -MachMgr::GetCalcTool( string& sTool) +MachMgr::GetCalcTool( string& sTool) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetCurrTool( sTool) : false) ; @@ -349,7 +349,7 @@ MachMgr::GetCalcTool( string& sTool) //---------------------------------------------------------------------------- double -MachMgr::GetCalcRot1W( void) +MachMgr::GetCalcRot1W( void) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetCurrRot1W() : false) ; @@ -357,7 +357,7 @@ MachMgr::GetCalcRot1W( void) //---------------------------------------------------------------------------- int -MachMgr::GetCurrLinAxes( void) +MachMgr::GetCurrLinAxes( void) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetCurrLinAxes() : false) ; @@ -365,7 +365,7 @@ MachMgr::GetCurrLinAxes( void) //---------------------------------------------------------------------------- int -MachMgr::GetCurrRotAxes( void) +MachMgr::GetCurrRotAxes( void) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetCurrRotAxes() : false) ; @@ -373,7 +373,7 @@ MachMgr::GetCurrRotAxes( void) //---------------------------------------------------------------------------- bool -MachMgr::GetAllCurrAxesName( STRVECTOR& vAxName) +MachMgr::GetAllCurrAxesName( STRVECTOR& vAxName) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetAllCurrAxesName( vAxName) : false) ; @@ -381,7 +381,7 @@ MachMgr::GetAllCurrAxesName( STRVECTOR& vAxName) //---------------------------------------------------------------------------- bool -MachMgr::GetAllCalcAxesHomePos( DBLVECTOR& vAxHomeVal) +MachMgr::GetAllCalcAxesHomePos( DBLVECTOR& vAxHomeVal) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetAllCurrAxesHomePos( vAxHomeVal) : false) ; @@ -390,7 +390,7 @@ MachMgr::GetAllCalcAxesHomePos( DBLVECTOR& vAxHomeVal) //---------------------------------------------------------------------------- bool MachMgr::GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, - int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) + int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetAngles( vtDirT, vtDirA, nStat, dAngA1, dAngB1, dAngA2, dAngB2) : false) ; @@ -399,7 +399,7 @@ MachMgr::GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, //---------------------------------------------------------------------------- bool MachMgr::GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, - int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) + int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetAngles( vtDirT, vtDirA, nStat, vAng1, vAng2) : false) ; @@ -408,7 +408,7 @@ MachMgr::GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, //---------------------------------------------------------------------------- bool MachMgr::GetCalcPositions( const Point3d& ptP, double dAngA, double dAngB, - int& nStat, double& dX, double& dY, double& dZ) + int& nStat, double& dX, double& dY, double& dZ) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetPositions( ptP, dAngA, dAngB, nStat, dX, dY, dZ) : false) ; @@ -417,7 +417,7 @@ MachMgr::GetCalcPositions( const Point3d& ptP, double dAngA, double dAngB, //---------------------------------------------------------------------------- bool MachMgr::GetCalcPositions( const Point3d& ptP, DBLVECTOR& vAng, - int& nStat, double& dX, double& dY, double& dZ) + int& nStat, double& dX, double& dY, double& dZ) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetPositions( ptP, vAng, nStat, dX, dY, dZ) : false) ; @@ -427,7 +427,7 @@ MachMgr::GetCalcPositions( const Point3d& ptP, DBLVECTOR& vAng, //---------------------------------------------------------------------------- bool MachMgr::GetCalcTipFromPositions( double dX, double dY, double dZ, double dAngA, double dAngB, - bool bOverall, bool bBottom, Point3d& ptTip) + bool bOverall, bool bBottom, Point3d& ptTip) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetTipFromPositions( dX, dY, dZ, dAngA, dAngB, bOverall, bBottom, ptTip) : false) ; @@ -435,7 +435,7 @@ MachMgr::GetCalcTipFromPositions( double dX, double dY, double dZ, double dAngA, //---------------------------------------------------------------------------- bool -MachMgr::GetCalcToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) +MachMgr::GetCalcToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetToolDirFromAngles( dAngA, dAngB, vtDir) : false) ; @@ -443,12 +443,20 @@ MachMgr::GetCalcToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) //---------------------------------------------------------------------------- bool -MachMgr::GetNearestAngleInStroke( int nInd, double dAngRef, double& dAng) +MachMgr::GetNearestAngleInStroke( int nInd, double dAngRef, double& dAng) const { Machine* pMch = GetCurrMachine() ; return ( ( pMch != nullptr) ? pMch->GetNearestAngleInStroke( nInd, dAngRef, dAng) : false) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::LimitAngleToStroke( int nInd, double& dAng) const +{ + Machine* pMch = GetCurrMachine() ; + return ( ( pMch != nullptr) ? pMch->LimitAngleToStroke( nInd, dAng) : false) ; +} + //---------------------------------------------------------------------------- bool MachMgr::VerifyOutstroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) diff --git a/Machine.h b/Machine.h index 6c80867..06d99a2 100644 --- a/Machine.h +++ b/Machine.h @@ -52,7 +52,7 @@ class Machine return ( IsHeadGroup( nId) ? nId : GDB_ID_NULL) ; } bool SetLook( int nFlag) ; bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) ; - bool GetLoadedTool( const std::string& sHead, int nExit, std::string& sTool) ; + bool GetLoadedTool( const std::string& sHead, int nExit, std::string& sTool) const ; bool UnloadTool( const string& sHead, int nExit) ; bool ResetHeadSet( const std::string& sHead) ; bool SetAxisPos( const std::string& sAxis, double dVal) ; @@ -76,11 +76,13 @@ class Machine bool BlockKinematicRotAxis( int nId, double dVal) ; bool FreeKinematicRotAxis( const std::string& sName) ; bool FreeKinematicRotAxis( int nId) ; - bool IsKinematicRotAxisBlocked( int nInd) ; + bool IsKinematicRotAxisBlocked( int nInd) const ; bool SetSolCh( int nScc) ; int GetCurrLinAxes( void) const ; int GetCurrRotAxes( void) const ; + bool GetCurrAxisName( int nInd, std::string& sAxName) const ; bool GetAllCurrAxesName( STRVECTOR& vAxName) const ; + bool GetCurrAxisToken( int nInd, std::string& sAxToken) const ; bool GetAllCurrAxesToken( STRVECTOR& vAxToken) const ; bool GetCurrAxisHomePos( int nInd, double& dHome) const ; bool GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const ; @@ -98,6 +100,7 @@ class Machine bool bBottom, bool bOverall, Point3d& ptTip) const ; bool GetToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) const ; bool GetNearestAngleInStroke( int nInd, double dAngRef, double& dAng) const ; + bool LimitAngleToStroke( int nInd, double& dAng) const ; bool VerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng, int& nStat) const ; const std::string& GetOutstrokeInfo( void) const { return m_sOutstrokeInfo ; } diff --git a/MachineCalc.cpp b/MachineCalc.cpp index 74b85dd..18d4ef2 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -454,7 +454,7 @@ Machine::FreeKinematicRotAxis( int nId) //---------------------------------------------------------------------------- bool -Machine::IsKinematicRotAxisBlocked( int nInd) +Machine::IsKinematicRotAxisBlocked( int nInd) const { int nRotAxTot = int( m_vCalcRotAx.size()) ; if ( nInd < 0 || nInd >= nRotAxTot) @@ -1006,6 +1006,21 @@ Machine::GetNearestAngleInStroke( int nInd, double dAngRef, double& dAng) const dAng <= m_vCalcRotAx[nInd].stroke.Max) ; } +//---------------------------------------------------------------------------- +bool +Machine::LimitAngleToStroke( int nInd, double& dAng) const +{ + // se angolo fittizio (non esiste l'asse rotante corrispondente), non c'è alcunchè da fare + if ( nInd < 0 || nInd >= int( m_vCalcRotAx.size())) + return true ; + // se angolo fuori corsa, lo porto all'estremo più vicino + if ( dAng < m_vCalcRotAx[nInd].stroke.Min) + dAng = m_vCalcRotAx[nInd].stroke.Min ; + else if ( dAng > m_vCalcRotAx[nInd].stroke.Max) + dAng = m_vCalcRotAx[nInd].stroke.Max ; + return true ; +} + //---------------------------------------------------------------------------- bool Machine::VerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng, int& nStat) const @@ -1061,6 +1076,29 @@ Machine::GetCurrRotAxes( void) const return int( m_vCalcRotAx.size()) ; } +//---------------------------------------------------------------------------- +bool +Machine::GetCurrAxisName( int nInd, string& sAxName) 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 ; + sAxName = pAx->GetName() ; + return true ; + } + else if ( nInd >= nLinAxes && nInd < nLinAxes + nRotAxes) { + Axis* pAx = GetAxis( m_vCalcRotAx[nInd-nLinAxes].nGrpId) ; + if ( pAx == nullptr) + return false ; + sAxName = pAx->GetName() ; + return true ; + } + return false ; +} + //---------------------------------------------------------------------------- bool Machine::GetAllCurrAxesName( STRVECTOR& vAxName) const @@ -1086,6 +1124,30 @@ Machine::GetAllCurrAxesName( STRVECTOR& vAxName) const return bOk ; } +//---------------------------------------------------------------------------- +bool +Machine::GetCurrAxisToken( int nInd, string& sAxToken) 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 ; + sAxToken = pAx->GetToken() ; + return true ; + } + else if ( nInd >= nLinAxes && nInd < nLinAxes + nRotAxes) { + Axis* pAx = GetAxis( m_vCalcRotAx[nInd-nLinAxes].nGrpId) ; + if ( pAx == nullptr) + return false ; + sAxToken = pAx->GetToken() ; + return true ; + } + return false ; + +} + //---------------------------------------------------------------------------- bool Machine::GetAllCurrAxesToken( STRVECTOR& vAxToken) const diff --git a/MachineHeads.cpp b/MachineHeads.cpp index ed9aa1a..089fa39 100644 --- a/MachineHeads.cpp +++ b/MachineHeads.cpp @@ -75,7 +75,7 @@ Machine::LoadTool( const string& sHead, int nExit, const string& sTool) //---------------------------------------------------------------------------- bool -Machine::GetLoadedTool( const string& sHead, int nExit, string& sTool) +Machine::GetLoadedTool( const string& sHead, int nExit, string& sTool) const { // controllo GeomDB if ( m_pGeomDB == nullptr) diff --git a/Milling.cpp b/Milling.cpp index ab3963e..dd088be 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -515,7 +515,8 @@ Milling::Apply( bool bRecalc) return true ; // calcolo gli assi macchina - if ( ! CalculateAxesValues()) + string sHint = ExtractHint( m_Params.m_sUserNotes) ; + if ( ! CalculateAxesValues( sHint)) return false ; // gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine della lavorazione diff --git a/Operation.cpp b/Operation.cpp index cb87be4..2af68d2 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -449,9 +449,28 @@ Operation::GetClPathFinalAxesValues( int nClPathId, DBLVECTOR& vAxVal) return ( vAxVal.size() > 0) ; } +//---------------------------------------------------------------------------- +std::string +Operation::ExtractHint( const std::string& sNotes) +{ + const string KEY_HINT = "Hint:" ; + string sHint ; + STRVECTOR vsCmd ; + Tokenize( sNotes, ";", vsCmd) ; + for each (const auto& sCmd in vsCmd) { + // se per assi rotanti + if ( sCmd.find( KEY_HINT) != string::npos) { + sHint = sCmd ; + ReplaceString( sHint, KEY_HINT, "") ; + break ; + } + } + return sHint ; +} + //---------------------------------------------------------------------------- bool -Operation::CalculateAxesValues( void) +Operation::CalculateAxesValues( const string& sHint) { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -483,7 +502,7 @@ Operation::CalculateAxesValues( void) int nLinAxes = m_pMchMgr->GetCurrLinAxes() ; int nRotAxes = m_pMchMgr->GetCurrRotAxes() ; - // assegno gli angoli iniziali + // Assegno gli angoli iniziali DBLVECTOR vAxRotPrec( nRotAxes, 0.) ; DBLVECTOR vAxVal ; // se utensile non cambiato, uso gli angoli finali della lavorazione precedente @@ -498,6 +517,25 @@ Operation::CalculateAxesValues( void) for ( int i = 0 ; i < nRotAxes ; ++ i) vAxRotPrec[i] = vAxVal[nLinAxes + i] ; } + // se ci sono suggerimenti validi per gli assi rotanti, li applico + if ( ! sHint.empty()) { + STRVECTOR vsTok ; + Tokenize( sHint, ",", vsTok) ; + for each (const auto& sTok in vsTok) { + string szKey, szVal ; + Split( sTok, "=", true, szKey, szVal) ; + for ( int i = 0 ; i < nRotAxes ; ++ i) { + string sAxToken ; + if ( m_pMchMgr->GetCurrMachine()->GetCurrAxisToken(nLinAxes + i, sAxToken) && + szKey == sAxToken) { + double dVal ; + if ( FromString( szVal, dVal)) + vAxRotPrec[i] = dVal ; + break ; + } + } + } + } // recupero peso primo asse rotante di testa double dRot1W = m_pMchMgr->GetCalcRot1W() ; @@ -581,12 +619,21 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, // porto gli angoli ai valori più vicini ai precedenti con offset di uno o più giri for ( size_t i = 0 ; i < vAng1.size() ; ++ i) m_pMchMgr->GetNearestAngleInStroke( int( i), vAxRotPrec[i], vAng1[i]) ; + // se sol.ne indeterminata (sempre il primo asse), assegno il precedente, limitandolo alla corsa + if ( nRStat < 0 && vAng1.size() >= 1) { + vAng1[0] = vAxRotPrec[0] ; + m_pMchMgr->LimitAngleToStroke( 0, vAng1[0]) ; + } } // per movimenti successivi else { // scelgo gli angoli più vicini, per continuità non applico offset per stare nelle corse for ( size_t i = 0 ; i < vAng1.size() ; ++ i) vAng1[i] = AngleNearAngle( vAng1[i], vAxRotPrec[i]) ; + // se sol.ne indeterminata (sempre il primo asse), assegno il precedente + if ( nRStat < 0 && vAng1.size() >= 1) { + vAng1[0] = vAxRotPrec[0] ; + } } } if ( abs( nRStat) == 2) { @@ -597,12 +644,23 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, m_pMchMgr->GetNearestAngleInStroke( int( i), vAxRotPrec[i], vAng1[i]) ; m_pMchMgr->GetNearestAngleInStroke( int( i), vAxRotPrec[i], vAng2[i]) ; } + // se sol.ne indeterminata (sempre il primo asse), assegno il precedente, limitandolo alla corsa + if ( nRStat < 0 && vAng1.size() >= 1) { + vAng1[0] = vAxRotPrec[0] ; + m_pMchMgr->LimitAngleToStroke( 0, vAng1[0]) ; + vAng2[0] = vAng1[0] ; + } } else { // scelgo gli angoli più vicini, per continuità non applico offset per stare nelle corse for ( size_t i = 0 ; i < vAng1.size() ; ++ i) { vAng1[i] = AngleNearAngle( vAng1[i], vAxRotPrec[i]) ; vAng2[i] = AngleNearAngle( vAng2[i], vAxRotPrec[i]) ; + // se sol.ne indeterminata (sempre il primo asse), assegno il precedente + if ( nRStat < 0 && vAng1.size() >= 1) { + vAng1[0] = vAxRotPrec[0] ; + vAng2[0] = vAng1[0] ; + } } } // scelgo la soluzione più vicina ai precedenti @@ -611,7 +669,7 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, bool bFirst = true ; for ( size_t i = 0 ; i < vAng1.size() ; ++ i) { // ignoro gli assi bloccati - if ( ! m_pMchMgr->IsKinematicRotAxisBlocked( int( i))) + if ( m_pMchMgr->IsKinematicRotAxisBlocked( int( i))) continue ; // calcolo i delta asse con eventuale peso dDelta1 += fabs( vAng1[i] - vAxRotPrec[i]) * ( bFirst ? dRot1W : 1) ; @@ -653,6 +711,14 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, } string sInfo = "Outstroke : " + m_pMchMgr->GetOutstrokeInfo() ; LOG_INFO( GetEMkLogger(), sInfo.c_str()) + // imposto stato + bFirst = false ; + // memorizzo i valori degli assi lineari come nuovi precedenti + dXprec = dX ; + dYprec = dY ; + dZprec = dZ ; + // memorizzo i valori degli angoli come nuovi precedenti + vAxRotPrec = vAng1 ; continue ; } // salvo i valori degli assi diff --git a/Operation.h b/Operation.h index 39f0d8d..e91b5ce 100644 --- a/Operation.h +++ b/Operation.h @@ -70,7 +70,8 @@ class Operation : public IUserObj bool GetClPathInitialAxesValues( int nClPathId, DBLVECTOR& vAxVal) ; bool GetFinalAxesValues( DBLVECTOR& vAxVal) ; bool GetClPathFinalAxesValues( int nClPathId, DBLVECTOR& vAxVal) ; - bool CalculateAxesValues( void) ; + std::string ExtractHint( const std::string& sNotes) ; + bool CalculateAxesValues( const std::string& sHint) ; bool CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W, DBLVECTOR& vAxRotPrec, int& nOutStrC) ; bool AdjustStartEndMovements( bool bOnlyStart = false) ; diff --git a/SawFinishing.cpp b/SawFinishing.cpp index 087d879..cde123c 100644 --- a/SawFinishing.cpp +++ b/SawFinishing.cpp @@ -443,7 +443,8 @@ SawFinishing::Apply( bool bRecalc) return true ; // calcolo gli assi macchina - if ( ! CalculateAxesValues()) + string sHint = ExtractHint( m_Params.m_sUserNotes) ; + if ( ! CalculateAxesValues( sHint)) return false ; // gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine della lavorazione diff --git a/SawRoughing.cpp b/SawRoughing.cpp index 9278340..e14bb62 100644 --- a/SawRoughing.cpp +++ b/SawRoughing.cpp @@ -422,7 +422,8 @@ SawRoughing::Apply( bool bRecalc) return true ; // calcolo gli assi macchina - if ( ! CalculateAxesValues()) + string sHint = ExtractHint( m_Params.m_sUserNotes) ; + if ( ! CalculateAxesValues( sHint)) return false ; // gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine della lavorazione diff --git a/Sawing.cpp b/Sawing.cpp index 545c473..18ee4e4 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -529,7 +529,8 @@ Sawing::Apply( bool bRecalc) return true ; // calcolo gli assi macchina - if ( ! CalculateAxesValues()) + string sHint = ExtractHint( m_Params.m_sUserNotes) ; + if ( ! CalculateAxesValues( sHint)) return false ; // gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine della lavorazione