From 4925ab462c1b4d36ff67492ecfd888688186d25b Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Wed, 18 Mar 2026 11:06:14 +0100 Subject: [PATCH] EgtMachKernel (NewLink) : - in SimulatorSP e SimulatorMP aggiunta gestione lavorazioni in doppio per OnPathStart. --- OutputConst.h | 1 + SimulatorMP.cpp | 22 ++++++++++++++++++---- SimulatorMP.h | 2 +- SimulatorSP.cpp | 22 ++++++++++++++++++---- SimulatorSP.h | 2 +- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/OutputConst.h b/OutputConst.h index 9f17035..a22bac9 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -88,6 +88,7 @@ static const std::string GVAR_MAXMIN = ".MAXMIN" ; // (double/s) minimo di static const std::string GVAR_MAXMAX = ".MAXMAX" ; // (double/s) massimo di ingombro degli assi della lavorazione static const std::string GVAR_PATHID = ".PATHID" ; // (int) identificativo percorso di lavorazione static const std::string GVAR_PATHIND = ".PATHIND" ; // (int) indice percorso di lavorazione +static const std::string GVAR_DBLPATHID = ".DBLPATHID" ; // (int) identificativo eventuale percorso di lavorazione in doppio static const std::string GVAR_START = ".START" ; // (Point3d) punto iniziale del percorso originale static const std::string GVAR_END = ".END" ; // (Point3d) punto finale del percorso originale static const std::string GVAR_EXTR = ".EXTR" ; // (Vector3d) versore estrusione diff --git a/SimulatorMP.cpp b/SimulatorMP.cpp index fcacfde..d03907d 100644 --- a/SimulatorMP.cpp +++ b/SimulatorMP.cpp @@ -960,6 +960,13 @@ SimulatorMP::FindAndManagePathStart( int& nStatus) // se trovato nuovo CLpath con entità, gestisco inizio percorso di lavoro if ( m_nEntId != GDB_ID_NULL) { ++ m_nCLPathInd ; + // verifico se Path in doppio + int nDBLPathId = GDB_ID_NULL ; + int nDBLId = m_pGeomDB->GetFirstNameInGroup( m_nOpId, MCH_DBL) ; + if ( nDBLId != GDB_ID_NULL) { + string sCLPathName ; m_pGeomDB->GetName( m_nCLPathId, sCLPathName) ; + nDBLPathId = m_pGeomDB->GetFirstNameInGroup( nDBLId, sCLPathName) ; + } // recupero punti di inizio e fine percorso Point3d ptStart ; m_pGeomDB->GetInfo( m_nCLPathId, KEY_START, ptStart) ; @@ -990,7 +997,7 @@ SimulatorMP::FindAndManagePathStart( int& nStatus) m_nAuxEInd = 0 ; m_nAuxETot = 0 ; // richiamo gestione evento inizio percorso di lavoro - if ( ! OnPathStart( m_nCLPathId, m_nCLPathInd, m_nAuxSTot, ptStart, ptEnd, vtExtr, + if ( ! OnPathStart( m_nCLPathId, m_nCLPathInd, nDBLPathId, m_nAuxSTot, ptStart, ptEnd, vtExtr, ptMin, ptMax, vAxMin, vAxMax, dElev, vActiveExit)) { nStatus = CalcStatusOnError( ERR_NONE) ; return false ; @@ -1961,6 +1968,8 @@ SimulatorMP::OnMachiningEnd( void) { // chiamo la funzione di fine lavorazione bool bOk = CallFunction( ON_SIMUL_MACHINING_END, true) ; + // reset eventuale Path in double + bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_DBLPATHID) ; // forzo aggiornamento posizione assi (possono essere stati mossi nello script) UpdateAxesPos() ; return bOk ; @@ -1968,13 +1977,18 @@ SimulatorMP::OnMachiningEnd( void) //---------------------------------------------------------------------------- bool -SimulatorMP::OnPathStart( int nClPathId, int nClPathInd, int nAS, const Point3d& ptStart, const Point3d& ptEnd, - const Vector3d& vtExtr, const Point3d& ptMin, const Point3d& ptMax, - const DBLVECTOR& vAxMin, const DBLVECTOR& vAxMax, double dElev, const INTVECTOR& vActiveExit) +SimulatorMP::OnPathStart( int nClPathId, int nClPathInd, int nDBLPathId, int nAS, const Point3d& ptStart, const Point3d& ptEnd, + const Vector3d& vtExtr, const Point3d& ptMin, const Point3d& ptMax, + const DBLVECTOR& vAxMin, const DBLVECTOR& vAxMax, double dElev, const INTVECTOR& vActiveExit) { // assegno identificativo e indice percorso di lavorazione bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PATHID, nClPathId) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PATHIND, nClPathInd) ; + // assegno identificativo percorso di lavorazione in doppio + if ( nDBLPathId == GDB_ID_NULL) + bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_DBLPATHID) ; + else + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DBLPATHID, nDBLPathId) ; // assegno numero di dati ausiliari iniziali bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUXTOT, nAS) ; // assegno punti iniziale e finale e versore estrusione diff --git a/SimulatorMP.h b/SimulatorMP.h index 9635854..9060e32 100644 --- a/SimulatorMP.h +++ b/SimulatorMP.h @@ -104,7 +104,7 @@ class SimulatorMP : public ISimulator bool OnMachiningEnd( void) ; bool OnPathStartAux( int nInd, const std::string& sAS, int& nErr) ; bool OnPathEndAux( int nInd, const std::string& sAE, int& nErr) ; - bool OnPathStart( int nClPathId, int nClPathInd, int nAS, const Point3d& ptStart, const Point3d& ptEnd, + bool OnPathStart( int nClPathId, int nClPathInd, int nDBLPathId, int nAS, const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtExtr, const Point3d& ptMin, const Point3d& ptMax, const DBLVECTOR& vAxMin, const DBLVECTOR& vAxMax, double dElev, const INTVECTOR& vActiveExit) ; bool OnPathEnd( int nAE) ; diff --git a/SimulatorSP.cpp b/SimulatorSP.cpp index 28380e8..b767bb7 100644 --- a/SimulatorSP.cpp +++ b/SimulatorSP.cpp @@ -907,6 +907,13 @@ SimulatorSP::FindAndManagePathStart( int& nStatus) // se trovato nuovo CLpath con entità, gestisco inizio percorso di lavoro if ( m_nEntId != GDB_ID_NULL) { ++ m_nCLPathInd ; + // verifico se Path in doppio + int nDBLPathId = GDB_ID_NULL ; + int nDBLId = m_pGeomDB->GetFirstNameInGroup( m_nOpId, MCH_DBL) ; + if ( nDBLId != GDB_ID_NULL) { + string sCLPathName ; m_pGeomDB->GetName( m_nCLPathId, sCLPathName) ; + nDBLPathId = m_pGeomDB->GetFirstNameInGroup( nDBLId, sCLPathName) ; + } // recupero punti di inizio e fine percorso Point3d ptStart ; m_pGeomDB->GetInfo( m_nCLPathId, KEY_START, ptStart) ; @@ -937,7 +944,7 @@ SimulatorSP::FindAndManagePathStart( int& nStatus) m_nAuxEInd = 0 ; m_nAuxETot = 0 ; // richiamo gestione evento inizio percorso di lavoro - if ( ! OnPathStart( m_nCLPathId, m_nCLPathInd, m_nAuxSTot, ptStart, ptEnd, vtExtr, + if ( ! OnPathStart( m_nCLPathId, m_nCLPathInd, nDBLPathId, m_nAuxSTot, ptStart, ptEnd, vtExtr, ptMin, ptMax, vAxMin, vAxMax, dElev, vActiveExit)) { nStatus = CalcStatusOnError( 0) ; return false ; @@ -2018,6 +2025,8 @@ SimulatorSP::OnMachiningEnd( void) return true ; // chiamo la funzione di fine lavorazione bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_MACHINING_END) ; + // reset eventuale Path in double + bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_DBLPATHID) ; // forzo aggiornamento posizione assi (possono essere stati mossi nello script) UpdateAxesPos() ; return bOk ; @@ -2025,13 +2034,18 @@ SimulatorSP::OnMachiningEnd( void) //---------------------------------------------------------------------------- bool -SimulatorSP::OnPathStart( int nClPathId, int nClPathInd, int nAS, const Point3d& ptStart, const Point3d& ptEnd, - const Vector3d& vtExtr, const Point3d& ptMin, const Point3d& ptMax, - const DBLVECTOR& vAxMin, const DBLVECTOR& vAxMax, double dElev, const INTVECTOR& vActiveExit) +SimulatorSP::OnPathStart( int nClPathId, int nClPathInd, int nDBLPathId, int nAS, const Point3d& ptStart, const Point3d& ptEnd, + const Vector3d& vtExtr, const Point3d& ptMin, const Point3d& ptMax, + const DBLVECTOR& vAxMin, const DBLVECTOR& vAxMax, double dElev, const INTVECTOR& vActiveExit) { // assegno identificativo e indice percorso di lavorazione bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PATHID, nClPathId) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PATHIND, nClPathInd) ; + // assegno identificativo percorso di lavorazione in doppio + if ( nDBLPathId == GDB_ID_NULL) + bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_DBLPATHID) ; + else + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DBLPATHID, nDBLPathId) ; // assegno numero di dati ausiliari iniziali bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUXTOT, nAS) ; // assegno punti iniziale e finale e versore estrusione diff --git a/SimulatorSP.h b/SimulatorSP.h index ae54298..bb1977b 100644 --- a/SimulatorSP.h +++ b/SimulatorSP.h @@ -103,7 +103,7 @@ class SimulatorSP : public ISimulator bool OnMachiningEnd( void) ; bool OnPathStartAux( int nInd, const std::string& sAS, int& nErr) ; bool OnPathEndAux( int nInd, const std::string& sAE, int& nErr) ; - bool OnPathStart( int nClPathId, int nClPathInd, int nAS, const Point3d& ptStart, const Point3d& ptEnd, + bool OnPathStart( int nClPathId, int nClPathInd, int nDBLPathId, int nAS, const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtExtr, const Point3d& ptMin, const Point3d& ptMax, const DBLVECTOR& vAxMin, const DBLVECTOR& vAxMax, double dElev, const INTVECTOR& vActiveExit) ; bool OnPathEnd( int nAE) ;