From a4c7789a9196a0596cf4215865476aade8a3fdfb Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 17 Jun 2017 16:55:44 +0000 Subject: [PATCH] EgtMachKernel 1.8f2 : - aggiunte Update di lavorazioni e disposizione per ricalcolo assi macchina ecollegamenti. --- Chiseling.cpp | 12 +++++ Chiseling.h | 1 + Disposition.cpp | 110 +++++++++++++++++++++++++----------------- Disposition.h | 1 + Drilling.cpp | 16 +++++- Drilling.h | 1 + EgtMachKernel.rc | Bin 11774 -> 11774 bytes GenMachining.cpp | 16 +++++- GenMachining.h | 1 + MachMgr.h | 2 + MachMgrOperations.cpp | 44 +++++++++++++++++ Machining.h | 1 + Milling.cpp | 12 +++++ Milling.h | 1 + Pocketing.cpp | 12 +++++ Pocketing.h | 1 + SawFinishing.cpp | 16 +++++- SawFinishing.h | 1 + SawRoughing.cpp | 16 +++++- SawRoughing.h | 1 + Sawing.cpp | 16 +++++- Sawing.h | 1 + 22 files changed, 232 insertions(+), 50 deletions(-) diff --git a/Chiseling.cpp b/Chiseling.cpp index c2a509d..259e8fa 100644 --- a/Chiseling.cpp +++ b/Chiseling.cpp @@ -487,6 +487,18 @@ Chiseling::Apply( bool bRecalc) nPathId = m_pGeomDB->GetNextGroup( nPathId) ; } + // eseguo aggiornamento assi macchina e collegamento con operazione precedente + return Update() ; +} + +//---------------------------------------------------------------------------- +bool +Chiseling::Update( void) +{ + // verifico validità gestore DB geometrico e Id del gruppo + if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) + return false ; + // se lavorazione vuota, esco if ( m_nChisels == 0) { LOG_INFO( GetEMkLogger(), "Warning in Chiseling : Plunges not found") diff --git a/Chiseling.h b/Chiseling.h index 74511d5..df0afb3 100644 --- a/Chiseling.h +++ b/Chiseling.h @@ -51,6 +51,7 @@ class Chiseling : public Machining bool SetGeometry( const SELVECTOR& vIds) override ; bool Preview( bool bRecalc) override ; bool Apply( bool bRecalc) override ; + bool Update( void) override ; bool GetParam( int nType, bool& bVal) const override ; bool GetParam( int nType, int& nVal) const override ; bool GetParam( int nType, double& dVal) const override ; diff --git a/Disposition.cpp b/Disposition.cpp index e5e2dcf..f0d69ce 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -1036,6 +1036,10 @@ Disposition::SpecialApply( bool bRecalc) m_bSomeByHand = false ; m_sTcPos.clear() ; + // verifico MachMgr e GeomDB + if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) + return false ; + // costanti static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo static const string EVAR_TABNAME = ".TABNAME" ; // IN (string) nome della tavola macchina @@ -1054,54 +1058,70 @@ Disposition::SpecialApply( bool bRecalc) if ( pMch == nullptr) return false ; + // se non esiste la funzione, non devo fare alcunché + if ( ! pMch->LuaExistsFunction( ON_SPECIAL_APPLY)) + return true ; + // eseguo l'azione - if ( pMch->LuaExistsFunction( ON_SPECIAL_APPLY)) { - bool bOk = true ; - int nErr = 99 ; - // verifico tavola - bOk = ( m_bTabOk || SetTable( m_sTabName)) ; - // imposto valori parametri - bOk = bOk && pMch->LuaCreateGlobTable( EMC_VAR) ; - bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TABNAME, m_sTabName) ; - bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_DISPID, m_nOwnerId) ; - bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_PHASE, GetPhase()) ; - // eseguo - bOk = bOk && pMch->LuaCallFunction( ON_SPECIAL_APPLY, false) ; - // recupero valori parametri obbligatori - bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_ERROR, nErr) ; - bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_HEAD, m_sHead) ; - bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_EXIT, m_nExit) ; - bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_SHIFTS, m_nShifts) ; - bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_SBH, m_bSomeByHand) ; - // recupero valori parametri opzionali - if ( bOk) - pMch->LuaGetGlobVar( EMC_VAR + EVAR_TCPOS, m_sTcPos) ; - // reset - bOk = bOk && pMch->LuaResetGlobVar( EMC_VAR) ; - // segnalo errori - if ( nErr != 0) { - bOk = false ; - m_nShifts = - 1 ; - string sOut = " Error in " + ON_SPECIAL_APPLY + " (" + ToString( nErr) + ")" ; - m_pMchMgr->SetLastError( 2006, sOut) ; - } - // se disposizione vuota o errore, esco - if ( m_nShifts <= 0 || ! bOk) - return bOk ; - // calcolo assi macchina - if ( ! CalculateAxesValues( "")) { - m_pMchMgr->SetLastError( 2007, "Error in Disposition : axes values not calculable") ; - return false ; - } - // gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine di tutti - if ( ! AdjustStartEndMovements()) { - m_pMchMgr->SetLastError( 2008, "Error in Disposition : link movements not calculable") ; - return false ; - } + bool bOk = true ; + int nErr = 99 ; + // verifico tavola + bOk = ( m_bTabOk || SetTable( m_sTabName)) ; + // imposto valori parametri + bOk = bOk && pMch->LuaCreateGlobTable( EMC_VAR) ; + bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TABNAME, m_sTabName) ; + bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_DISPID, m_nOwnerId) ; + bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_PHASE, GetPhase()) ; + // eseguo + bOk = bOk && pMch->LuaCallFunction( ON_SPECIAL_APPLY, false) ; + // recupero valori parametri obbligatori + bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_ERROR, nErr) ; + bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_HEAD, m_sHead) ; + bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_EXIT, m_nExit) ; + bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_SHIFTS, m_nShifts) ; + bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_SBH, m_bSomeByHand) ; + // recupero valori parametri opzionali + if ( bOk) + pMch->LuaGetGlobVar( EMC_VAR + EVAR_TCPOS, m_sTcPos) ; + // reset + bOk = bOk && pMch->LuaResetGlobVar( EMC_VAR) ; + // segnalo errori ed esco + if ( ! bOk || nErr != 0) { + m_nShifts = - 1 ; + string sOut = " Error in " + ON_SPECIAL_APPLY + " (" + ToString( nErr) + ")" ; + m_pMchMgr->SetLastError( 2006, sOut) ; + return false ; + } + + // eseguo aggiornamento assi macchina e collegamento con operazione precedente + return SpecialUpdate() ; +} + +//---------------------------------------------------------------------------- +bool +Disposition::SpecialUpdate( void) +{ + // verifico MachMgr e GeomDB + if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) + return false ; + + // se disposizione vuota, esco + if ( m_nShifts <= 0) { + if ( m_nShifts < 0) + LOG_INFO( GetEMkLogger(), "Warning in Disposition : No shifts") return true ; } - else - return true ; + // calcolo assi macchina + if ( ! CalculateAxesValues( "")) { + m_pMchMgr->SetLastError( 2007, "Error in Disposition : axes values not calculable") ; + return false ; + } + // gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine di tutti + if ( ! AdjustStartEndMovements()) { + m_pMchMgr->SetLastError( 2008, "Error in Disposition : link movements not calculable") ; + return false ; + } + return true ; } //---------------------------------------------------------------------------- diff --git a/Disposition.h b/Disposition.h index 5f1e68a..7ec16e4 100644 --- a/Disposition.h +++ b/Disposition.h @@ -102,6 +102,7 @@ class Disposition : public Operation double& dAngDeg, double& dMov) const ; bool GetMoveRawData( int nInd, int& nRawId, int& nType, Point3d& ptPos, int& nFlag) const ; bool SpecialApply( bool bRecalc) ; + bool SpecialUpdate( void) ; bool GetToolData( std::string& sName, std::string& sHead, int& nExit, std::string& sTcPos) const ; bool GetSomeByHand( void) const { return m_bSomeByHand ; } diff --git a/Drilling.cpp b/Drilling.cpp index 4bf9eba..33a9f70 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -483,9 +483,23 @@ Drilling::Apply( bool bRecalc) else return false ; + // eseguo aggiornamento assi macchina e collegamento con operazione precedente + return Update() ; +} + +//---------------------------------------------------------------------------- +bool +Drilling::Update( void) +{ + // verifico validità gestore DB geometrico e Id del gruppo + if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) + return false ; + // se lavorazione vuota, esco - if ( m_nDrillings == 0) + if ( m_nDrillings == 0) { + LOG_INFO( GetEMkLogger(), "Warning in Drilling : No machinable hole") return true ; + } // imposto eventuale asse bloccato da lavorazione if ( ! m_Params.m_sBlockedAxis.empty()) { diff --git a/Drilling.h b/Drilling.h index 1955104..226afc8 100644 --- a/Drilling.h +++ b/Drilling.h @@ -51,6 +51,7 @@ class Drilling : public Machining bool SetGeometry( const SELVECTOR& vIds) override ; bool Preview( bool bRecalc) override ; bool Apply( bool bRecalc) override ; + bool Update( void) override ; bool GetParam( int nType, bool& bVal) const override ; bool GetParam( int nType, int& nVal) const override ; bool GetParam( int nType, double& dVal) const override ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index d411fdd1b0f3a8ab38f09da17c90cbf54d3a13ee..d4d16987dae1ac1e7dcb7ab5d539fc196d7b8a8b 100644 GIT binary patch delta 97 zcmewt{V#gMFE&P_&A-`fnHh~HKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmU8!BZvS1 delta 97 zcmewt{V#gMFE&QQ&A-`fnHdcyKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmU3rBY*$^ diff --git a/GenMachining.cpp b/GenMachining.cpp index cfc759e..cf9bde9 100644 --- a/GenMachining.cpp +++ b/GenMachining.cpp @@ -536,9 +536,23 @@ GenMachining::Apply( bool bRecalc) return false ; } + // eseguo aggiornamento assi macchina e collegamento con operazione precedente + return Update() ; +} + +//---------------------------------------------------------------------------- +bool +GenMachining::Update( void) +{ + // verifico validità gestore DB geometrico e Id del gruppo + if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) + return false ; + // se lavorazione vuota, esco - if ( m_nMills == 0) + if ( m_nMills == 0) { + LOG_INFO( GetEMkLogger(), "Warning in GenMachining : No machinable path") return true ; + } // imposto eventuale asse bloccato da lavorazione if ( ! m_Params.m_sBlockedAxis.empty()) { diff --git a/GenMachining.h b/GenMachining.h index 0a3a906..77678de 100644 --- a/GenMachining.h +++ b/GenMachining.h @@ -50,6 +50,7 @@ class GenMachining : public Machining bool SetGeometry( const SELVECTOR& vIds) override ; bool Preview( bool bRecalc) override ; bool Apply( bool bRecalc) override ; + bool Update( void) override ; bool GetParam( int nType, bool& bVal) const override ; bool GetParam( int nType, int& nVal) const override ; bool GetParam( int nType, double& dVal) const override ; diff --git a/MachMgr.h b/MachMgr.h index 80716f4..1cedcad 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -230,6 +230,7 @@ class MachMgr : public IMachMgr // Operations : dispositions int GetPhaseDisposition( int nPhase) const override ; bool DispositionSpecialApply( int nId, bool bRecalc) override ; + bool DispositionSpecialUpdate( int nId) override ; // Operations : machinings int AddMachining( const std::string& sName, const std::string& sMachining) override ; int AddMachining( const std::string& sName, int nMchType, const std::string& sTool) override ; @@ -245,6 +246,7 @@ class MachMgr : public IMachMgr bool ExistsMachiningPreview( void) override ; bool RemoveMachiningPreview( void) override ; bool MachiningApply( bool bRecalc) override ; + bool MachiningUpdate( void) override ; bool GetMachiningParam( int nType, bool& bVal) const override ; bool GetMachiningParam( int nType, int& dVal) const override ; bool GetMachiningParam( int nType, double& dVal) const override ; diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index 6674d63..a25dbd4 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -606,6 +606,25 @@ MachMgr::DispositionSpecialApply( int nId, bool bRecalc) return pDisp->SpecialApply( bRecalc) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::DispositionSpecialUpdate( int nId) +{ + ResetLastError() ; + // verifico sia attiva + bool bActive ; + if ( ! GetOperationMode( nId, bActive)) + return false ; + if ( ! bActive) + return true ; + // recupero la disposizione + Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( nId)) ; + if ( pDisp == nullptr) + return false ; + // lancio l'azione + return pDisp->SpecialUpdate() ; +} + //---------------------------------------------------------------------------- // Machinings //---------------------------------------------------------------------------- @@ -932,6 +951,31 @@ MachMgr::MachiningApply( bool bRecalc) return pMch->Apply( bRecalc) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::MachiningUpdate( void) +{ + ResetLastError() ; + // recupero la lavorazione corrente + int nCurrMchId = GetCurrMachining() ; + if ( nCurrMchId == GDB_ID_NULL) + return false ; + // verifico sia attiva + bool bActive ; + if ( ! GetOperationMode( nCurrMchId, bActive)) + return false ; + if ( ! bActive) + return true ; + // ne recupero il gestore + Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nCurrMchId)) ; + if ( pMch == nullptr) + return false ; + // imposto fase della lavorazione come temporaneamente corrente + SetTempPhase TmpPhase( this, pMch->GetPhase()) ; + // aggiorno valori assi macchina e collegamento con operazione precedente + return pMch->Update() ; +} + //---------------------------------------------------------------------------- bool MachMgr::GetMachiningParam( int nType, bool& bVal) const diff --git a/Machining.h b/Machining.h index c2d2855..25be729 100644 --- a/Machining.h +++ b/Machining.h @@ -35,6 +35,7 @@ class Machining : public Operation virtual bool SetGeometry( const SELVECTOR& vIds) = 0 ; virtual bool Preview( bool bRecalc) = 0 ; virtual bool Apply( bool bRecalc) = 0 ; + virtual bool Update( void) = 0 ; virtual bool GetParam( int nType, bool& bVal) const = 0 ; virtual bool GetParam( int nType, int& nVal) const = 0 ; virtual bool GetParam( int nType, double& dVal) const = 0 ; diff --git a/Milling.cpp b/Milling.cpp index 43a8d05..eaef887 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -548,6 +548,18 @@ Milling::Apply( bool bRecalc) nPathId = m_pGeomDB->GetNextGroup( nPathId) ; } + // eseguo aggiornamento assi macchina e collegamento con operazione precedente + return Update() ; +} + +//---------------------------------------------------------------------------- +bool +Milling::Update( void) +{ + // verifico validità gestore DB geometrico e Id del gruppo + if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) + return false ; + // se lavorazione vuota, esco if ( m_nMills == 0) { LOG_INFO( GetEMkLogger(), "Warning in Milling : No machinable path") diff --git a/Milling.h b/Milling.h index 8e54ce0..95e4363 100644 --- a/Milling.h +++ b/Milling.h @@ -50,6 +50,7 @@ class Milling : public Machining bool SetGeometry( const SELVECTOR& vIds) override ; bool Preview( bool bRecalc) override ; bool Apply( bool bRecalc) override ; + bool Update( void) override ; bool GetParam( int nType, bool& bVal) const override ; bool GetParam( int nType, int& nVal) const override ; bool GetParam( int nType, double& dVal) const override ; diff --git a/Pocketing.cpp b/Pocketing.cpp index daca313..8ebe110 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -524,6 +524,18 @@ Pocketing::Apply( bool bRecalc) if ( ! bOk) return false ; + // eseguo aggiornamento assi macchina e collegamento con operazione precedente + return Update() ; +} + +//---------------------------------------------------------------------------- +bool +Pocketing::Update( void) +{ + // verifico validità gestore DB geometrico e Id del gruppo + if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) + return false ; + // se lavorazione vuota, esco if ( m_nPockets == 0) { LOG_INFO( GetEMkLogger(), "Warning in Pocketing : No machinable pocket") diff --git a/Pocketing.h b/Pocketing.h index f04f490..62c2f9f 100644 --- a/Pocketing.h +++ b/Pocketing.h @@ -51,6 +51,7 @@ class Pocketing : public Machining bool SetGeometry( const SELVECTOR& vIds) override ; bool Preview( bool bRecalc) override ; bool Apply( bool bRecalc) override ; + bool Update( void) override ; bool GetParam( int nType, bool& bVal) const override ; bool GetParam( int nType, int& nVal) const override ; bool GetParam( int nType, double& dVal) const override ; diff --git a/SawFinishing.cpp b/SawFinishing.cpp index cecde09..908ea87 100644 --- a/SawFinishing.cpp +++ b/SawFinishing.cpp @@ -464,9 +464,23 @@ SawFinishing::Apply( bool bRecalc) } } + // eseguo aggiornamento assi macchina e collegamento con operazione precedente + return Update() ; +} + +//---------------------------------------------------------------------------- +bool +SawFinishing::Update( void) +{ + // verifico validità gestore DB geometrico e Id del gruppo + if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) + return false ; + // se lavorazione vuota, esco - if ( m_nCuts == 0) + if ( m_nCuts == 0) { + LOG_INFO( GetEMkLogger(), "Warning in SawFinishing : No machinable path") return true ; + } // imposto eventuale asse bloccato da lavorazione if ( ! m_Params.m_sBlockedAxis.empty()) { diff --git a/SawFinishing.h b/SawFinishing.h index d46a9f2..ecd2892 100644 --- a/SawFinishing.h +++ b/SawFinishing.h @@ -53,6 +53,7 @@ class SawFinishing : public Machining bool SetGeometry( const SELVECTOR& vIds) override ; bool Preview( bool bRecalc) override ; bool Apply( bool bRecalc) override ; + bool Update( void) override ; bool GetParam( int nType, bool& bVal) const override ; bool GetParam( int nType, int& nVal) const override ; bool GetParam( int nType, double& dVal) const override ; diff --git a/SawRoughing.cpp b/SawRoughing.cpp index 36f145f..c3ffd90 100644 --- a/SawRoughing.cpp +++ b/SawRoughing.cpp @@ -440,9 +440,23 @@ SawRoughing::Apply( bool bRecalc) return false ; m_nCuts = 1 ; + // eseguo aggiornamento assi macchina e collegamento con operazione precedente + return Update() ; +} + +//---------------------------------------------------------------------------- +bool +SawRoughing::Update( void) +{ + // verifico validità gestore DB geometrico e Id del gruppo + if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) + return false ; + // se lavorazione vuota, esco - if ( m_nCuts == 0) + if ( m_nCuts == 0) { + LOG_INFO( GetEMkLogger(), "Warning in SawRoughing : No machinable path") return true ; + } // imposto eventuale asse bloccato da lavorazione if ( ! m_Params.m_sBlockedAxis.empty()) { diff --git a/SawRoughing.h b/SawRoughing.h index 3d449c9..0106b73 100644 --- a/SawRoughing.h +++ b/SawRoughing.h @@ -53,6 +53,7 @@ class SawRoughing : public Machining bool SetGeometry( const SELVECTOR& vIds) override ; bool Preview( bool bRecalc) override ; bool Apply( bool bRecalc) override ; + bool Update( void) override ; bool GetParam( int nType, bool& bVal) const override ; bool GetParam( int nType, int& nVal) const override ; bool GetParam( int nType, double& dVal) const override ; diff --git a/Sawing.cpp b/Sawing.cpp index 5edad55..84bf3e2 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -554,9 +554,23 @@ Sawing::Apply( bool bRecalc) nPathId = m_pGeomDB->GetNextGroup( nPathId) ; } + // eseguo aggiornamento assi macchina e collegamento con operazione precedente + return Update() ; +} + +//---------------------------------------------------------------------------- +bool +Sawing::Update( void) +{ + // verifico validità gestore DB geometrico e Id del gruppo + if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId)) + return false ; + // se lavorazione vuota, esco - if ( m_nCuts == 0) + if ( m_nCuts == 0) { + LOG_INFO( GetEMkLogger(), "Warning in Sawing : No machinable path") return true ; + } // imposto eventuale asse bloccato da lavorazione if ( ! m_Params.m_sBlockedAxis.empty()) { diff --git a/Sawing.h b/Sawing.h index f5f57e9..2967a81 100644 --- a/Sawing.h +++ b/Sawing.h @@ -53,6 +53,7 @@ class Sawing : public Machining bool SetGeometry( const SELVECTOR& vIds) override ; bool Preview( bool bRecalc) override ; bool Apply( bool bRecalc) override ; + bool Update( void) override ; bool GetParam( int nType, bool& bVal) const override ; bool GetParam( int nType, int& nVal) const override ; bool GetParam( int nType, double& dVal) const override ;