//---------------------------------------------------------------------------- // EgalTech 2015-2015 //---------------------------------------------------------------------------- // File : MachMgrSimulation.cpp Data : 20.10.15 Versione : 1.6j2 // Contenuto : Implementazione gestione simulazione della classe MachMgr. // // // // Modifiche : 20.10.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "DllMain.h" #include "MachMgr.h" #include "MachConst.h" #include "Simulator.h" using namespace std ; //---------------------------------------------------------------------------- bool MachMgr::SimStart( bool bFirst) { // alloco simulatore if ( m_pSimul != nullptr) delete m_pSimul ; m_pSimul = new( std::nothrow) Simulator ; if ( m_pSimul == nullptr) return false ; // lo inizializzo if ( ! m_pSimul->Init( this)) return false ; // lo avvio return m_pSimul->Start( bFirst) ; } //---------------------------------------------------------------------------- bool MachMgr::SimMove( int& nStatus) { // verifico simulatore if ( m_pSimul == nullptr) { nStatus = MCH_SIM_ERR ; return false ; } // eseguo movimento return m_pSimul->Move( nStatus) ; } //---------------------------------------------------------------------------- bool MachMgr::SimGetAxisInfoPos( int nI, string& sName, string& sToken, bool& bLinear, double& dVal) const { // verifico simulatore if ( m_pSimul == nullptr) return false ; // recupero dati return m_pSimul->GetAxisInfoPos( nI, sName, sToken, bLinear, dVal) ; } //---------------------------------------------------------------------------- bool MachMgr::SimGetToolInfo( string& sName, double& dSpeed) const { // verifico simulatore if ( m_pSimul == nullptr) return false ; // recupero dati utensile corrente return m_pSimul->GetToolInfo( sName, dSpeed) ; } //---------------------------------------------------------------------------- bool MachMgr::SimGetOperationInfo( string& sName, int& nType) const { // verifico simulatore if ( m_pSimul == nullptr) return false ; // recupero dati operazione corrente return m_pSimul->GetOperationInfo( sName, nType) ; } //---------------------------------------------------------------------------- bool MachMgr::SimGetMoveInfo( int& nGmove, double& dFeed) const { // verifico simulatore if ( m_pSimul == nullptr) return false ; // recupero quote return m_pSimul->GetMoveInfo( nGmove, dFeed) ; } //---------------------------------------------------------------------------- bool MachMgr::SimSetStep( double dStep) { // verifico simulatore if ( m_pSimul == nullptr) return false ; // imposto lo step di riferimento return m_pSimul->SetStep( dStep) ; } //---------------------------------------------------------------------------- bool MachMgr::SimSetUiStatus( int nUiStatus) { // verifico simulatore if ( m_pSimul == nullptr) return false ; // imposto lo stato utente del simulatore return m_pSimul->SetUiStatus( nUiStatus) ; } //---------------------------------------------------------------------------- bool MachMgr::SimGoHome( void) { // verifico simulatore if ( m_pSimul == nullptr) return false ; // eseguo movimento in home return m_pSimul->GoHome() ; } //---------------------------------------------------------------------------- bool MachMgr::SimStop( void) { // verifico simulatore if ( m_pSimul == nullptr) return true ; // lo cancello (il distruttore provvede ovviamente a fermarlo) delete m_pSimul ; m_pSimul = nullptr ; return true ; }