From fe0cbd019148c45594abe5321c341b8a2ed995eb Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 2 Jun 2016 07:03:24 +0000 Subject: [PATCH] =?UTF-8?q?EgtMachKernel=201.6r8=20:=20-=20aggiunta=20gest?= =?UTF-8?q?ione=20SCC=20(Solution=20Choice=20Criterion)=20nelle=20lavorazi?= =?UTF-8?q?oni=20-=20possibilit=C3=A0=20di=20calcolo=20Tip=20con=20dimensi?= =?UTF-8?q?oni=20massime=20anzich=C3=A8=20quelle=20di=20lavoro=20-=20migli?= =?UTF-8?q?orato=20controllo=20pezzi=20prima=20di=20inserimento=20nei=20gr?= =?UTF-8?q?ezzi=20-=20migliorato=20caricamento=20tavola=20al=20cambio=20di?= =?UTF-8?q?=20gruppo=20di=20lavoro=20-=20aggiunta=20prima=20versione=20di?= =?UTF-8?q?=20risalita=20tra=20i=20percorsi=20di=20lavorazione=20in=20base?= =?UTF-8?q?=20a=20controllo=20collisioni=20(ora=20solo=20box)=20-=20in=20s?= =?UTF-8?q?imulazione=20imposto=20variabile=20nome=20tavola=20prima=20di?= =?UTF-8?q?=20OnDispositionStart.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CamData.h | 2 +- Disposition.cpp | 4 +- Disposition.h | 4 +- Drilling.cpp | 8 +++ Drilling.h | 2 + DrillingData.cpp | 26 +++++++- DrillingData.h | 4 +- EgtMachKernel.rc | Bin 11782 -> 11782 bytes Head.cpp | 5 +- MachMgr.h | 3 +- MachMgrBasic.cpp | 2 +- MachMgrMachines.cpp | 15 ++++- MachMgrParts.cpp | 7 +- MachMgrPhases.cpp | 4 +- Machine.cpp | 2 + Machine.h | 6 +- MachineCalc.cpp | 98 ++++++++++++++++++++++++--- Milling.cpp | 155 ++++++++++++++++++++++++++++++++++--------- Milling.h | 2 + MillingData.cpp | 57 +++++++++++++++- MillingData.h | 9 ++- Operation.cpp | 124 ++++++++++++++++++++++++++-------- Operation.h | 3 +- SawFinishing.cpp | 8 +++ SawFinishing.h | 2 + SawFinishingData.cpp | 27 +++++++- SawFinishingData.h | 4 +- SawRoughing.cpp | 8 +++ SawRoughing.h | 2 + SawRoughingData.cpp | 26 +++++++- SawRoughingData.h | 4 +- Sawing.cpp | 8 +++ Sawing.h | 2 + SawingData.cpp | 26 +++++++- SawingData.h | 4 +- Simulator.cpp | 38 +++++++---- Simulator.h | 2 +- 37 files changed, 593 insertions(+), 110 deletions(-) diff --git a/CamData.h b/CamData.h index ad1b0bf..8611541 100644 --- a/CamData.h +++ b/CamData.h @@ -97,7 +97,7 @@ class CamData : public IUserObj { return m_dMachRad ; } const double GetAxesAngCen( void) const { return m_dMachAngCen ; } - const Vector3d& GetAxisNormDir( void) const + const Vector3d& GetAxesNormDir( void) const { return m_vtMachN ; } public : diff --git a/Disposition.cpp b/Disposition.cpp index cda17fc..0756047 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -326,10 +326,10 @@ Disposition::GetTableArea1( BBox3d& b3Area1) const //---------------------------------------------------------------------------- bool -Disposition::Apply(void) +Disposition::Apply( bool bVerifyTab) { // verifico tavola - if ( ! m_bTabOk && ! SetTable( m_sTabName)) + if ( ( ! m_bTabOk || bVerifyTab) && ! SetTable( m_sTabName)) return false ; // aggiornamento sottopezzi for ( auto& FixData : m_vFixData) { diff --git a/Disposition.h b/Disposition.h index f3a4260..6fb51b9 100644 --- a/Disposition.h +++ b/Disposition.h @@ -65,6 +65,8 @@ class Disposition : public Operation const std::string& GetHeadName( void) const ; int GetExitNbr( void) const ; const std::string& GetToolTcPos( void) const ; + int GetSolCh( void) const override + { return 0 ; } bool AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP) override { return true ; } @@ -73,7 +75,7 @@ class Disposition : public Operation public : bool SetTable( const std::string& sTable) ; - bool Apply( void) ; + bool Apply( bool bVerifyTab) ; bool IsSetTableName( void) const { return ! m_sTabName.empty() ; } bool GetTable( std::string& sTable) const ; diff --git a/Drilling.cpp b/Drilling.cpp index b5fcc1e..f125e6e 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -221,6 +221,11 @@ Drilling::SetParam( int nType, int nVal) case MPA_SUBTYPE : m_Params.m_nSubType = nVal ; return true ; + case MPA_SCC : + if ( ! m_Params.VerifySolCh( nVal)) + return false ; + m_Params.m_nSolCh = nVal ; + return true ; } return false ; } @@ -954,6 +959,9 @@ Drilling::GetParam( int nType, int& nVal) const case MPA_SUBTYPE : nVal = m_Params.m_nSubType ; return true ; + case MPA_SCC : + nVal = m_Params.m_nSolCh ; + return true ; } return false ; } diff --git a/Drilling.h b/Drilling.h index 27562e7..dcb9a51 100644 --- a/Drilling.h +++ b/Drilling.h @@ -38,6 +38,8 @@ class Drilling : public Machining { return ( m_nDrillings == 0) ; } protected : // Operation + int GetSolCh( void) const override + { return m_Params.m_nSolCh ; } bool AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP) override ; public : // Machining diff --git a/DrillingData.cpp b/DrillingData.cpp index cc53a46..8f52ad4 100644 --- a/DrillingData.cpp +++ b/DrillingData.cpp @@ -17,6 +17,7 @@ #include "MachiningDataFactory.h" #include "MachiningConst.h" #include "/EgtDev/Include/EmkToolConst.h" +#include "/EgtDev/Include/EmkSimuGenConst.h" #include "/EgtDev/Include/EGnStringUtils.h" #include #include @@ -44,6 +45,7 @@ enum nDrillingKey { KEY_PS, KEY_S, KEY_SAL, + KEY_SCC, KEY_ST, KEY_SUBTYPE, KEY_TNAME, @@ -71,6 +73,7 @@ static const std::array sDrillingKey = { "PS", "S", "SAL", + "SCC", "ST", "SUB", "TN", @@ -110,6 +113,7 @@ DrillingData::CopyFrom( const MachiningData* pMdata) // eseguo copia m_Uuid = pDdata->m_Uuid ; m_sName = pDdata->m_sName ; + m_nSolCh = pDdata->m_nSolCh ; m_ToolUuid = pDdata->m_ToolUuid ; m_sToolName = pDdata->m_sToolName ; m_dSpeed = pDdata->m_dSpeed ; @@ -151,6 +155,7 @@ DrillingData::SameAs(const MachiningData* pMdata) const m_sName == pDdata->m_sName && m_ToolUuid == pDdata->m_ToolUuid && m_sToolName == pDdata->m_sToolName && + m_nSolCh == pDdata->m_nSolCh && abs( m_dSpeed - pDdata->m_dSpeed) < EPS_MACH_ANG_PAR && abs( m_dFeed - pDdata->m_dFeed) < EPS_MACH_LEN_PAR && abs( m_dEndFeed - pDdata->m_dEndFeed) < EPS_MACH_LEN_PAR && @@ -273,6 +278,9 @@ DrillingData::FromString( const string& sString, int& nKey) case KEY_SAL : bOk = ::FromString( sVal, m_dStartAddLen) ; break ; + case KEY_SCC : + bOk = ::FromString( sVal, m_nSolCh) ; + break ; case KEY_ST : bOk = ::FromString( sVal, m_dStep) ; break ; @@ -319,6 +327,7 @@ DrillingData::ToString( int nKey) const case KEY_PS : return ( sDrillingKey[KEY_PS] + "=" + ::ToString( m_dStartPos)) ; case KEY_S : return ( sDrillingKey[KEY_S] + "=" + ::ToString( m_dSpeed)) ; case KEY_SAL : return ( sDrillingKey[KEY_SAL] + "=" + ::ToString( m_dStartAddLen)) ; + case KEY_SCC : return ( sDrillingKey[KEY_SCC] + "=" + ::ToString( m_nSolCh)) ; case KEY_ST : return ( sDrillingKey[KEY_ST] + "=" + ::ToString( m_dStep)) ; case KEY_TNAME : return ( sDrillingKey[KEY_TNAME] + "=" + m_sToolName) ; case KEY_TUUID : return ( sDrillingKey[KEY_TUUID] + "=" + ::ToString( m_ToolUuid)) ; @@ -334,7 +343,14 @@ DrillingData::IsOptional( int nKey) const { return ( nKey == KEY_EAL || nKey == KEY_F || nKey == KEY_FE || nKey == KEY_FS || nKey == KEY_FT || nKey == KEY_NNS || nKey == KEY_NNU || nKey == KEY_S || nKey == KEY_SAL || - nKey == KEY_SUBTYPE || nKey == KEY_OFF || nKey == KEY_OVL) ; + nKey == KEY_SUBTYPE || nKey == KEY_OFF || nKey == KEY_OVL || nKey == KEY_SCC) ; +} + +//---------------------------------------------------------------------------- +bool +DrillingData::VerifySolCh( int nVal) const +{ + return IsValidOperationScc( nVal) ; } //---------------------------------------------------------------------------- @@ -382,6 +398,11 @@ DrillingData::SetParam( int nType, int nVal) case MPA_SUBTYPE : m_nSubType = nVal ; return true ; + case MPA_SCC : + if ( ! VerifySolCh( nVal)) + return false ; + m_nSolCh = nVal ; + return true ; } return false ; } @@ -509,6 +530,9 @@ DrillingData::GetParam( int nType, int& nVal) const case MPA_SUBTYPE : nVal = m_nSubType ; return true ; + case MPA_SCC : + nVal = m_nSolCh ; + return true ; } return false ; } diff --git a/DrillingData.h b/DrillingData.h index 282a3e7..a46a820 100644 --- a/DrillingData.h +++ b/DrillingData.h @@ -20,6 +20,7 @@ struct DrillingData : public MachiningData { EgtUUID m_ToolUuid ; // identificativo universale dell'utensile std::string m_sToolName ; // nome dell'utensile + int m_nSolCh ; // criterio scelta soluzione (quando possibili molteplici) double m_dSpeed ; // velocità di rotazione (+ se CCW, - se CW) ( se 0 da utensile) double m_dFeed ; // velocità di lavorazione normale ( se 0 da utensile) double m_dStartFeed ; // velocità di lavorazione iniziale ( se 0 da utensile) @@ -42,7 +43,7 @@ struct DrillingData : public MachiningData std::string m_sUserNotes ; // note dell'utente DrillingData( void) - : m_ToolUuid(), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), + : m_ToolUuid(), m_nSolCh( 0), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), m_bInvert( false), m_dStartPos( 0), m_dStartSlowLen( 0), m_dEndSlowLen( 0), m_dThroughAddLen( 0), m_dStep( 0), m_dReturnPos( 0), m_nSubType(0), m_dStartAddLen(0), m_dEndAddLen( 0) {} @@ -67,6 +68,7 @@ struct DrillingData : public MachiningData bool GetParam( int nType, std::string& sVal) const override ; bool GetTool( const ToolsMgr* pToolsMgr, const ToolData*& pTdata) const override ; bool VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const override ; + bool VerifySolCh( int nVal) const ; } ; //---------------------------------------------------------------------------- diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 0d30e26e3aec60b94f731869af5cf1ec91bf192a..ac5e38435c90b5c13857d5abb4ab774996f5033e 100644 GIT binary patch delta 97 zcmZpRX^YwLhmFx<^ItYwW=4z2j>5W|vxM9jH?QON0rG*u7nvrX5iEd9O=7{OSQ@Kh Hr8(RHS3w|Z delta 97 zcmZpRX^YwLhmFyE^ItYwW=8YLj>5W|vxM9jH?QON0rG*u7nvrX5iEd9O=7{OSQ@Kh Hr8(RHRjnXm diff --git a/Head.cpp b/Head.cpp index c5b4938..f3594d2 100644 --- a/Head.cpp +++ b/Head.cpp @@ -115,7 +115,10 @@ Head::Set( const string& sName, int nType, const string& sHSet, const Vector3d& m_vtADir = vtADir ; m_dRot1W = dRot1W ; m_Rot2Stroke = Rot2Stroke ; - m_nSolCh = nSolCh ; + if ( IsValidHeadScc( nSolCh)) + m_nSolCh = nSolCh ; + else + m_nSolCh = MCH_SCC_NONE ; return true ; } diff --git a/MachMgr.h b/MachMgr.h index b01a360..0dd535c 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -242,7 +242,7 @@ class MachMgr : public IMachMgr bool GetCalcPositions( const Point3d& ptP, DBLVECTOR& vAng, int& nStat, double& dX, double& dY, double& dZ) ; bool GetCalcTipFromPositions( double dX, double dY, double dZ, double dAngA, double dAngB, - bool bBottom, Point3d& ptTip) override ; + bool bOverall, bool bBottom, Point3d& ptTip) override ; bool GetCalcToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) override ; bool GetNearestAngleInStroke( int nId, double dAngRef, double& dAng) override ; bool VerifyOutstroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) override ; @@ -307,6 +307,7 @@ class MachMgr : public IMachMgr bool ApplyRotAxisBlock( void) ; bool IsKinematicRotAxisBlocked( int nInd) ; double GetCalcRot1W( void) ; + bool SetCalcSolCh( int nScc) ; // operations bool GetOperationNewName( std::string& sName) const ; const ToolData* GetMachiningToolData( void) const ; diff --git a/MachMgrBasic.cpp b/MachMgrBasic.cpp index e86cdca..b171887 100644 --- a/MachMgrBasic.cpp +++ b/MachMgrBasic.cpp @@ -139,7 +139,7 @@ bool MachMgr::Insert( int nInsGrp) { // cerco MachBase nel gruppo di inserimento - int nInsMachBaseId = FindMachBase( nInsGrp) ; + int nInsMachBaseId = FindMachBase( nInsGrp) ; if ( nInsMachBaseId == GDB_ID_NULL) return true ; // verifica ed eventuale creazione del gruppo base per le lavorazioni diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index 4e5ac61..676d4b5 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -301,6 +301,17 @@ MachMgr::IsKinematicRotAxisBlocked( int nInd) return ( ( pMch != nullptr) ? pMch->IsKinematicRotAxisBlocked( nInd) : false) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::SetCalcSolCh( int nScc) +{ + Machine* pMch = GetCurrMachine() ; + if ( pMch == nullptr) + return false ; + // imposto il criterio di scelta della soluzione + return pMch->SetSolCh( nScc) ; +} + //---------------------------------------------------------------------------- bool MachMgr::GetCalcTool( string& sTool) @@ -389,10 +400,10 @@ MachMgr::GetCalcPositions( const Point3d& ptP, DBLVECTOR& vAng, //---------------------------------------------------------------------------- bool MachMgr::GetCalcTipFromPositions( double dX, double dY, double dZ, double dAngA, double dAngB, - bool bBottom, Point3d& ptTip) + bool bOverall, bool bBottom, Point3d& ptTip) { Machine* pMch = GetCurrMachine() ; - return ( ( pMch != nullptr) ? pMch->GetTipFromPositions( dX, dY, dZ, dAngA, dAngB, bBottom, ptTip) : false) ; + return ( ( pMch != nullptr) ? pMch->GetTipFromPositions( dX, dY, dZ, dAngA, dAngB, bOverall, bBottom, ptTip) : false) ; } //---------------------------------------------------------------------------- diff --git a/MachMgrParts.cpp b/MachMgrParts.cpp index 46a4417..840ceeb 100644 --- a/MachMgrParts.cpp +++ b/MachMgrParts.cpp @@ -75,8 +75,11 @@ MachMgr::AddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) // verifica validità grezzo if ( ! VerifyRawPart( nRawId)) return false ; - // verifico che il pezzo non sia già usato nella macchinata corrente - if ( m_pGeomDB->GetParentId( nPartId) != GDB_ID_ROOT) + // verifico che il pezzo sia tale e non sia già usato nella macchinata corrente + int nLevel ; + if ( m_pGeomDB->GetGdbType( nPartId) != GDB_TY_GROUP || + m_pGeomDB->GetParentId( nPartId) != GDB_ID_ROOT || + ( m_pGeomDB->GetCalcLevel( nPartId, nLevel) && nLevel != GDB_LV_USER)) return false ; // recupero il box del solido del grezzo in locale int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; diff --git a/MachMgrPhases.cpp b/MachMgrPhases.cpp index 20458c0..6b7f2fe 100644 --- a/MachMgrPhases.cpp +++ b/MachMgrPhases.cpp @@ -121,7 +121,9 @@ MachMgr::PrepareCurrPhase( int nPhase, bool bDoDisp, bool bForced) } if ( pDisp != nullptr) { pDisp->Init( this) ; - if ( pDisp->IsSetTableName() && ! pDisp->Apply()) + // se impostazione fase per impostazione gruppo di lavoro forzo verifica tavola + bool bVerifyTable = ( m_nCurrPhase == 0) ; + if ( pDisp->IsSetTableName() && ! pDisp->Apply( bVerifyTable)) return false ; } else diff --git a/Machine.cpp b/Machine.cpp index cd7ed9c..46a4c07 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -45,6 +45,8 @@ Machine::Machine( void) m_nCalcSolCh = MCH_SCC_NONE ; m_dCalcTLen = 0 ; m_dCalcTRad = 0 ; + m_dCalcTOvLen = 0 ; + m_dCalcTOvRad = 0 ; } //---------------------------------------------------------------------------- diff --git a/Machine.h b/Machine.h index ec36b5a..053d834 100644 --- a/Machine.h +++ b/Machine.h @@ -77,9 +77,11 @@ class Machine bool FreeKinematicRotAxis( const std::string& sName) ; bool FreeKinematicRotAxis( int nId) ; bool IsKinematicRotAxisBlocked( int nInd) ; + bool SetSolCh( int nScc) ; int GetCurrLinAxes( void) const ; int GetCurrRotAxes( void) const ; bool GetAllCurrAxesName( STRVECTOR& vAxName) const ; + bool GetCurrAxisHomePos( int nInd, double& dHome) const ; bool GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const ; bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const ; @@ -90,7 +92,7 @@ class Machine bool GetPositions( const Point3d& ptP, DBLVECTOR vAng, int& nStat, double& dX, double& dY, double& dZ) const ; bool GetTipFromPositions( double dX, double dY, double dZ, double dAngA, double dAngB, - bool bBottom, Point3d& ptTip) const ; + bool bBottom, bool bOverall, Point3d& ptTip) const ; bool GetToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) const ; bool GetNearestAngleInStroke( int nId, double dAngRef, double& dAng) const ; bool VerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng, int& nStat) const ; @@ -208,6 +210,8 @@ class Machine Vector3d m_vtCalcADir ; // direzione ausiliaria a riposo per calcoli double m_dCalcTLen ; // lunghezza utensile corrente per calcoli double m_dCalcTRad ; // raggio utensile corrente per calcoli + double m_dCalcTOvLen ; // lunghezza di ingombro utensile corrente per calcoli + double m_dCalcTOvRad ; // raggio di ingombro utensile corrente per calcoli KINAXISVECTOR m_vCalcLinAx ; // vettore assi lineari attivi per calcoli KINAXISVECTOR m_vCalcRotAx ; // vettore assi rotanti attivi per calcoli mutable std::string m_sOutstrokeInfo ; // informazioni su ultimo extra corsa diff --git a/MachineCalc.cpp b/MachineCalc.cpp index c808774..f312736 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -121,6 +121,8 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) m_nCalcSolCh = MCH_SCC_NONE ; m_dCalcTLen = 0 ; m_dCalcTRad = 0 ; + m_dCalcTOvLen = 0 ; + m_dCalcTOvRad = 0 ; // recupero il gruppo della testa int nHeadId = GetGroup( sHead) ; // recupero i dati della testa @@ -144,6 +146,8 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) int nToolId = GDB_ID_NULL ; double dTLen = 0 ; double dTDiam = 0 ; + double dTOvLen = 0 ; + double dTOvDiam = 0 ; // se definito if ( ! sTool.empty()) { if ( ! LoadTool( sHead, nExit, sTool)) @@ -153,7 +157,9 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) return false ; if ( ! m_pMchMgr->TdbSetCurrTool( sTool) || ! m_pMchMgr->TdbGetCurrToolParam( TPA_LEN, dTLen) || - ! m_pMchMgr->TdbGetCurrToolParam( TPA_DIAM, dTDiam)) + ! m_pMchMgr->TdbGetCurrToolParam( TPA_DIAM, dTDiam) || + ! m_pMchMgr->TdbGetCurrToolParam( TPA_TOTLEN, dTOvLen) || + ! m_pMchMgr->TdbGetCurrToolParam( TPA_TOTDIAM, dTOvDiam)) return false ; } // altrimenti casi speciali senza utensile @@ -164,6 +170,8 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) nToolId = GDB_ID_NULL ; dTLen = 0 ; dTDiam = 0 ; + dTOvLen = 0 ; + dTOvDiam = 0 ; m_pMchMgr->TdbSetCurrTool( sTool) ; } // assegno tutti i dati @@ -177,6 +185,8 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) m_vtCalcADir = pHead->GetADir() ; m_dCalcTLen = dTLen ; m_dCalcTRad = dTDiam / 2 ; + m_dCalcTOvLen = dTOvLen ; + m_dCalcTOvRad = dTOvDiam / 2 ; // lancio eventuale funzione lua di personalizzazione if ( LuaExistsFunction( ON_SET_HEAD)) { bool bOk = LuaCreateGlobTable( EMC_VAR) ; @@ -448,6 +458,47 @@ Machine::IsKinematicRotAxisBlocked( int nInd) return m_vCalcRotAx[nInd].bFixed ; } +//---------------------------------------------------------------------------- +bool +Machine::SetSolCh( int nScc) +{ + // se standard o suo opposto + if ( nScc == MCH_SCC_STD || nScc == MCH_SCC_OPPOSITE) { + // recupero i dati della testa + Head* pHead = GetHead( m_nCalcHeadId) ; + if ( pHead == nullptr) { + LOG_INFO( GetEMkLogger(), "Missing head in SetSolCh") + return false ; + } + // assegno il criterio definito nella testa (standard) + m_nCalcSolCh = pHead->GetSolCh() ; + if ( nScc == MCH_SCC_STD) + return true ; + // essendo opposto, devo invertirlo + switch ( m_nCalcSolCh) { + case MCH_SCC_NONE : break ; + case MCH_SCC_ADIR_XP : m_nCalcSolCh = MCH_SCC_ADIR_XM ; break ; + case MCH_SCC_ADIR_XM : m_nCalcSolCh = MCH_SCC_ADIR_XP ; break ; + case MCH_SCC_ADIR_YP : m_nCalcSolCh = MCH_SCC_ADIR_YM ; break ; + case MCH_SCC_ADIR_YM : m_nCalcSolCh = MCH_SCC_ADIR_YP ; break ; + case MCH_SCC_ADIR_ZP : m_nCalcSolCh = MCH_SCC_ADIR_ZM ; break ; + case MCH_SCC_ADIR_ZM : m_nCalcSolCh = MCH_SCC_ADIR_ZP ; break ; + case MCH_SCC_ADIR_NEAR : m_nCalcSolCh = MCH_SCC_ADIR_FAR ; break ; + case MCH_SCC_ADIR_FAR : m_nCalcSolCh = MCH_SCC_ADIR_NEAR ; break ; + default : m_nCalcSolCh = MCH_SCC_NONE ; break ; + } + return true ; + } + // altri casi + if ( IsValidHeadScc( nScc)) { + m_nCalcSolCh = nScc ; + return true ; + } + // non previsto + m_nCalcSolCh = MCH_SCC_NONE ; + return false ; +} + //---------------------------------------------------------------------------- bool Machine::GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, @@ -881,7 +932,7 @@ Machine::GetDirection( const Vector3d& vtDir, double dAngA, double dAngB, Vector //---------------------------------------------------------------------------- bool Machine::GetTipFromPositions( double dX, double dY, double dZ, double dAngA, double dAngB, - bool bBottom, Point3d& ptTip) const + bool bOverall, bool bBottom, Point3d& ptTip) const { // la posizione deve essere espressa rispetto allo ZERO MACCHINA // per ora gestisco solo gli assi rotanti di testa @@ -893,18 +944,24 @@ Machine::GetTipFromPositions( double dX, double dY, double dZ, double dAngA, dou return false ; ptTip.Set( dX - dRecX, dY - dRecY, dZ - dRecZ) ; - // Se richiesto punto sotto del tip utensile - if ( bBottom) { + // Se richiesto ingombro totale o punto sotto del tip utensile + if ( bOverall || bBottom) { // calcolo la direzione fresa Vector3d vtDirT ; if ( ! GetDirection( m_vtCalcDir, dAngA, dAngB, vtDirT)) return false ; - // se direzione fresa non esattamente verticale, esiste un punto più basso del'utensile - if ( ! vtDirT.IsZplus() && ! vtDirT.IsZminus()) { + // se richiesto ingombro totale + if ( bOverall) + ptTip -= vtDirT * max( m_dCalcTOvLen - m_dCalcTLen, 0.) ; + // se richiesto punto più basso e direzione fresa non esattamente verticale + if ( bBottom && ! vtDirT.IsZplus() && ! vtDirT.IsZminus()) { // calcolo la direzione perpendicolare più verticale possibile Vector3d vtCorr = FromUprightOrtho( vtDirT) ; // correggo il tip - ptTip -= vtCorr * m_dCalcTRad ; + if ( bOverall) + ptTip -= vtCorr * max( m_dCalcTOvRad, m_dCalcTRad) ; + else + ptTip -= vtCorr * m_dCalcTRad ; } } @@ -938,9 +995,9 @@ Machine::VerifyScc( const Vector3d& vtDirI, const Vector3d& vtDirA, int nSolCh) case MCH_SCC_ADIR_ZM : return ( vtDirI.z < EPS_ZERO) ; case MCH_SCC_ADIR_NEAR : - return ( ( vtDirI * vtDirA) > cos( 60 * DEGTORAD)) ; + return ( vtDirA.IsSmall() || ( vtDirI * vtDirA) > cos( 60 * DEGTORAD)) ; case MCH_SCC_ADIR_FAR : - return ( ( vtDirI * vtDirA) < cos( 120 * DEGTORAD)) ; + return ( vtDirA.IsSmall() || ( vtDirI * vtDirA) < cos( 120 * DEGTORAD)) ; } } @@ -1052,6 +1109,29 @@ Machine::GetAllCurrAxesName( STRVECTOR& vAxName) const return bOk ; } +//---------------------------------------------------------------------------- +bool +Machine::GetCurrAxisHomePos( int nInd, double& dHome) 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 ; + dHome = pAx->GetHomeVal() ; + return true ; + } + else if ( nInd >= nLinAxes && nInd < nLinAxes + nRotAxes) { + Axis* pAx = GetAxis( m_vCalcRotAx[nInd-nLinAxes].nGrpId) ; + if ( pAx == nullptr) + return false ; + dHome = pAx->GetHomeVal() ; + return true ; + } + return false ; +} + //---------------------------------------------------------------------------- bool Machine::GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const diff --git a/Milling.cpp b/Milling.cpp index 4bb22ca..c0f7cd6 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -222,6 +222,11 @@ Milling::SetParam( int nType, int nVal) return false ; m_Params.m_nLeadOutType = nVal ; return true ; + case MPA_SCC : + if ( ! m_Params.VerifySolCh( nVal)) + return false ; + m_Params.m_nSolCh = nVal ; + return true ; } return false ; } @@ -287,6 +292,12 @@ Milling::SetParam( int nType, double dVal) case MPA_STEP : m_Params.m_dStep = dVal ; return true ; + case MPA_STARTADDLEN : + m_Params.m_dStartAddLen = dVal ; + return true ; + case MPA_ENDADDLEN : + m_Params.m_dEndAddLen = dVal ; + return true ; case MPA_LITANG : m_Params.m_dLiTang = dVal ; return true ; @@ -297,6 +308,18 @@ Milling::SetParam( int nType, double dVal) m_Params.m_dLiElev = dVal ; return true ; case MPA_LICOMPLEN : + m_Params.m_dLiCompLen = dVal ; + return true ; + case MPA_LOTANG : + m_Params.m_dLoTang = dVal ; + return true ; + case MPA_LOPERP : + m_Params.m_dLoPerp = dVal ; + return true ; + case MPA_LOELEV : + m_Params.m_dLoElev = dVal ; + return true ; + case MPA_LOCOMPLEN : m_Params.m_dLoCompLen = dVal ; return true ; } @@ -472,6 +495,9 @@ Milling::GetParam( int nType, int& nVal) const case MPA_LEADOUTTYPE : nVal = m_Params.m_nLeadOutType ; return true ; + case MPA_SCC : + nVal = m_Params.m_nSolCh ; + return true ; } return false ; } @@ -511,6 +537,12 @@ Milling::GetParam( int nType, double& dVal) const case MPA_STEP : dVal = m_Params.m_dStep ; return true ; + case MPA_STARTADDLEN : + dVal = m_Params.m_dStartAddLen ; + return true ; + case MPA_ENDADDLEN : + dVal = m_Params.m_dEndAddLen ; + return true ; case MPA_LITANG : dVal = m_Params.m_dLiTang ; return true ; @@ -521,9 +553,20 @@ Milling::GetParam( int nType, double& dVal) const dVal = m_Params.m_dLiElev ; return true ; case MPA_LICOMPLEN : + dVal = m_Params.m_dLiCompLen ; + return true ; + case MPA_LOTANG : + dVal = m_Params.m_dLoTang ; + return true ; + case MPA_LOPERP : + dVal = m_Params.m_dLoPerp ; + return true ; + case MPA_LOELEV : + dVal = m_Params.m_dLoElev ; + return true ; + case MPA_LOCOMPLEN : dVal = m_Params.m_dLoCompLen ; return true ; - } return false ; } @@ -608,8 +651,12 @@ Milling::VerifyGeometry( SelData Id, int& nSubs) // se direttamente la curva if ( Id.nSub == SEL_SUB_ALL) { pCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ; - if ( pCurve != nullptr && pCurve->GetType() == CRV_COMPO) - nSubs = ::GetCurveComposite( pCurve)->GetCurveCount() ; + if ( pCurve != nullptr) { + if ( pCurve->GetType() == CRV_COMPO) + nSubs = ::GetCurveComposite( pCurve)->GetCurveCount() ; + else + nSubs = 0 ; + } } // altrimenti sottocurva di composita else { @@ -809,14 +856,39 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) return false ; ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( nCopyId)) ; - // unisco le parti allineate - //if ( ! pCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL)) - // return false ; + // unisco le parti allineate (tranne inizio-fine se chiusa) + if ( ! pCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, false)) + return false ; // eventuale inversione percorso if ( m_Params.m_bInvert) pCompo->Invert() ; + // eventuale allungamento/accorciamento dell'inizio + if ( abs( m_Params.m_dStartAddLen) > EPS_SMALL) { + if ( m_Params.m_dStartAddLen > 0) { + if ( ! pCompo->ExtendStartByLen( m_Params.m_dStartAddLen)) + return false ; + } + else { + if ( ! pCompo->TrimStartAtLen( - m_Params.m_dStartAddLen)) + return false ; + } + } + + // eventuale allungamento/accorciamento della fine + if ( abs( m_Params.m_dEndAddLen) > EPS_SMALL) { + if ( m_Params.m_dEndAddLen > 0) { + if ( ! pCompo->ExtendEndByLen( m_Params.m_dEndAddLen)) + return false ; + } + else { + double dLen ; + if ( ! pCompo->GetLength( dLen) || ! pCompo->TrimEndAtLen( dLen + m_Params.m_dEndAddLen)) + return false ; + } + } + // se utensile non centrato, eseguo correzione raggio utensile ed eventuale offset double dOffs = 0.5 * m_TParams.m_dTDiam + GetOffsR() ; if ( m_Params.m_nWorkSide != MILL_WS_CENTER && abs( dOffs) > EPS_SMALL) { @@ -841,12 +913,14 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) } // recupero distanza da fondo dei grezzi interessati dal percorso - double dRbDist ; - if ( ! GetDistanceFromRawBottom( m_nPhase, nCopyId, 2 * m_TParams.m_dThick, dRbDist)) - return false ; + double dRbDist = 0 ; + if ( AreSameVectorApprox( vtExtr, Z_AX)) { + if ( ! GetDistanceFromRawBottom( m_nPhase, nCopyId, m_TParams.m_dDiam, dRbDist)) + return false ; + } // valuto l'espressione dell'affondamento - ExeLuaSetGlobNumVar( "TH", (( dThick * vtExtr.z < 0) ? fabs( dThick) : 0)) ; + ExeLuaSetGlobNumVar( "TH", ( dThick >= 0 ? 0 : -dThick)) ; ExeLuaSetGlobNumVar( "RB", dRbDist) ; double dDepth ; if ( ! ExeLuaEvalNumExpr( m_Params.m_sDepth, &dDepth)) { @@ -918,7 +992,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) LOG_INFO( GetEMkLogger(), "Error in Milling : Entity GetElevation") ; return false ; } - if ( dElev < EPS_SMALL) { + if ( dElev < EPS_SMALL && AreSameVectorApprox( vtExtr, Z_AX)) { BBox3d b3Crv ; pCurve->GetLocalBBox( b3Crv) ; dElev = max( 0., b3Raw.GetMax().z - b3Crv.GetMin().z) ; @@ -934,14 +1008,23 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) Point3d ptP1 ; if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1)) return false ; - // aggiungo approccio - if ( ! AddApproach( ptP1, vtTool, dSafeZ, dElev, dAppr)) - return false ; - // affondo al punto iniziale - SetFlag( 0) ; - SetFeed( GetTipFeed()) ; - if ( AddLinearMove( ptP1) == GDB_ID_NULL) - return false ; + // aggiungo approccio per frese normali + if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) { + if ( ! AddApproach( ptP1, vtTool, dSafeZ, dElev, dAppr)) + return false ; + // affondo al punto iniziale + SetFlag( 0) ; + SetFeed( GetTipFeed()) ; + if ( AddLinearMove( ptP1) == GDB_ID_NULL) + return false ; + } + // altrimenti, approccio per lame + else { + // affondo al punto iniziale + SetFlag( 0) ; + if ( AddRapidStart( ptP1) == GDB_ID_NULL) + return false ; + } // aggiungo attacco SetFeed( GetStartFeed()) ; if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr)) { @@ -982,9 +1065,13 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) LOG_INFO( GetEMkLogger(), "Error in Milling : LeadOut not computable") ; return false ; } - // aggiungo retrazione - if ( ! AddRetract( ptP1, vtTool, dSafeZ, dElev, dAppr)) - return false ; + // aggiungo retrazione per frese normali + if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) { + // aggiungo retrazione + if ( ! AddRetract( ptP1, vtTool, dSafeZ, dElev, dAppr)) + return false ; + } + // per lame non è necessario } } @@ -999,7 +1086,7 @@ bool Milling::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) { // se distanza di sicurezza minore di distanza di inizio - if ( dSafeZ < m_Params.m_dStartPos + 10 * EPS_SMALL) { + if ( dSafeZ < dAppr + 10 * EPS_SMALL) { // 1 -> punto sopra inizio SetFlag( 1) ; Point3d ptP1 = ptP + vtTool * ( dElev + dAppr) ; @@ -1010,13 +1097,15 @@ Milling::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, // 1a -> punto sopra inizio SetFlag( 1) ; Point3d ptP1b = ptP + vtTool * ( dElev + dAppr) ; - Point3d ptP1a = ptP1b + vtTool * ( dSafeZ - m_Params.m_dStartPos) ; + Point3d ptP1a = ptP1b + vtTool * ( dSafeZ - dAppr) ; if ( AddRapidStart( ptP1a) == GDB_ID_NULL) return false ; // 1b -> punto appena sopra inizio - SetFlag( 0) ; - if ( AddRapidMove( ptP1b) == GDB_ID_NULL) - return false ; + if ( ( dElev + dAppr) > EPS_SMALL) { + SetFlag( 0) ; + if ( AddRapidMove( ptP1b) == GDB_ID_NULL) + return false ; + } } return true ; } @@ -1025,7 +1114,7 @@ Milling::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, bool Milling::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) { - if ( dSafeZ < m_Params.m_dStartPos + 10 * EPS_SMALL) { + if ( dSafeZ < dAppr + 10 * EPS_SMALL) { // 4 -> movimento di risalita sopra il punto finale SetFeed( GetEndFeed()) ; Point3d ptP4 = ptP + vtTool * ( dElev + dAppr) ; @@ -1034,12 +1123,14 @@ Milling::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, } else { // 4a -> movimento di risalita appena sopra il punto finale - SetFeed( GetEndFeed()) ; Point3d ptP4a = ptP + vtTool * ( dElev + dAppr) ; - if ( AddLinearMove( ptP4a) == GDB_ID_NULL) - return false ; + if ( dElev + dAppr > EPS_SMALL) { + SetFeed( GetEndFeed()) ; + if ( AddLinearMove( ptP4a) == GDB_ID_NULL) + return false ; + } // 4b -> movimento di risalita sopra il punto finale - Point3d ptP4b = ptP4a + vtTool * ( dSafeZ - m_Params.m_dStartPos) ; + Point3d ptP4b = ptP4a + vtTool * ( dSafeZ - dAppr) ; if ( AddRapidMove( ptP4b) == GDB_ID_NULL) return false ; } diff --git a/Milling.h b/Milling.h index 28af8d9..0f89933 100644 --- a/Milling.h +++ b/Milling.h @@ -36,6 +36,8 @@ class Milling : public Machining { return ( m_nMills == 0) ; } protected : // Operation + int GetSolCh( void) const override + { return m_Params.m_nSolCh ; } bool AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP) override ; public : // Machining diff --git a/MillingData.cpp b/MillingData.cpp index 3e172c0..e680669 100644 --- a/MillingData.cpp +++ b/MillingData.cpp @@ -17,6 +17,7 @@ #include "MachiningDataFactory.h" #include "MachiningConst.h" #include "/EgtDev/Include/EmkToolConst.h" +#include "/EgtDev/Include/EmkSimuGenConst.h" #include "/EgtDev/Include/EGnStringUtils.h" #include #include @@ -26,6 +27,7 @@ using namespace std ; //---------------------------------------------------------------------------- enum nMillingKey { KEY_DH = 0, + KEY_EAL, KEY_F, KEY_FE, KEY_FS, @@ -51,6 +53,8 @@ enum nMillingKey { KEY_PS, KEY_S, KEY_SA, + KEY_SAL, + KEY_SCC, KEY_ST, KEY_STY, KEY_TA, @@ -65,6 +69,7 @@ enum nMillingKey { static const std::array sMillingKey = { "DH", + "EAL", "F", "FE", "FS", @@ -90,6 +95,8 @@ static const std::array sMillingKey = { "PS", "S", "SA", + "SAL", + "SCC", "ST", "STY", "TA", @@ -136,6 +143,7 @@ MillingData::CopyFrom( const MachiningData* pMdata) m_sName = pSdata->m_sName ; m_ToolUuid = pSdata->m_ToolUuid ; m_sToolName = pSdata->m_sToolName ; + m_nSolCh = pSdata->m_nSolCh ; m_dSpeed = pSdata->m_dSpeed ; m_dFeed = pSdata->m_dFeed ; m_dEndFeed = pSdata->m_dEndFeed ; @@ -151,6 +159,8 @@ MillingData::CopyFrom( const MachiningData* pMdata) m_dStep = pSdata->m_dStep ; m_nStepType = pSdata->m_nStepType ; m_dSideAngle = pSdata->m_dSideAngle ; + m_dStartAddLen = pSdata->m_dStartAddLen ; + m_dEndAddLen = pSdata->m_dEndAddLen ; m_bLeaveTab = pSdata->m_bLeaveTab ; m_dTabLen = pSdata->m_dTabLen ; m_dTabDist = pSdata->m_dTabDist ; @@ -187,6 +197,7 @@ MillingData::SameAs(const MachiningData* pMdata) const m_sName == pSdata->m_sName && m_ToolUuid == pSdata->m_ToolUuid && m_sToolName == pSdata->m_sToolName && + m_nSolCh == pSdata->m_nSolCh && abs( m_dSpeed - pSdata->m_dSpeed) < EPS_MACH_ANG_PAR && abs( m_dFeed - pSdata->m_dFeed) < EPS_MACH_LEN_PAR && abs( m_dEndFeed - pSdata->m_dEndFeed) < EPS_MACH_LEN_PAR && @@ -202,6 +213,8 @@ MillingData::SameAs(const MachiningData* pMdata) const abs( m_dStep - pSdata->m_dStep) < EPS_MACH_LEN_PAR && m_nStepType == pSdata->m_nStepType && abs( m_dSideAngle - pSdata->m_dSideAngle) < EPS_MACH_ANG_PAR && + abs( m_dStartAddLen - pSdata->m_dStartAddLen) < EPS_MACH_LEN_PAR && + abs( m_dEndAddLen - pSdata->m_dEndAddLen) < EPS_MACH_LEN_PAR && m_bLeaveTab == pSdata->m_bLeaveTab && abs( m_dTabLen - pSdata->m_dTabLen) < EPS_MACH_LEN_PAR && abs( m_dTabDist - pSdata->m_dTabDist) < EPS_MACH_LEN_PAR && @@ -262,6 +275,9 @@ MillingData::FromString( const string& sString, int& nKey) if ( m_sDepth.empty()) m_sDepth = "0" ; break ; + case KEY_EAL : + bOk = ::FromString( sVal, m_dEndAddLen) ; + break ; case KEY_F : bOk = ::FromString( sVal, m_dFeed) ; break ; @@ -338,6 +354,12 @@ MillingData::FromString( const string& sString, int& nKey) case KEY_SA : bOk = ::FromString( sVal, m_dSideAngle) ; break ; + case KEY_SAL : + bOk = ::FromString( sVal, m_dStartAddLen) ; + break ; + case KEY_SCC : + bOk = ::FromString( sVal, m_nSolCh) ; + break ; case KEY_ST : bOk = ::FromString( sVal, m_dStep) ; break ; @@ -381,6 +403,7 @@ MillingData::ToString( int nInd) const { switch ( nInd) { case KEY_DH : return ( sMillingKey[KEY_DH] + "=" + m_sDepth) ; + case KEY_EAL : return ( sMillingKey[KEY_EAL] + "=" + ::ToString( m_dEndAddLen)) ; case KEY_F : return ( sMillingKey[KEY_F] + "=" + ::ToString( m_dFeed)) ; case KEY_FE : return ( sMillingKey[KEY_FE] + "=" + ::ToString( m_dEndFeed)) ; case KEY_FS : return ( sMillingKey[KEY_FS] + "=" + ::ToString( m_dStartFeed)) ; @@ -406,6 +429,8 @@ MillingData::ToString( int nInd) const case KEY_PS : return ( sMillingKey[KEY_PS] + "=" + ::ToString( m_dStartPos)) ; case KEY_S : return ( sMillingKey[KEY_S] + "=" + ::ToString( m_dSpeed)) ; case KEY_SA : return ( sMillingKey[KEY_SA] + "=" + ::ToString( m_dSideAngle)) ; + case KEY_SAL : return ( sMillingKey[KEY_SAL] + "=" + ::ToString( m_dStartAddLen)) ; + case KEY_SCC : return ( sMillingKey[KEY_SCC] + "=" + ::ToString( m_nSolCh)) ; case KEY_ST : return ( sMillingKey[KEY_ST] + "=" + ::ToString( m_dStep)) ; case KEY_STY : return ( sMillingKey[KEY_STY] + "=" + ::ToString( m_nStepType)) ; case KEY_TA : return ( sMillingKey[KEY_TA] + "=" + ::ToString( m_dTabAngle)) ; @@ -424,8 +449,16 @@ MillingData::ToString( int nInd) const bool MillingData::IsOptional( int nKey) const { - return ( nKey == KEY_F || nKey == KEY_FE || nKey == KEY_FS || nKey == KEY_FT || - nKey == KEY_NNS || nKey == KEY_NNU || nKey == KEY_OL || nKey == KEY_OR || nKey == KEY_S) ; + return ( nKey == KEY_EAL || nKey == KEY_F || nKey == KEY_FE || nKey == KEY_FS || nKey == KEY_FT || + nKey == KEY_NNS || nKey == KEY_NNU || nKey == KEY_OL || nKey == KEY_OR || nKey == KEY_S || + nKey == KEY_SAL || nKey == KEY_SCC) ; +} + +//---------------------------------------------------------------------------- +bool +MillingData::VerifySolCh( int nVal) const +{ + return IsValidOperationScc( nVal) ; } //---------------------------------------------------------------------------- @@ -529,6 +562,11 @@ MillingData::SetParam( int nType, int nVal) return false ; m_nLeadOutType = nVal ; return true ; + case MPA_SCC : + if ( ! VerifySolCh( nVal)) + return false ; + m_nSolCh = nVal ; + return true ; } return false ; } @@ -576,6 +614,12 @@ MillingData::SetParam( int nType, double dVal) return false ; m_dSideAngle = dVal ; return true ; + case MPA_STARTADDLEN : + m_dStartAddLen = dVal ; + return true ; + case MPA_ENDADDLEN : + m_dEndAddLen = dVal ; + return true ; case MPA_TABLEN : m_dTabLen = dVal ; return true ; @@ -688,6 +732,9 @@ MillingData::GetParam( int nType, int& nVal) const case MPA_LEADOUTTYPE : nVal = m_nLeadOutType ; return true ; + case MPA_SCC : + nVal = m_nSolCh ; + return true ; } return false ; } @@ -730,6 +777,12 @@ MillingData::GetParam( int nType, double& dVal) const case MPA_SIDEANGLE : dVal = m_dSideAngle ; return true ; + case MPA_STARTADDLEN : + dVal = m_dStartAddLen ; + return true ; + case MPA_ENDADDLEN : + dVal = m_dEndAddLen ; + return true ; case MPA_TABLEN : dVal = m_dTabLen ; return true ; diff --git a/MillingData.h b/MillingData.h index 8cbe3ba..5d8249d 100644 --- a/MillingData.h +++ b/MillingData.h @@ -20,6 +20,7 @@ struct MillingData : public MachiningData { EgtUUID m_ToolUuid ; // identificativo universale dell'utensile std::string m_sToolName ; // nome dell'utensile + int m_nSolCh ; // criterio scelta soluzione (quando possibili molteplici) double m_dSpeed ; // velocità di rotazione (+ se CCW, - se CW) ( se 0 da utensile) double m_dFeed ; // velocità di lavorazione normale ( se 0 da utensile) double m_dStartFeed ; // velocità di lavorazione iniziale ( se 0 da utensile) @@ -35,6 +36,8 @@ struct MillingData : public MachiningData double m_dStep ; // passo di affondamento (0=nessun passo) int m_nStepType ; // tipo di lavorazione a step (a gradini, una via, a spirale) double m_dSideAngle ; // angolo di sbandamento (0-60deg) + double m_dStartAddLen ; // lunghezza da aggiungere/togliere all'inizio se percorso aperto + double m_dEndAddLen ; // lunghezza da aggiungere/togliere alla fine se percorso aperto bool m_bLeaveTab ; // lasciare i tab double m_dTabLen ; // lunghezza dei tab lasciati per tenere il pezzo double m_dTabDist ; // distanza tra due tab consecutivi @@ -54,9 +57,10 @@ struct MillingData : public MachiningData std::string m_sUserNotes ; // note dell'utente MillingData( void) - : m_ToolUuid(), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), + : m_ToolUuid(), m_nSolCh( 0), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), m_dOffsR( UNKNOWN_PAR), m_dOffsL( UNKNOWN_PAR), m_bInvert( false), m_nWorkSide( 0), - m_dStartPos(0), m_dOverlap( 0), m_dStep( 0), m_nStepType( 0), m_dSideAngle( 0), + m_dStartPos( 0), m_dOverlap( 0), m_dStep( 0), m_nStepType( 0), m_dSideAngle( 0), + m_dStartAddLen( 0), m_dEndAddLen( 0), m_bLeaveTab( false), m_dTabLen( 0), m_dTabDist( 0), m_dTabHeight( 0), m_dTabAngle( 0), m_nLeadInType( 0), m_dLiTang( 0), m_dLiPerp( 0), m_dLiElev( 0), m_dLiCompLen( 0), m_nLeadOutType( 0), m_dLoTang( 0), m_dLoPerp( 0), m_dLoElev( 0), m_dLoCompLen( 0) {} @@ -81,6 +85,7 @@ struct MillingData : public MachiningData bool GetParam( int nType, std::string& sVal) const override ; bool GetTool( const ToolsMgr* pToolsMgr, const ToolData*& pTdata) const override ; bool VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const override ; + bool VerifySolCh( int nVal) const ; bool VerifyWorkSide( int nVal) const ; bool VerifyStepType( int nVal) const ; bool VerifyLeadInType( int nVal) const ; diff --git a/Operation.cpp b/Operation.cpp index 121d717..438ec54 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -476,6 +476,9 @@ Operation::CalculateAxesValues( void) // applico eventuali blocchi di assi rotanti m_pMchMgr->ApplyRotAxisBlock() ; + // applico il criterio di scelta della soluzione quando molteplici + m_pMchMgr->SetCalcSolCh( GetSolCh()) ; + // recupero gruppo della geometria di lavorazione (Cutter Location) int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; if ( nClId == GDB_ID_NULL) @@ -682,7 +685,7 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, const int NUM_VERIF_STEP = 16 ; Point3d ptCen = pCamData->GetAxesCen() ; double dAngCenStep = pCamData->GetAxesAngCen() / NUM_VERIF_STEP ; - Vector3d vtN = pCamData->GetAxisNormDir() ; + Vector3d vtN = pCamData->GetAxesNormDir() ; Vector3d vtCurr = Point3d( dXprec, dYprec, dZprec) - ptCen ; for ( int i = 1 ; i < NUM_VERIF_STEP ; ++ i) { vtCurr.Rotate( vtN, dAngCenStep) ; @@ -744,6 +747,7 @@ Operation::AdjustStartEndMovements(void) // determino posizione precedente assi DBLVECTOR vAxVal ; + bool bHomeZ = false ; // se primo utensile, uso la posizione home if ( sPrevTool.empty()) { // imposto l'utensile per i calcoli macchina @@ -752,6 +756,8 @@ Operation::AdjustStartEndMovements(void) // recupero posizione home if ( ! m_pMchMgr->GetAllCalcAxesHomePos( vAxVal)) return false ; + // si parte da HomeZ + bHomeZ = true ; } // se utensile non cambiato o su diversa uscita della stessa testa, uso posizione finale della lavorazione precedente else if ( ! ToolChangeNeeded( *pPrevOp, *this)) { @@ -764,21 +770,30 @@ Operation::AdjustStartEndMovements(void) DBLVECTOR vAxIni ; if ( ! pPrevOp->GetFinalAxesValues( vAxVal) || ! GetInitialAxesValues( vAxIni)) return false ; - // verifico se la testa interferisce con i pezzi o i bloccaggi sulla tavola - if ( ! TestCollisionAvoid( vAxVal, vAxIni)) { - if ( ! pPrevOp->AddRise( vAxVal)) - return false ; - } // determino delta Z rispetto a posizione finale if ( vAxVal.size() >= 4 && vAxIni.size() >= 4) { + // verifico se movimento assi rotanti richiede una risalita parziale double dDelta = 0 ; if ( ! CalcDeltaZForHeadRotation( vAxVal, vAxIni, dDelta)) return false ; + // se necessaria, aggiungo risalita parziale if ( dDelta > EPS_SMALL) { if ( ! pPrevOp->AddRise( vAxVal, dDelta)) return false ; + // aggiorno quota in Z della posizione iniziale ( anche se verrà aggiornata solo in seguito) + vAxIni[2] = vAxVal[2] ; } } + // verifico se la testa interferisce con i pezzi o i bloccaggi sulla tavola + if ( ! TestCollisionAvoid( vAxVal, vAxIni)) { + // cancello eventuale risalita parziale della lavorazione precedente + pPrevOp->RemoveRise() ; + // aggiungo risalita a Zmax + if ( ! pPrevOp->AddRise( vAxVal)) + return false ; + // si parte da HomeZ + bHomeZ = true ; + } } // altrimenti aggiungo uscita per cambio utensile alla lavorazione precedente e parto da questa else { @@ -792,6 +807,8 @@ Operation::AdjustStartEndMovements(void) // imposto l'utensile per i calcoli macchina if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr())) return false ; + // si parte da HomeZ + bHomeZ = true ; } // aggiusto l'inizio di ogni percorso di lavoro @@ -799,8 +816,9 @@ Operation::AdjustStartEndMovements(void) int nClPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ; while ( bOk && nClPathId != GDB_ID_NULL) { // sistemo inizio - if ( ! AdjustOneStartMovement( nClPathId, vAxVal)) + if ( ! AdjustOneStartMovement( nClPathId, vAxVal, bHomeZ)) bOk = false ; + bHomeZ = false ; // recupero nuovi finali if ( ! GetClPathFinalAxesValues( nClPathId, vAxVal)) bOk = false ; @@ -817,7 +835,7 @@ Operation::AdjustStartEndMovements(void) //---------------------------------------------------------------------------- bool -Operation::AdjustOneStartMovement( int nClPathId, const DBLVECTOR& vAxPrev) +Operation::AdjustOneStartMovement( int nClPathId, const DBLVECTOR& vAxPrev, bool bHomeZ) { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; @@ -830,23 +848,8 @@ Operation::AdjustOneStartMovement( int nClPathId, const DBLVECTOR& vAxPrev) // recupero i valori degli assi DBLVECTOR vAxCurr ; vAxCurr = pCamData->GetAxesVal() ; - // se Z pressochè uguali non devo fare alcunché - if ( fabs( vAxCurr[2] - vAxPrev[2]) < 10 * EPS_SMALL) - return true ; - // se Z corrente maggiore della precedente - else if ( vAxCurr[2] > vAxPrev[2]) { - // copio l'entità - if ( m_pGeomDB->Copy( nEntId, GDB_ID_NULL, nEntId, GDB_AFTER) == GDB_ID_NULL) - return false ; - // modifico quella originale (è la prima del percorso) - DBLVECTOR vAxNew = vAxPrev ; - vAxNew[2] = vAxCurr[2] ; - pCamData->SetAxes( CamData::AS_OK, vAxNew) ; - pCamData->ChangeAxesMask( CamData::MSK_L3) ; - pCamData->SetFlag( 0) ; - } - // altrimenti Z corrente minore della precedente - else { + // se provengo da HomeZ (ovvero Z massima) + if ( bHomeZ) { // copio l'entità if ( m_pGeomDB->Copy( nEntId, GDB_ID_NULL, nEntId, GDB_AFTER) == GDB_ID_NULL) return false ; @@ -857,6 +860,68 @@ Operation::AdjustOneStartMovement( int nClPathId, const DBLVECTOR& vAxPrev) pCamData->ChangeAxesMask( CamData::MSK_L1 | CamData::MSK_L2 | CamData::MSK_R1 | CamData::MSK_R2) ; pCamData->SetFlag( 2) ; } + // verifico se la testa interferisce con i pezzi o i bloccaggi sulla tavola + else if ( ! TestCollisionAvoid( vAxPrev, vAxCurr)) { + // recupero HomeZ + Machine* pMch = m_pMchMgr->GetCurrMachine() ; + double dHomeZ ; + if ( pMch == nullptr || ! pMch->GetCurrAxisHomePos( 2, dHomeZ)) + return false ; + // risalita sopra fine percorso precedente + // copio l'entità + int nNew1Id = m_pGeomDB->Copy( nEntId, GDB_ID_NULL, nEntId, GDB_BEFORE) ; + CamData* pNew1CamData = GetCamData( m_pGeomDB->GetUserObj( nNew1Id)) ; + if ( pNew1CamData == nullptr) + return false ; + // modifico questa entità + DBLVECTOR vAxNew1 = vAxPrev ; + vAxNew1[2] = dHomeZ ; + pNew1CamData->SetAxes( CamData::AS_OK, vAxNew1) ; + pNew1CamData->ChangeAxesMask( CamData::MSK_L3) ; + pNew1CamData->SetFlag( 0) ; + // spostamento sopra inizio percorso corrente + // copio l'entità + int nNew2Id = m_pGeomDB->Copy( nEntId, GDB_ID_NULL, nEntId, GDB_BEFORE) ; + CamData* pNew2CamData = GetCamData( m_pGeomDB->GetUserObj( nNew2Id)) ; + if ( pNew2CamData == nullptr) + return false ; + // modifico quella originale (è la prima del percorso) + DBLVECTOR vAxNew2 = vAxCurr ; + vAxNew2[2] = dHomeZ ; + pNew2CamData->SetAxes( CamData::AS_OK, vAxNew2) ; + pNew2CamData->ChangeAxesMask( CamData::MSK_L1 | CamData::MSK_L2 | CamData::MSK_R1 | CamData::MSK_R2) ; + pNew2CamData->SetFlag( 2) ; + } + // altrimenti + else { + // se Z pressochè uguali non devo fare alcunché + if ( fabs( vAxCurr[2] - vAxPrev[2]) < 10 * EPS_SMALL) + return true ; + // se Z corrente maggiore della precedente + else if ( vAxCurr[2] > vAxPrev[2]) { + // copio l'entità + if ( m_pGeomDB->Copy( nEntId, GDB_ID_NULL, nEntId, GDB_AFTER) == GDB_ID_NULL) + return false ; + // modifico quella originale (è la prima del percorso) + DBLVECTOR vAxNew = vAxPrev ; + vAxNew[2] = vAxCurr[2] ; + pCamData->SetAxes( CamData::AS_OK, vAxNew) ; + pCamData->ChangeAxesMask( CamData::MSK_L3) ; + pCamData->SetFlag( 0) ; + } + // altrimenti Z corrente minore della precedente + else { + // copio l'entità + if ( m_pGeomDB->Copy( nEntId, GDB_ID_NULL, nEntId, GDB_AFTER) == GDB_ID_NULL) + return false ; + // modifico quella originale (è la prima del percorso) + DBLVECTOR vAxNew = vAxCurr ; + vAxNew[2] = vAxPrev[2] ; + pCamData->SetAxes( CamData::AS_OK, vAxNew) ; + pCamData->ChangeAxesMask( CamData::MSK_L1 | CamData::MSK_L2 | CamData::MSK_R1 | CamData::MSK_R2) ; + pCamData->SetFlag( 2) ; + } + } return true ; } @@ -1074,8 +1139,8 @@ Operation::CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR // determino le variazioni di ciascun asse double dR1Delta = dR1End - dR1Start ; double dR2Delta = dR2End - dR2Start ; - // divido il movimento in step di massimo 15 gradi - int nStep = int( max( abs( dR1Delta), abs( dR2Delta)) / 15.0) + 1 ; + // divido il movimento in step di massimo 5 gradi + int nStep = int( max( abs( dR1Delta), abs( dR2Delta)) / 5.0) + 1 ; double dR1Step = dR1Delta / nStep ; double dR2Step = dR2Delta / nStep ; // calcolo @@ -1087,7 +1152,7 @@ Operation::CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR double dR1 = dR1Start + i * dR1Step ; double dR2 = dR2Start + i * dR2Step ; Point3d ptTip ; - if ( ! m_pMchMgr->GetCalcTipFromPositions( dL1, dL2, dL3, dR1, dR2, true, ptTip)) + if ( ! m_pMchMgr->GetCalcTipFromPositions( dL1, dL2, dL3, dR1, dR2, true, true, ptTip)) return false ; if ( i == 0) { dZStart = ptTip.z ; @@ -1162,7 +1227,8 @@ Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEn } for ( const auto nFxtId : vFxtId) { BBox3d b3Fxt ; - if ( m_pGeomDB->GetGlobalBBox( nFxtId, b3Fxt) && b3Head.Overlaps( b3Fxt)) { + int nFlag = BBF_ONLY_VISIBLE | BBF_IGNORE_TEXT | BBF_IGNORE_TEXT ; + if ( m_pGeomDB->GetGlobalBBox( nFxtId, b3Fxt, nFlag) && b3Head.Overlaps( b3Fxt)) { bCollide = true ; break ; } diff --git a/Operation.h b/Operation.h index 704c183..987912b 100644 --- a/Operation.h +++ b/Operation.h @@ -44,6 +44,7 @@ class Operation : public IUserObj virtual const std::string& GetToolName( void) const = 0 ; virtual const std::string& GetHeadName( void) const = 0 ; virtual int GetExitNbr( void) const = 0 ; + virtual int GetSolCh( void) const = 0 ; virtual const std::string& GetToolTcPos( void) const = 0 ; virtual bool AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP) = 0 ; @@ -69,7 +70,7 @@ class Operation : public IUserObj bool CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W, DBLVECTOR& vAxRotPrec, int& nOutStrC) ; bool AdjustStartEndMovements( void) ; - bool AdjustOneStartMovement( int nClPathId, const DBLVECTOR& vAxPrev) ; + bool AdjustOneStartMovement( int nClPathId, const DBLVECTOR& vAxPrev, bool bHomeZ) ; bool ToolChangeNeeded( const Operation& Op1, const Operation& Op2) ; bool AddRise( DBLVECTOR& vAxVal, double dDelta = - 1) ; bool RemoveRise( void) ; diff --git a/SawFinishing.cpp b/SawFinishing.cpp index ea1de7b..c7f2be0 100644 --- a/SawFinishing.cpp +++ b/SawFinishing.cpp @@ -243,6 +243,11 @@ SawFinishing::SetParam( int nType, int nVal) return false ; m_Params.m_nLeadLinkType = nVal ; return true ; + case MPA_SCC : + if ( ! m_Params.VerifySolCh( nVal)) + return false ; + m_Params.m_nSolCh = nVal ; + return true ; } return false ; } @@ -480,6 +485,9 @@ SawFinishing::GetParam( int nType, int& nVal) const case MPA_LEADLINKTYPE : nVal = m_Params.m_nLeadLinkType ; return true ; + case MPA_SCC : + nVal = m_Params.m_nSolCh ; + return true ; } return false ; } diff --git a/SawFinishing.h b/SawFinishing.h index 76a6151..3b6539f 100644 --- a/SawFinishing.h +++ b/SawFinishing.h @@ -40,6 +40,8 @@ class SawFinishing : public Machining { return ( m_nCuts == 0) ; } protected : // Operation + int GetSolCh( void) const override + { return m_Params.m_nSolCh ; } bool AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP) override ; public : // Machining diff --git a/SawFinishingData.cpp b/SawFinishingData.cpp index d932a01..fb886af 100644 --- a/SawFinishingData.cpp +++ b/SawFinishingData.cpp @@ -17,6 +17,7 @@ #include "MachiningDataFactory.h" #include "MachiningConst.h" #include "/EgtDev/Include/EmkToolConst.h" +#include "/EgtDev/Include/EmkSimuGenConst.h" #include "/EgtDev/Include/EGnStringUtils.h" #include #include @@ -41,6 +42,7 @@ enum nSawFinishingKey { KEY_OR, KEY_PS, KEY_S, + KEY_SCC, KEY_SS, KEY_ST, KEY_STY, @@ -67,6 +69,7 @@ static const std::array sSawFinishingKey = { "OR", "PS", "S", + "SCC", "SS", "ST", "STY", @@ -110,6 +113,7 @@ SawFinishingData::CopyFrom( const MachiningData* pMdata) m_sName = pSdata->m_sName ; m_ToolUuid = pSdata->m_ToolUuid ; m_sToolName = pSdata->m_sToolName ; + m_nSolCh = pSdata->m_nSolCh ; m_dSpeed = pSdata->m_dSpeed ; m_dFeed = pSdata->m_dFeed ; m_dEndFeed = pSdata->m_dEndFeed ; @@ -148,6 +152,7 @@ SawFinishingData::SameAs(const MachiningData* pMdata) const m_sName == pSdata->m_sName && m_ToolUuid == pSdata->m_ToolUuid && m_sToolName == pSdata->m_sToolName && + m_nSolCh == pSdata->m_nSolCh && abs( m_dSpeed - pSdata->m_dSpeed) < EPS_MACH_ANG_PAR && abs( m_dFeed - pSdata->m_dFeed) < EPS_MACH_LEN_PAR && abs( m_dEndFeed - pSdata->m_dEndFeed) < EPS_MACH_LEN_PAR && @@ -256,6 +261,9 @@ SawFinishingData::FromString( const string& sString, int& nKey) case KEY_S : bOk = ::FromString( sVal, m_dSpeed) ; break ; + case KEY_SCC : + bOk = ::FromString( sVal, m_nSolCh) ; + break ; case KEY_SS : bOk = ::FromString( sVal, m_dSideStep) ; break ; @@ -305,6 +313,7 @@ SawFinishingData::ToString( int nInd) const case KEY_OR : return ( sSawFinishingKey[KEY_OR] + "=" + ::ToString( m_dOffsR)) ; case KEY_PS : return ( sSawFinishingKey[KEY_PS] + "=" + ::ToString( m_dStartPos)) ; case KEY_S : return ( sSawFinishingKey[KEY_S] + "=" + ::ToString( m_dSpeed)) ; + case KEY_SCC : return ( sSawFinishingKey[KEY_SCC] + "=" + ::ToString( m_nSolCh)) ; case KEY_SS : return ( sSawFinishingKey[KEY_SS] + "=" + ::ToString( m_dSideStep)) ; case KEY_ST : return ( sSawFinishingKey[KEY_ST] + "=" + ::ToString( m_dStep)) ; case KEY_STY : return ( sSawFinishingKey[KEY_STY] + "=" + ::ToString( m_nStepType)) ; @@ -320,7 +329,15 @@ SawFinishingData::ToString( int nInd) const bool SawFinishingData::IsOptional( int nKey) const { - return ( nKey == KEY_FV || nKey == KEY_ST || nKey == KEY_SUBTYPE || nKey == KEY_INV) ; + return ( nKey == KEY_FV || nKey == KEY_ST || nKey == KEY_SCC || nKey == KEY_SUBTYPE || + nKey == KEY_INV) ; +} + +//---------------------------------------------------------------------------- +bool +SawFinishingData::VerifySolCh( int nVal) const +{ + return IsValidOperationScc( nVal) ; } //---------------------------------------------------------------------------- @@ -412,6 +429,11 @@ SawFinishingData::SetParam( int nType, int nVal) return false ; m_nLeadLinkType = nVal ; return true ; + case MPA_SCC : + if ( ! VerifySolCh( nVal)) + return false ; + m_nSolCh = nVal ; + return true ; } return false ; } @@ -530,6 +552,9 @@ SawFinishingData::GetParam( int nType, int& nVal) const case MPA_LEADLINKTYPE : nVal = m_nLeadLinkType ; return true ; + case MPA_SCC : + nVal = m_nSolCh ; + return true ; } return false ; } diff --git a/SawFinishingData.h b/SawFinishingData.h index e4ce701..d34ebf3 100644 --- a/SawFinishingData.h +++ b/SawFinishingData.h @@ -20,6 +20,7 @@ struct SawFinishingData : public MachiningData { EgtUUID m_ToolUuid ; // identificativo universale dell'utensile std::string m_sToolName ; // nome dell'utensile + int m_nSolCh ; // criterio scelta soluzione (quando possibili molteplici) double m_dSpeed ; // velocità di rotazione (+ se CCW, - se CW) ( se 0 da utensile) double m_dFeed ; // velocità di lavorazione normale ( se 0 da utensile) double m_dStartFeed ; // velocità di lavorazione iniziale ( se 0 da utensile) @@ -41,7 +42,7 @@ struct SawFinishingData : public MachiningData std::string m_sUserNotes ; // note dell'utente SawFinishingData( void) - : m_ToolUuid(), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), m_dVertFeed(0), + : m_ToolUuid(), m_nSolCh( 0), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), m_dVertFeed(0), m_dOffsR( UNKNOWN_PAR), m_bInvert( false), m_nHeadSide( 0), m_dStartPos( 0), m_dSideStep( 0), m_dStep( 0), m_nSubType( 0), m_nStepType( 0), m_nLeadLinkType( 0), m_dApprox( 0) {} @@ -66,6 +67,7 @@ struct SawFinishingData : public MachiningData bool GetParam( int nType, std::string& sVal) const override ; bool GetTool( const ToolsMgr* pToolsMgr, const ToolData*& pTdata) const override ; bool VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const override ; + bool VerifySolCh( int nVal) const ; bool VerifyHeadSide( int nVal) const ; bool VerifyStepType( int nVal) const ; bool VerifySubType( int nVal) const ; diff --git a/SawRoughing.cpp b/SawRoughing.cpp index 0af5b8d..614385b 100644 --- a/SawRoughing.cpp +++ b/SawRoughing.cpp @@ -227,6 +227,11 @@ SawRoughing::SetParam( int nType, int nVal) return false ; m_Params.m_nLeadLinkType = nVal ; return true ; + case MPA_SCC : + if ( ! m_Params.VerifySolCh( nVal)) + return false ; + m_Params.m_nSolCh = nVal ; + return true ; } return false ; } @@ -453,6 +458,9 @@ SawRoughing::GetParam( int nType, int& nVal) const case MPA_LEADLINKTYPE : nVal = m_Params.m_nLeadLinkType ; return true ; + case MPA_SCC : + nVal = m_Params.m_nSolCh ; + return true ; } return false ; } diff --git a/SawRoughing.h b/SawRoughing.h index 1f12b3d..b2cb334 100644 --- a/SawRoughing.h +++ b/SawRoughing.h @@ -40,6 +40,8 @@ class SawRoughing : public Machining { return ( m_nCuts == 0) ; } protected : // Operation + int GetSolCh( void) const override + { return m_Params.m_nSolCh ; } bool AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP) override ; public : // Machining diff --git a/SawRoughingData.cpp b/SawRoughingData.cpp index ffab7d8..316992c 100644 --- a/SawRoughingData.cpp +++ b/SawRoughingData.cpp @@ -17,6 +17,7 @@ #include "MachiningDataFactory.h" #include "MachiningConst.h" #include "/EgtDev/Include/EmkToolConst.h" +#include "/EgtDev/Include/EmkSimuGenConst.h" #include "/EgtDev/Include/EGnStringUtils.h" #include #include @@ -40,6 +41,7 @@ enum nSawRoughingKey { KEY_OR, KEY_PS, KEY_S, + KEY_SCC, KEY_SS, KEY_ST, KEY_STY, @@ -64,6 +66,7 @@ static const std::array sSawRoughingKey = { "OR", "PS", "S", + "SCC", "SS", "ST", "STY", @@ -106,6 +109,7 @@ SawRoughingData::CopyFrom( const MachiningData* pMdata) m_sName = pSdata->m_sName ; m_ToolUuid = pSdata->m_ToolUuid ; m_sToolName = pSdata->m_sToolName ; + m_nSolCh = pSdata->m_nSolCh ; m_dSpeed = pSdata->m_dSpeed ; m_dFeed = pSdata->m_dFeed ; m_dEndFeed = pSdata->m_dEndFeed ; @@ -142,6 +146,7 @@ SawRoughingData::SameAs(const MachiningData* pMdata) const m_sName == pSdata->m_sName && m_ToolUuid == pSdata->m_ToolUuid && m_sToolName == pSdata->m_sToolName && + m_nSolCh == pSdata->m_nSolCh && abs( m_dSpeed - pSdata->m_dSpeed) < EPS_MACH_ANG_PAR && abs( m_dFeed - pSdata->m_dFeed) < EPS_MACH_LEN_PAR && abs( m_dEndFeed - pSdata->m_dEndFeed) < EPS_MACH_LEN_PAR && @@ -245,6 +250,9 @@ SawRoughingData::FromString( const string& sString, int& nKey) case KEY_S : bOk = ::FromString( sVal, m_dSpeed) ; break ; + case KEY_SCC : + bOk = ::FromString( sVal, m_nSolCh) ; + break ; case KEY_SS : bOk = ::FromString( sVal, m_dSideStep) ; break ; @@ -290,6 +298,7 @@ SawRoughingData::ToString( int nInd) const case KEY_OR : return ( sSawRoughingKey[KEY_OR] + "=" + ::ToString( m_dOffsR)) ; case KEY_PS : return ( sSawRoughingKey[KEY_PS] + "=" + ::ToString( m_dStartPos)) ; case KEY_S : return ( sSawRoughingKey[KEY_S] + "=" + ::ToString( m_dSpeed)) ; + case KEY_SCC : return ( sSawRoughingKey[KEY_SCC] + "=" + ::ToString( m_nSolCh)) ; case KEY_SS : return ( sSawRoughingKey[KEY_SS] + "=" + ::ToString( m_dSideStep)) ; case KEY_ST : return ( sSawRoughingKey[KEY_ST] + "=" + ::ToString( m_dStep)) ; case KEY_STY : return ( sSawRoughingKey[KEY_STY] + "=" + ::ToString( m_nStepType)) ; @@ -304,7 +313,14 @@ SawRoughingData::ToString( int nInd) const bool SawRoughingData::IsOptional( int nKey) const { - return false ; + return ( nKey == KEY_SCC) ; +} + +//---------------------------------------------------------------------------- +bool +SawRoughingData::VerifySolCh( int nVal) const +{ + return IsValidOperationScc( nVal) ; } //---------------------------------------------------------------------------- @@ -381,6 +397,11 @@ SawRoughingData::SetParam( int nType, int nVal) return false ; m_nLeadLinkType = nVal ; return true ; + case MPA_SCC : + if ( ! VerifySolCh( nVal)) + return false ; + m_nSolCh = nVal ; + return true ; } return false ; } @@ -493,6 +514,9 @@ SawRoughingData::GetParam( int nType, int& nVal) const case MPA_LEADLINKTYPE : nVal = m_nLeadLinkType ; return true ; + case MPA_SCC : + nVal = m_nSolCh ; + return true ; } return false ; } diff --git a/SawRoughingData.h b/SawRoughingData.h index 5832a5d..531e78b 100644 --- a/SawRoughingData.h +++ b/SawRoughingData.h @@ -20,6 +20,7 @@ struct SawRoughingData : public MachiningData { EgtUUID m_ToolUuid ; // identificativo universale dell'utensile std::string m_sToolName ; // nome dell'utensile + int m_nSolCh ; // criterio scelta soluzione (quando possibili molteplici) double m_dSpeed ; // velocità di rotazione (+ se CCW, - se CW) ( se 0 da utensile) double m_dFeed ; // velocità di lavorazione normale ( se 0 da utensile) double m_dStartFeed ; // velocità di lavorazione iniziale ( se 0 da utensile) @@ -39,7 +40,7 @@ struct SawRoughingData : public MachiningData std::string m_sUserNotes ; // note dell'utente SawRoughingData( void) - : m_ToolUuid(), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), + : m_ToolUuid(), m_nSolCh( 0), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), m_dOffsR( UNKNOWN_PAR), m_dOffsL( UNKNOWN_PAR), m_nHeadSide(0), m_dStartPos( 0), m_dSideStep( 0), m_dStep( 0), m_nStepType( 0), m_nLeadLinkType( 0), m_dApprox( 0) {} @@ -64,6 +65,7 @@ struct SawRoughingData : public MachiningData bool GetParam( int nType, std::string& sVal) const override ; bool GetTool( const ToolsMgr* pToolsMgr, const ToolData*& pTdata) const override ; bool VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const override ; + bool VerifySolCh( int nVal) const ; bool VerifyHeadSide( int nVal) const ; bool VerifyStepType( int nVal) const ; bool VerifyLeadLinkType( int nVal) const ; diff --git a/Sawing.cpp b/Sawing.cpp index 0019fa9..87ee19b 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -241,6 +241,11 @@ Sawing::SetParam( int nType, int nVal) return false ; m_Params.m_nCurveUse = nVal ; return true ; + case MPA_SCC : + if ( ! m_Params.VerifySolCh( nVal)) + return false ; + m_Params.m_nSolCh = nVal ; + return true ; } return false ; } @@ -569,6 +574,9 @@ Sawing::GetParam( int nType, int& nVal) const case MPA_CURVEUSE : nVal = m_Params.m_nCurveUse ; return true ; + case MPA_SCC : + nVal = m_Params.m_nSolCh ; + return true ; } return false ; } diff --git a/Sawing.h b/Sawing.h index 123bd31..9577300 100644 --- a/Sawing.h +++ b/Sawing.h @@ -40,6 +40,8 @@ class Sawing : public Machining { return ( m_nCuts == 0) ; } protected : // Operation + int GetSolCh( void) const override + { return m_Params.m_nSolCh ; } bool AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP) override ; public : // Machining diff --git a/SawingData.cpp b/SawingData.cpp index 600d33b..492066c 100644 --- a/SawingData.cpp +++ b/SawingData.cpp @@ -17,6 +17,7 @@ #include "MachiningDataFactory.h" #include "MachiningConst.h" #include "/EgtDev/Include/EmkToolConst.h" +#include "/EgtDev/Include/EmkSimuGenConst.h" #include "/EgtDev/Include/EGnStringUtils.h" #include #include @@ -47,6 +48,7 @@ enum nSawingKey { KEY_S, KEY_SA, KEY_SAL, + KEY_SCC, KEY_ST, KEY_STEA, KEY_STIA, @@ -80,6 +82,7 @@ static const std::array sSawingKey = { "S", "SA", "SAL", + "SCC", "ST", "STEA", "STIA", @@ -124,6 +127,7 @@ SawingData::CopyFrom( const MachiningData* pMdata) m_sName = pSdata->m_sName ; m_ToolUuid = pSdata->m_ToolUuid ; m_sToolName = pSdata->m_sToolName ; + m_nSolCh = pSdata->m_nSolCh ; m_dSpeed = pSdata->m_dSpeed ; m_dFeed = pSdata->m_dFeed ; m_dEndFeed = pSdata->m_dEndFeed ; @@ -169,6 +173,7 @@ SawingData::SameAs(const MachiningData* pMdata) const m_sName == pSdata->m_sName && m_ToolUuid == pSdata->m_ToolUuid && m_sToolName == pSdata->m_sToolName && + m_nSolCh == pSdata->m_nSolCh && abs( m_dSpeed - pSdata->m_dSpeed) < EPS_MACH_ANG_PAR && abs( m_dFeed - pSdata->m_dFeed) < EPS_MACH_LEN_PAR && abs( m_dEndFeed - pSdata->m_dEndFeed) < EPS_MACH_LEN_PAR && @@ -302,6 +307,9 @@ SawingData::FromString( const string& sString, int& nKey) case KEY_SAL : bOk = ::FromString( sVal, m_dStartAddLen) ; break ; + case KEY_SCC : + bOk = ::FromString( sVal, m_nSolCh) ; + break ; case KEY_ST : bOk = ::FromString( sVal, m_dStep) ; break ; @@ -360,6 +368,7 @@ SawingData::ToString( int nInd) const case KEY_S : return ( sSawingKey[KEY_S] + "=" + ::ToString( m_dSpeed)) ; case KEY_SA : return ( sSawingKey[KEY_SA] + "=" + ::ToString( m_dSideAngle)) ; case KEY_SAL : return ( sSawingKey[KEY_SAL] + "=" + ::ToString( m_dStartAddLen)) ; + case KEY_SCC : return ( sSawingKey[KEY_SCC] + "=" + ::ToString( m_nSolCh)) ; case KEY_ST : return ( sSawingKey[KEY_ST] + "=" + ::ToString( m_dStep)) ; case KEY_STEA : return ( sSawingKey[KEY_STEA] + "=" + ::ToString( m_dStepExtArc)) ; case KEY_STIA : return ( sSawingKey[KEY_STIA] + "=" + ::ToString( m_dStepIntArc)) ; @@ -378,7 +387,14 @@ SawingData::IsOptional( int nKey) const { return ( nKey == KEY_F || nKey == KEY_FE || nKey == KEY_FS || nKey == KEY_FT || nKey == KEY_NNS || nKey == KEY_NNU || nKey == KEY_OL || nKey == KEY_OR || - nKey == KEY_S || nKey == KEY_STEA || nKey == KEY_STIA) ; + nKey == KEY_S || nKey == KEY_SCC || nKey == KEY_STEA || nKey == KEY_STIA) ; +} + +//---------------------------------------------------------------------------- +bool +SawingData::VerifySolCh( int nVal) const +{ + return IsValidOperationScc( nVal) ; } //---------------------------------------------------------------------------- @@ -517,6 +533,11 @@ SawingData::SetParam( int nType, int nVal) return false ; m_nCurveUse = nVal ; return true ; + case MPA_SCC : + if ( ! VerifySolCh( nVal)) + return false ; + m_nSolCh = nVal ; + return true ; } return false ; } @@ -658,6 +679,9 @@ SawingData::GetParam( int nType, int& nVal) const case MPA_CURVEUSE : nVal = m_nCurveUse ; return true ; + case MPA_SCC : + nVal = m_nSolCh ; + return true ; } return false ; } diff --git a/SawingData.h b/SawingData.h index aacd561..ccb0985 100644 --- a/SawingData.h +++ b/SawingData.h @@ -20,6 +20,7 @@ struct SawingData : public MachiningData { EgtUUID m_ToolUuid ; // identificativo universale dell'utensile std::string m_sToolName ; // nome dell'utensile + int m_nSolCh ; // criterio scelta soluzione (quando possibili molteplici) double m_dSpeed ; // velocità di rotazione (+ se CCW, - se CW) ( se 0 da utensile) double m_dFeed ; // velocità di lavorazione normale ( se 0 da utensile) double m_dStartFeed ; // velocità di lavorazione iniziale ( se 0 da utensile) @@ -48,7 +49,7 @@ struct SawingData : public MachiningData std::string m_sUserNotes ; // note dell'utente SawingData( void) - : m_ToolUuid(), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), + : m_ToolUuid(), m_nSolCh( 0), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), m_dOffsR( UNKNOWN_PAR), m_dOffsL( UNKNOWN_PAR), m_bInvert( false), m_nWorkSide( 0), m_nHeadSide(0), m_dStartPos( 0), m_dStep( 0), m_dStepExtArc( 0), m_dStepIntArc( 0), m_nStepType( 0), m_dSideAngle( 0), m_dStartAddLen(0), m_dEndAddLen(0), @@ -74,6 +75,7 @@ struct SawingData : public MachiningData bool GetParam( int nType, std::string& sVal) const override ; bool GetTool( const ToolsMgr* pToolsMgr, const ToolData*& pTdata) const override ; bool VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const override ; + bool VerifySolCh( int nVal) const ; bool VerifyWorkSide( int nVal) const ; bool VerifyHeadSide( int nVal) const ; bool VerifyStepType( int nVal) const ; diff --git a/Simulator.cpp b/Simulator.cpp index d1fdf98..ac634ee 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -87,8 +87,12 @@ Simulator::Start( void) return false ; // definisco tavola variabili globali bool bOk = m_pMachine->LuaCreateGlobTable( GLOB_VAR) ; + // recupero dati tavola macchina + Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nOpId)) ; + string sTable ; + pDisp->GetTable( sTable) ; // richiamo gestione evento inizio e fine disposizione - if ( ! OnDispositionStart( m_nOpId, m_nOpInd, 1, true) || + if ( ! OnDispositionStart( m_nOpId, m_nOpInd, 1, sTable, true) || ! OnDispositionEnd()) return false ; // cerco la prima lavorazione valida @@ -202,6 +206,9 @@ Simulator::Move( int& nStatus) if ( pDisp != nullptr) { // cambio fase m_pMchMgr->SetCurrPhase( pDisp->GetPhase()) ; + // recupero dati tavola + string sTable ; + pDisp->GetTable( sTable) ; // se con movimenti autonomi if ( ! pDisp->IsEmpty()) { // aggiorno utensile e assi conseguenti @@ -211,7 +218,7 @@ Simulator::Move( int& nStatus) } ++ m_nOpInd ; // richiamo gestione evento inizio disposizione - if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), false)) { + if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), sTable, false)) { nStatus = MCH_SIM_ERR ; return false ; } @@ -223,7 +230,7 @@ Simulator::Move( int& nStatus) else { ++ m_nOpInd ; // richiamo gestione evento inizio e fine disposizione - if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), true) || + if ( ! OnDispositionStart( m_nOpId, m_nOpInd, pDisp->GetPhase(), sTable, true) || ! OnDispositionEnd()) { nStatus = MCH_SIM_ERR ; return false ; @@ -320,17 +327,20 @@ Simulator::Move( int& nStatus) m_pMachine->SetAxisPos( m_AxesName[i], dVal) ; } } - // Eseguo movimento su arco (per ora sempre nel piano XY) + // Eseguo movimento su arco else { // primi due assi lineari Point3d ptCen = pCamData->GetAxesCen() ; double dAngCen = pCamData->GetAxesAngCen() ; - Vector3d vtCurr = Point3d( m_AxesVal[0], m_AxesVal[1], ptCen.z) - ptCen ; - vtCurr.Rotate( Z_AX, m_dCoeff * dAngCen) ; - m_pMachine->SetAxisPos( m_AxesName[0], ptCen.x + vtCurr.x) ; - m_pMachine->SetAxisPos( m_AxesName[1], ptCen.y + vtCurr.y) ; + Vector3d vtN = pCamData->GetAxesNormDir() ; + Vector3d vtRot = Point3d( m_AxesVal[0], m_AxesVal[1], m_AxesVal[2]) - ptCen ; + vtRot.Rotate( vtN, m_dCoeff * dAngCen) ; + double dDeltaN = ( Point3d( AxesEnd[0], AxesEnd[1], AxesEnd[2]) - ptCen) * vtN ; + m_pMachine->SetAxisPos( m_AxesName[0], ptCen.x + vtRot.x + m_dCoeff * dDeltaN * vtN.x) ; + m_pMachine->SetAxisPos( m_AxesName[1], ptCen.y + vtRot.y + m_dCoeff * dDeltaN * vtN.y) ; + m_pMachine->SetAxisPos( m_AxesName[2], ptCen.z + vtRot.z + m_dCoeff * dDeltaN * vtN.z) ; // altri assi - for ( size_t i = 2 ; i < m_AxesName.size() ; ++ i) { + for ( size_t i = 3 ; i < m_AxesName.size() ; ++ i) { double dVal = m_AxesVal[i] * ( 1 - m_dCoeff) + AxesEnd[i] * m_dCoeff ; m_pMachine->SetAxisPos( m_AxesName[i], dVal) ; } @@ -581,18 +591,20 @@ Simulator::OnOperationEnd( void) //---------------------------------------------------------------------------- bool -Simulator::OnDispositionStart( int nOpId, int nOpInd, int nPhase, bool bEmpty) +Simulator::OnDispositionStart( int nOpId, int nOpInd, int nPhase, const string& sTable, bool bEmpty) { - // verifico esistenza funzione - if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_DISPOSITION_START)) - return true ; // assegno identificativo e indice disposizione bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPID, nOpId) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPIND, nOpInd) ; // assegno nuovo indice di fase bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PHASE, nPhase) ; + // assegno nome della tavola corrente + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TABNAME, sTable) ; // assegno flag disposizione passiva bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EMPTY, bEmpty) ; + // verifico esistenza funzione + if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_DISPOSITION_START)) + return true ; // chiamo la funzione di inizio disposizione bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_DISPOSITION_START) ; return bOk ; diff --git a/Simulator.h b/Simulator.h index 4cb1a20..3f9d5d4 100644 --- a/Simulator.h +++ b/Simulator.h @@ -43,7 +43,7 @@ class Simulator private : bool OnOperationEnd( void) ; - bool OnDispositionStart( int nOpId, int nOpInd, int nPhase, bool bEmpty) ; + bool OnDispositionStart( int nOpId, int nOpInd, int nPhase, const std::string& sTable, bool bEmpty) ; bool OnDispositionEnd( void) ; bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit) ; bool OnToolDeselect( void) ;