diff --git a/Machine.h b/Machine.h index e4bd095..50afee6 100644 --- a/Machine.h +++ b/Machine.h @@ -297,6 +297,7 @@ class Machine static int LuaEmtUnlinkPartFromGroup( lua_State* L) ; static int LuaEmtUnlinkAllPartsFromGroups( lua_State* L) ; static int LuaEmtWrite( lua_State* L) ; + static int LuaEmtSetOutstrokeInfo( lua_State* L) ; } ; //---------------------------------------------------------------------------- diff --git a/MachineCalc.cpp b/MachineCalc.cpp index 6440333..99b35d4 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -327,7 +327,7 @@ Machine::GetCurrHead( void) const //---------------------------------------------------------------------------- bool -Machine::GetCurrHead( std::string& sHead) const +Machine::GetCurrHead( string& sHead) const { // controllo GeomDB if ( m_pGeomDB == nullptr) @@ -1352,7 +1352,7 @@ Machine::VerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng } //---------------------------------------------------------------------------- -std::string +string Machine::GetOutstrokeInfo( bool bMM) const { // se non c'è extracorsa, ritorno stringa vuota diff --git a/MachineLua.cpp b/MachineLua.cpp index 4a9943d..e9df6d0 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -106,6 +106,8 @@ Machine::LuaInit( const string& sMachineName) m_LuaMgr.RegisterFunction( "EmtGetAxesPos", Machine::LuaEmtGetAxesPos) ; // registro le funzioni di scrittura part program per lua m_LuaMgr.RegisterFunction( "EmtWrite", Machine::LuaEmtWrite) ; + // registro la funzione per impostare informazioni di outstroke + m_LuaMgr.RegisterFunction( "EmtSetOutstrokeInfo", Machine::LuaEmtSetOutstrokeInfo) ; return true ; } @@ -935,3 +937,33 @@ Machine::LuaEmtWrite( lua_State* L) LuaSetParam( L, bOk) ; return 1 ; } + +//---------------------------------------------------------------------------- +int +Machine::LuaEmtSetOutstrokeInfo( lua_State* L) +{ + // 5 parametri : sAxName, sAxToken, bLinear, dExtra, sAuxInfo + string sAxName ; + LuaCheckParam( L, 1, sAxName) + string sAxToken ; + LuaCheckParam( L, 2, sAxToken) + bool bLinear ; + LuaCheckParam( L, 3, bLinear) + double dExtra ; + LuaCheckParam( L, 4, dExtra) + string sAuxInfo ; + LuaCheckParam( L, 5, sAuxInfo) + LuaClearStack( L) ; + // verifico ci sia una macchina attiva + if ( m_pMchLua == nullptr) + return luaL_error( L, " Unknown Machine") ; + // assegno i dati + m_pMchLua->m_OutstrokeInfo.sAxName = sAxName ; + m_pMchLua->m_OutstrokeInfo.sAxToken = sAxToken ; + m_pMchLua->m_OutstrokeInfo.bLinear = bLinear ; + m_pMchLua->m_OutstrokeInfo.dExtra = dExtra ; + m_pMchLua->m_OutstrokeInfo.sAuxInfo = sAuxInfo ; + // assegno risultato + LuaSetParam( L, true) ; + return 1 ; +} diff --git a/OutputConst.h b/OutputConst.h index 732f6d1..951a6a1 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -20,6 +20,7 @@ static const int MAX_AXES = 7 ; // Variabili static const std::string GLOB_VAR = "EMT" ; // tavola variabili globali +static const std::string GVAR_ERR = ".ERR" ; // (int) codice di errore (0=ok) static const std::string GVAR_USETO1 = ".USETO1" ; // (bool) flag per utilizzo origine tavola static const std::string GVAR_MODAL = ".MODAL" ; // (bool) flag per emissione modale dei valori static const std::string GVAR_NUM = ".NUM" ; // (bool) flag numerazione diff --git a/Simulator.cpp b/Simulator.cpp index 6837020..c8ec910 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -891,11 +891,15 @@ Simulator::ManageMove( int& nStatus) // Se inizio di nuova entità if ( m_nEntId != GDB_ID_NULL && m_dCoeff < EPS_ZERO) { ++ m_nEntInd ; - if ( ! OnMoveStart( pCamData)) { + int nErr ; + if ( ! OnMoveStart( pCamData, nErr)) { if ( Stopped()) return true ; else { - nStatus = MCH_SIM_ERR ; + if ( nErr == 1) + nStatus = MCH_SIM_OUTSTROKE ; + else + nStatus = MCH_SIM_ERR ; return false ; } } @@ -1385,8 +1389,10 @@ Simulator::OnPathEndAux( int nInd, const string& sAE) //---------------------------------------------------------------------------- bool -Simulator::OnMoveStart( const CamData* pCamData) +Simulator::OnMoveStart( const CamData* pCamData, int& nErr) { + // reset stato di errore da script + nErr = 0 ; // recupero e assegno i dati // dati generali bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEID, m_nEntId) ; @@ -1424,6 +1430,11 @@ Simulator::OnMoveStart( const CamData* pCamData) return false ; } + // verifico codice di errore + m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ; + if ( nErr != 0) + return false ; + // forzo aggiornamento posizione assi (possono essere stati mossi nello script) UpdateAxesPos() ; diff --git a/Simulator.h b/Simulator.h index 131409b..ea766c0 100644 --- a/Simulator.h +++ b/Simulator.h @@ -75,7 +75,7 @@ class Simulator 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) ; - bool OnMoveStart( const CamData* pCamData) ; + bool OnMoveStart( const CamData* pCamData, int& nErr) ; bool OnMoveEnd( void) ; bool OnResetMachine( void) ;