3076dccb4b
- introdotto uso ObjUser per gruppi di macchina - prima versione prototipo delle forature - migliorie al calolo angoli e posizioni macchina.
98 lines
3.1 KiB
C++
98 lines
3.1 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : MachineAXes.cpp Data : 11.05.15 Versione : 1.6e3
|
|
// Contenuto : Implementazione gestione macchina : funzioni per assi.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 11.05.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "MachMgr.h"
|
|
#include "DllMain.h"
|
|
#include "Axis.h"
|
|
#include "/EgtDev/Include/EGkGeoVector3d.h"
|
|
#include "/EgtDev/Include/EGnStringUtils.h"
|
|
#include "/EgtDev/Include/EGnFileUtils.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::SetAxisPos( const string& sAxis, double dVal)
|
|
{
|
|
// recupero il gruppo dell'asse
|
|
int nAxGrp = GetGroup( sAxis) ;
|
|
// recupero il relativo gestore
|
|
Axis* pAx = GetAxis( nAxGrp) ;
|
|
if ( pAx == nullptr)
|
|
return false ;
|
|
// tipo di asse
|
|
bool bLinear = ( pAx->GetType() != MCH_AT_ROTARY) ;
|
|
// posizione attuale
|
|
double dCurrVal = pAx->GetCurrVal() ;
|
|
// limiti della corsa
|
|
STROKE Stroke = pAx->GetStroke() ;
|
|
// recupero il vettore dell'asse
|
|
int nV = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nAxGrp, sAxis) ;
|
|
const IGeoVector3d* pGV = GetGeoVector3d( m_pMchMgr->m_pGeomDB->GetGeoObj( nV)) ;
|
|
if ( pGV == nullptr)
|
|
return false ;
|
|
Point3d ptPos = pGV->GetBase() ;
|
|
Vector3d vtDir = pGV->GetVector() / AXIS_LEN ;
|
|
// limito il movimento alla corsa dell'asse
|
|
if ( dVal > Stroke.Max)
|
|
dVal = Stroke.Max ;
|
|
else if ( dVal < Stroke.Min)
|
|
dVal = Stroke.Min ;
|
|
// eseguo il movimento
|
|
if ( bLinear)
|
|
m_pMchMgr->m_pGeomDB->TranslateGroup( nAxGrp, vtDir * ( dVal - dCurrVal)) ;
|
|
else
|
|
m_pMchMgr->m_pGeomDB->RotateGroup( nAxGrp, ptPos, vtDir, ( dVal - dCurrVal)) ;
|
|
// salvo la nuova posizione
|
|
return pAx->SetCurrVal( dVal) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::GetAxisPos( const string& sAxis, double& dVal)
|
|
{
|
|
// recupero il relativo gestore
|
|
Axis* pAx = GetAxis( GetGroup( sAxis)) ;
|
|
if ( pAx == nullptr)
|
|
return false ;
|
|
// recupero la posizione corrente
|
|
dVal = pAx->GetCurrVal() ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::GetAxisHomePos( const string& sAxis, double& dHomeVal)
|
|
{
|
|
// recupero il gestore dell'asse
|
|
Axis* pAx = GetAxis( GetGroup( sAxis)) ;
|
|
if ( pAx == nullptr)
|
|
return false ;
|
|
// recupero la posizione home
|
|
dHomeVal = pAx->GetHomeVal() ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::ResetAxisPos( const string& sAxis)
|
|
{
|
|
// recupero la posizione home
|
|
double dHomeVal ;
|
|
if ( ! GetAxisHomePos( sAxis, dHomeVal))
|
|
return false ;
|
|
// eseguo il movimento
|
|
return SetAxisPos( sAxis, dHomeVal) ;
|
|
} |