EgtMachKernel 1.6e4 :
- aggiunta gestione Assi di macchina per lettura e movimento - aggiunta gestione Teste di macchina per lettura e carico/scarico utensili.
This commit is contained in:
+104
@@ -0,0 +1,104 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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 "/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) ;
|
||||
if ( nAxGrp == GDB_ID_NULL || ! IsAxisGroup( nAxGrp))
|
||||
return false ;
|
||||
// recupero il tipo di asse
|
||||
string sType ;
|
||||
if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nAxGrp, "Type", sType))
|
||||
return false ;
|
||||
bool bLinear = ( sType != MCH_AXIS + ToString( MCH_AT_ROTARY)) ;
|
||||
// recupero la posizione attuale
|
||||
double dCurrVal ;
|
||||
if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nAxGrp, "Val", dCurrVal))
|
||||
return false ;
|
||||
// recupero i limiti della corsa
|
||||
STROKE Stroke ; string sTmp ;
|
||||
if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nAxGrp, "Stroke", sTmp) || ! FromString( sTmp, Stroke.v))
|
||||
return false ;
|
||||
// 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 m_pMchMgr->m_pGeomDB->SetInfo( nAxGrp, "Val", dVal) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::GetAxisPos( const string& sAxis, double& dVal)
|
||||
{
|
||||
// recupero il gruppo dell'asse
|
||||
int nAxGrp = GetGroup( sAxis) ;
|
||||
if ( nAxGrp == GDB_ID_NULL || ! IsAxisGroup( nAxGrp))
|
||||
return false ;
|
||||
// recupero la posizione corrente
|
||||
return m_pMchMgr->m_pGeomDB->GetInfo( nAxGrp, "Val", dVal) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::GetAxisHomePos( const string& sAxis, double& dHomeVal)
|
||||
{
|
||||
// recupero il gruppo dell'asse
|
||||
int nAxGrp = GetGroup( sAxis) ;
|
||||
if ( nAxGrp == GDB_ID_NULL || ! IsAxisGroup( nAxGrp))
|
||||
return false ;
|
||||
// recupero la posizione corrente
|
||||
return m_pMchMgr->m_pGeomDB->GetInfo( nAxGrp, "HVal", dHomeVal) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::ResetAxisPos( const string& sAxis)
|
||||
{
|
||||
// recupero il gruppo dell'asse
|
||||
int nAxGrp = GetGroup( sAxis) ;
|
||||
if ( nAxGrp == GDB_ID_NULL || ! IsAxisGroup( nAxGrp))
|
||||
return false ;
|
||||
// recupero la posizione home
|
||||
double dHomeVal ;
|
||||
if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nAxGrp, "HVal", dHomeVal))
|
||||
return false ;
|
||||
// eseguo il movimento
|
||||
return SetAxisPos( sAxis, dHomeVal) ;
|
||||
}
|
||||
Reference in New Issue
Block a user