EgtMachKernel 1.6r1 :

- in SplitFlatRawPartW se c'è curva di kerf si splitta e si riporta nei nuovi grezzi
- in Simulator migliorata gestione Home e Stop, corretto posizione precedente degli assi al cambio utensile/testa.
This commit is contained in:
Dario Sassi
2016-05-12 15:27:25 +00:00
parent b8965da858
commit 31b4099d0f
8 changed files with 109 additions and 41 deletions
BIN
View File
Binary file not shown.
+6 -7
View File
@@ -37,8 +37,6 @@ Generator::Generator( void)
m_pMchMgr = nullptr ;
m_pGeomDB = nullptr ;
m_pMachine = nullptr ;
m_sPrevTool.clear() ;
m_sTool.clear() ;
m_AxesName.reserve( 8) ;
m_AxesVal.reserve( 8) ;
}
@@ -60,6 +58,7 @@ Generator::Init( MachMgr* pMchMgr)
m_pMchMgr = pMchMgr ;
m_pGeomDB = m_pMchMgr->GetGeomDB() ;
m_pMachine = m_pMchMgr->GetCurrMachine() ;
m_sPrevTool.clear() ;
m_sTool.clear() ;
return true ;
}
@@ -196,6 +195,7 @@ Generator::ProcessDisposition( int nOpId, int nOpInd)
else
break ;
}
bool bOk = true ;
// Se disposizione con movimenti macchina
if ( ! pDisp->IsEmpty()) {
@@ -219,7 +219,6 @@ Generator::ProcessDisposition( int nOpId, int nOpInd)
return false ;
}
// Ciclo su tutti i percorsi CL della disposizione
bool bOk = true ;
int nClPathInd = 0 ;
int nClId = m_pGeomDB->GetFirstNameInGroup( nOpId, MCH_CL) ;
int nClPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ;
@@ -234,10 +233,9 @@ Generator::ProcessDisposition( int nOpId, int nOpInd)
}
// Emetto fine disposizione
if ( ! OnDispositionEnd())
return false ;
bOk = bOk && OnDispositionEnd() ;
return true ;
return bOk ;
}
//----------------------------------------------------------------------------
@@ -537,8 +535,9 @@ Generator::OnRawMoveData( int nRawId, int RawMoveInd, int nType, const Point3d&
bool
Generator::OnToolSelect( void)
{
// assegno il nome dell'utensile
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, m_sTool) ;
// assegno il nome degli assi
bool bOk = true ;
int nNumAxes = int( m_AxesName.size()) ;
for ( int i = 1 ; i <= MAX_AXES ; ++ i) {
if ( i <= nNumAxes)
+2
View File
@@ -43,6 +43,8 @@ const std::string MACH_RAW_SOLID = "RawSolid" ;
const std::string MACH_RAW_CENTER = "RawCenter" ;
// Nome del contorno esterno del grezzo
const std::string MACH_RAW_OUTLINE = "RawOutline" ;
// Nome del kerf del grezzo
const std::string MACH_RAW_KERF = "Kerf" ;
//----------------------------------------------------------------------------
// Nome sottodirettorio delle fixtures
+57 -5
View File
@@ -23,6 +23,7 @@
#include "/EgtDev/Include/EGkCurveAux.h"
#include "/EgtDev/Include/EGkOffsetCurve.h"
#include "/EgtDev/Include/EgkDistPointCurve.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EGkStmStandard.h"
#include "/EgtDev/Include/EGkStmFromCurves.h"
#include "/EgtDev/Include/EmkMachiningGeoConst.h"
@@ -767,6 +768,10 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId)
// il colore del grezzo
Color cCol = AQUA ;
m_pGeomDB->GetCalcMaterial( nRawSolId, cCol) ;
// il riferimento del grezzo
Frame3d frRaw ;
if ( ! m_pGeomDB->GetGroupGlobFrame( nRawId, frRaw))
return GDB_ID_NULL ;
// creo la regione del grezzo a partire dal suo contorno
// recupero il contorno
@@ -781,17 +786,29 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId)
return GDB_ID_NULL ;
m_pGeomDB->SetLevel( nSfrId, GDB_LV_TEMP) ;
// se esiste il kerf, ne creo la regione
PtrOwner<ISurfFlatRegion> pSfrKerf ;
int nKerfId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_KERF) ;
ICurve* pKerfCrv = GetCurve( m_pGeomDB->GetGeoObj( nKerfId)) ;
if ( pKerfCrv != nullptr) {
SurfFlatRegionByContours SfrCntr ;
SfrCntr.AddCurve( pKerfCrv->Clone()) ;
pSfrKerf.Set( SfrCntr.GetSurf()) ;
if ( IsNull( pSfrKerf))
return GDB_ID_NULL ;
}
// recupero le regioni delle lavorazioni
INTVECTOR vMchRReg ;
for ( auto nMchId : vMchId) {
// recupero gruppo preview lavorazioni nella lavorazione
int nPVGrp = m_pGeomDB->GetFirstNameInGroup( nMchId, MCH_PV) ;
if ( nPVGrp == GDB_ID_NULL)
return false ;
return GDB_ID_NULL ;
// se vuoto, cerco il rimando al preview nel pezzo
if ( m_pGeomDB->GetGroupObjs( nPVGrp) == 0 &&
! m_pGeomDB->GetInfo( nPVGrp, MCH_PV_KEY_RELOCATE, nPVGrp))
return false ;
return GDB_ID_NULL ;
// ciclo sui percorsi utensile (CL)
int nClId = m_pGeomDB->GetFirstGroupInGroup( nPVGrp) ;
while ( nClId != GDB_ID_NULL) {
@@ -824,12 +841,47 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId)
if ( nId == GDB_ID_NULL)
return GDB_ID_NULL ;
vNewIds.emplace_back( nId) ;
// imposto lo stato del contorno di questo grezzo come quello del grezzo di partenza
int nStat = GDB_ST_ON ;
if ( m_pGeomDB->GetStatus( nOutCrvId, nStat) && nStat == GDB_ST_OFF)
m_pGeomDB->SetStatus( m_pGeomDB->GetFirstNameInGroup( nId, MACH_RAW_OUTLINE), nStat) ;
// assegno la fase al gruppo
m_pGeomDB->SetInfo( nId, MACH_RAW_PHASE, m_nCurrPhase) ;
++ nChunk ;
// cancello la curva
m_pGeomDB->Erase( nFirstLoopId) ;
// se esiste il kerf uso questa curva per creare il kerf del nuovo grezzo
if ( ! IsNull( pSfrKerf)) {
// creo la regione con la curva
SurfFlatRegionByContours SfrCntr ;
SfrCntr.AddCurve( GetCurve( m_pGeomDB->RemoveGeoObjAndErase( nFirstLoopId))) ;
PtrOwner<ISurfFlatRegion> pSfrNewKerf( SfrCntr.GetSurf()) ;
if ( IsNull( pSfrNewKerf))
return GDB_ID_NULL ;
// la limito con la regione di kerf
if ( ! pSfrNewKerf->Intersect( *pSfrKerf))
return GDB_ID_NULL ;
// se risultato non vuoto
if ( pSfrNewKerf->IsValid()) {
// riferimento del nuovo grezzo
Frame3d frNewRaw ;
if ( ! m_pGeomDB->GetGroupGlobFrame( nId, frNewRaw))
return GDB_ID_NULL ;
// la porto dal riferimento del grezzo originale al riferimento di questo grezzo
pSfrNewKerf->LocToLoc( frRaw, frNewRaw) ;
// la porto sulla faccia sopra del grezzo
pSfrNewKerf->Translate( Vector3d( 0, 0, dHeight)) ;
// recupero il contorno e lo inserisco come kerf del nuovo grezzo
PtrOwner<ICurve> pCrv( pSfrNewKerf->GetLoop( 0, 0)) ;
int nNewKerfId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nId, Release( pCrv)) ;
if ( nNewKerfId == GDB_ID_NULL)
return GDB_ID_NULL ;
m_pGeomDB->CopyMaterial( nKerfId, nNewKerfId) ;
m_pGeomDB->SetName( nNewKerfId, MACH_RAW_KERF) ;
}
}
// altrimenti la cancello
else
m_pGeomDB->Erase( nFirstLoopId) ;
// passo alla prossima curva
++ nChunk ;
nFirstLoopId = ExeExtractSurfFrChunkLoops( nSfrId, nChunk, nRawId, nullptr) ;
}
// cancello la regione
+2 -2
View File
@@ -172,7 +172,7 @@ Machine::AdjustAuxGeometry( const STRVECTOR& vsAux, int nLay)
{
// sistemo la geometria ausiliaria
for ( const auto& sAux : vsAux) {
// recupero pezzo e layer della geometria ausiliaria della base
// recupero pezzo e layer della geometria ausiliaria
string sAuxPart, sAuxLay ;
Split( sAux, "/", true, sAuxPart, sAuxLay) ;
// cerco il gruppo nella geometria originale
@@ -180,7 +180,7 @@ Machine::AdjustAuxGeometry( const STRVECTOR& vsAux, int nLay)
int nAuxLay = m_pGeomDB->GetFirstNameInGroup( nAuxPart, sAuxLay) ;
if ( nAuxLay == GDB_ID_NULL)
return false ;
// lo sposto nel gruppo della base
// lo sposto nel gruppo
if ( ! m_pGeomDB->RelocateGlob( nAuxLay, nLay, GDB_LAST_SON))
return false ;
}
+8 -2
View File
@@ -121,15 +121,21 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
int nHeadId = GetGroup( sHead) ;
// recupero i dati della testa
Head* pHead = GetHead( nHeadId) ;
if ( pHead == nullptr)
if ( pHead == nullptr) {
string sOut = "Missing head " + sHead ;
LOG_INFO( GetEMkLogger(), sOut.c_str())
return false ;
}
// recupero il gruppo dell'uscita
string sExit = MCH_EXIT + ToString( nExit) ;
int nExitId = m_pGeomDB->GetFirstNameInGroup( nHeadId, sExit) ;
// recupero i dati dell'uscita
Exit* pExit = GetExit( nExitId) ;
if ( pExit == nullptr)
if ( pExit == nullptr) {
string sOut = "Missing exit " + ToString( nExit) + " on head " + sHead ;
LOG_INFO( GetEMkLogger(), sOut.c_str())
return false ;
}
// recupero i dati dell'utensile
int nToolId = GDB_ID_NULL ;
double dTLen = 0 ;
+1
View File
@@ -46,6 +46,7 @@ static const std::string GVAR_RAWIND = ".RAWIND" ; // (int) indice mov
static const std::string GVAR_RAWTYPE = ".RAWTYPE" ; // (int) tipo di movimento del grezzo
static const std::string GVAR_RAWPOS = ".RAWPOS" ; // (Point3d) posizione di movimento del grezzo
static const std::string GVAR_RAWFLAG = ".RAWFLAG" ; // (int) flag per movimento del grezzo
static const std::string GVAR_TOOL = ".TOOL" ; // (string) nome utensile
static const std::string GVAR_MCHID = ".MCHID" ; // (int) identificativo lavorazione
static const std::string GVAR_MCHIND = ".MCHIND" ; // (int) indice lavorazione
static const std::string GVAR_PATHID = ".PATHID" ; // (int) identificativo percorso di lavorazione
+33 -25
View File
@@ -72,6 +72,12 @@ Simulator::Start( void)
int nMachGrp = m_pMchMgr->GetCurrMachGroup() ;
if ( nMachGrp == GDB_ID_NULL)
return false ;
// reset utensile e assi correnti
m_sTool.clear() ;
m_AxesName.clear() ;
// porto la macchina in home
if ( ! GoHome())
return false ;
// imposto fase iniziale
m_pMchMgr->SetCurrPhase( 1) ;
// verifico la disposizione iniziale della macchinata
@@ -102,10 +108,6 @@ Simulator::Start( void)
if ( ! UpdateTool( true) || ! UpdateAxes())
return false ;
// porto la macchina in home
if ( ! GoHome())
return false ;
// richiamo gestione evento inizio lavorazione
++ m_nOpInd ;
if ( ! OnMachiningStart( m_nOpId, m_nOpInd))
@@ -131,7 +133,7 @@ bool
Simulator::Move( int& nStatus)
{
// Verifiche
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) {
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr || m_pMachine == nullptr) {
nStatus = MCH_SIM_ERR ;
return false ;
}
@@ -279,7 +281,7 @@ Simulator::Move( int& nStatus)
for ( size_t i = OutAxes.size() ; i < 5 ; ++ i)
OutAxes.emplace_back( 0) ;
int nStat ;
m_pMchMgr->VerifyOutstroke( OutAxes[0], OutAxes[1], OutAxes[2], OutAxes[3], OutAxes[4], nStat) ;
m_pMachine->VerifyOutstroke( OutAxes[0], OutAxes[1], OutAxes[2], OutAxes[3], OutAxes[4], nStat) ;
nStatus = MCH_SIM_OUTSTROKE ;
return false ; }
case CamData::AS_DIR_ERR :
@@ -307,7 +309,7 @@ Simulator::Move( int& nStatus)
if ( nMoveType != 2 && nMoveType != 3) {
for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) {
double dVal = m_AxesVal[i] * ( 1 - m_dCoeff) + AxesEnd[i] * m_dCoeff ;
m_pMchMgr->SetAxisPos( m_AxesName[i], dVal) ;
m_pMachine->SetAxisPos( m_AxesName[i], dVal) ;
}
}
// Eseguo movimento su arco (per ora sempre nel piano XY)
@@ -317,12 +319,12 @@ Simulator::Move( int& nStatus)
double dAngCen = pCamData->GetAxesAngCen() ;
Vector3d vtCurr = Point3d( m_AxesVal[0], m_AxesVal[1], ptCen.z) - ptCen ;
vtCurr.Rotate( Z_AX, m_dCoeff * dAngCen) ;
m_pMchMgr->SetAxisPos( m_AxesName[0], ptCen.x + vtCurr.x) ;
m_pMchMgr->SetAxisPos( m_AxesName[1], ptCen.y + vtCurr.y) ;
m_pMachine->SetAxisPos( m_AxesName[0], ptCen.x + vtCurr.x) ;
m_pMachine->SetAxisPos( m_AxesName[1], ptCen.y + vtCurr.y) ;
// altri assi
for ( size_t i = 2 ; i < m_AxesName.size() ; ++ i) {
double dVal = m_AxesVal[i] * ( 1 - m_dCoeff) + AxesEnd[i] * m_dCoeff ;
m_pMchMgr->SetAxisPos( m_AxesName[i], dVal) ;
m_pMachine->SetAxisPos( m_AxesName[i], dVal) ;
}
}
@@ -411,12 +413,26 @@ Simulator::SetStep( double dStep)
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::GoHome( void)
{
// reset stato macchina
OnResetMachine() ;
// porto la macchina in home
m_pMchMgr->ResetAllAxesPos() ;
// assegno valori home degli assi macchina attivi
return m_pMchMgr->GetAllCalcAxesHomePos( m_AxesVal) ;
}
//----------------------------------------------------------------------------
bool
Simulator::Stop( void)
{
// reset stato macchina
OnResetMachine() ;
// porto la macchina in home
m_pMchMgr->ResetAllAxesPos() ;
// rimuovo tavola variabili globali
m_pMachine->LuaResetGlobVar( GLOB_VAR) ;
// reset dello stato
@@ -477,23 +493,14 @@ Simulator::UpdateAxes( void)
if ( pMachine == nullptr)
return false ;
// Carico i nomi degli assi macchina attivi
return pMachine->GetAllCurrAxesName( m_AxesName) ;
if ( ! pMachine->GetAllCurrAxesName( m_AxesName))
return false ;
// Aggiorno la posizione corrente degli assi macchina attivi
for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i)
m_pMachine->GetAxisPos( m_AxesName[i], m_AxesVal[i]) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::GoHome( void)
{
// reset stato macchina
OnResetMachine() ;
// porto la macchina in home
m_pMchMgr->ResetAllAxesPos() ;
// assegno valori home degli assi macchina attivi
return m_pMchMgr->GetAllCalcAxesHomePos( m_AxesVal) ;
}
//----------------------------------------------------------------------------
bool
Simulator::OnOperationEnd( void)
@@ -613,6 +620,7 @@ Simulator::OnMoveStart( void)
// assegno dati
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEID, m_nEntId) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEIND, m_nEntInd) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, pCamData->GetMoveType()) ;
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG, nFlag) ;
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MOVE_START))