b88aa9cf18
- correzioni per rinvio da sotto speciale (MDC) - ottimizzato caricamento altri utensili su testa con più uscite - salvato stato visualizzazione macchina e aggiunta funzione per restituirlo - si garantisce la visualizzazione completa della macchina durante Apply e Update delle lavorazioni.
201 lines
6.9 KiB
C++
201 lines
6.9 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::ShowTool( int nPath, double dFraz) 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 i dati di questa entità
|
|
const CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nEntId)) ;
|
|
if ( pCamData == nullptr)
|
|
return false ;
|
|
Point3d ptEnd = pCamData->GetEndPoint() ;
|
|
Vector3d vtTool = pCamData->GetToolDir() ;
|
|
// creo o svuoto gruppo per anteprima utensile
|
|
int nStId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_ST) ;
|
|
// se non c'è, lo aggiungo
|
|
if ( nStId == GDB_ID_NULL) {
|
|
nStId = m_pGeomDB->AddGroup( GDB_ID_NULL, GetOwner(), Frame3d()) ;
|
|
if ( nStId == GDB_ID_NULL)
|
|
return false ;
|
|
m_pGeomDB->SetName( nStId, MCH_ST) ;
|
|
m_pGeomDB->SetLevel( nStId, GDB_LV_TEMP) ;
|
|
}
|
|
// altrimenti lo svuoto
|
|
else
|
|
m_pGeomDB->EmptyGroup( nStId) ;
|
|
// copio la testa della lavorazione nel gruppo
|
|
int nHeadId = m_pMchMgr->GetHeadId( GetHeadName()) ;
|
|
int nId = m_pGeomDB->CopyGlob( nHeadId, GDB_ID_NULL, nStId) ;
|
|
m_pGeomDB->SetStatus( nId, GDB_ST_ON) ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
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 ;
|
|
} |