//---------------------------------------------------------------------------- // EgalTech 2015-2015 //---------------------------------------------------------------------------- // File : MachMgr.cpp Data : 23.03.15 Versione : 1.6c6 // Contenuto : Implementazione della classe MachMgr. // // // // Modifiche : 23.03.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "DllMain.h" #include "MachMgr.h" #include "MachConst.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/SELkKeyProc.h" #include "/EgtDev/Include/EgtKeyCodes.h" #include using namespace std ; //---------------------------------------------------------------------------- IMachMgr* CreateMachMgr( void) { // verifico la chiave e le opzioni unsigned int nOpt1, nOpt2 ; int nOptExpDays ; int nRet = GetKeyOptions( GetEMkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, nOpt1, nOpt2, nOptExpDays) ; if ( nRet != KEY_OK) { string sErr = "Error on Key (MKC/" + ToString( nRet) + ")" ; LOG_ERROR( GetEMkLogger(), sErr.c_str()) ; return false ; } if ( (nOpt1 & KEYOPT_EMK_BASE) == 0 || nOptExpDays < GetCurrDay()) { string sErr = "Error on Key (MKC/OPT)" ; LOG_ERROR( GetEMkLogger(), sErr.c_str()) ; return false ; } // creo il MachMgr return static_cast ( new(nothrow) MachMgr) ; } //---------------------------------------------------------------------------- // MachMgr //---------------------------------------------------------------------------- MachMgr::MachMgr( void) { m_pGeomDB = nullptr ; } //---------------------------------------------------------------------------- bool MachMgr::Init( IGeomDB* pGeomDB) { m_pGeomDB = pGeomDB ; return ( m_pGeomDB != nullptr) ; } //---------------------------------------------------------------------------- int MachMgr::VerifyMachBase( void) { // verifica collegamento a DB geometrico if ( m_pGeomDB == nullptr) return GDB_ID_NULL ; // verifica esistenza gruppo di base per macchinate int nId = m_pGeomDB->GetFirstGroupInGroup( GDB_ID_ROOT) ; while ( nId != GDB_ID_NULL) { // verifica del nome string sName ; if ( m_pGeomDB->GetName( nId, sName) && sName == MACH_BASE) return nId ; // passo al successivo nId = m_pGeomDB->GetNextGroup( nId) ; } // non trovato, devo creare il gruppo di base delle lavorazioni int nNewId = m_pGeomDB->InsertGroup( GDB_ID_NULL, GDB_ID_ROOT, GDB_FIRST_SON, GLOB_FRM) ; if ( nNewId == GDB_ID_NULL) return GDB_ID_NULL ; // imposto nome del gruppo m_pGeomDB->SetName( nNewId, MACH_BASE) ; // imposto livello del gruppo a System m_pGeomDB->SetLevel( nNewId, GDB_LV_SYSTEM) ; return nNewId ; } //---------------------------------------------------------------------------- int MachMgr::AddMachGroup( const string& sName, const string& sMachineName) { // verifica del gruppo base per le lavorazioni int nMbId = VerifyMachBase() ; if ( nMbId == GDB_ID_NULL) return false ; // verifico esistenza della macchina // !!!! TO DO !!!! // inserisco il gruppo in coda int nNewId = m_pGeomDB->AddGroup( GDB_ID_NULL, nMbId, GLOB_FRM) ; // assegno il nome m_pGeomDB->SetName( nNewId, sName) ; return nNewId ; }