//---------------------------------------------------------------------------- // EgalTech 2015-2015 //---------------------------------------------------------------------------- // File : MachMgrMachines.cpp Data : 02.05.15 Versione : 1.6e1 // Contenuto : Implementazione gestione macchine della classe MachMgr. // // // // Modifiche : 02.05.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "MachMgr.h" #include "MachConst.h" #include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EgnStringUtils.h" #include "/EgtDev/Include/EgnFileUtils.h" #include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; //---------------------------------------------------------------------------- bool MachMgr::LoadMachine( const string& sMachineName) { // verifico validitą del nome if ( ! IsValidName( sMachineName)) return false ; // se macchina gią caricata, non devo fare alcunchč if ( GetMachine( sMachineName) != - 1) return true ; // creo gruppo ausiliario di base per le macchine if ( ! CreateMachAux()) return false ; // creo una nuova macchina PtrOwner pMch( new( nothrow) Machine) ; if ( IsNull( pMch)) return false ; // tento di caricarla if ( pMch->Init( sMachineName, this)) { m_vMachines.push_back( Release( pMch)) ; return true ; } return false ; } //---------------------------------------------------------------------------- int MachMgr::GetMachine( const string& sMachineName) const { // ciclo sulle macchine for ( size_t i = 0 ; i < m_vMachines.size() ; ++ i) { if ( m_vMachines[i] != nullptr && EqualNoCase( m_vMachines[i]->GetMachineName(), sMachineName)) return int( i) ; } return - 1 ; } //---------------------------------------------------------------------------- int MachMgr::GetCurrMGeoId( void) const { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return GDB_ID_NULL ; return m_vMachines[m_nCurrMch]->GetMGeoId() ; } //---------------------------------------------------------------------------- bool MachMgr::SetAxisPos( const string& sAxis, double dVal) { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return GDB_ID_NULL ; return m_vMachines[m_nCurrMch]->SetAxisPos( sAxis, dVal) ; } //---------------------------------------------------------------------------- bool MachMgr::GetAxisPos( const string& sAxis, double& dVal) { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return GDB_ID_NULL ; return m_vMachines[m_nCurrMch]->GetAxisPos( sAxis, dVal) ; } //---------------------------------------------------------------------------- bool MachMgr::GetAxisHomePos( const string& sAxis, double& dHomeVal) { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return GDB_ID_NULL ; return m_vMachines[m_nCurrMch]->GetAxisHomePos( sAxis, dHomeVal) ; } //---------------------------------------------------------------------------- bool MachMgr::ResetAxisPos( const string& sAxis) { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return GDB_ID_NULL ; return m_vMachines[m_nCurrMch]->ResetAxisPos( sAxis) ; } //---------------------------------------------------------------------------- bool MachMgr::LoadTool( const string& sHead, int nExit, const string& sTool) { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return false ; return m_vMachines[m_nCurrMch]->LoadTool( sHead, nExit, sTool) ; } //---------------------------------------------------------------------------- bool MachMgr::ResetHeadSet( const string& sHead) { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return false ; return m_vMachines[m_nCurrMch]->ResetHeadSet( sHead) ; } //---------------------------------------------------------------------------- bool MachMgr::SetCalcTable( const string& sTable) { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return false ; return m_vMachines[m_nCurrMch]->SetCurrTable( sTable) ; } //---------------------------------------------------------------------------- bool MachMgr::SetCalcTool( const string& sTool, const string& sHead, int nExit) { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return false ; return m_vMachines[m_nCurrMch]->SetCurrTool( sTool, sHead, nExit) ; } //---------------------------------------------------------------------------- bool MachMgr::GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return false ; return m_vMachines[m_nCurrMch]->GetAngles( vtDirT, vtDirA, nStat, dAngA1, dAngB1, dAngA2, dAngB2) ; } //---------------------------------------------------------------------------- bool MachMgr::GetCalcPositions( const Point3d& ptP, double dAngA, double dAngB, int& nStat, double& dX, double& dY, double& dZ) { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return false ; return m_vMachines[m_nCurrMch]->GetPositions( ptP, dAngA, dAngB, nStat, dX, dY, dZ) ; } //---------------------------------------------------------------------------- bool MachMgr::VerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) { if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) || m_vMachines[m_nCurrMch] == nullptr) return false ; return m_vMachines[m_nCurrMch]->VerifyOutOfStroke( dX, dY, dZ, dAngA, dAngB, nStat) ; }