diff --git a/MachMgr.h b/MachMgr.h index f9b619b..e8ba2a8 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -165,6 +165,7 @@ class MachMgr : public IMachMgr int GetCurrSetup( void) const override ; bool GetDefaultSetupName( std::string& sName) const override ; bool ImportSetup( const std::string& sName) override ; + bool VerifyCurrSetup( STRVECTOR& vsErrors) override ; // Machinings DataBase bool MdbGetMachiningNewName( std::string& sName) const override ; bool MdbAddMachining( const std::string& sName, int nType) ; diff --git a/MachMgrSetup.cpp b/MachMgrSetup.cpp index bffbc0d..d2c6cc2 100644 --- a/MachMgrSetup.cpp +++ b/MachMgrSetup.cpp @@ -75,3 +75,49 @@ MachMgr::ImportSetup( const string& sName) // lo inserisco nel progetto return stuMgr.Save() ; } + +//---------------------------------------------------------------------------- +bool +MachMgr::VerifyCurrSetup( STRVECTOR& vsErrors) +{ + // pulizia vettore degli utensili mancanti + vsErrors.clear() ; + + // recupero attrezzaggio corrente + SetupMgr stuMgr ; + if ( ! stuMgr.Init( this) || ! stuMgr.Load()) + return false ; + + // 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 ( ! 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() ; +}