From e9cf46d2200346cd7c1ada327f50c6c68d599309 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 9 Nov 2016 14:06:41 +0000 Subject: [PATCH] EgtExecutor : - migliorato backup e restore stato CAM al salvataggio - aggiunta gestione modifica parametri lavorazioni per impostazione progetto modificato. --- EXE_GeomDB.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++------- EXE_MachMgr.cpp | 24 ++++++++++++++-------- 2 files changed, 62 insertions(+), 15 deletions(-) diff --git a/EXE_GeomDB.cpp b/EXE_GeomDB.cpp index 9e7a2c8..9f44a7b 100644 --- a/EXE_GeomDB.cpp +++ b/EXE_GeomDB.cpp @@ -358,25 +358,64 @@ ExeInsertFile( const string& sFilePath) return bOk ; } +//----------------------------------------------------------------------------- +class CamStatus +{ + public : + CamStatus( void) : m_nCurrMachGroup( GDB_ID_NULL), m_nCurrPhase( 0) { + IMachMgr* pMachMgr = GetCurrMachMgr() ; + if ( pMachMgr == nullptr) + return ; + m_nCurrMachGroup = pMachMgr->GetCurrMachGroup() ; + if ( m_nCurrMachGroup == GDB_ID_NULL) + return ; + m_nCurrPhase = pMachMgr->GetCurrPhase() ; + if ( m_nCurrPhase == 0) + return ; + int nId = pMachMgr->GetPhaseDisposition( m_nCurrPhase) ; + while ( nId != GDB_ID_NULL && pMachMgr->GetOperationPhase( nId) == m_nCurrPhase) { + bool bShow = false ; + pMachMgr->GetOperationStatus( nId, bShow) ; + m_vIdStat.push_back( ( bShow ? nId : - nId)) ; + nId = pMachMgr->GetNextOperation( nId) ; + } + } + void Restore( void) { + IMachMgr* pMachMgr = GetCurrMachMgr() ; + if ( pMachMgr == nullptr) + return ; + if ( m_nCurrMachGroup == GDB_ID_NULL) + return ; + pMachMgr->SetCurrMachGroup( m_nCurrMachGroup) ; + if ( m_nCurrPhase == 0) + return ; + pMachMgr->SetCurrPhase( m_nCurrPhase, true) ; + for ( auto nId : m_vIdStat) { + pMachMgr->SetOperationStatus( abs( nId), ( nId > 0)) ; + } + } + + private : + int m_nCurrMachGroup ; + int m_nCurrPhase ; + INTVECTOR m_vIdStat ; +} ; + //----------------------------------------------------------------------------- bool ExeSaveFile( const string& sFilePath, int nFlag) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) - // se ero in CAM, esco - int nCurrMachGroup = ExeGetCurrMachGroup() ; - int nCurrPhase = ExeGetCurrPhase() ; + // se ero in CAM, esco dopo averne salvato lo stato + CamStatus CurrCamStatus ; ExeResetCurrMachGroup() ; // imposto path corrente del file pGseCtx->m_sFilePath = sFilePath ; // salvo il file bool bOk = pGseCtx->m_pGeomDB->Save( GDB_ID_ROOT, sFilePath, nFlag) ; // eventuale ripristino precedente CAM - if ( nCurrMachGroup != GDB_ID_NULL) { - ExeSetCurrMachGroup( nCurrMachGroup) ; - ExeSetCurrPhase( nCurrPhase, true) ; - } + CurrCamStatus.Restore() ; // aggiorno stato file corrente if ( bOk) ExeResetModified() ; diff --git a/EXE_MachMgr.cpp b/EXE_MachMgr.cpp index 9bae9a1..ef876b8 100644 --- a/EXE_MachMgr.cpp +++ b/EXE_MachMgr.cpp @@ -1858,8 +1858,10 @@ ExeSetMachiningParam( int nType, bool bVal) IMachMgr* pMachMgr = GetCurrMachMgr() ; VERIFY_MACHMGR( pMachMgr, false) // imposto un parametro alla lavorazione corrente - bool bOk = pMachMgr->SetMachiningParam( nType, bVal) ; - ExeSetModified() ; + bool bChanged ; + bool bOk = pMachMgr->SetMachiningParam( nType, bVal, &bChanged) ; + if ( bChanged) + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSetMachiningParam(" + ToString( nType) + "," + @@ -1877,8 +1879,10 @@ ExeSetMachiningParam( int nType, int nVal) IMachMgr* pMachMgr = GetCurrMachMgr() ; VERIFY_MACHMGR( pMachMgr, false) // imposto un parametro alla lavorazione corrente - bool bOk = pMachMgr->SetMachiningParam( nType, nVal) ; - ExeSetModified() ; + bool bChanged ; + bool bOk = pMachMgr->SetMachiningParam( nType, nVal, &bChanged) ; + if ( bChanged) + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSetMachiningParam(" + ToString( nType) + "," + @@ -1896,8 +1900,10 @@ ExeSetMachiningParam( int nType, double dVal) IMachMgr* pMachMgr = GetCurrMachMgr() ; VERIFY_MACHMGR( pMachMgr, false) // imposto un parametro alla lavorazione corrente - bool bOk = pMachMgr->SetMachiningParam( nType, dVal) ; - ExeSetModified() ; + bool bChanged ; + bool bOk = pMachMgr->SetMachiningParam( nType, dVal, &bChanged) ; + if ( bChanged) + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSetMachiningParam(" + ToString( nType) + "," + @@ -1915,8 +1921,10 @@ ExeSetMachiningParam( int nType, const string& sVal) IMachMgr* pMachMgr = GetCurrMachMgr() ; VERIFY_MACHMGR( pMachMgr, false) // imposto un parametro alla lavorazione corrente - bool bOk = pMachMgr->SetMachiningParam( nType, sVal) ; - ExeSetModified() ; + bool bChanged ; + bool bOk = pMachMgr->SetMachiningParam( nType, sVal, &bChanged) ; + if ( bChanged) + ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSetMachiningParam(" + ToString( nType) + "," +