9351b9b2d8
- aggiunte funzioni lua EmtRemoveCollisionObj e EmtGetCollisionObj per meglio gestire gli oggetti di collisione di tipo testa da postproc.
268 lines
8.1 KiB
C++
268 lines
8.1 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 "SimulatorSP.h"
|
|
#include "SimulatorMP.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::SimInit( void)
|
|
{
|
|
// alloco o rialloco il simulatore
|
|
if ( m_pSimul != nullptr)
|
|
delete m_pSimul ;
|
|
if ( GetCurrMachine() == nullptr)
|
|
return false ;
|
|
if ( GetCurrMachine()->GetMultiProcess( 2))
|
|
m_pSimul = CreateSimulatorMP() ;
|
|
else
|
|
m_pSimul = CreateSimulatorSP() ;
|
|
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::SimEnableToolTipTrace( bool bEnable)
|
|
{
|
|
// verifico simulatore
|
|
if ( m_pSimul == nullptr)
|
|
return false ;
|
|
// imposto abilitazione disegno traccia della punta utensile
|
|
return m_pSimul->EnableToolTipTrace( bEnable) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
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::SimRemoveCollisionObj( int nFrameId)
|
|
{
|
|
// verifico simulatore
|
|
if ( m_pSimul == nullptr)
|
|
return false ;
|
|
// rimuovo gli oggetti da verificare per la collisione con il grezzo con FrameId indicato
|
|
return m_pSimul->RemoveCollisionObj( nFrameId) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::SimGetCollisionObj( int nPos, int& nInd, bool& bToolOn, int& nFrameId, int& nType,
|
|
Vector3d& vtMove, double& dPar1, double& dPar2, double& dPar3) const
|
|
{
|
|
// verifico simulatore
|
|
if ( m_pSimul == nullptr)
|
|
return false ;
|
|
// recupero i dati dell'oggetto di collisione di posizione indicata nel relativo vettore
|
|
return m_pSimul->GetCollisionObj( nPos, 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, int nFlag, double dPar1, double dPar2,
|
|
const INTVECTOR& vVmill, bool bFirst)
|
|
{
|
|
// verifico simulatore
|
|
if ( m_pSimul == nullptr)
|
|
return false ;
|
|
// imposto utensile per Vmill
|
|
return m_pSimul->SetToolForVmill( sTool, sHead, nExit, nFlag, dPar1, dPar2, vVmill, bFirst) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::SimEnableToolsForVmill( bool bEnable)
|
|
{
|
|
// verifico simulatore
|
|
if ( m_pSimul == nullptr)
|
|
return false ;
|
|
// imposto abilitazione Vmill
|
|
return m_pSimul->EnableToolsForVmill( bEnable) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::SimMoveAxes( int nMoveType, const SAMVECTOR& vAxNaEpSt)
|
|
{
|
|
// verifico simulatore
|
|
if ( m_pSimul == nullptr)
|
|
return SIM_AXMV_RES_ERR ;
|
|
// lancio movimento assi
|
|
return m_pSimul->MoveAxes( nMoveType, vAxNaEpSt) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::SimSaveCmd( int nType, int nPar, const string& sPar, const string& sPar2)
|
|
{
|
|
// verifico simulatore
|
|
if ( m_pSimul == nullptr)
|
|
return false ;
|
|
// salvo il comando
|
|
return m_pSimul->SaveCmd( nType, nPar, sPar, sPar2) ;
|
|
}
|