diff --git a/EXE_GeomDB.cpp b/EXE_GeomDB.cpp index 5569ffa..2ae3103 100644 --- a/EXE_GeomDB.cpp +++ b/EXE_GeomDB.cpp @@ -348,14 +348,17 @@ ExeSaveFile( const string& sFilePath, int nFlag) VERIFY_CTX_GEOMDB( pGseCtx, false) // se ero in CAM, esco int nCurrMachGroup = ExeGetCurrMachGroup() ; + int nCurrPhase = ExeGetCurrPhase() ; 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) + if ( nCurrMachGroup != GDB_ID_NULL) { ExeSetCurrMachGroup( nCurrMachGroup) ; + ExeSetCurrPhase( nCurrPhase) ; + } // aggiorno stato file corrente if ( bOk) ExeResetModified() ; diff --git a/EXE_MachMgr.cpp b/EXE_MachMgr.cpp index d1a25c6..4baba81 100644 --- a/EXE_MachMgr.cpp +++ b/EXE_MachMgr.cpp @@ -228,6 +228,48 @@ ExeGetCurrMachGroup( void) return pMachMgr->GetCurrMachGroup() ; } +//----------------------------------------------------------------------------- +// Phases +//----------------------------------------------------------------------------- +int +ExeAddPhase( void) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, 0) + // aggiungo una nuova fase di lavorazione alla macchinata corrente + return pMachMgr->AddPhase() ; +} + +//----------------------------------------------------------------------------- +bool +ExeSetCurrPhase( int nPhase) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, false) + // imposto la fase di lavorazione corrente nella macchinata corrente + return pMachMgr->SetCurrPhase( nPhase) ; +} + +//----------------------------------------------------------------------------- +int +ExeGetCurrPhase( void) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, false) + // recupero la fase di lavorazione corrente nella macchinata corrente + return pMachMgr->GetCurrPhase() ; +} + +//----------------------------------------------------------------------------- +int +ExeGetPhaseCount( void) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, 0) + // recupero il numero totale di fasi di lavorazione della macchinata corrente + return pMachMgr->GetPhaseCount() ; +} + //----------------------------------------------------------------------------- // Raw Parts & Parts //----------------------------------------------------------------------------- @@ -360,6 +402,25 @@ ExeModifyRawPartHeight( int nRawId, double dHeight) return bOk ; } +//----------------------------------------------------------------------------- +bool +ExeKeepRawPart( int nRawId) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // confermo il grezzo nella fase corrente della macchinata corrente + bool bOk = pGseCtx->m_pMachMgr->KeepRawPart( nRawId) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtKeepRawPart(" + ToString( nRawId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + //----------------------------------------------------------------------------- bool ExeRemoveRawPart( int nRawId) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index f937167..a15b5c8 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp index d6f1ed2..2828ae8 100644 --- a/LUA_MachMgr.cpp +++ b/LUA_MachMgr.cpp @@ -222,6 +222,65 @@ LuaGetCurrMachGroup( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +// Phases +//------------------------------------------------------------------------------- +static int +LuaAddPhase( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // aggiungo una nuova fase di lavorazione alla macchinata corrente + int nPhase = ExeAddPhase() ; + // restituisco il risultato + if ( nPhase > 0) + LuaSetParam( L, nPhase) ; + else + LuaSetParam( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaSetCurrPhase( lua_State* L) +{ + // 1 parametro : nPhase + int nPhase ; + LuaCheckParam( L, 1, nPhase) + LuaClearStack( L) ; + // imposto la fase di lavorazione corrente nella macchinata corrente + bool bOk = ExeSetCurrPhase( nPhase) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetCurrPhase( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // recupero la fase di lavorazione corrente nella macchinata corrente + int nCount = ExeGetCurrPhase() ; + // restituisco il risultato + LuaSetParam( L, nCount) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetPhaseCount( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // recupero il numero totale di fasi di lavorazione nella macchinata corrente + int nCount = ExeGetPhaseCount() ; + // restituisco il risultato + LuaSetParam( L, nCount) ; + return 1 ; +} + //------------------------------------------------------------------------------- // Raw Parts & Parts //------------------------------------------------------------------------------- @@ -358,6 +417,21 @@ LuaModifyRawPartHeight( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaKeepRawPart( lua_State* L) +{ + // 1 parametro : nRawId + int nRawId ; + LuaCheckParam( L, 1, nRawId) + LuaClearStack( L) ; + // confermo il grezzo nella fase corrente della macchinata corrente + bool bOk = ExeKeepRawPart( nRawId) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaRemoveRawPart( lua_State* L) @@ -1978,6 +2052,11 @@ LuaInstallMachMgr( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSetCurrMachGroup", LuaSetCurrMachGroup) ; bOk = bOk && luaMgr.RegisterFunction( "EgtResetCurrMachGroup", LuaResetCurrMachGroup) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetCurrMachGroup", LuaGetCurrMachGroup) ; + // Phases + bOk = bOk && luaMgr.RegisterFunction( "EgtAddPhase", LuaAddPhase) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSetCurrPhase", LuaSetCurrPhase) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetCurrPhase", LuaGetCurrPhase) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetPhaseCount", LuaGetPhaseCount) ; // Raw Parts & Parts bOk = bOk && luaMgr.RegisterFunction( "EgtGetRawPartCount", LuaGetRawPartCount) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstRawPart", LuaGetFirstRawPart) ; @@ -1986,6 +2065,7 @@ LuaInstallMachMgr( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtAddRawPartWithPart", LuaAddRawPartWithPart) ; bOk = bOk && luaMgr.RegisterFunction( "EgtModifyRawPartSize", LuaModifyRawPartSize) ; bOk = bOk && luaMgr.RegisterFunction( "EgtModifyRawPartHeight", LuaModifyRawPartHeight) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtKeepRawPart", LuaKeepRawPart) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveRawPart", LuaRemoveRawPart) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRotateRawPart", LuaRotateRawPart) ; bOk = bOk && luaMgr.RegisterFunction( "EgtMoveToCornerRawPart", LuaMoveToCornerRawPart) ;