diff --git a/Disposition.cpp b/Disposition.cpp index c8bd2c7..08beffc 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -1241,11 +1241,15 @@ bool Disposition::SpecialApply( bool bRecalc) { // reset + string sCurrHead = m_sHead ; m_sHead.clear() ; + int nCurrExit = m_nExit ; m_nExit = 0 ; int nCurrShifts = m_nShifts ; m_nShifts = 0 ; + bool bCurrSomeByHand = m_bSomeByHand ; m_bSomeByHand = false ; + string sCurrTcPos = m_sTcPos ; m_sTcPos.clear() ; // verifico MachMgr e GeomDB @@ -1266,7 +1270,11 @@ Disposition::SpecialApply( bool bRecalc) // verifico se necessario continuare nell'aggiornamento if ( ! bRecalc && m_nStatus == MCH_ST_OK) { + m_sHead = sCurrHead ; + m_nExit = nCurrExit ; m_nShifts = nCurrShifts ; + m_bSomeByHand = bCurrSomeByHand ; + m_sTcPos = sCurrTcPos ; LOG_INFO( GetEMkLogger(), "Disposition postapply skipped : status already ok") ; return true ; } diff --git a/MachMgr.h b/MachMgr.h index ec4303f..3f54a81 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -313,7 +313,7 @@ class MachMgr : public IMachMgr bool GetAxisToken( const std::string& sAxis, std::string& sToken) const override ; bool GetAxisType( const std::string& sAxis, bool& bLinear) const override ; bool GetAxisInvert( const std::string& sAxis, bool& bInvert) const override ; - bool SetAxisPos( const std::string& sAxis, double dVal) override ; + bool SetAxisPos( const std::string& sAxis, double dVal, double* pdNewVal = nullptr) override ; bool GetAxisPos( const std::string& sAxis, double& dVal) const override ; bool GetAxisHomePos( const std::string& sAxis, double& dHomeVal) const override ; bool ResetAxisPos( const std::string& sAxis) override ; diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index 963c9ff..e95c0a8 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -281,10 +281,10 @@ MachMgr::GetAxisInvert( const string& sAxis, bool& bInvert) const //---------------------------------------------------------------------------- bool -MachMgr::SetAxisPos( const string& sAxis, double dVal) +MachMgr::SetAxisPos( const string& sAxis, double dVal, double* pdNewVal) { Machine* pMch = GetCurrMachine() ; - return ( ( pMch != nullptr) ? pMch->SetAxisPos( sAxis, dVal) : false) ; + return ( ( pMch != nullptr) ? pMch->SetAxisPos( sAxis, dVal, pdNewVal) : false) ; } //---------------------------------------------------------------------------- diff --git a/Machine.h b/Machine.h index 3ac4540..da6bad5 100644 --- a/Machine.h +++ b/Machine.h @@ -71,7 +71,7 @@ class Machine bool GetAxisToken( const std::string& sAxis, std::string& sToken) const ; bool GetAxisInvert( const std::string& sAxis, bool& bInvert) const ; bool GetAxisType( const std::string& sAxis, bool& bLinear) const ; - bool SetAxisPos( const std::string& sAxis, double dVal) ; + bool SetAxisPos( const std::string& sAxis, double dVal, double* pdNewVal = nullptr) ; bool GetAxisPos( const std::string& sAxis, double& dVal) const ; bool GetAxisHomePos( const std::string& sAxis, double& dHomeVal) const ; bool ResetAxisPos( const std::string& sAxis) ; diff --git a/MachineAxes.cpp b/MachineAxes.cpp index 187637d..d81e5e9 100644 --- a/MachineAxes.cpp +++ b/MachineAxes.cpp @@ -72,7 +72,7 @@ Machine::GetAxisType( const string& sAxis, bool& bLinear) const //---------------------------------------------------------------------------- bool -Machine::SetAxisPos( const string& sAxis, double dVal) +Machine::SetAxisPos( const string& sAxis, double dVal, double* pdNewVal) { // controllo GeomDB if ( m_pGeomDB == nullptr) @@ -107,6 +107,9 @@ Machine::SetAxisPos( const string& sAxis, double dVal) m_pGeomDB->TranslateGroup( nAxGrp, vtDir * ( dVal - dCurrVal)) ; else m_pGeomDB->RotateGroup( nAxGrp, ptPos, vtDir, ( dVal - dCurrVal)) ; + // se richiesto, restituisco la nuova posizione + if ( pdNewVal != nullptr) + *pdNewVal = dVal ; // salvo la nuova posizione return pAx->SetCurrVal( dVal) ; } diff --git a/Simulator.cpp b/Simulator.cpp index 7aeece3..794f8d2 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -788,8 +788,9 @@ Simulator::ManagePathStartAux( int& nStatus) return false ; } // richiamo gestione evento ausiliario prima di inizio percorso di lavoro - if ( ! OnPathStartAux( m_nAuxSInd, sAS)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + int nErr ; + if ( ! OnPathStartAux( m_nAuxSInd, sAS, nErr)) { + nStatus = ( Stopped() ? MCH_SIM_STOP : ( nErr == 1 ? MCH_SIM_OUTSTROKE : MCH_SIM_ERR)) ; return false ; } nStatus = MCH_SIM_END_STEP ; @@ -809,8 +810,9 @@ Simulator::ManagePathEndAux( int& nStatus) return false ; } // richiamo gestione evento ausiliario dopo fine percorso di lavoro - if ( ! OnPathEndAux( m_nAuxEInd, sAE)) { - nStatus = ( Stopped() ? MCH_SIM_STOP : MCH_SIM_ERR) ; + int nErr ; + if ( ! OnPathEndAux( m_nAuxEInd, sAE, nErr)) { + nStatus = ( Stopped() ? MCH_SIM_STOP : ( nErr == 1 ? MCH_SIM_OUTSTROKE : MCH_SIM_ERR)) ; return false ; } nStatus = MCH_SIM_END_STEP ; @@ -1345,36 +1347,46 @@ Simulator::OnPathEnd( int nAE) //---------------------------------------------------------------------------- bool -Simulator::OnPathStartAux( int nInd, const string& sAS) +Simulator::OnPathStartAux( int nInd, const string& sAS, int& nErr) { + // reset stato di errore da script + nErr = 0 ; // verifico esistenza funzione if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_PATH_START_AUX)) return true ; - // assegno indice e valore dato ausiliario + // assegno indice, valore dato ausiliario e resetto errore bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUXIND, nInd) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUX, sAS) ; + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ; // chiamo la funzione di evento ausiliario all'inizio del percorso bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_PATH_START_AUX) ; // forzo aggiornamento posizione assi (possono essere stati mossi nello script) UpdateAxesPos() ; - return bOk ; + // verifico codice di errore + bOk = bOk && m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ; + return ( bOk && nErr == 0) ; } //---------------------------------------------------------------------------- bool -Simulator::OnPathEndAux( int nInd, const string& sAE) +Simulator::OnPathEndAux( int nInd, const string& sAE, int& nErr) { + // reset stato di errore da script + nErr = 0 ; // verifico esistenza funzione if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_PATH_END_AUX)) return true ; // assegno identificativo e indice percorso di lavorazione bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUXIND, nInd) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_AUX, sAE) ; + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ; // chiamo la funzione di evento ausiliario alla fine del percorso bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_PATH_END_AUX) ; // forzo aggiornamento posizione assi (possono essere stati mossi nello script) UpdateAxesPos() ; - return bOk ; + // verifico codice di errore + bOk = bOk && m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ; + return ( bOk && nErr == 0) ; } //---------------------------------------------------------------------------- diff --git a/Simulator.h b/Simulator.h index a542b63..e55d121 100644 --- a/Simulator.h +++ b/Simulator.h @@ -71,8 +71,8 @@ class Simulator bool OnToolDeselect( const std::string& sNextTool, const std::string& sNextHead, int nNextExit, const std::string& sNextTcPos) ; bool OnMachiningStart( int nOpId, int nOpInd, const Point3d& ptMin, const Point3d& ptMax) ; bool OnMachiningEnd( void) ; - bool OnPathStartAux( int nInd, const std::string& sAS) ; - bool OnPathEndAux( int nInd, const std::string& sAE) ; + 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, const Vector3d& vtExtr, const Point3d& ptMin, const Point3d& ptMax, double dElev) ; bool OnPathEnd( int nAE) ;