Files
EgtMachKernel/MachMgrSimulation.cpp
T
DarioS b2dacc0cef EgtMachKernel :
- aggiunto flag bToolOn a EmtAddCollisionObjEx per dichiarare che è utensile in lavoro (necessario quando si usano più utensili contemporaneamente).
2023-01-18 08:43:12 +01:00

205 lines
5.9 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2015-2023
//----------------------------------------------------------------------------
// File : MachMgrSimulation.cpp Data : 16.01.23 Versione : 2.5a2
// 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::SimInit( void)
{
// alloco o rialloco il simulatore
if ( m_pSimul != nullptr)
delete m_pSimul ;
m_pSimul = new( nothrow) Simulator ;
if ( m_pSimul == nullptr)
return false ;
// lo inizializzo
return m_pSimul->Init( this) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SimStart( bool bFirst)
{
// verifico simulatore
if ( m_pSimul == nullptr)
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::SimExit( 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 ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SimAddCollisionObj( int nInd, bool bToolOn, int nFrameId, int nType, const Vector3d& vtMove, double dPar1, double dPar2, double dPar3)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// aggiungo un oggetto da verificare per la collisione con il grezzo
return m_pSimul->AddCollisionObj( nInd, bToolOn, nFrameId, nType, vtMove, dPar1, dPar2, dPar3) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SimExecCollisionCheck( int& nCdInd, int& nObjInd, int nMoveType)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// eseguo verifica di collisione (nessuna collisione -> true)
return m_pSimul->ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SimOnCollision( int nCdInd, int nObjInd, int& nErr)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// lancio funzione di gestione collisione
return m_pSimul->OnCollision( nCdInd, nObjInd, nErr) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SimSetToolForVmill( const string& sTool, const string& sHead, int nExit, const INTVECTOR& vVmill, bool bFirst)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// imposto utensile per Vmill
return m_pSimul->SetToolForVmill( sTool, sHead, nExit, vVmill, bFirst) ;
}
//----------------------------------------------------------------------------
int
MachMgr::SimMoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// lancio movimento assi
return m_pSimul->MoveAxes( nMoveType, vAxNaEpSt) ;
}