diff --git a/Disposition.cpp b/Disposition.cpp index fc33d08..231a63d 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -461,8 +461,13 @@ Disposition::AddFixture( const string& sName, const Point3d& ptPos, double dAngD // resetto il riferimento del gruppo Frame3d* pfrFixt = m_pGeomDB->GetGroupFrame( nFixtId) ; pfrFixt->Reset() ; + // recupero eventuale spostamento corrente della tavola + Vector3d vtDelta1 ; + Machine* pMch = m_pMchMgr->GetCurrMachine() ; + if ( pMch == nullptr || ! pMch->GetCurrTableDeltaRef1( vtDelta1)) + return false ; // la muovo nella posizione voluta - Vector3d vtMove = ( m_ptRef1 + ptPos) - ORIG ; + Vector3d vtMove = ( m_ptRef1 + vtDelta1 + ptPos) - ORIG ; m_pGeomDB->TranslateGlob( nFixtId, vtMove) ; // la ruoto if ( fabs( dAngDeg) > EPS_ANG_SMALL) @@ -529,10 +534,15 @@ Disposition::MoveFixture( int nId, const Vector3d& vtMove) // verifico aggiornamento tavola if ( ! m_bTabOk && ! SetTable( m_sTabName)) return false ; - // verifico che la posizione finale sia nell'area della tavola + // recupero eventuale spostamento corrente della tavola + Vector3d vtDelta1 ; + Machine* pMch = m_pMchMgr->GetCurrMachine() ; + if ( pMch == nullptr || ! pMch->GetCurrTableDeltaRef1( vtDelta1)) + return false ; + // verifico che la posizione finale sia nell'area della tavola (espressa in posizione 0) Frame3d frFixt ; if ( ! m_pGeomDB->GetGroupFrame( nId, frFixt) || - ! m_b3Area1.EnclosesXY( frFixt.Orig() + vtMove)) + ! m_b3Area1.EnclosesXY( frFixt.Orig() - vtDelta1 + vtMove)) return false ; // muovo l'oggetto m_pGeomDB->TranslateGlob( nId, vtMove) ; @@ -616,8 +626,13 @@ Disposition::PlaceFixture( int nId, const Point3d& ptPos, double dAngDeg, double // resetto il riferimento del gruppo Frame3d* pfrFixt = m_pGeomDB->GetGroupFrame( nId) ; pfrFixt->Reset() ; + // recupero eventuale spostamento corrente della tavola + Vector3d vtDelta1 ; + Machine* pMch = m_pMchMgr->GetCurrMachine() ; + if ( pMch == nullptr || ! pMch->GetCurrTableDeltaRef1( vtDelta1)) + return false ; // lo muovo nella posizione voluta - Vector3d vtMove = ( m_ptRef1 + ptPos) - ORIG ; + Vector3d vtMove = ( m_ptRef1 + vtDelta1 + ptPos) - ORIG ; m_pGeomDB->TranslateGlob( nId, vtMove) ; // lo ruoto if ( fabs( dAngDeg) > EPS_ANG_SMALL) @@ -771,9 +786,15 @@ Disposition::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag, boo b3Raw.Translate( vtMove) ; if ( ! m_b3Area1.EnclosesXY( b3Raw)) return false ; + // recupero eventuale spostamento corrente della tavola + Vector3d vtDelta1 ; + Machine* pMch = m_pMchMgr->GetCurrMachine() ; + if ( pMch == nullptr || ! pMch->GetCurrTableDeltaRef1( vtDelta1)) + return false ; // eseguo traslazione in globale - if ( ! vtMove.IsSmall()) - m_pGeomDB->TranslateGlob( nRawId, vtMove) ; + Vector3d vtTotMove = vtMove + vtDelta1 ; + if ( ! vtTotMove.IsSmall()) + m_pGeomDB->TranslateGlob( nRawId, vtTotMove) ; // se da aggiungere alla lista if ( bAddToList) { auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(), @@ -816,7 +837,7 @@ Disposition::MoveRawPart( int nRawId, const Vector3d& vtMove) Machine* pMch = m_pMchMgr->GetCurrMachine() ; if ( pMch == nullptr || ! pMch->GetCurrTableDeltaRef1( vtDelta1)) return false ; - // verifico se il grezzo nella posizione finale sarà nella tavola + // verifico se il grezzo nella posizione finale sarà nella tavola (espressa in posizione 0) b3Raw.Translate( vtMove - vtDelta1) ; if ( ! m_b3Area1.EnclosesXY( b3Raw)) return false ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 87cf5df..487bca8 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Generator.cpp b/Generator.cpp index d092600..cb8fa0c 100644 --- a/Generator.cpp +++ b/Generator.cpp @@ -90,7 +90,7 @@ Generator::Run( const string& sCncFile, const std::string& sInfo) } // apertura file di output ed evento inizio programma - if ( bOk && ! OnProgramStart( sCncFile, sInfo)) { + if ( bOk && ! OnProgramStart( m_pMachine->GetMachineName(), sCncFile, sInfo)) { bOk = false ; LOG_INFO( GetEMkLogger(), "OnProgramStart error") ; } @@ -466,12 +466,14 @@ Generator::OnEnd( void) //---------------------------------------------------------------------------- bool -Generator::OnProgramStart( const string& sCncFile, const string& sInfo) +Generator::OnProgramStart( const string& sMachName, const string& sCncFile, const string& sInfo) { // apro il file di output bool bOk = m_pMachine->WriterOpen( sCncFile) ; if ( ! bOk) LOG_INFO( GetEMkLogger(), "Error opening Cnc file") ; + // assegno nome macchina + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MACHNAME, sMachName) ; // assegno nome file bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FILE, sCncFile) ; // assegno info @@ -545,10 +547,11 @@ Generator::ProcessToolData( void) return a.sHead < b.sHead ; }) ; // emetto l'elenco degli utensili bool bOk = true ; - string sPrevHead ; int nPrevExit = 0 ; string sPrevTool ; + string sPrevHead ; int nPrevExit = 0 ; string sPrevTcPos ; string sPrevTool ; for ( size_t i = 0 ; i < vTdata.size() ; ++ i) { - // se posizione diversa - if ( vTdata[i].sHead != sPrevHead || vTdata[i].nExit != nPrevExit) { + // se posizione diversa (testa o uscita o toolchanger) + if ( vTdata[i].sHead != sPrevHead || vTdata[i].nExit != nPrevExit || + vTdata[i].sTcPos != sPrevTcPos) { bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, vTdata[i].sName) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, vTdata[i].sHead) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, vTdata[i].nExit) ; @@ -563,6 +566,7 @@ Generator::ProcessToolData( void) sPrevHead = vTdata[i].sHead ; nPrevExit = vTdata[i].nExit ; sPrevTool = vTdata[i].sName ; + sPrevTcPos = vTdata[i].sTcPos ; } // altrimenti else { diff --git a/Generator.h b/Generator.h index 8d7e14d..bf98493 100644 --- a/Generator.h +++ b/Generator.h @@ -38,7 +38,7 @@ class Generator bool UpdateAxes( void) ; bool OnStart( void) ; bool OnEnd( void) ; - bool OnProgramStart( const std::string& sCncFile, const std::string& sInfo) ; + bool OnProgramStart( const std::string& sMachName, const std::string& sCncFile, const std::string& sInfo) ; bool OnProgramEnd( void) ; bool ProcessToolData( void) ; bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit) ; diff --git a/MachMgr.h b/MachMgr.h index 1a43ab4..c567d3b 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -150,6 +150,7 @@ class MachMgr : public IMachMgr bool TdbGetCurrToolParam( int nType, int& nVal) const override ; bool TdbGetCurrToolParam( int nType, double& dVal) const override ; bool TdbGetCurrToolParam( int nType, std::string& sVal) const override ; + bool TdbReload( void) override ; bool TdbSave( void) const override ; bool TdbGetToolDir( std::string& sToolDir) const override ; bool TdbGetToolHolderDir( std::string& sTHolderDir) const override ; @@ -176,6 +177,7 @@ class MachMgr : public IMachMgr bool MdbSetGeneralParam( int nType, double dVal) override ; bool MdbGetGeneralParam( int nType, bool& bVal) const override ; bool MdbGetGeneralParam( int nType, double& dVal) const override ; + bool MdbReload( void) override ; bool MdbSave( void) const override ; bool MdbGetMachiningDir( std::string& sMchDir) const override ; // Operations : general @@ -203,6 +205,7 @@ class MachMgr : public IMachMgr bool GetOperationStatus( int nId, bool& bShow) const override ; bool SetAllOperationsStatus(bool bExceptFirstDisp, bool bShow) override ; bool ChangeOperationPhase( int nMchId, int nNewPhase) override ; + int GetPhaseLastOperation( int nPhase) const override ; bool RemoveOperationHome( int nId) override ; // Operations : dispositions int GetPhaseDisposition( int nPhase) const override ; diff --git a/MachMgrDBMachinings.cpp b/MachMgrDBMachinings.cpp index 78c4db7..084fee6 100644 --- a/MachMgrDBMachinings.cpp +++ b/MachMgrDBMachinings.cpp @@ -334,6 +334,18 @@ MachMgr::MdbGetGeneralParam( int nType, double& dVal) const return false ; } +//---------------------------------------------------------------------------- +bool +MachMgr::MdbReload( void) +{ + // recupero il gestore di lavorazioni della macchina corrente + MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ; + if ( pMsMgr == nullptr) + return false ; + // ricarico il DB lavorazioni + return pMsMgr->Reload() ; +} + //---------------------------------------------------------------------------- bool MachMgr::MdbSave( void) const diff --git a/MachMgrDBTools.cpp b/MachMgrDBTools.cpp index a8072ad..7c34a50 100644 --- a/MachMgrDBTools.cpp +++ b/MachMgrDBTools.cpp @@ -243,6 +243,18 @@ MachMgr::TdbGetCurrToolParam( int nType, string& sVal) const return pTsMgr->GetCurrToolParam( nType, sVal) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::TdbReload( void) +{ + // recupero il gestore di utensili della macchina corrente + ToolsMgr* pTsMgr = GetCurrToolsMgr() ; + if ( pTsMgr == nullptr) + return nullptr ; + // ricarico il db utensili + return pTsMgr->Reload() ; +} + //---------------------------------------------------------------------------- bool MachMgr::TdbSave( void) const diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index 89d2420..4bee034 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -470,22 +470,13 @@ MachMgr::ChangeOperationPhase( int nMchId, int nNewPhase) if ( nType == OPER_NULL || nType == OPER_DISP) return false ; // verifico che la nuova fase esista - if ( nNewPhase > m_nPhasesCount) + if ( nNewPhase <= 0 || nNewPhase > m_nPhasesCount) return false ; // se la fase dell'operazione è già giusta, esco subito con successo if ( GetOperationPhase( nMchId) == nNewPhase) return true ; // cerco l'ultima operazione della nuova fase - int nRefId = GDB_ID_NULL ; - int nCurrId = GetFirstOperation() ; - while ( nCurrId != GDB_ID_NULL) { - int nPhase = GetOperationPhase( nCurrId) ; - if ( nPhase == nNewPhase) - nRefId = nCurrId ; - else if ( nPhase > nNewPhase) - break ; - nCurrId = GetNextOperation( nCurrId) ; - } + int nRefId = GetPhaseLastOperation( nNewPhase) ; if ( nRefId == GDB_ID_NULL) return false ; // recupero la lavorazione @@ -499,6 +490,27 @@ MachMgr::ChangeOperationPhase( int nMchId, int nNewPhase) return pMch->SetPhase( nNewPhase) ; } +//---------------------------------------------------------------------------- +int +MachMgr::GetPhaseLastOperation( int nPhase) const +{ + // verifico esistenza fase + if ( nPhase <= 0 || nPhase > m_nPhasesCount) + return GDB_ID_NULL ; + // cerco l'ultima operazione della fase + int nOperId = GDB_ID_NULL ; + int nCurrId = GetFirstOperation() ; + while ( nCurrId != GDB_ID_NULL) { + int nOperPhase = GetOperationPhase( nCurrId) ; + if ( nPhase == nOperPhase) + nOperId = nCurrId ; + else if ( nPhase < nOperPhase) + break ; + nCurrId = GetNextOperation( nCurrId) ; + } + return nOperId ; +} + //---------------------------------------------------------------------------- bool MachMgr::RemoveOperationHome( int nId) @@ -652,8 +664,11 @@ MachMgr::AddMachining( const string& sName, const string& sMachining) string sNewName = sName ; if ( ! GetOperationNewName( sNewName)) return GDB_ID_NULL ; - // inserisco il gruppo - int nId = m_pGeomDB->AddGroup( GDB_ID_NULL, nOperGrpId, GLOB_FRM) ; + // inserisco il gruppo della lavorazione alla fine della fase corrente + int nRefId = GetPhaseLastOperation( m_nCurrPhase) ; + if ( nRefId == GDB_ID_NULL) + return GDB_ID_NULL ; + int nId = m_pGeomDB->InsertGroup( GDB_ID_NULL, nRefId, GDB_AFTER, GLOB_FRM) ; if ( nId == GDB_ID_NULL) return GDB_ID_NULL ; // assegno il nome @@ -696,8 +711,11 @@ MachMgr::AddMachining( const string& sName, int nMchType, const string& sTool) string sNewName = sName ; if ( ! GetOperationNewName( sNewName)) return GDB_ID_NULL ; - // inserisco il gruppo - int nId = m_pGeomDB->AddGroup( GDB_ID_NULL, nOperGrpId, GLOB_FRM) ; + // inserisco il gruppo della lavorazione alla fine della fase corrente + int nRefId = GetPhaseLastOperation( m_nCurrPhase) ; + if ( nRefId == GDB_ID_NULL) + return GDB_ID_NULL ; + int nId = m_pGeomDB->InsertGroup( GDB_ID_NULL, nRefId, GDB_AFTER, GLOB_FRM) ; if ( nId == GDB_ID_NULL) return GDB_ID_NULL ; // assegno il nome diff --git a/MachMgrRawParts.cpp b/MachMgrRawParts.cpp index 3ba9c84..fb0aa73 100644 --- a/MachMgrRawParts.cpp +++ b/MachMgrRawParts.cpp @@ -17,6 +17,8 @@ #include "MachMgr.h" #include "MachConst.h" #include "Disposition.h" +#include "/EgtDev/Include/EMkMachiningGeoConst.h" +#include "/EgtDev/Include/EXeCmdLogOff.h" #include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkGeoPoint3d.h" @@ -26,7 +28,6 @@ #include "/EgtDev/Include/EGkSfrCreate.h" #include "/EgtDev/Include/EGkStmStandard.h" #include "/EgtDev/Include/EGkStmFromCurves.h" -#include "/EgtDev/Include/EmkMachiningGeoConst.h" #include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; @@ -825,6 +826,9 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId) if ( ! VerifyRawPart( nRawId) || VerifyRawPartPhase( nRawId, m_nCurrPhase)) return GDB_ID_NULL ; + // disabilito eventuale registrazione comandi EXE (riabilitazione automatica) + CmdLogOff cmdLogOff ; + // recupero alcuni dati del grezzo // il solido del grezzo int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; @@ -902,9 +906,15 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId) // creo i grezzi risultanti // creo i nuovi grezzi INTVECTOR vNewIds ; + int nCount ; int nChunk = 0 ; - int nFirstLoopId = ExeExtractSurfFrChunkLoops( nSfrId, nChunk, nRawId, nullptr) ; + int nFirstLoopId = ExeExtractSurfFrChunkLoops( nSfrId, nChunk, nRawId, &nCount) ; while ( nFirstLoopId != GDB_ID_NULL) { + // !!! in attesa di gestire i grezzi con i buchi !!! + // cancello le eventuali curve successive (sono i loop interni ovvero i buchi) + for ( int i = 1 ; i < nCount ; ++ i) { + m_pGeomDB->Erase( nFirstLoopId + i) ; + } // dichiaro temporanea la curva m_pGeomDB->SetLevel( nFirstLoopId, GDB_LV_TEMP) ; // creo il grezzo @@ -953,7 +963,7 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId) m_pGeomDB->Erase( nFirstLoopId) ; // passo alla prossima curva ++ nChunk ; - nFirstLoopId = ExeExtractSurfFrChunkLoops( nSfrId, nChunk, nRawId, nullptr) ; + nFirstLoopId = ExeExtractSurfFrChunkLoops( nSfrId, nChunk, nRawId, &nCount) ; } // cancello la regione m_pGeomDB->Erase( nSfrId) ; @@ -977,14 +987,20 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId) if ( ( ( nEntGeoType & GEO_CURVE) != 0 && ExeMidPoint( nEntId, nNewId, ptTest)) || ( ( nEntGeoType & GEO_CURVE) == 0 && ExeCenterPoint( nEntId, nNewId, ptTest))) { int nOutCrvId = m_pGeomDB->GetFirstNameInGroup( nNewId, MACH_RAW_OUTLINE) ; - ICurve* pCurve = GetCurve( m_pGeomDB->GetGeoObj( nOutCrvId)) ; - if ( pCurve != nullptr) { - int nSide ; - double dDist ; - DistPointCurve distPC( ptTest, *pCurve) ; - if ( distPC.GetDist( dDist) && dDist < 100 * EPS_SMALL || - (distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT)) - break ; + BBox3d b3Raw ; m_pGeomDB->GetGlobalBBox( nOutCrvId, b3Raw) ; + double dRawDiam = 0 ; b3Raw.GetDiameter( dRawDiam) ; + BBox3d b3Part ; m_pGeomDB->GetGlobalBBox( nEntId, b3Part) ; + double dPartDiam = 0 ; b3Part.GetDiameter( dPartDiam) ; + if ( dRawDiam > 0.9 * dPartDiam) { + ICurve* pCurve = GetCurve( m_pGeomDB->GetGeoObj( nOutCrvId)) ; + if ( pCurve != nullptr) { + int nSide ; + double dDist ; + DistPointCurve distPC( ptTest, *pCurve) ; + if ( distPC.GetDist( dDist) && dDist < 100 * EPS_SMALL || + (distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT)) + break ; + } } } // altrimenti scambio pezzo ed elimino gruppo diff --git a/MachineCalc.cpp b/MachineCalc.cpp index 502c5e6..433a14e 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -742,7 +742,9 @@ Machine::GetMyAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, if ( ! bDet2) { bool bDetX ; vtDirI2.GetRotation( vtDirAn, vtAx1, dAngA2, bDetX) ; - if ( ! bDetX) + if ( bDetX) + bDet2 = true ; + else dAngA2 = 0 ; } } @@ -761,7 +763,9 @@ Machine::GetMyAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, if ( ! bDet1) { bool bDetX ; vtDirI1.GetRotation( vtDirAn, vtAx1, dAngA1, bDetX) ; - if ( ! bDetX) + if ( bDetX) + bDet1 = true ; + else dAngA1 = 0 ; } } diff --git a/MachiningsMgr.cpp b/MachiningsMgr.cpp index 2b5cc52..66d0ff0 100644 --- a/MachiningsMgr.cpp +++ b/MachiningsMgr.cpp @@ -75,12 +75,12 @@ MachiningsMgr::MachiningsMgr( void) //---------------------------------------------------------------------------- MachiningsMgr::~MachiningsMgr( void) { - Clear() ; + Clear( true) ; } //---------------------------------------------------------------------------- bool -MachiningsMgr::Clear( void) +MachiningsMgr::Clear( bool bReset) { // libero la memoria dalle lavorazioni for ( auto iIter = m_umData.begin() ; iIter != m_umData.end() ; ++ iIter) { @@ -88,7 +88,8 @@ MachiningsMgr::Clear( void) delete iIter->second ; } // reset puntatore a gestore utensili - m_pTsMgr = nullptr ; + if ( bReset) + m_pTsMgr = nullptr ; // pulisco le tabelle m_umData.clear() ; m_suData.clear() ; @@ -106,13 +107,10 @@ MachiningsMgr::Clear( void) bool MachiningsMgr::Load( const string& sMachsFile, const ToolsMgr* pTsMgr) { - // Pulisco - Clear() ; - // Salvo la path del file con i dati m_sMachsFile = sMachsFile ; - { string sOut = "MachiningsMgr Init : " + m_sMachsFile ; - LOG_INFO( GetEMkLogger(), sOut.c_str()) } + string sOut = "MachiningsMgr Init : " + m_sMachsFile ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) // Verifico il gestore degli utensili if ( pTsMgr == nullptr) { @@ -121,10 +119,27 @@ MachiningsMgr::Load( const string& sMachsFile, const ToolsMgr* pTsMgr) } m_pTsMgr = pTsMgr ; + // carico + return Reload() ; +} + +//---------------------------------------------------------------------------- +bool +MachiningsMgr::Reload( void) +{ + // Pulisco + Clear( false) ; + + // Verifico il gestore degli utensili + if ( m_pTsMgr == nullptr) { + LOG_ERROR( GetEMkLogger(), "ReloadMachinings : Error on ToolsMgr") + return false ; + } + // Inizializzo lo scanner Scanner TheScanner ; if ( ! TheScanner.Init( m_sMachsFile, ";")) { - LOG_ERROR( GetEMkLogger(), "LoadMachinings : Error on Init") + LOG_ERROR( GetEMkLogger(), "ReloadMachinings : Error on Init") return false ; } @@ -137,18 +152,18 @@ MachiningsMgr::Load( const string& sMachsFile, const ToolsMgr* pTsMgr) int nTotal = 0 ; if ( ! LoadHeader( TheScanner, nVersion, nTotal, bEnd)) { bOk = false ; - string sOut = "LoadMachinings : Error on Header" ; + string sOut = "ReloadMachinings : Error on Header" ; LOG_ERROR( GetEMkLogger(), sOut.c_str()) } { - string sOut = "LoadMachinings : FileVer = " + ToString( nVersion) + " CurrVer = " + ToString( MF_CURR_VER) ; + string sOut = "ReloadMachinings : FileVer = " + ToString( nVersion) + " CurrVer = " + ToString( MF_CURR_VER) ; LOG_INFO( GetEMkLogger(), sOut.c_str()) } // Leggo i dati generali (da versione 1002) if ( nVersion >= 1002 && ! LoadGeneral( TheScanner, bEnd)) { bOk = false ; - string sOut = "LoadMachinings : Error on General" ; + string sOut = "ReloadMachinings : Error on General" ; LOG_ERROR( GetEMkLogger(), sOut.c_str()) } @@ -160,7 +175,7 @@ MachiningsMgr::Load( const string& sMachsFile, const ToolsMgr* pTsMgr) do { if ( ! LoadOneMachining( TheScanner, bEnd)) { bOk = false ; - string sOut = "LoadMachinings : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ; + string sOut = "ReloadMachinings : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ; LOG_ERROR( GetEMkLogger(), sOut.c_str()) } } while ( bOk && ! bEnd) ; diff --git a/MachiningsMgr.h b/MachiningsMgr.h index c540687..1ec4366 100644 --- a/MachiningsMgr.h +++ b/MachiningsMgr.h @@ -27,6 +27,7 @@ class MachiningsMgr MachiningsMgr( void) ; ~MachiningsMgr( void) ; bool Load( const std::string& sMachsFile, const ToolsMgr* pTsMgr) ; + bool Reload( void) ; bool Save( bool bCompressed = true) const ; bool GetMachiningNewName( std::string& sName) const ; bool AddMachining( const std::string& sName, int nType) ; @@ -73,7 +74,7 @@ class MachiningsMgr { return m_nSplitArcs ; } private : - bool Clear( void) ; + bool Clear( bool bReset) ; bool LoadHeader( Scanner& TheScanner, int& nVersion, int& nTotal, bool& bEnd) ; bool LoadGeneral( Scanner& TheScanner, bool& bEnd) ; bool LoadOneMachining( Scanner& TheScanner, bool& bEnd) ; diff --git a/Milling.cpp b/Milling.cpp index 017442a..1c422bf 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -951,31 +951,33 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) } } - // eventuali allungamenti per percorso aperto + // eventuali allungamenti/accorciamenti per percorso aperto bool bOverlapOn = false ; if ( ! pCompo->IsClosed()) { - // eventuale allungamento/accorciamento dell'inizio - if ( abs( m_Params.m_dStartAddLen) > EPS_SMALL) { - if ( m_Params.m_dStartAddLen > 0) { - if ( ! pCompo->ExtendStartByLen( m_Params.m_dStartAddLen)) - return false ; - } - else { - if ( ! pCompo->TrimStartAtLen( - m_Params.m_dStartAddLen)) - return false ; - } + // verifico che il percorso sia abbastanza lungo + double dLen ; pCompo->GetLength( dLen) ; + if ( dLen + m_Params.m_dStartAddLen + m_Params.m_dEndAddLen < 10 * EPS_SMALL) { + LOG_INFO( GetEMkLogger(), "Warning in Milling : skipped Path too small") ; + return true ; } - // eventuale allungamento/accorciamento della fine - if ( abs( m_Params.m_dEndAddLen) > EPS_SMALL) { - if ( m_Params.m_dEndAddLen > 0) { - if ( ! pCompo->ExtendEndByLen( m_Params.m_dEndAddLen)) - return false ; - } - else { - double dLen ; - if ( ! pCompo->GetLength( dLen) || ! pCompo->TrimEndAtLen( dLen + m_Params.m_dEndAddLen)) - return false ; - } + // eventuali allungamenti + if ( m_Params.m_dStartAddLen > EPS_SMALL) { + if ( ! pCompo->ExtendStartByLen( m_Params.m_dStartAddLen)) + return false ; + } + if ( m_Params.m_dEndAddLen > EPS_SMALL) { + if ( ! pCompo->ExtendEndByLen( m_Params.m_dEndAddLen)) + return false ; + } + // eventuale accorciamenti (da fare dopo tutti gli allungamenti) + if ( m_Params.m_dStartAddLen < - EPS_SMALL) { + if ( ! pCompo->TrimStartAtLen( - m_Params.m_dStartAddLen)) + return false ; + } + if ( m_Params.m_dEndAddLen < - EPS_SMALL) { + double dLen ; + if ( ! pCompo->GetLength( dLen) || ! pCompo->TrimEndAtLen( dLen + m_Params.m_dEndAddLen)) + return false ; } } // eventuale sovrapposizione per percorso chiuso diff --git a/OutputConst.h b/OutputConst.h index d6428f1..55754af 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -30,6 +30,7 @@ static const std::string GVAR_F = ".F" ; // (num) valore del static const std::string GVAR_FT = ".Ft" ; // (string) token per feed static const std::string GVAR_S = ".S" ; // (num) valore della speed static const std::string GVAR_ST = ".St" ; // (string) token per speed +static const std::string GVAR_MACHNAME = ".MACHNAME" ; // (string) nome macchina static const std::string GVAR_FILE = ".FILE" ; // (string) path file di output static const std::string GVAR_INFO = ".INFO" ; // (string) informazioni iniziali static const std::string GVAR_DISPID = ".DISPID" ; // (int) identificativo disposizione diff --git a/Sawing.cpp b/Sawing.cpp index c9f1d7b..1e6baa0 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -989,29 +989,32 @@ Sawing::ProcessPath( int nPathId, int nPvId, int nClId) if ( m_Params.m_bInvert) pCompo->Invert() ; - // eventuale allungamento/accorciamento dell'inizio - if ( abs( m_Params.m_dStartAddLen) > EPS_SMALL) { - if ( m_Params.m_dStartAddLen > 0) { - if ( ! pCompo->ExtendStartByLen( m_Params.m_dStartAddLen)) - return false ; - } - else { - if ( ! pCompo->TrimStartAtLen( - m_Params.m_dStartAddLen)) - return false ; - } + // verifico che il percorso sia abbastanza lungo + double dLen ; pCompo->GetLength( dLen) ; + if ( dLen + m_Params.m_dStartAddLen + m_Params.m_dEndAddLen < 10 * EPS_SMALL) { + LOG_INFO( GetEMkLogger(), "Warning in Sawing : skipped Path too small") ; + return true ; } - // eventuale allungamento/accorciamento della fine - if ( abs( m_Params.m_dEndAddLen) > EPS_SMALL) { - if ( m_Params.m_dEndAddLen > 0) { - if ( ! pCompo->ExtendEndByLen( m_Params.m_dEndAddLen)) - return false ; - } - else { - double dLen ; - if ( ! pCompo->GetLength( dLen) || ! pCompo->TrimEndAtLen( dLen + m_Params.m_dEndAddLen)) - return false ; - } + // eventuali allungamenti + if ( m_Params.m_dStartAddLen > EPS_SMALL) { + if ( ! pCompo->ExtendStartByLen( m_Params.m_dStartAddLen)) + return false ; + } + if ( m_Params.m_dEndAddLen > EPS_SMALL) { + if ( ! pCompo->ExtendEndByLen( m_Params.m_dEndAddLen)) + return false ; + } + + // eventuale accorciamenti (da fare dopo tutti gli allungamenti) + if ( m_Params.m_dStartAddLen < - EPS_SMALL) { + if ( ! pCompo->TrimStartAtLen( - m_Params.m_dStartAddLen)) + return false ; + } + if ( m_Params.m_dEndAddLen < - EPS_SMALL) { + double dLen ; + if ( ! pCompo->GetLength( dLen) || ! pCompo->TrimEndAtLen( dLen + m_Params.m_dEndAddLen)) + return false ; } // elaboro la curva composita e la esplodo nelle curve componenti diff --git a/ToolsMgr.cpp b/ToolsMgr.cpp index eb2441a..4c788ba 100644 --- a/ToolsMgr.cpp +++ b/ToolsMgr.cpp @@ -59,18 +59,26 @@ ToolsMgr::Clear( void) bool ToolsMgr::Load( const string& sToolsFile) { - // pulisco - Clear() ; - // salvo la path del file con i dati m_sToolsFile = sToolsFile ; - { string sOut = "ToolsMgr Init : " + m_sToolsFile ; - LOG_INFO( GetEMkLogger(), sOut.c_str()) } + string sOut = "ToolsMgr Init : " + m_sToolsFile ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) + + // carico + return Reload() ; +} + +//---------------------------------------------------------------------------- +bool +ToolsMgr::Reload( void) +{ + // pulisco + Clear() ; // inizializzo lo scanner Scanner TheScanner ; if ( ! TheScanner.Init( m_sToolsFile, ";")) { - LOG_ERROR( GetEMkLogger(), "LoadTools : Error on Init") + LOG_ERROR( GetEMkLogger(), "ReloadTools : Error on Init") return false ; } @@ -84,11 +92,11 @@ ToolsMgr::Load( const string& sToolsFile) int nTotal = 0 ; if ( ! LoadHeader( TheScanner, nVersion, nToolSize, nTotal, bEnd)) { bOk = false ; - string sOut = "LoadTools : Error on Header" ; + string sOut = "ReloadTools : Error on Header" ; LOG_ERROR( GetEMkLogger(), sOut.c_str()) } { - string sOut = "LoadTools : FileVer = " + ToString( nVersion) + " CurrVer = " + ToString( TF_CURR_VER) ; + string sOut = "ReloadTools : FileVer = " + ToString( nVersion) + " CurrVer = " + ToString( TF_CURR_VER) ; LOG_INFO( GetEMkLogger(), sOut.c_str()) } @@ -100,7 +108,7 @@ ToolsMgr::Load( const string& sToolsFile) do { if ( ! LoadOneTool( TheScanner, nToolSize, bEnd)) { bOk = false ; - string sOut = "LoadTools : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ; + string sOut = "ReloadTools : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ; LOG_ERROR( GetEMkLogger(), sOut.c_str()) } } while ( bOk && ! bEnd) ; @@ -111,7 +119,7 @@ ToolsMgr::Load( const string& sToolsFile) // verifico di aver letto il numero di utensili indicato in header if ( m_utData.size() != nTotal) { bOk = false ; - LOG_ERROR( GetEMkLogger(), "LoadTools : Tools number wrong") + LOG_ERROR( GetEMkLogger(), "ReloadTools : Tools number wrong") } return bOk ; diff --git a/ToolsMgr.h b/ToolsMgr.h index 9590890..4b17f63 100644 --- a/ToolsMgr.h +++ b/ToolsMgr.h @@ -26,6 +26,7 @@ class ToolsMgr public : ToolsMgr( void) ; bool Load( const std::string& sToolsFile) ; + bool Reload( void) ; bool Save( bool bCompressed = true) const ; bool GetToolNewName( std::string& sName) const ; bool AddTool( const std::string& sName, int nType) ;