3016bcf90b
- aggiunta in interfaccia funzione GetAxisInvert.
174 lines
5.1 KiB
C++
174 lines
5.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::GetAxisToken( const string& sAxis, string& sToken) const
|
|
{
|
|
// controllo GeomDB
|
|
if ( m_pGeomDB == nullptr)
|
|
return false ;
|
|
// recupero il relativo gestore
|
|
Axis* pAx = GetAxis( GetGroup( sAxis)) ;
|
|
if ( pAx == nullptr)
|
|
return false ;
|
|
// recupero il token dell'asse
|
|
sToken = pAx->GetToken() ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::GetAxisInvert( const string& sAxis, bool& bInvert) const
|
|
{
|
|
// controllo GeomDB
|
|
if ( m_pGeomDB == nullptr)
|
|
return false ;
|
|
// recupero il relativo gestore
|
|
Axis* pAx = GetAxis( GetGroup( sAxis)) ;
|
|
if ( pAx == nullptr)
|
|
return false ;
|
|
// recupero il flag di inversione dell'asse in visualizzazione
|
|
bInvert = pAx->GetInvert() ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::GetAxisType( const string& sAxis, bool& bLinear) const
|
|
{
|
|
// controllo GeomDB
|
|
if ( m_pGeomDB == nullptr)
|
|
return false ;
|
|
// recupero il relativo gestore
|
|
Axis* pAx = GetAxis( GetGroup( sAxis)) ;
|
|
if ( pAx == nullptr)
|
|
return false ;
|
|
// recupero il tipo dell'asse
|
|
bLinear = ( pAx->GetType() == MCH_AT_LINEAR) ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::SetAxisPos( const string& sAxis, double dVal)
|
|
{
|
|
// controllo GeomDB
|
|
if ( m_pGeomDB == nullptr)
|
|
return false ;
|
|
// 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_pGeomDB->GetFirstNameInGroup( nAxGrp, sAxis) ;
|
|
const IGeoVector3d* pGV = GetGeoVector3d( m_pGeomDB->GetGeoObj( nV)) ;
|
|
if ( pGV == nullptr)
|
|
return false ;
|
|
Point3d ptPos = pGV->GetBase() ;
|
|
Vector3d vtDir = pGV->GetVector() ;
|
|
vtDir.Normalize() ;
|
|
// 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_pGeomDB->TranslateGroup( nAxGrp, vtDir * ( dVal - dCurrVal)) ;
|
|
else
|
|
m_pGeomDB->RotateGroup( nAxGrp, ptPos, vtDir, ( dVal - dCurrVal)) ;
|
|
// salvo la nuova posizione
|
|
return pAx->SetCurrVal( dVal) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::GetAxisPos( const string& sAxis, double& dVal) const
|
|
{
|
|
// controllo GeomDB
|
|
if ( m_pGeomDB == nullptr)
|
|
return false ;
|
|
// 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) const
|
|
{
|
|
// controllo GeomDB
|
|
if ( m_pGeomDB == nullptr)
|
|
return false ;
|
|
// 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)
|
|
{
|
|
// controllo GeomDB
|
|
if ( m_pGeomDB == nullptr)
|
|
return false ;
|
|
// recupero la posizione home
|
|
double dHomeVal ;
|
|
if ( ! GetAxisHomePos( sAxis, dHomeVal))
|
|
return false ;
|
|
// eseguo il movimento
|
|
return SetAxisPos( sAxis, dHomeVal) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machine::ResetAllAxesPos( void)
|
|
{
|
|
// ciclo sui gruppi della macchina
|
|
for ( auto Iter = m_mapGroups.cbegin() ; Iter != m_mapGroups.cend() ; ++ Iter) {
|
|
if ( IsAxisGroup( Iter->second)) {
|
|
if ( ! ResetAxisPos( Iter->first))
|
|
return false ;
|
|
}
|
|
}
|
|
return true ;
|
|
}
|