//---------------------------------------------------------------------------- // EgalTech 2017-2017 //---------------------------------------------------------------------------- // File : MachMgrSetup.cpp Data : 09.01.17 Versione : 1.6x5 // Contenuto : Implementazione gestione attrezzaggio della classe MachMgr. // // // // Modifiche : 09.01.17 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "DllMain.h" #include "MachMgr.h" #include "/EgtDev/Include/EgtIniFile.h" using namespace std ; //---------------------------------------------------------------------------- int MachMgr::GetCurrSetup( void) const { return GetCurrSetupGroupId() ; } //---------------------------------------------------------------------------- bool MachMgr::GetDefaultSetupName( string& sName) const { // verifico esista macchina corrente Machine* pMch = GetCurrMachine() ; if ( pMch == nullptr) return false ; // recupero da file Ini della macchina string sMachIni = pMch->GetMachineDir() + "\\" + pMch->GetMachineName() + ".ini" ; string sDefault = GetPrivateProfileStringUtf8( SETUP_SEC.c_str(), SETUP_DEF_KEY.c_str(), "", sMachIni.c_str()) ; // se non trovato, errore if ( IsEmptyOrSpaces( sDefault)) return false ; // assegno il nome sName = sDefault ; return true ; } //---------------------------------------------------------------------------- bool MachMgr::ImportSetup( const string& sName) { // definisco path completa del file di attrezzaggio string sFileName = GetCurrSetupDir() + "\\" ; // se ricevuto nome if ( ! IsEmptyOrSpaces( sName)) { sFileName += sName + "." + SETUP_EXT ; } // altrimenti cerco default else { string sDefault ; if ( ! GetDefaultSetupName( sDefault)) return false ; sFileName += sDefault + "." + SETUP_EXT ; } // importo l'attrezzaggio if ( ! m_stuMgr.Import( sFileName)) return false ; // lo inserisco nel progetto return m_stuMgr.Save() ; } //---------------------------------------------------------------------------- bool MachMgr::VerifyCurrSetup( STRVECTOR& vsErrors) { // pulizia vettore degli utensili mancanti vsErrors.clear() ; // ciclo sulle lavorazioni della macchinata corrente per ricavare gli utensili utilizzati int nOpId = GetFirstActiveOperation() ; while ( nOpId != GDB_ID_NULL) { // processo l'operazione int nType = GetOperationType( nOpId) ; if ( IsValidMachiningType( nType)) { // Imposto come lavorazione corrente if ( ! SetCurrMachining( nOpId)) continue ; // Recupero l'utensile della lavorazione corrente string sTuuid, sTool ; if ( ! GetMachiningParam( MPA_TUUID, sTuuid) || ! TdbGetToolFromUUID( sTuuid, sTool)) { string sMchName ; m_pGeomDB->GetName( nOpId, sMchName) ; string sToolName ; GetMachiningParam( MPA_TOOL, sToolName) ; string sErr = sMchName + "/" + sToolName ; vsErrors.push_back( sErr) ; } // Se utensile non attrezzato if ( ! m_stuMgr.FindTool( sTool)) { // se non presente nella lista dei non attrezzati, lo aggiungo if ( find( vsErrors.begin(), vsErrors.end(), sTool) == vsErrors.end()) vsErrors.push_back( sTool) ; } } // passo alla operazione successiva nOpId = GetNextActiveOperation( nOpId) ; } return vsErrors.empty() ; } //---------------------------------------------------------------------------- bool MachMgr::FindToolInCurrSetup( const string& sTool) { return m_stuMgr.FindTool( sTool) ; } //---------------------------------------------------------------------------- bool MachMgr::GetToolsInCurrSetupPos( const string& sTcPos, STRVECTOR& vsTools) { return m_stuMgr.GetToolsInSetupPos( sTcPos, vsTools) ; } //---------------------------------------------------------------------------- bool MachMgr::UpdateCurrSetup( void) { // aggiorno attrezzaggio if ( ! m_stuMgr.Load()) return false ; // carico utensili relativi Machine* pMch = GetCurrMachine() ; if ( pMch == nullptr) return false ; return pMch->LoadAllTools() ; } //---------------------------------------------------------------------------- bool MachMgr::EraseCurrSetup( void) { // pulisco attrezzaggio if ( ! m_stuMgr.Clear()) return false ; // salvo i dati return m_stuMgr.Save() ; }