diff --git a/Axis.cpp b/Axis.cpp index 29ca98c..abb0508 100644 --- a/Axis.cpp +++ b/Axis.cpp @@ -125,3 +125,28 @@ Axis::Set( const string& sName, int nType, return m_vtDir.Normalize() ; } +//---------------------------------------------------------------------------- +bool +Axis::Modify( const STROKE& Stroke) +{ + m_Stroke = Stroke ; + if ( m_dHomeVal < m_Stroke.Min) + m_dHomeVal = m_Stroke.Min ; + else if ( m_dHomeVal > m_Stroke.Max) + m_dHomeVal = m_Stroke.Max ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Axis::Modify( double dHome) +{ + if ( dHome < m_Stroke.Min) + m_dHomeVal = m_Stroke.Min ; + else if ( dHome > m_Stroke.Max) + m_dHomeVal = m_Stroke.Max ; + else + m_dHomeVal = dHome ; + return true ; +} + diff --git a/Axis.h b/Axis.h index 94bc458..8802cba 100644 --- a/Axis.h +++ b/Axis.h @@ -32,14 +32,24 @@ class Axis : public IUserObj Axis( void) ; bool Set( const std::string& sName, int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome) ; - bool SetCurrVal( double dVal) { m_dCurrVal = dVal ; return true ; } - const std::string& GetName( void) { return m_sName ; } - int GetType( void) { return m_nType ; } - const Point3d& GetPos( void) { return m_ptPos ; } - const Vector3d& GetDir( void) { return m_vtDir ; } - const STROKE& GetStroke( void) { return m_Stroke ; } - double GetHomeVal( void) { return m_dHomeVal ; } - double GetCurrVal( void) { return m_dCurrVal ; } + bool Modify( const STROKE& Stroke) ; + bool Modify( double dHome) ; + bool SetCurrVal( double dVal) + { m_dCurrVal = dVal ; return true ; } + const std::string& GetName( void) + { return m_sName ; } + int GetType( void) + { return m_nType ; } + const Point3d& GetPos( void) + { return m_ptPos ; } + const Vector3d& GetDir( void) + { return m_vtDir ; } + const STROKE& GetStroke( void) + { return m_Stroke ; } + double GetHomeVal( void) + { return m_dHomeVal ; } + double GetCurrVal( void) + { return m_dCurrVal ; } private : int m_nOwnerId ; diff --git a/Drilling.cpp b/Drilling.cpp index 6cec4c5..73b645b 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -556,6 +556,8 @@ Drilling::Chain( int nGrpDestId) } } // preparo i dati per il concatenamento + bool bFirst = true ; + Point3d ptNear = ORIG ; double dToler = 10 * EPS_SMALL ; ChainCurves chainC ; chainC.Init( true, dToler, int( vpCrvs.size())) ; @@ -572,10 +574,14 @@ Drilling::Chain( int nGrpDestId) return false ; if ( ! chainC.AddCurve( int( i + 1), ptStart, vtStart, ptEnd, vtEnd)) return false ; + // se prima curva, assegno inizio della ricerca + if ( bFirst) { + ptNear = ptStart + 10 * EPS_SMALL * vtStart ; + bFirst = false ; + } } // recupero i percorsi concatenati int nCount = 0 ; - Point3d ptNear = ORIG ; INTVECTOR vnId2 ; while ( chainC.GetChainFromNear( ptNear, false, vnId2)) { // creo una curva composita diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index dabcd91..d3d6f1d 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Generator.cpp b/Generator.cpp index b111b2c..1c7a722 100644 --- a/Generator.cpp +++ b/Generator.cpp @@ -88,7 +88,6 @@ static const string GVAR_C3T = ".C3t" ; // (num) token del terzo static const string GVAR_RRT = ".RRt" ; // (num) token del raggio per arco static const string GVAR_MASK = ".MASK" ; // (int) mask associato ai movimenti in rapido static const string GVAR_FLAG = ".FLAG" ; // (int) flag associato ad ogni movimento -static const string TEMP_VAR = "LOC" ; // tavola variabili locali (temporanee) static const string ON_START = "OnStart" ; static const string ON_END = "OnEnd" ; static const string ON_PROGRAM_START = "OnProgramStart" ; @@ -435,8 +434,6 @@ Generator::OnStart( void) { // definisco tavola variabili globali bool bOk = m_pMachine->LuaCreateGlobTable( GLOB_VAR) ; - // definisco tavola variabili locali (temporanee) - bOk = bOk && m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // assegno valori di default bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_USETO1, false) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MODAL, false) ; @@ -452,8 +449,6 @@ Generator::OnStart( void) bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ST, "S") ; // chiamo la funzione bOk = bOk && m_pMachine->LuaCallFunction( ON_START) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; return bOk ; } @@ -461,12 +456,8 @@ Generator::OnStart( void) bool Generator::OnEnd( void) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // chiamo la funzione - bOk = bOk && m_pMachine->LuaCallFunction( ON_END) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; + bool bOk = m_pMachine->LuaCallFunction( ON_END) ; return bOk ; } @@ -480,15 +471,11 @@ Generator::OnProgramStart( const string& sCncFile, const string& sInfo) LOG_INFO( GetEMkLogger(), "Error opening Cnc file") ; // assegno nome file bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FILE, sCncFile) ; - // definisco tavola variabili locali (temporanee) - bOk = bOk && m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // assegno info string sTxt = sInfo + " " + CurrDateTime() ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_INFO, sTxt) ; // chiamo la funzione di inizio programma bOk = bOk && m_pMachine->LuaCallFunction( ON_PROGRAM_START) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; return bOk ; } @@ -496,12 +483,8 @@ Generator::OnProgramStart( const string& sCncFile, const string& sInfo) bool Generator::OnProgramEnd( void) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // chiamo fine programma - bOk = bOk && m_pMachine->LuaCallFunction( ON_PROGRAM_END) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; + bool bOk = m_pMachine->LuaCallFunction( ON_PROGRAM_END) ; return bOk ; } @@ -509,17 +492,13 @@ Generator::OnProgramEnd( void) bool Generator::OnDispositionStart( int nOpId, int nOpInd, int nPhase) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // assegno identificativo e indice disposizione - bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPID, nOpId) ; + bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPID, nOpId) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPIND, nOpInd) ; // assegno nuovo indice di fase bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PHASE, nPhase) ; // chiamo la funzione di inizio disposizione bOk = bOk && m_pMachine->LuaCallFunction( ON_DISPOSITION_START) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; return bOk ; } @@ -527,12 +506,8 @@ Generator::OnDispositionStart( int nOpId, int nOpInd, int nPhase) bool Generator::OnDispositionEnd( void) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // chiamo la funzione di fine disposizione - bOk = bOk && m_pMachine->LuaCallFunction( ON_DISPOSITION_END) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; + bool bOk = m_pMachine->LuaCallFunction( ON_DISPOSITION_END) ; return bOk ; } @@ -540,15 +515,11 @@ Generator::OnDispositionEnd( void) bool Generator::OnTableData( const string& sName, const Point3d& ptOri1) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // assegno nome tavola e valore riferimento - bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TABNAME, sName) ; + bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TABNAME, sName) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TABORI1, ptOri1) ; // chiamo la funzione di gestione dati tavola bOk = bOk && m_pMachine->LuaCallFunction( ON_TABLE_DATA) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; return bOk ; } @@ -556,18 +527,14 @@ Generator::OnTableData( const string& sName, const Point3d& ptOri1) bool Generator::OnFixtureData( int nFixId, int nFixInd, const string& sName, const Point3d& ptPos, double dAngDeg) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // assegno dati bloccaggio - bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIXID, nFixId) ; + bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIXID, nFixId) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIXIND, nFixInd) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIXNAME, sName) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIXPOS, ptPos) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIXANG, dAngDeg) ; // chiamo la funzione di gestione dati bloccaggio bOk = bOk && m_pMachine->LuaCallFunction( ON_FIXTURE_DATA) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; return bOk ; } @@ -575,18 +542,14 @@ Generator::OnFixtureData( int nFixId, int nFixInd, const string& sName, const Po bool Generator::OnRawMoveData( int nRawId, int RawMoveInd, int nType, const Point3d& ptPos, int nFlag) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // assegno dati bloccaggio - bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_RAWID, nRawId) ; + bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_RAWID, nRawId) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_RAWIND, RawMoveInd) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_RAWTYPE, nType) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_RAWPOS, ptPos) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_RAWFLAG, nFlag) ; // chiamo la funzione di gestione movimento del grezzo bOk = bOk && m_pMachine->LuaCallFunction( ON_RAWMOVE_DATA) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; return bOk ; } @@ -594,9 +557,8 @@ Generator::OnRawMoveData( int nRawId, int RawMoveInd, int nType, const Point3d& bool Generator::OnToolSelect( void) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // 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) @@ -606,8 +568,6 @@ Generator::OnToolSelect( void) } // chiamo la funzione di selezione utensile bOk = bOk && m_pMachine->LuaCallFunction( ON_TOOL_SELECT) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; return bOk ; } @@ -615,12 +575,8 @@ Generator::OnToolSelect( void) bool Generator::OnToolDeselect( void) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // chiamo la funzione di deselezione utensile - bOk = bOk && m_pMachine->LuaCallFunction( ON_TOOL_DESELECT) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; + bool bOk = m_pMachine->LuaCallFunction( ON_TOOL_DESELECT) ; return bOk ; } @@ -628,17 +584,13 @@ Generator::OnToolDeselect( void) bool Generator::OnMachiningStart( int nOpId, int nOpInd, double dSpeed) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // assegno identificativo e indice lavorazione - bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHID, nOpId) ; + bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHID, nOpId) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHIND, nOpInd) ; // assegno speed bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_S, dSpeed) ; // chiamo la funzione di inizio lavorazione bOk = bOk && m_pMachine->LuaCallFunction( ON_MACHINING_START) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; return bOk ; } @@ -646,12 +598,8 @@ Generator::OnMachiningStart( int nOpId, int nOpInd, double dSpeed) bool Generator::OnMachiningEnd( void) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // chiamo la funzione di fine lavorazione - bOk = bOk && m_pMachine->LuaCallFunction( ON_MACHINING_END) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; + bool bOk = m_pMachine->LuaCallFunction( ON_MACHINING_END) ; return bOk ; } @@ -659,15 +607,11 @@ Generator::OnMachiningEnd( void) bool Generator::OnPathStart( int nClPathId, int nClPathInd) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // assegno identificativo e indice percorso di lavorazione - bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PATHID, nClPathId) ; + bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PATHID, nClPathId) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_PATHIND, nClPathInd) ; // chiamo la funzione di inizio percorso di lavorazione bOk = bOk && m_pMachine->LuaCallFunction( ON_PATH_START) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; return bOk ; } @@ -675,12 +619,8 @@ Generator::OnPathStart( int nClPathId, int nClPathInd) bool Generator::OnPathEnd( void) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // chiamo la funzione di fine percorso di lavorazione - bOk = bOk && m_pMachine->LuaCallFunction( ON_PATH_END) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; + bool bOk = m_pMachine->LuaCallFunction( ON_PATH_END) ; return bOk ; } @@ -690,10 +630,8 @@ Generator::OnRapid( int nMove, const DBLVECTOR& AxesEnd, int nAxesMask, int nFla { // cancello variabili estranee ResetArcData() ; - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // assegno il tipo di movimento - bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ; + bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ; // assegno il valore degli assi int nNumAxes = int( AxesEnd.size()) ; for ( int i = 1 ; i <= MAX_AXES ; ++ i) { @@ -708,8 +646,6 @@ Generator::OnRapid( int nMove, const DBLVECTOR& AxesEnd, int nAxesMask, int nFla bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG, nFlag) ; // chiamo la funzione di movimento in rapido bOk = bOk && m_pMachine->LuaCallFunction( ON_RAPID) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; return bOk ; } @@ -719,10 +655,8 @@ Generator::OnLinear( int nMove, const DBLVECTOR& AxesEnd, double dFeed, int nFla { // cancello variabili estranee ResetArcData() ; - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // assegno il tipo di movimento - bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ; + bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ; // assegno il valore degli assi int nNumAxes = int( AxesEnd.size()) ; for ( int i = 1 ; i <= MAX_AXES ; ++ i) { @@ -737,8 +671,6 @@ Generator::OnLinear( int nMove, const DBLVECTOR& AxesEnd, double dFeed, int nFla bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG, nFlag) ; // chiamo la funzione di movimento in rapido bOk = bOk && m_pMachine->LuaCallFunction( ON_LINEAR) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; return bOk ; } @@ -747,10 +679,8 @@ bool Generator::OnArc( int nMove, const DBLVECTOR& AxesEnd, const Point3d& ptCen, double dRad, double dAngCen, double dFeed, int nFlag) { - // definisco tavola variabili locali (temporanee) - bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ; // assegno il tipo di movimento - bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ; + bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, nMove) ; // assegno il valore degli assi int nNumAxes = int( AxesEnd.size()) ; for ( int i = 1 ; i <= MAX_AXES ; ++ i) { @@ -773,8 +703,6 @@ Generator::OnArc( int nMove, const DBLVECTOR& AxesEnd, const Point3d& ptCen, dou bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG, nFlag) ; // chiamo la funzione di movimento in rapido bOk = bOk && m_pMachine->LuaCallFunction( ON_ARC) ; - // cancello variabili locali - bOk = bOk && m_pMachine->LuaResetGlobVar( TEMP_VAR) ; return bOk ; } diff --git a/MachMgr.h b/MachMgr.h index ff51dbb..66995ec 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -106,6 +106,7 @@ class MachMgr : public IMachMgr bool TranslatePartInRawPart( int nPartId, const Vector3d& vtMove) override ; bool RotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) override ; // Tables and Fixtures + bool ExistsTable( const std::string& sTable) override ; bool SetTable( const std::string& sTable) override ; bool GetTableRef( int nInd, Point3d& ptPos) override ; bool GetTableArea( int nInd, BBox3d& b3Area) override ; diff --git a/MachMgrFixtures.cpp b/MachMgrFixtures.cpp index 8d36a64..fdc5bb5 100644 --- a/MachMgrFixtures.cpp +++ b/MachMgrFixtures.cpp @@ -23,6 +23,18 @@ using namespace std ; +//---------------------------------------------------------------------------- +bool +MachMgr::ExistsTable( const string& sTable) +{ + // recupero la macchina corrente + Machine* pMch = GetCurrMachine() ; + if ( pMch == nullptr) + return false ; + // verifico esistenza della tavola nella macchina corrente + return ( pMch->GetTable( sTable) != nullptr) ; +} + //---------------------------------------------------------------------------- bool MachMgr::SetTable( const string& sTable) diff --git a/Machine.cpp b/Machine.cpp index 81b39f7..d6e23f5 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -353,6 +353,40 @@ Machine::AdjustAxisVector( int nLay, const string& sPart, const string& sName, } } +//---------------------------------------------------------------------------- +bool +Machine::ModifyMachineAxisStroke( const string& sName, const STROKE& Stroke) +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return false ; + // recupero il gruppo dell'asse + int nAxGrp = GetGroup( sName) ; + // recupero il relativo gestore + Axis* pAx = GetAxis( nAxGrp) ; + if ( pAx == nullptr) + return false ; + // eseguo la modifica + return pAx->Modify( Stroke) ; +} + +//---------------------------------------------------------------------------- +bool +Machine::ModifyMachineAxisHome( const string& sName, double dHome) +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return false ; + // recupero il gruppo dell'asse + int nAxGrp = GetGroup( sName) ; + // recupero il relativo gestore + Axis* pAx = GetAxis( nAxGrp) ; + if ( pAx == nullptr) + return false ; + // eseguo la modifica + return pAx->Modify( dHome) ; +} + //---------------------------------------------------------------------------- bool Machine::LoadMachineStdHead( const string& sName, const string& sParent, const std::string& sHSet, diff --git a/Machine.h b/Machine.h index 19a4a12..2fa06d9 100644 --- a/Machine.h +++ b/Machine.h @@ -44,7 +44,6 @@ class Machine bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) ; bool ResetHeadSet( const std::string& sHead) ; bool SetAxisPos( const std::string& sAxis, double dVal) ; - bool SetAxisPos( int nAxGrp, double dVal) ; bool GetAxisPos( const std::string& sAxis, double& dVal) ; bool GetAxisHomePos( const std::string& sAxis, double& dHomeVal) ; bool ResetAxisPos( const std::string& sAxis) ; @@ -72,6 +71,7 @@ class Machine bool VerifyOutstroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) ; const std::string& GetOutstrokeInfo( void) const { return m_sOutstrokeInfo ; } + bool LuaExistsFunction( const std::string& sFun) ; bool LuaCallFunction( const std::string& sFun) ; bool LuaCreateGlobTable( const std::string& sName) ; bool LuaResetGlobVar( const std::string& sName) ; @@ -95,6 +95,8 @@ class Machine const STROKE& Stroke, const std::string& sGeo, double dHome) ; bool AdjustAxisVector( int nLay, const std::string& sPart, const std::string& sName, int nType, const Point3d& ptPos, const Vector3d& vtDir) ; + bool ModifyMachineAxisStroke( const std::string& sName, const STROKE& Stroke) ; + bool ModifyMachineAxisHome( const std::string& sName, double dHome) ; bool LoadMachineStdHead( const std::string& sName, const std::string& sParent, const std::string& sHSet, const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir, double dRot1W, const STROKE& Rot2Stroke, int nSolCh, const std::string& sGeo) ; @@ -174,6 +176,8 @@ class Machine static int LuaEmtHead( lua_State* L) ; static int LuaEmtStdHead( lua_State* L) ; static int LuaEmtMultiHead( lua_State* L) ; + static int LuaEmtModifyAxisStroke( lua_State* L) ; + static int LuaEmtModifyAxisHome( lua_State* L) ; static int LuaEmtWrite( lua_State* L) ; } ; @@ -193,6 +197,8 @@ Machine::LuaSetGlobVar( const std::string& sVar, const T& Val) // ripristino contesto originale if ( nOldCtx != m_pMchMgr->GetContextId()) ExeSetCurrentContext( nOldCtx) ; + // reset dell'oggetto corrente per Lua + m_pMchLua = nullptr ; return bOk ; } @@ -212,5 +218,7 @@ Machine::LuaGetGlobVar( const std::string& sVar, T& Val) // ripristino contesto originale if ( nOldCtx != m_pMchMgr->GetContextId()) ExeSetCurrentContext( nOldCtx) ; + // reset dell'oggetto corrente per Lua + m_pMchLua = nullptr ; return bOk ; } diff --git a/MachineCalc.cpp b/MachineCalc.cpp index f4c0d3a..ace94ad 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -26,6 +26,12 @@ using namespace std ; +//---------------------------------------------------------------------------- +static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo +static const string EVAR_TABNAME = ".TABNAME" ; // (string) nome della tavola macchina +static const string ON_SET_TABLE = "OnSetTable" ; + + //---------------------------------------------------------------------------- bool Machine::SetCurrTable( const string& sTable) @@ -39,7 +45,16 @@ Machine::SetCurrTable( const string& sTable) m_nCalcTabId = GDB_ID_NULL ; return false ; } - return true ; + // lancio eventuale funzione lua di personalizzazione + if ( LuaExistsFunction( ON_SET_TABLE)) { + bool bOk = LuaCreateGlobTable( EMC_VAR) ; + bOk = bOk && LuaSetGlobVar( EMC_VAR + EVAR_TABNAME, sTable) ; + bOk = bOk && LuaCallFunction( ON_SET_TABLE) ; + bOk = bOk && LuaResetGlobVar( EMC_VAR) ; + return bOk ; + } + else + return true ; } //---------------------------------------------------------------------------- diff --git a/MachineLua.cpp b/MachineLua.cpp index 46cfe06..9d57b55 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -54,6 +54,9 @@ Machine::LuaInit( const string& sMachineName) m_LuaMgr.RegisterFunction( "EmtTable", Machine::LuaEmtTable) ; m_LuaMgr.RegisterFunction( "EmtAxis", Machine::LuaEmtAxis) ; m_LuaMgr.RegisterFunction( "EmtHead", Machine::LuaEmtHead) ; + // registro le funzioni di modifica macchina per lua + m_LuaMgr.RegisterFunction( "EmtModifyAxisStroke", Machine::LuaEmtModifyAxisStroke) ; + m_LuaMgr.RegisterFunction( "EmtModifyAxisHome", Machine::LuaEmtModifyAxisHome) ; // registro le funzioni di scrittura part program per lua m_LuaMgr.RegisterFunction( "EmtWrite", Machine::LuaEmtWrite) ; @@ -72,6 +75,26 @@ Machine::LuaExit( void) return true ; } +//---------------------------------------------------------------------------- +bool +Machine::LuaExistsFunction( const string& sFun) +{ + // imposto contesto corretto + int nOldCtx = ExeGetCurrentContext() ; + if ( nOldCtx != m_pMchMgr->GetContextId()) + ExeSetCurrentContext( m_pMchMgr->GetContextId()) ; + // imposto l'oggetto corrente per Lua + m_pMchLua = this ; + // verifico esistenza della funzione + bool bOk = m_LuaMgr.ExistsFunction( sFun) ; + // ripristino contesto originale + if ( nOldCtx != m_pMchMgr->GetContextId()) + ExeSetCurrentContext( nOldCtx) ; + // reset dell'oggetto corrente per Lua + m_pMchLua = nullptr ; + return bOk ; +} + //---------------------------------------------------------------------------- bool Machine::LuaCallFunction( const string& sFun) @@ -87,6 +110,8 @@ Machine::LuaCallFunction( const string& sFun) // ripristino contesto originale if ( nOldCtx != m_pMchMgr->GetContextId()) ExeSetCurrentContext( nOldCtx) ; + // reset dell'oggetto corrente per Lua + m_pMchLua = nullptr ; return bOk ; } @@ -105,6 +130,8 @@ Machine::LuaCreateGlobTable( const string& sName) // ripristino contesto originale if ( nOldCtx != m_pMchMgr->GetContextId()) ExeSetCurrentContext( nOldCtx) ; + // reset dell'oggetto corrente per Lua + m_pMchLua = nullptr ; return bOk ; } @@ -123,6 +150,8 @@ Machine::LuaResetGlobVar( const string& sName) // ripristino contesto originale if ( nOldCtx != m_pMchMgr->GetContextId()) ExeSetCurrentContext( nOldCtx) ; + // reset dell'oggetto corrente per Lua + m_pMchLua = nullptr ; return bOk ; } @@ -144,6 +173,8 @@ Machine::LuaLoadMachine( const string& sFile) // ripristino contesto originale if ( nOldCtx != m_pMchMgr->GetContextId()) ExeSetCurrentContext( nOldCtx) ; + // reset dell'oggetto corrente per Lua + m_pMchLua = nullptr ; return bOk ; } @@ -461,6 +492,46 @@ Machine::LuaEmtMultiHead( lua_State* L) return 0 ; } +//---------------------------------------------------------------------------- +int +Machine::LuaEmtModifyAxisStroke( lua_State* L) +{ + // 2 parametri : sAxisName, {dMin, dMax} + string sAxisName ; + LuaCheckParam( L, 1, sAxisName) + STROKE Stroke ; + LuaCheckParam( L, 2, Stroke.v) + LuaClearStack( L) ; + // verifico ci sia una macchina attiva + if ( m_pMchLua == nullptr) + return luaL_error( L, " Unknown Machine") ; + // modifico i limiti di corsa dell'asse + bool bOk = m_pMchLua->ModifyMachineAxisStroke( sAxisName, Stroke) ; + // assegno risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +int +Machine::LuaEmtModifyAxisHome( lua_State* L) +{ + // 2 parametri : sAxisName, dHome + string sAxisName ; + LuaCheckParam( L, 1, sAxisName) + double dHome ; + LuaCheckParam( L, 2, dHome) + LuaClearStack( L) ; + // verifico ci sia una macchina attiva + if ( m_pMchLua == nullptr) + return luaL_error( L, " Unknown Machine") ; + // modifico la posizione home dell'asse + bool bOk = m_pMchLua->ModifyMachineAxisHome( sAxisName, dHome) ; + // assegno risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + //---------------------------------------------------------------------------- int Machine::LuaEmtWrite( lua_State* L) @@ -469,9 +540,12 @@ Machine::LuaEmtWrite( lua_State* L) string sOut ; LuaCheckParam( L, 1, sOut) LuaClearStack( L) ; + // verifico ci sia una macchina attiva + if ( m_pMchLua == nullptr) + return luaL_error( L, " Unknown Machine") ; // emetto stringa bool bOk = m_pMchLua->WriterEmit( sOut) ; // assegno risultato LuaSetParam( L, bOk) ; return 1 ; -} \ No newline at end of file +} diff --git a/Milling.cpp b/Milling.cpp index 0285f0a..396ac61 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -516,6 +516,8 @@ Milling::Chain( int nGrpDestId) } } // preparo i dati per il concatenamento + bool bFirst = true ; + Point3d ptNear = ORIG ; double dToler = 10 * EPS_SMALL ; ChainCurves chainC ; chainC.Init( true, dToler, int( vpCrvs.size())) ; @@ -532,10 +534,14 @@ Milling::Chain( int nGrpDestId) return false ; if ( ! chainC.AddCurve( int( i + 1), ptStart, vtStart, ptEnd, vtEnd)) return false ; + // se prima curva, assegno inizio della ricerca + if ( bFirst) { + ptNear = ptStart + 10 * EPS_SMALL * vtStart ; + bFirst = false ; + } } // recupero i percorsi concatenati int nCount = 0 ; - Point3d ptNear = ORIG ; INTVECTOR vnId2 ; while ( chainC.GetChainFromNear( ptNear, false, vnId2)) { // creo una curva composita diff --git a/SawFinishing.cpp b/SawFinishing.cpp index 91f5591..4964f7a 100644 --- a/SawFinishing.cpp +++ b/SawFinishing.cpp @@ -22,7 +22,6 @@ #include "/EgtDev/Include/EGkCurveLine.h" #include "/EgtDev/Include/EGkCurveArc.h" #include "/EgtDev/Include/EGkCurveComposite.h" -#include "/EgtDev/Include/EGkChainCurves.h" #include "/EgtDev/Include/EgkOffsetCurve.h" #include "/EgtDev/Include/EgkOffsetCurveOnX.h" #include "/EgtDev/Include/EGkSfrCreate.h" diff --git a/SawRoughing.cpp b/SawRoughing.cpp index e60d99f..e591b70 100644 --- a/SawRoughing.cpp +++ b/SawRoughing.cpp @@ -22,7 +22,6 @@ #include "/EgtDev/Include/EGkCurveLine.h" #include "/EgtDev/Include/EGkCurveArc.h" #include "/EgtDev/Include/EGkCurveComposite.h" -#include "/EgtDev/Include/EGkChainCurves.h" #include "/EgtDev/Include/EgkOffsetCurve.h" #include "/EgtDev/Include/EgkOffsetCurveOnX.h" #include "/EgtDev/Include/EGkSfrCreate.h" @@ -842,6 +841,10 @@ SawRoughing::CalculateToolPath( int nAuxId, int nClId) OffsetCurve OffsCrv ; OffsCrv.Make( pCurve, dOffsR, ICurve::OFF_FILLET) ; pOvrCrv.Set( OffsCrv.GetLongerCurve()) ; + if ( IsNull( pOvrCrv)) { + LOG_INFO( GetEMkLogger(), "Error in SawRoughing : OffsetCurve") ; + return false ; + } // ricavo dalla sezione la curva per centro in basso della lama double dOffsX = 0.5 * m_TParams.m_dThick + GetOffsL() - GetOffsR() ; @@ -849,12 +852,16 @@ SawRoughing::CalculateToolPath( int nAuxId, int nClId) OffsetCurveOnX OffsCrvX ; OffsCrvX.Make( pOvrCrv, dOffsX) ; pCrv.Set( OffsCrvX.GetLongerCurve()) ; + if ( IsNull( pCrv)) { + LOG_INFO( GetEMkLogger(), "Error in SawRoughing : OffsetCurveOnX") ; + return false ; + } // determino l'ingombro della curva risultante in locale BBox3d b3Crv ; pCrv->GetLocalBBox( b3Crv) ; - //int nCrvId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, ::Release( pCrv)) ; - //m_pGeomDB->Save( nCrvId, "C:\\EgtData\\Varie\\Test\\aaa.nge", GDB_SV_TXT) ; - //pCrv.Set( ::GetCurve( m_pGeomDB->RemoveGeoObjAndErase( nCrvId))) ; + //int nBBBId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, ::Release( pCrv)) ; + //m_pGeomDB->Save( nBBBId, "C:\\EgtData\\Varie\\Test\\bbb.nge", GDB_SV_TXT) ; + //pCrv.Set( ::GetCurve( m_pGeomDB->RemoveGeoObjAndErase( nBBBId))) ; // valuto l'espressione dell'affondamento ExeLuaSetGlobNumVar( "TH", 0) ; diff --git a/Sawing.cpp b/Sawing.cpp index a915e0f..23c655b 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -846,6 +846,8 @@ Sawing::Chain( int nGrpDestId) } } // preparo i dati per il concatenamento + bool bFirst = true ; + Point3d ptNear = ORIG ; double dToler = 10 * EPS_SMALL ; ChainCurves chainC ; chainC.Init( true, dToler, int( vpCrvs.size())) ; @@ -862,10 +864,14 @@ Sawing::Chain( int nGrpDestId) return false ; if ( ! chainC.AddCurve( int( i + 1), ptStart, vtStart, ptEnd, vtEnd)) return false ; + // se prima curva, assegno inizio della ricerca + if ( bFirst) { + ptNear = ptStart + 10 * EPS_SMALL * vtStart ; + bFirst = false ; + } } // recupero i percorsi concatenati int nCount = 0 ; - Point3d ptNear = ORIG ; INTVECTOR vnId2 ; while ( chainC.GetChainFromNear( ptNear, false, vnId2)) { // creo una curva composita