44a9bdadf6
- aggiunte GetMachiningStartPoint e GetMachiningEndPoint.
160 lines
5.3 KiB
C++
160 lines
5.3 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : Machining.cpp Data : 10.06.15 Versione : 1.6f2
|
|
// Contenuto : Implementazione gestione base lavorazioni.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 10.06.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "DllMain.h"
|
|
#include "MachMgr.h"
|
|
#include "Machining.h"
|
|
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
|
#include "/EgtDev/Include/EGkCurve.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
//----------------------------------------------------------------------------
|
|
Machining::Machining( void)
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
const string&
|
|
Machining::GetToolName( void) const
|
|
{
|
|
return GetToolData().m_sName ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
const string&
|
|
Machining::GetHeadName( void) const
|
|
{
|
|
return GetToolData().m_sHead ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
Machining::GetExitNbr( void) const
|
|
{
|
|
return GetToolData().m_nExit ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
const string&
|
|
Machining::GetToolTcPos( void) const
|
|
{
|
|
return GetToolData().m_sTcPos ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machining:: NeedPrevHome( void) const
|
|
{
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machining::GetStartPoint( Point3d& ptStart) const
|
|
{
|
|
// verifico validità gestore DB geometrico
|
|
if ( m_pGeomDB == nullptr)
|
|
return false ;
|
|
// recupero gruppo per geometria di lavorazione (Cutter Location)
|
|
int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ;
|
|
if ( nClId == GDB_ID_NULL)
|
|
return false ;
|
|
// recupero la prima entità del primo sottogruppo
|
|
int nEntId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetFirstGroupInGroup( nClId)) ;
|
|
if ( nEntId == GDB_ID_NULL)
|
|
return false ;
|
|
// recupero il punto iniziale di questa entità
|
|
const IGeoObj* pGeoObj = m_pGeomDB->GetGeoObj( nEntId) ;
|
|
if ( pGeoObj->GetType() == GEO_PNT3D) {
|
|
ptStart = GetGeoPoint3d( pGeoObj)->GetPoint() ;
|
|
return true ;
|
|
}
|
|
else if ( ( pGeoObj->GetType() & GEO_CURVE) != 0)
|
|
return GetCurve( pGeoObj)->GetStartPoint( ptStart) ;
|
|
else
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machining::GetEndPoint( Point3d& ptEnd) const
|
|
{
|
|
// verifico validità gestore DB geometrico
|
|
if ( m_pGeomDB == nullptr)
|
|
return false ;
|
|
// recupero gruppo per geometria di lavorazione (Cutter Location)
|
|
int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ;
|
|
if ( nClId == GDB_ID_NULL)
|
|
return false ;
|
|
// recupero l'ultima entità dell'ultimo sottogruppo
|
|
int nEntId = m_pGeomDB->GetLastInGroup( m_pGeomDB->GetLastGroupInGroup( nClId)) ;
|
|
if ( nEntId == GDB_ID_NULL)
|
|
return false ;
|
|
// recupero il punto finale di questa entità
|
|
const IGeoObj* pGeoObj = m_pGeomDB->GetGeoObj( nEntId) ;
|
|
if ( pGeoObj->GetType() == GEO_PNT3D) {
|
|
ptEnd = GetGeoPoint3d( pGeoObj)->GetPoint() ;
|
|
return true ;
|
|
}
|
|
else if ( ( pGeoObj->GetType() & GEO_CURVE) != 0)
|
|
return GetCurve( pGeoObj)->GetEndPoint( ptEnd) ;
|
|
else
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Machining::PostApply( void)
|
|
{
|
|
// recupero la macchina corrente
|
|
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
|
|
if ( pMch == nullptr)
|
|
return false ;
|
|
// costanti
|
|
static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo
|
|
static const string EVAR_PHASE = ".PHASE" ; // IN (int) indice fase
|
|
static const string EVAR_MCHID = ".MCHID" ; // IN (int) identificativo della lavorazione
|
|
static const string EVAR_ERROR = ".ERR" ; // OUT (int) codice di errore ( 0 = ok)
|
|
static const string ON_POST_APPLY = "OnPostApplyMachining" ;
|
|
|
|
// eseguo l'azione
|
|
if ( pMch->LuaExistsFunction( ON_POST_APPLY)) {
|
|
bool bOk = true ;
|
|
int nErr = 99 ;
|
|
// imposto valori parametri
|
|
bOk = bOk && pMch->LuaCreateGlobTable( EMC_VAR) ;
|
|
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_PHASE, m_nPhase) ;
|
|
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_MCHID, m_nOwnerId) ;
|
|
// eseguo
|
|
bOk = bOk && pMch->LuaCallFunction( ON_POST_APPLY, false) ;
|
|
// recupero valori parametri obbligatori
|
|
bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_ERROR, nErr) ;
|
|
// recupero valori parametri opzionali
|
|
// ...
|
|
// reset
|
|
bOk = bOk && pMch->LuaResetGlobVar( EMC_VAR) ;
|
|
// segnalo errori
|
|
if ( nErr != 0) {
|
|
bOk = false ;
|
|
string sOut = " Error in " + ON_POST_APPLY + " (" + ToString( nErr) + ")" ;
|
|
LOG_INFO( GetEMkLogger(), sOut.c_str())
|
|
}
|
|
return bOk ;
|
|
}
|
|
else
|
|
return true ;
|
|
} |